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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: shihao zhong <zhong950419(at)gmail(dot)com>
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:25:59
Message-ID: 1874583.1795724759@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

shihao zhong <zhong950419(at)gmail(dot)com> writes:
> 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.

Hmm, why should it matter whether the opfamily is default or not?
I grant that the pattern_ops opfamily is collation-insensitive,
but we shouldn't assume that that's universally true.

> 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?

It's not clear to me whether that's sufficiently closely related to be
considered the same bug. Do you have an idea where it needs to be
fixed?

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2026-11-26 21:18:48 Re: btree_gist: <-> fails on same-sign infinite intervals
Previous Message shihao zhong 2026-11-26 20:16:58 Re: BUG #19873: planner silently drops the second ORDER BY sort key when both keys reference the same expression und