| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Ruslan Zakirov <ruslan(dot)zakirov(at)gmail(dot)com> |
| Cc: | Thomas Kellerer <shammat(at)gmx(dot)net>, pgsql-general(at)lists(dot)postgresql(dot)org |
| Subject: | Re: Reproducing incorrect order with order by in a subquery |
| Date: | 2023-06-13 15:06:53 |
| Message-ID: | 1635592.1686668813@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Ruslan Zakirov <ruslan(dot)zakirov(at)gmail(dot)com> writes:
> I know how to fix the problem and I know that ORDER BY should be in the
> outermost select.
> However, I want to write a test case that shows that the old code is wrong,
> but can not create
> minimal set of tables to reproduce it. With this I'm looking for help.
The ORDER BY in the sub-select will be honored at the output of the
sub-select. To have a different ordering at the final output, you
need the upper query to do something that would re-order the rows.
Joining the sub-select to something else might make that happen,
or you could apply DISTINCT or some other non-trivial processing
in the upper query.
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Dominique Devienne | 2023-06-13 15:11:18 | Re: "paths" between two ROLEs |
| Previous Message | Ruslan Zakirov | 2023-06-13 14:58:25 | Re: Reproducing incorrect order with order by in a subquery |