file_fdw: Add regression test for file_fdw with ON_ERROR='set_null'

Commit 2a525cc97e 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
This commit is contained in:
Fujii Masao 2026-03-16 12:13:11 +09:00
parent bfa3c4f106
commit d8879d34b9
2 changed files with 14 additions and 2 deletions

View 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

View 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;