]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
file_fdw: Add regression test for file_fdw with ON_ERROR='set_null'
authorFujii Masao <fujii@postgresql.org>
Mon, 16 Mar 2026 03:13:11 +0000 (12:13 +0900)
committerFujii Masao <fujii@postgresql.org>
Mon, 16 Mar 2026 03:13:11 +0000 (12:13 +0900)
Commit 2a525cc97e1 introduced the ON_ERROR = 'set_null' option for COPY,
allowing it to be used with foreign tables backed by file_fdw. However,
unlike ON_ERROR = 'ignore', no regression test was added to verify
this behavior for file_fdw.

This commit adds a regression test to ensure that foreign tables using
file_fdw work correctly with ON_ERROR = 'set_null', improving test coverage.

Author: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Yi Ding <dingyi_yale@163.com>
Discussion: https://postgr.es/m/CAHGQGwGmPc6aHpA5=WxKreiDePiOEitfOFsW2dSo5m81xWXgRA@mail.gmail.com

contrib/file_fdw/expected/file_fdw.out
contrib/file_fdw/sql/file_fdw.sql

index 251f00bd258b60e316089b5fe0a21b2c8648fc89..640986528ae19c8f45dec11ddfe445965395a580 100644 (file)
@@ -246,7 +246,17 @@ SELECT * FROM agg_bad;               -- ERROR
 ERROR:  invalid input syntax for type real: "aaa"
 CONTEXT:  COPY agg_bad, line 3, column b: "aaa"
 -- on_error, log_verbosity and reject_limit tests
-ALTER FOREIGN TABLE agg_bad OPTIONS (ADD on_error 'ignore');
+ALTER FOREIGN TABLE agg_bad OPTIONS (ADD on_error 'set_null');
+SELECT * FROM agg_bad;
+  a  |   b    
+-----+--------
+ 100 | 99.097
+   0 | _null_
+  42 | 324.78
+   1 | _null_
+(4 rows)
+
+ALTER FOREIGN TABLE agg_bad OPTIONS (SET on_error 'ignore');
 SELECT * FROM agg_bad;
 NOTICE:  2 rows were skipped due to data type incompatibility
   a  |   b    
index 2cba84b1db76786f24b9245aba7b18181c5d6f44..56bfc926c004edb6580d869e1eac65bd6c0a62b8 100644 (file)
@@ -171,7 +171,9 @@ SELECT * FROM agg_csv c JOIN agg_text t ON (t.a = c.a) ORDER BY c.a;
 SELECT * FROM agg_bad;               -- ERROR
 
 -- on_error, log_verbosity and reject_limit tests
-ALTER FOREIGN TABLE agg_bad OPTIONS (ADD on_error 'ignore');
+ALTER FOREIGN TABLE agg_bad OPTIONS (ADD on_error 'set_null');
+SELECT * FROM agg_bad;
+ALTER FOREIGN TABLE agg_bad OPTIONS (SET on_error 'ignore');
 SELECT * FROM agg_bad;
 ALTER FOREIGN TABLE agg_bad OPTIONS (ADD log_verbosity 'silent');
 SELECT * FROM agg_bad;