external_file
Access external server-side files through PostgreSQL functions
external_file : Access external server-side files through PostgreSQL functions
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 4285 | external_file | external_file | 1.2 |
UTIL | PostgreSQL | SQL |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| ----d-- | No | No | No | Yes | no | no |
| Relationships | |
|---|---|
| Schemas | external_file |
| See Also | fio floatfile file_fdw byteamagic aws_s3 envvar pg_bulkload basic_archive basebackup_to_shell pg_parquet |
Fixed schema external_file; superuser required.
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY | 1.2 |
18 17 16 15 14 | external_file |
- |
| RPM | PIGSTY | 1.2 |
18 17 16 15 14 | external_file_$v |
- |
| DEB | PIGSTY | 1.2 |
18 17 16 15 14 | postgresql-$v-external-file |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 |
| el8.aarch64 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 |
| el9.x86_64 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 |
| el9.aarch64 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 |
| el10.x86_64 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 |
| el10.aarch64 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 |
| d12.x86_64 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 |
| d12.aarch64 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 |
| d13.x86_64 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 |
| d13.aarch64 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 |
| u22.x86_64 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 |
| u22.aarch64 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 |
| u24.x86_64 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 |
| u24.aarch64 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 |
| u26.x86_64 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 |
| u26.aarch64 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 |
Source
github.com/darold/external_file
external_file-1.2.tar.gz
Install
Make sure PGDG and PIGSTY repo available:
Install this extension with pig:
Create this extension with:
Usage
Source: README, Release v1.2
external_file stores file locators as (directory, filename) pairs and accesses server-side files through PostgreSQL lo_* helpers rather than direct file reads.
Basic workflow
Core objects
directories: maps an alias to an on-server directory path.directory_roles: grants read/write rights on that alias to roles.efilename(directory, filename): constructs anefilelocator.readEfile(efile): reads the target file intobytea.writeEfile(bytea, efile): writesbyteato the target file.copyEfile(src, dest): copies one external file to another.getEfilePath(efile, need_read, need_write): resolves the full path and checks access.
Caveats
- Creating the extension requires a PostgreSQL superuser.
- Upstream creates all objects in the
external_fileschema by default. - The PostgreSQL OS user still needs filesystem read/write permission on the target directory.
- Filenames must not contain
/or\; access is intentionally mediated through the directory tables.