[BUG FIX] Fix validation of COPY options FORCE_NOT_NULL/FORCE_NULL

From: "Joel Jacobson" <joel(at)compiler(dot)org>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: [BUG FIX] Fix validation of COPY options FORCE_NOT_NULL/FORCE_NULL
Date: 2024-10-11 23:48:15
Message-ID: 65030d1d-5f90-4fa4-92eb-f5f50389858e@app.fastmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers,

Here is a patch that fixes a minor problem in copy.c's ProcessCopyOptions,
as well as fixing thinko in its tests, as well as adding new tests for
the bugfix.

[PATCH 1/2] Fix thinko in tests for COPY options force_not_null
and force_null.

Use COPY FROM for the negative tests that check that FORMAT text
cannot be used for these options, since if testing COPY TO,
which is invalid for these two options, we're testing two
invalid options at the same time, which doesn't seem intentional,
since the other tests seems to be testing invalid options one by one.

In passing, consistently use "stdin" for COPY FROM and "stdout" for COPY TO,
even though it has no effect on the tests per se, it seems
better to be consistent, to avoid confusion.

[PATCH 2/2] Fix validation of FORCE_NOT_NULL/FORCE_NULL for
all-columns case.

Add missing checks for FORCE_NOT_NULL and FORCE_NULL when applied to
all columns via "*". These options now correctly require CSV mode and
are disallowed in COPY TO as appropriate. Adjusted regression
tests to verify correct behavior for the all-columns case.

/Joel

Attachment Content-Type Size
0001-Fix-thinko-in-tests-for-COPY-options-force_not_null-.patch application/octet-stream 4.6 KB
0002-Fix-validation-of-FORCE_NOT_NULL-FORCE_NULL-for-all-.patch application/octet-stream 5.0 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2024-10-11 23:48:26 Re: Add contrib/pg_logicalsnapinspect
Previous Message Peter Geoghegan 2024-10-11 23:29:12 Re: Avoiding superfluous buffer locking during nbtree backwards scans