Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6e6cc59

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 checkat validation time if possible. Lightly modified version of a patchby Shigeru Hanada.
1 parent2e56fa8 commit6e6cc59

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
aint2,

‎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
aint2,
8082
bfloat4

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp