From d8879d34b9dd651080a4994b58fd7eb0e5049252 Mon Sep 17 00:00:00 2001 From: Fujii Masao Date: Mon, 16 Mar 2026 12:13:11 +0900 Subject: [PATCH] file_fdw: Add regression test for file_fdw with ON_ERROR='set_null' 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 Reviewed-by: Yi Ding Discussion: https://postgr.es/m/CAHGQGwGmPc6aHpA5=WxKreiDePiOEitfOFsW2dSo5m81xWXgRA@mail.gmail.com --- contrib/file_fdw/expected/file_fdw.out | 12 +++++++++++- contrib/file_fdw/sql/file_fdw.sql | 4 +++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/contrib/file_fdw/expected/file_fdw.out b/contrib/file_fdw/expected/file_fdw.out index 251f00bd258..640986528ae 100644 --- a/contrib/file_fdw/expected/file_fdw.out +++ b/contrib/file_fdw/expected/file_fdw.out @@ -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 diff --git a/contrib/file_fdw/sql/file_fdw.sql b/contrib/file_fdw/sql/file_fdw.sql index 2cba84b1db7..56bfc926c00 100644 --- a/contrib/file_fdw/sql/file_fdw.sql +++ b/contrib/file_fdw/sql/file_fdw.sql @@ -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;