fio
fio
pg_fio : PostgreSQL File I/O Functions
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 5230 | fio
|
pg_fio
|
1.0 |
ADMIN
|
BSD 3-Clause
|
C
|
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
--s-d-r
|
No
|
Yes
|
No
|
Yes
|
yes
|
no
|
| Relationships | |
|---|---|
| See Also | pgfincore
adminpack
file_fdw
pageinspect
pgstattuple
pg_repack
pg_rewrite
pg_squeeze
|
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY
|
1.0 |
18
17
16
15
14
|
pg_fio |
- |
| RPM | PIGSTY
|
1.0 |
18
17
16
15
14
|
pg_fio_$v |
- |
| DEB | PIGSTY
|
1.0 |
18
17
16
15
14
|
postgresql-$v-pg-fio |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
el8.x86_64
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
el8.aarch64
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
el9.x86_64
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
el9.aarch64
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
el10.x86_64
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
el10.aarch64
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
d12.x86_64
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
d12.aarch64
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
d13.x86_64
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
d13.aarch64
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
u22.x86_64
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
u22.aarch64
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
u24.x86_64
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
u24.aarch64
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
PIGSTY 1.0
|
Source
pig build pkg pg_fio; # build rpm/debInstall
Make sure PGDG and PIGSTY repo available:
pig repo add pgsql -u # add both repo and update cacheInstall this extension with pig:
pig install pg_fio; # install via package name, for the active PG version
pig install fio; # install by extension name, for the current active PG version
pig install fio -v 18; # install for PG 18
pig install fio -v 17; # install for PG 17
pig install fio -v 16; # install for PG 16
pig install fio -v 15; # install for PG 15
pig install fio -v 14; # install for PG 14Create this extension with:
CREATE EXTENSION fio;Usage
The fio extension provides file system I/O functions accessible from SQL, enabling reading, writing, and managing files and directories directly from PostgreSQL.
File Operations
-- Read file contents (returns bytea)
SELECT fio_readfile('/etc/hostname');
-- Write content to file
SELECT fio_writefile('/tmp/output.txt', 'Hello World'::bytea);
-- Write with auto-create directory and overwrite
SELECT fio_writefile('/tmp/newdir/output.txt', 'data'::bytea, true, true);
-- Remove a file
SELECT fio_removefile('/tmp/output.txt');
-- Rename / move a file
SELECT fio_renamefile('/tmp/old.txt', '/tmp/new.txt');Directory Operations
-- List directory contents
SELECT fio_readdir('/usr/', '*');
-- List with pattern filter
SELECT fio_readdir('/var/log/', '*.log');
-- Create a directory with permissions
SELECT fio_mkdir('/tmp/mydir', '0755');
-- Create nested directories recursively
SELECT fio_mkdir('/tmp/a/b/c', '0755', true);
-- Change file/directory permissions
SELECT fio_chmod('/tmp/mydir', '0700');Function Reference
| Function | Description |
|---|---|
fio_readfile(path) |
Read file contents as bytea |
fio_writefile(path, content, mkdir, overwrite) |
Write bytea content to file |
fio_removefile(path) |
Delete a file |
fio_renamefile(old, new) |
Rename or move a file |
fio_readdir(path, pattern) |
List directory entries matching pattern |
fio_mkdir(path, mode, recursive) |
Create directory with permissions |
fio_chmod(path, mode) |
Change file/directory permissions |
Last updated on