diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2011-07-05 18:46:03 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2011-07-05 18:46:03 -0400 |
commit | 6e6cc5910b6b5db5e3662dc389e749763e5717f5 (patch) | |
tree | bb381a3909318731b6ebb439d745054e1ef20e40 /contrib/file_fdw/file_fdw.c | |
parent | 2e56fa863221d60d8bf8a8b946aaf8ba28ed05e7 (diff) |
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.
Diffstat (limited to 'contrib/file_fdw/file_fdw.c')
-rw-r--r-- | contrib/file_fdw/file_fdw.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/contrib/file_fdw/file_fdw.c b/contrib/file_fdw/file_fdw.c index f2d7f3a6a88..224e74ff321 100644 --- a/contrib/file_fdw/file_fdw.c +++ b/contrib/file_fdw/file_fdw.c @@ -216,6 +216,14 @@ file_fdw_validator(PG_FUNCTION_ARGS) */ ProcessCopyOptions(NULL, true, other_options); + /* + * Filename option is required for file_fdw foreign tables. + */ + if (catalog == ForeignTableRelationId && filename == NULL) + ereport(ERROR, + (errcode(ERRCODE_FDW_DYNAMIC_PARAMETER_VALUE_NEEDED), + errmsg("filename is required for file_fdw foreign tables"))); + PG_RETURN_VOID(); } @@ -287,10 +295,14 @@ fileGetOptions(Oid foreigntableid, } prev = lc; } + + /* + * The validator should have checked that a filename was included in the + * options, but check again, just in case. + */ if (*filename == NULL) - ereport(ERROR, - (errcode(ERRCODE_FDW_UNABLE_TO_CREATE_REPLY), - errmsg("filename is required for file_fdw foreign tables"))); + elog(ERROR, "filename is required for file_fdw foreign tables"); + *other_options = options; } |