From: Shigeru Hanada Date: Thu, 30 Jun 2011 06:37:54 +0000 (+0900) Subject: Fix file_fdw to require filename in its validator. X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=8b3612807cb6e2822e20d2c4fbdda5a6841aba59;p=users%2Fhanada%2Fpostgres.git Fix file_fdw to require filename in its validator. Before this fix, requirement of filename had been checked in fileGetOptions() which is called by PlanForeignScan(). Now file_fdw can check it in creation/alteration time. --- diff --git a/contrib/file_fdw/file_fdw.c b/contrib/file_fdw/file_fdw.c index 466c015107..a883f7551a 100644 --- a/contrib/file_fdw/file_fdw.c +++ b/contrib/file_fdw/file_fdw.c @@ -215,6 +215,16 @@ file_fdw_validator(PG_FUNCTION_ARGS) */ 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(); } diff --git a/contrib/file_fdw/input/file_fdw.source b/contrib/file_fdw/input/file_fdw.source index 9ff7235a12..8d6dfa3c4a 100644 --- a/contrib/file_fdw/input/file_fdw.source +++ b/contrib/file_fdw/input/file_fdw.source @@ -59,6 +59,7 @@ CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'csv', delimiter '); -- 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 2ba36c9368..6cc6746b0c 100644 --- a/contrib/file_fdw/output/file_fdw.source +++ b/contrib/file_fdw/output/file_fdw.source @@ -75,6 +75,8 @@ ERROR: COPY delimiter cannot be newline or carriage return 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