pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: 125atishprak@gmail.com
Subject: BUG #19844: COPY ON_ERROR set_null error context names the wrong column
Date: Sat, 07 Nov 2026 14:14:15 +0000
Message-ID: <19844-eccbc58101e119c2@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      19844
Logged by:          Atish Prakash
Email address:      125atishprak@gmail.com
PostgreSQL version: 19rc1
Operating system:   Linux x86_64
Description:        

When ON_ERROR set_null replaces a value in the last column of a row, a later
error for that row still reports that column in its CONTEXT line, even
though
the error has nothing to do with it:

    CREATE TABLE zp(a int, b int) PARTITION BY LIST (a);
    CREATE TABLE zp1 PARTITION OF zp FOR VALUES IN (1);

    COPY zp FROM STDIN (ON_ERROR set_null);
    9   x
    \.

Actual output:

    ERROR:  no partition of relation "zp" found for row
    DETAIL:  Partition key of the failing row contains (a) = (9).
    CONTEXT:  COPY zp, line 1, column b: "x"

Expected: the context does not blame column b, whose value was handled,
since
the failing partition key is column a:

    CONTEXT:  COPY zp, line 1: "9       x"

in NextCopyFrom(), the set_null path does "continue" before the
statements that reset cstate->cur_attname and cur_attval. If the failing
field
is the last one, they stay set for the rest of the row's processing.

A possible patch is attached (0001-fix-copy-set-null-error-context.patch),
which
removes that "continue" so the reset always runs. Regression tests pass with
it
on master; it adds no new test.

Found with semantic differential tests . I reproduced and checked the result
myself.







view thread (2+ messages)  latest in thread

Message-ID: <19844-eccbc58101e119c2@postgresql.org>
Permalink:  ../19844-eccbc58101e119c2@postgresql.org/
Also on:    postgresql.org/message-id/19844-eccbc58101e119c2@postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, 125atishprak@gmail.com
  Subject: Re: BUG #19844: COPY ON_ERROR set_null error context names the wrong column
  In-Reply-To: <19844-eccbc58101e119c2@postgresql.org>
  References: <19844-eccbc58101e119c2@postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox