Summary
file_fdw currently accepts the foreign-table program option, but scanning such a table reaches a Rust panic! instead of either executing COPY FROM PROGRAM or returning a controlled SQL error.
Why this looks reachable
The validator path accepts program for foreign tables:
crates/contrib/file_fdw/src/lib.rs:207 treats "filename" | "program" as valid table-level source options.
crates/contrib/file_fdw/src/lib.rs:218 checks pg_execute_server_program privilege for program, but does not reject it as unsupported.
file_get_options() then preserves the is_program flag for executor setup.
crates/contrib/file_fdw/src/lib.rs:632 file_begin_foreign_scan() calls file_get_options(), and the is_program branch panics at line 646:
panic!(
"file_fdw: program option (COPY FROM PROGRAM, OpenPipeStream lane) is unported \
for table \"{}\"",
rel.name()
);
I also checked origin/v0.3-beta; it still has the same file_begin_foreign_scan() panic path.
Reproduction sketch
As a role that can set program on file_fdw foreign tables:
CREATE EXTENSION file_fdw;
CREATE SERVER file_srv FOREIGN DATA WRAPPER file_fdw;
-- Superuser, or a role with pg_execute_server_program, can create this option.
CREATE FOREIGN TABLE ft_program(line text)
SERVER file_srv
OPTIONS (program 'printf "hello\n"', format 'text');
SELECT * FROM ft_program;
Expected behavior
Either:
- support
COPY FROM PROGRAM for file_fdw scans, matching PostgreSQL behavior, or
- reject the unsupported
program path with a normal SQL error, preferably at validation time or at scan startup.
The important part is that reachable SQL should not be able to panic the backend.
Actual behavior
The option is accepted, then SELECT reaches file_begin_foreign_scan() and panics because the OpenPipeStream lane is marked unported.
Validation performed
- Refreshed the current issue list and searched for existing
file_fdw / COPY FROM PROGRAM / program option / OpenPipeStream reports; I did not find a duplicate.
- Checked
origin/v0.3-beta; the same panic branch is still present there.
- Ran
cargo test -p file_fdw --lib; the crate builds and its current 2 unit tests pass.
Summary
file_fdwcurrently accepts the foreign-tableprogramoption, but scanning such a table reaches a Rustpanic!instead of either executingCOPY FROM PROGRAMor returning a controlled SQL error.Why this looks reachable
The validator path accepts
programfor foreign tables:crates/contrib/file_fdw/src/lib.rs:207treats"filename" | "program"as valid table-level source options.crates/contrib/file_fdw/src/lib.rs:218checkspg_execute_server_programprivilege forprogram, but does not reject it as unsupported.file_get_options()then preserves theis_programflag for executor setup.crates/contrib/file_fdw/src/lib.rs:632file_begin_foreign_scan()callsfile_get_options(), and theis_programbranch panics at line 646:I also checked
origin/v0.3-beta; it still has the samefile_begin_foreign_scan()panic path.Reproduction sketch
As a role that can set
programonfile_fdwforeign tables:Expected behavior
Either:
COPY FROM PROGRAMforfile_fdwscans, matching PostgreSQL behavior, orprogrampath with a normal SQL error, preferably at validation time or at scan startup.The important part is that reachable SQL should not be able to panic the backend.
Actual behavior
The option is accepted, then
SELECTreachesfile_begin_foreign_scan()and panics because the OpenPipeStream lane is marked unported.Validation performed
file_fdw/COPY FROM PROGRAM/program option/OpenPipeStreamreports; I did not find a duplicate.origin/v0.3-beta; the same panic branch is still present there.cargo test -p file_fdw --lib; the crate builds and its current 2 unit tests pass.