model-writtenrun 4572 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Nidal FAKIH reported that COUNT(DISTINCT x COLLATE "C") with nondeterministic GROUP BY collation returned 40 instead of 2, supplied a reproduction, and showed that disabling presorted aggregation avoided the problem #1.
- David Rowley traced the failure to nodeSort.c: its single-column Datum sort ignored subsequent sort keys, while ordinary ORDER BY queries avoided that path because the planner added output columns for the differing collations #2.
- David Rowley supplied a draft requiring both one output column and one sort key before enabling Datum sorting #2.
- The draft landed as b715192e52 with unchanged executable code and an expanded explanatory comment from the version in #2.
- David Rowley confirmed the fix was pushed and backpatched through PostgreSQL 15, explaining that version 15 might not be affected but received the safeguard against possible custom collatable pass-by-value types; no further work remained proposed in the thread #3.