]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Compare collations before merging UNION operations.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 19 Nov 2024 23:26:19 +0000 (18:26 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 19 Nov 2024 23:26:19 +0000 (18:26 -0500)
commitc1ebef3c10dbfd8c6ec4c9b9ab03b7d1fe00ac79
tree9980a13c89eab01eeffc078d9ef2265b71831357
parent6304632eaa2107bb1763d29e213ff166ff6104c0
Compare collations before merging UNION operations.

In the dim past we figured it was okay to ignore collations
when combining UNION set-operation nodes into a single N-way
UNION operation.  I believe that was fine at the time, but
it stopped being fine when we added nondeterministic collations:
the semantics of distinct-ness are affected by those.  v17 made
it even less fine by allowing per-child sorting operations to
be merged via MergeAppend, although I think we accidentally
avoided any live bug from that.

Add a check that collations match before deciding that two
UNION nodes are equivalent.  I also failed to resist the
temptation to comment plan_union_children() a little better.

Back-patch to all supported branches (v13 now), since they
all have nondeterministic collations.

Discussion: https://postgr.es/m/3605568.1731970579@sss.pgh.pa.us
src/backend/optimizer/prep/prepunion.c