pgsql: Fix spurious errors in COPY FROM (FORMAT {text,csv}).

From: Nathan Bossart <nathan(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix spurious errors in COPY FROM (FORMAT {text,csv}).
Date: 2026-09-01 19:21:46
Message-ID: E1x1U3F-000000034qV-0enF@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix spurious errors in COPY FROM (FORMAT {text,csv}).

The SIMD path for these commands reads ahead into the input buffer
via CopyLoadInputBuf(), which reports encoding and conversion
errors. The problem is that the errant data might lie beyond the
end-of-copy marker, which we aren't copying and thus needn't error
for. To fix, add a "speculative" parameter to CopyLoadInputBuf()
that defers these errors, and use it in the SIMD path. The errors
are instead reported only if we actually reach the errant data.
Testing indicates this does not meaningfully impact performance.

Oversight in commit e0a3a3fd53.

Reviewed-by: Greg Burd <greg(at)burd(dot)me>
Reviewed-by: Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com>
Discussion: https://postgr.es/m/apWOr1kgVSqweBnU%40nathan
Backpatch-through: 19

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/f26ab219e28ceb88b29f9165800879548dcc6646

Modified Files
--------------
src/backend/commands/copyfromparse.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Nathan Bossart 2026-09-01 20:21:03 pgsql: Fix scaling of autovacuum freeze scores.
Previous Message Peter Eisentraut 2026-09-01 19:19:04 pgsql: Fix assertion failures in DELETE FOR PORTION OF tuple routing