Re: Weird error message from Postgres 18

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Weird error message from Postgres 18
Date: 2025-08-21 15:17:44
Message-ID: 1438877.1755789464@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Ranier Vilela <ranier(dot)vf(at)gmail(dot)com> writes:
> 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).

You are misunderstanding the effects of that INSERT. The AS labels
have zero to do with the semantics, so you are inserting 0 to col1,
null to col2 & col3, and by default null to col4.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kirill Reshke 2025-08-21 15:20:52 Re: misleading error message in ProcessUtilitySlow T_CreateStatsStmt
Previous Message Jingtang Zhang 2025-08-21 15:07:05 Re: Memory leak of SMgrRelation object on standby