Re: BUG #15666: Seemingly incorrect error reporting/logging for violation of non-null constraint

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: dirkjan(at)ochtman(dot)nl
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #15666: Seemingly incorrect error reporting/logging for violation of non-null constraint
Date: 2019-03-04 14:27:43
Message-ID: 32405.1551709663@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

PG Bug reporting form <noreply(at)postgresql(dot)org> writes:
> I'm modifying the data model for the application I work on, and in the
> process of doing so, I'm seeing this error:

> db | 2019-03-04 09:48:54.485 UTC [198] ERROR: null value in column
> "accountid" violates not-null constraint
> db | 2019-03-04 09:48:54.485 UTC [198] DETAIL: Failing row contains
> (14, 138962.38, 0, null, 13).
> db | 2019-03-04 09:48:54.485 UTC [198] STATEMENT: insert into
> JournalEntryRecord (accountId, amount, journalEntryId, type, id) values ($1,
> $2, $3, $4, $5)

> This is very confusing to me because the tuple from the "Failing row"
> message clearly has the `null` in fourth position, but the error message
> reports that the column "accountid" (or "accountId" -- but I understand
> column names are casefolded) is the problem, which should ostensibly be the
> first value from the failing row tuple (if that tuple is ordered the same
> way as the statement suggests).

Well, maybe it isn't. That DETAIL line would report all the columns of the
table, in their physical order. That doesn't necessarily have anything to
do with the original INSERT, which --- if it has a column list, as this
does --- can choose to target any subset of the columns in any order.

We can't very well order the DETAIL to match the original INSERT, since
it's entirely possible that the complaint is about a column not even
mentioned in the INSERT.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Jeremy Finzel 2019-03-04 14:28:36 Re: Segmentation Fault in logical decoding get/peek API
Previous Message Derek Hans 2019-03-04 13:57:48 Re: BUG #15662: Row update in foreign partition does not move row based on partition key