Reproducing incorrect order with order by in a subquery

From: Ruslan Zakirov <ruslan(dot)zakirov(at)gmail(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Reproducing incorrect order with order by in a subquery
Date: 2023-06-13 07:49:50
Message-ID: CAMOxC8tBBR8DK3c73zUWSWRzTPP2FHv5+sLFqL2ZWWwLqGmzhw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

For example I have a query:

SELECT main.*, count(*) OVER () FROM (SELECT DISTINCT ... ORDER BY X) main;

So the `ORDER BY` clause ended up in a subquery. Most of the time ordering
works until it doesn't.

Can you help me create a set of test tables with some data to reproduce
this problem more repeatedly? I just want to write a regression test to
make sure it doesn't happen again.

--
Best regards, Ruslan.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael Paquier 2023-06-13 07:50:54 Re: Support logical replication of DDLs
Previous Message Wen Yi 2023-06-13 06:49:02 Re: How to trace the postgres?