Weird error message from Postgres 18

From: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Weird error message from Postgres 18
Date: 2025-08-21 14:25:38
Message-ID: CAEudQApWA_+AOmcwn8vqwZcYEV2WJh0X-rvO4wQSOr_UVJXcKA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi.

I noticed a weird message error from Postgres 18.

sql reproducible test:
create table inserttest (col1 serial PRIMARY KEY, col2 int4 NOT NULL, col3
text NOT NULL, col4 text NULL);
insert into inserttest select 0 AS col2, NULL AS col3, NULL AS col4;
ERROR: null value in column "col2" of relation "inserttest" violates
not-null constraint
DETAIL: Failing row contains (0, null, null, null).
drop table inserttest;

It seems that the message is confusing.
col2 and col3 IS NOT NULL, but col2 has value 0.

best regards,
Ranier Vilela

Attachment Content-Type Size
insert_into_select_test.sql application/octet-stream 200 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jingtang Zhang 2025-08-21 15:07:05 Re: Memory leak of SMgrRelation object on standby
Previous Message Kirill Reshke 2025-08-21 14:10:43 Remove unneeded cast in heap_xlog_lock.