Re: COPY FROM ON_ERROR SET_NULL bypasses domain NOT NULL with partial column list - Mailing list pgsql-hackers

From Fujii Masao
Subject Re: COPY FROM ON_ERROR SET_NULL bypasses domain NOT NULL with partial column list
Date
Msg-id CAHGQGwEvUj+ycr5vYMPQhZ8gk1of4HiSGfKVBJ15nA8d3MyDhQ@mail.gmail.com
Whole thread
In response to Re: COPY FROM ON_ERROR SET_NULL bypasses domain NOT NULL with partial column list  (jian he <jian.universality@gmail.com>)
Responses Re: COPY FROM ON_ERROR SET_NULL bypasses domain NOT NULL with partial column list
List pgsql-hackers
On Fri, Apr 17, 2026 at 12:59 PM jian he <jian.universality@gmail.com> wrote:
>
> On Fri, Apr 17, 2026 at 1:09 AM SATYANARAYANA NARLAPURAM
> <satyanarlapuram@gmail.com> wrote:
> >
> > HI hackers,
> >
> > domain_with_constraint[] was allocated with list_length(attnumlist)
> > elements and indexed sequentially via foreach_current_index(), but
> > copyfromparse.c accesses it via attnum - 1 (physical attribute index).
> > With a partial column list targeting high-numbered columns, this caused
> > an out-of-bounds read that bypassed domain NOT NULL checks, silently
> > inserting NULL into NOT NULL domain columns.
> >
> > Fix by allocating with num_phys_attrs and indexing by attnum - 1,
> > consistent with all other per-column arrays in BeginCopyFrom().
> >
> > Patch is attached, and added a new test case to cover this scenario.
> >
>
> The patch looks good to me.
> I simplified the tests.

The patch looks good to me. Barring any objections, I will commit it.

Regards,

--
Fujii Masao



pgsql-hackers by date:

Previous
From: vignesh C
Date:
Subject: Re: Proposal: Conflict log history table for Logical Replication
Next
From: Daniel Gustafsson
Date:
Subject: Re: [oauth] Fix minimal typo in OAuth