Re: BUG #19873: planner silently drops the second ORDER BY sort key when both keys reference the same expression und

From: shihao zhong <zhong950419(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: 303677365(at)qq(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19873: planner silently drops the second ORDER BY sort key when both keys reference the same expression und
Date: 2026-11-26 20:16:58
Message-ID: CAGRkXqSRz-9hmS4v56_mDHxYEpPoh+6EahyMH0P-yu+gyqiZMA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi Tom,

Thanks, v2 does it in the planner. Under a nondeterministic collation
a sort key with a non-default opfamily now gets its own
EquivalenceClass, so it is never merged with other keys or clauses.

I also found that GROUP BY x ORDER BY x USING ~<~ is wrong with a
sorted GroupAggregate. It returns 4 groups on the report's table, and
HashAggregate returns 2. Should we fix that in this thread too?

Thank,
Shihao

Attachment Content-Type Size
v2-0001-Fix-merging-of-sort-keys-under-nondeterministic-coll.patch application/x-patch 6.1 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2026-11-26 20:25:59 Re: BUG #19873: planner silently drops the second ORDER BY sort key when both keys reference the same expression und
Previous Message Kirill Reshke 2026-11-26 20:14:01 Re: BUG #19942: SIGSEGV crash (and wrong results) in MERGE ... RETURNING WITH (OLD/NEW) with VIRTUAL generated colum