Re: Re:BUG #18221: Unexpected Query Result - Mailing list pgsql-bugs

From Ba Jinsheng
Subject Re: Re:BUG #18221: Unexpected Query Result
Date
Msg-id SEZPR06MB64946F78596BF44C8753C5B58A86A@SEZPR06MB6494.apcprd06.prod.outlook.com
Whole thread Raw
In response to Re:BUG #18221: Unexpected Query Result  (Sergei Kornilov <sk@zsrv.org>)
List 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@zsrv.org>
Sent: Sunday, December 3, 2023 9:44 PM
To: PG Bug reporting form <noreply@postgresql.org>
Cc: Ba Jinsheng <bajinsheng@u.nus.edu>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.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

pgsql-bugs by date:

Previous
From: Jeff Laing
Date:
Subject: RE: BUG #18219: libpq does not take into consideration UNICODE define
Next
From: PG Bug reporting form
Date:
Subject: BUG #18222: Unexpected Error--Cannot delete from scalar