Skip to content

Commit 6e6cc59

Browse files
committed
Make the file_fdw validator check that a filename option has been provided.
This was already a runtime failure condition, but it's better to check at validation time if possible. Lightly modified version of a patch by Shigeru Hanada.
1 parent 2e56fa8 commit 6e6cc59

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

contrib/file_fdw/file_fdw.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,14 @@ file_fdw_validator(PG_FUNCTION_ARGS)
216216
*/
217217
ProcessCopyOptions(NULL, true, other_options);
218218

219+
/*
220+
* Filename option is required for file_fdw foreign tables.
221+
*/
222+
if (catalog == ForeignTableRelationId && filename == NULL)
223+
ereport(ERROR,
224+
(errcode(ERRCODE_FDW_DYNAMIC_PARAMETER_VALUE_NEEDED),
225+
errmsg("filename is required for file_fdw foreign tables")));
226+
219227
PG_RETURN_VOID();
220228
}
221229

@@ -287,10 +295,14 @@ fileGetOptions(Oid foreigntableid,
287295
}
288296
prev = lc;
289297
}
298+
299+
/*
300+
* The validator should have checked that a filename was included in the
301+
* options, but check again, just in case.
302+
*/
290303
if (*filename == NULL)
291-
ereport(ERROR,
292-
(errcode(ERRCODE_FDW_UNABLE_TO_CREATE_REPLY),
293-
errmsg("filename is required for file_fdw foreign tables")));
304+
elog(ERROR, "filename is required for file_fdw foreign tables");
305+
294306
*other_options = options;
295307
}
296308

contrib/file_fdw/input/file_fdw.source

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'csv', delimiter
5959
'); -- ERROR
6060
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'csv', null '
6161
'); -- ERROR
62+
CREATE FOREIGN TABLE tbl () SERVER file_server; -- ERROR
6263

6364
CREATE FOREIGN TABLE agg_text (
6465
a int2,

contrib/file_fdw/output/file_fdw.source

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ ERROR: COPY delimiter cannot be newline or carriage return
7575
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'csv', null '
7676
'); -- ERROR
7777
ERROR: COPY null representation cannot use newline or carriage return
78+
CREATE FOREIGN TABLE tbl () SERVER file_server; -- ERROR
79+
ERROR: filename is required for file_fdw foreign tables
7880
CREATE FOREIGN TABLE agg_text (
7981
a int2,
8082
b float4

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy