| From: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
|---|---|
| To: | Fujii Masao <masao(dot)fujii(at)gmail(dot)com> |
| Cc: | jian he <jian(dot)universality(at)gmail(dot)com>, SATYANARAYANA NARLAPURAM <satyanarlapuram(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: COPY FROM ON_ERROR SET_NULL bypasses domain NOT NULL with partial column list |
| Date: | 2026-05-18 22:27:54 |
| Message-ID: | 0ED082D4-70CB-4144-8A00-EFE63FCC15B1@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
> On May 18, 2026, at 21:22, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
>
> On Fri, Apr 17, 2026 at 12:59 PM jian he <jian(dot)universality(at)gmail(dot)com> wrote:
>>
>> On Fri, Apr 17, 2026 at 1:09 AM SATYANARAYANA NARLAPURAM
>> <satyanarlapuram(at)gmail(dot)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
I also found this bug and reported it here [1]. I just reviewed v2, the code change of the fix itself is exactly the same as my version in [1]. The new test is slightly different from my version, but I think that also works.
[1] https://www.postgresql.org/message-id/8A72720A-55AC-4D41-B9DF-5610307600E6%40gmail.com
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Peter Smith | 2026-05-18 23:08:18 | Make the logical replication conflict messages more like each other |
| Previous Message | Nazir Bilal Yavuz | 2026-05-18 22:27:52 | Re: Heads Up: cirrus-ci is shutting down June 1st |