Re: BUG #19531: Inconsistent Error Messages for the Same SQL Query

From: Francisco Olarte <folarte(at)peoplecall(dot)com>
To: 1804981203(at)qq(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19531: Inconsistent Error Messages for the Same SQL Query
Date: 2026-06-24 08:20:59
Message-ID: CA+bJJbzkGXXku8i6wR4qZeX8OV5-ACe5502oyQF0xg30hANxGg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, 24 Jun 2026 at 10:00, PG Bug reporting form
<noreply(at)postgresql(dot)org> wrote:
...
> Inconsistent Error Messages for the Same SQL Query in PostgreSQL
...
> Context:
> My application relies on the error messages returned by SQL statement
> execution to perform subsequent operations. During development, I discovered
> that the same SQL query can return different error messages . I'm not sure
> if this is a bug, but it does affect my application's ability to reliably
> handle errors.

From your posted code only, it seems error MESSAGES are consistent, it
is ERRORS that are different.

And given you are changing the context via set, this is expected.

If I do "select a/a, a*a from t" and I have just a zero row, I get
division by zero, -1000, in smallint, I get overflow, 1 i get 1,1. I
can get the three results from the same 1 row table varying the
context by "update set a=" before the select. Your example is just
doing the same thing on a more convoluted way.
...

> Observation:
> The same SQL query SELECT c2 / c2 AS e0, c2 * c2 AS e1 FROM t GROUP BY c1,
> c2; executed against the same data returns two different error messages:
... two different errors..
> - ERROR: division by zero
> - ERROR: smallint out of range
...
> I'm not certain whether this qualifies as a bug, but it does create a real
> problem for applications that depend on consistent error reporting from the
> database.Thanks for reading my report!

Wiser people may say other thing, but the reporting is consistent. The
errors are consistent too, same options, same error always. The
behaviour you have shown is different results ( loosely defining
"resultset or raised error" as result ) for the same query in
different contexts. IMO this is normal. It is like writing a
parameterless function which raises A if seqscan is enabled ( reading
the setting directly ) or B if not and complaining that it does not
always raise the same error when calling in the same way.

Francisco Olarte.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Etsuro Fujita 2026-06-24 09:15:25 Re: BUG #19484: Segmentation fault triggered by FDW
Previous Message Laurenz Albe 2026-06-24 08:19:52 Re: BUG #19531: Inconsistent Error Messages for the Same SQL Query