Re: Fix stale column context after COPY FROM conversion errors

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix stale column context after COPY FROM conversion errors
Date: 2026-11-05 08:04:17
Message-ID: auw4gQ9IWJ2In_1M@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Nov 05, 2026 at 02:43:54PM +0800, Chao Li wrote:
> So the fix is simple: we can add the cleanup in the
> COPY_ON_ERROR_IGNORE branch and remove the COPY_ON_ERROR_SET_NULL
> branch, letting it fall through so that the cleanup is performed.

I've also wondered exactly about that a couple of hours ago while
looking at a different bug in the same area of the code.. Interesting
timing.

I don't buy that the current coding on HEAD is correct, based on what
I can see here from this test:
* SQL input:
CREATE TABLE check_ign_err (n int, m int[], k int);
COPY check_ign_err FROM STDIN WITH (on_error ignore);
bad {1} 3
1 {1} 3 abc
\.

* HEAD:
ERROR: 22P04: extra data after last expected column
CONTEXT: COPY check_ign_err, line 2, column n: "1"
* with your patch:
ERROR: 22P04: extra data after last expected column
CONTEXT: COPY check_ign_err, line 2: "1 {1} 3 4"

Complaining about the first column on the second line is incorrect and
gets fed from the first incorrect line: we have extra fields on this
line, they should be mentioned.
--
Michael

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2026-11-05 08:05:52 Re: Partitioned index marked valid while a partition is pending detach
Previous Message Zsolt Parragi 2026-11-05 08:03:31 Re: Preferred way to submit a very large batch of bugs?