Re: Re:BUG #18221: Unexpected Query Result

From: Ba Jinsheng <bajinsheng(at)u(dot)nus(dot)edu>
To: Sergei Kornilov <sk(at)zsrv(dot)org>, PG Bug reporting form <noreply(at)postgresql(dot)org>
Cc: "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: Re:BUG #18221: Unexpected Query Result
Date: 2023-12-04 01:17:57
Message-ID: SEZPR06MB64946F78596BF44C8753C5B58A86A@SEZPR06MB6494.apcprd06.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

> Can you reproduce the unexpected behavior with explicit order by clause?
Oh yes. For this query, the unexpected behavior disappears.
SELECT DISTINCT ON (t2.c0) t2.c0, abs(t1.c0) FROM t1, t3, t2 ORDER BY t2.c0, t1.c0, t3.c0;

Thanks for explanation!

________________________________
From: Sergei Kornilov <sk(at)zsrv(dot)org>
Sent: Sunday, December 3, 2023 9:44 PM
To: PG Bug reporting form <noreply(at)postgresql(dot)org>
Cc: Ba Jinsheng <bajinsheng(at)u(dot)nus(dot)edu>; pgsql-bugs(at)lists(dot)postgresql(dot)org <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re:BUG #18221: Unexpected Query Result

- External Email -

Hello

Using "distinct on" without specifying an explicit "order by" is unpredictable in itself. I'll quote from the manual:

> Note that the “first row” of each set is unpredictable unless ORDER BY is used to ensure that the desired row appears first.

Can you reproduce the unexpected behavior with explicit order by clause?

regards, Sergei

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2023-12-04 05:56:09 BUG #18222: Unexpected Error--Cannot delete from scalar
Previous Message Jeff Laing 2023-12-03 22:31:20 RE: BUG #18219: libpq does not take into consideration UNICODE define