postgresql/src/backend/utils
Tom Lane 630520c22f Avoid assertion failure if a setop leaf query contains setops.
Ordinarily transformSetOperationTree will collect all UNION/
INTERSECT/EXCEPT steps into the setOperations tree of the topmost
Query, so that leaf queries do not contain any setOperations.
However, it cannot thus flatten a subquery that also contains
WITH, ORDER BY, FOR UPDATE, or LIMIT.  I (tgl) forgot that in
commit 07b4c48b6 and wrote an assertion in rule deparsing that
a leaf's setOperations would always be empty.

If it were nonempty then we would want to parenthesize the subquery
to ensure that the output represents the setop nesting correctly
(e.g. UNION below INTERSECT had better get parenthesized).  So
rather than just removing the faulty Assert, let's change it into
an additional case to check to decide whether to add parens.  We
don't expect that the additional case will ever fire, but it's
cheap insurance.

Man Zeng and Tom Lane

Discussion: https://postgr.es/m/tencent_7ABF9B1F23B0C77606FC5FE3@qq.com
2024-11-20 12:03:47 -05:00
..
adt Avoid assertion failure if a setop leaf query contains setops. 2024-11-20 12:03:47 -05:00
cache Revert "For inplace update, send nontransactional invalidations." 2024-11-02 09:05:07 -07:00
error Fix Y2038 issues with MyStartTime. 2024-10-07 13:51:03 -05:00
fmgr Fix -Wcast-function-type warnings 2024-11-08 09:42:21 +10:30
hash Fix -Wcast-function-type warnings 2024-11-08 09:42:21 +10:30
init Fix per-session activation of ALTER {ROLE|DATABASE} SET role. 2024-11-15 20:40:00 -08:00
mb Dial back -Wimplicit-fallthrough to level 3 2020-05-13 15:31:14 -04:00
misc Fix per-session activation of ALTER {ROLE|DATABASE} SET role. 2024-11-15 20:40:00 -08:00
mmgr Ignore not-yet-defined Portals in pg_cursors view. 2024-10-06 16:03:48 -04:00
resowner Improve performance of "simple expressions" in PL/pgSQL. 2020-03-26 18:58:57 -04:00
sort Clarify comment for LogicalTapeSetBlocks(). 2024-03-25 12:01:11 -07:00
time Revert "Improve error message on snapshot import in snapmgr.c" 2023-09-14 16:00:43 +09:00
.gitignore Rearrange makefile rules for running Gen_fmgrtab.pl. 2018-05-03 17:54:18 -04:00
errcodes.txt Make SQL/JSON error code names match SQL standard 2020-04-30 09:34:54 +02:00
Gen_dummy_probes.pl Emit dummy statements for probes.d probes when disabled 2021-05-10 13:56:21 +02:00
Gen_dummy_probes.sed Emit dummy statements for probes.d probes when disabled 2021-05-10 13:56:21 +02:00
Gen_fmgrtab.pl Use perl warnings pragma consistently 2020-04-13 11:55:45 -04:00
generate-errcodes.pl Update copyrights for 2020 2020-01-01 12:21:45 -05:00
Makefile Update copyrights for 2020 2020-01-01 12:21:45 -05:00
probes.d Update copyrights for 2020 2020-01-01 12:21:45 -05:00