diff --git a/contrib/file_fdw/file_fdw.c b/contrib/file_fdw/file_fdw.c index 466c015..57e522f 100644 *** a/contrib/file_fdw/file_fdw.c --- b/contrib/file_fdw/file_fdw.c *************** file_fdw_validator(PG_FUNCTION_ARGS) *** 215,220 **** --- 215,230 ---- */ ProcessCopyOptions(NULL, true, other_options); + /* + * filename is a required option. Validity of other options including + * relative ones have been checked in ProcessCopyOptions(). + * Note: We don't care its value even though it might be empty, because + * COPY comand doesn't. + */ + if (catalog == ForeignTableRelationId && filename == NULL) + ereport(ERROR, + (errmsg("filename is required for file_fdw foreign tables"))); + PG_RETURN_VOID(); } *************** fileGetOptions(Oid foreigntableid, *** 286,295 **** } prev = lc; } - if (*filename == NULL) - ereport(ERROR, - (errcode(ERRCODE_FDW_UNABLE_TO_CREATE_REPLY), - errmsg("filename is required for file_fdw foreign tables"))); *other_options = options; } --- 296,301 ---- *************** filePlanForeignScan(Oid foreigntableid, *** 308,313 **** --- 314,323 ---- /* Fetch options --- we only need filename at this point */ fileGetOptions(foreigntableid, &filename, &options); + if (filename == NULL) + ereport(ERROR, + (errcode(ERRCODE_FDW_UNABLE_TO_CREATE_REPLY), + errmsg("filename is required for file_fdw foreign tables"))); /* Construct FdwPlan with cost estimates */ fdwplan = makeNode(FdwPlan); diff --git a/contrib/file_fdw/input/file_fdw.source b/contrib/file_fdw/input/file_fdw.source index 9ff7235..8d6dfa3 100644 *** a/contrib/file_fdw/input/file_fdw.source --- b/contrib/file_fdw/input/file_fdw.source *************** CREATE FOREIGN TABLE tbl () SERVER file_ *** 59,64 **** --- 59,65 ---- '); -- ERROR CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'csv', null ' '); -- ERROR + CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'csv'); -- ERROR CREATE FOREIGN TABLE agg_text ( a int2, diff --git a/contrib/file_fdw/output/file_fdw.source b/contrib/file_fdw/output/file_fdw.source index 2ba36c9..6cc6746 100644 *** a/contrib/file_fdw/output/file_fdw.source --- b/contrib/file_fdw/output/file_fdw.source *************** ERROR: COPY delimiter cannot be newline *** 75,80 **** --- 75,82 ---- CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'csv', null ' '); -- ERROR ERROR: COPY null representation cannot use newline or carriage return + CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'csv'); -- ERROR + ERROR: filename is required for file_fdw foreign tables CREATE FOREIGN TABLE agg_text ( a int2, b float4