fio
PostgreSQL File I/O Functions
Repository
csimsek/pgsql-fio
https://github.com/csimsek/pgsql-fio
Source
pg_fio-1.0.tar.gz
pg_fio-1.0.tar.gz
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pg_fio | 1.0 | ADMIN | BSD 3-Clause | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 5230 | fio | No | Yes | No | Yes | No | Yes | - |
| Related | pgfincore adminpack file_fdw pageinspect pgstattuple pg_repack pg_rewrite pg_squeeze |
|---|
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 1.0 | 1817161514 | pg_fio | - |
| RPM | PIGSTY | 1.0 | 1817161514 | pg_fio_$v | - |
| DEB | PIGSTY | 1.0 | 1817161514 | postgresql-$v-pg-fio | - |
Build
You can build the RPM / DEB packages for pg_fio using pig build:
pig build pkg pg_fio # build RPM / DEB packages
Install
You can install pg_fio directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
pig repo add pgsql -u # Add repo and update cache
Install the extension using pig or apt/yum/dnf:
pig install pg_fio; # Install for current active PG version
pig ext install -y pg_fio -v 18 # PG 18
pig ext install -y pg_fio -v 17 # PG 17
pig ext install -y pg_fio -v 16 # PG 16
pig ext install -y pg_fio -v 15 # PG 15
pig ext install -y pg_fio -v 14 # PG 14
dnf install -y pg_fio_18 # PG 18
dnf install -y pg_fio_17 # PG 17
dnf install -y pg_fio_16 # PG 16
dnf install -y pg_fio_15 # PG 15
dnf install -y pg_fio_14 # PG 14
apt install -y postgresql-18-pg-fio # PG 18
apt install -y postgresql-17-pg-fio # PG 17
apt install -y postgresql-16-pg-fio # PG 16
apt install -y postgresql-15-pg-fio # PG 15
apt install -y postgresql-14-pg-fio # PG 14
Create Extension:
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 |
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.