Subject: Path to unreverting "Allow planner to use Merge Append to efficiently implement UNION"

From: David Rowley <[email-masked]>
Date: Tue, 21 May 2024 14:58:10 +1200

Earlier today in [1], a bug was reported regarding a problem with the
code added in 66c0185a3 where I'd failed to handle the case correctly
where the UNION's targetlist has columns which are not sortable.  For
pg_class, that's relfrozenxid, relminmxid and relacl.

The most minimal reproducer prior to the revert is:

set enable_hashagg=0;
explain (costs off) select '123'::xid union select '123'::xid;

There is still some ongoing discussion about this on the release
mailing list as per mentioned by Tom in the commit message in
7204f3591.

At some point that discussion is going to need to circle back onto
-hackers again, and since I've already written a patch to fix the
issue and un-revert Tom's revert. I just wanted a place on -hackers to
allow that code to be viewed and discussed.  I did also post a patch
on [2], but that no longer applies to master due to the revert.

I'll allow the RMT to choose where the outcome of the RMT decision
goes.  Let this thread be for at least the coding portion of this or
be my thread for this patch for the v18 cycle if the RMT rules in
favour of keeping that code reverted for v17.

I've attached 2 patches.

0001 is a simple revert of Tom's revert (7204f3591).
0002 fixes the issue reported by Hubert.

If anyone wants to have a look, I'd be grateful for that.  Tom did
call for further review after this being the 4th issue reported for
66c0185a3.

David

[1] https://postgr.es/message-id/Zktzf926vslR35Fv%40depesz.com
[2] https://www.postgresql.org/message-id/CAApHDvpDQh1NcL7nAsd3YAKj4vgORwesB3GYuNPnEXXRfA2g4w%40mail.gmail.com

---

From: Alvaro Herrera <[email-masked]>
Date: Tue, 21 May 2024 14:34:56 +0200

> 0002 fixes the issue reported by Hubert.

I would like to request that you don't keep 0001's message as you have
it here.  It'd be more readable to take 66c0185a3d14's whole commit
message with a small suffix like "try 2" in the commit title, and add an
additional second paragraph stating it was transiently reverted by
7204f35919b7.  Otherwise it's harder to make sense of the commit on its
own later.

-- 
Álvaro Herrera        Breisgau, Deutschland  —  https://www.EnterpriseDB.com/