]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix UNION/INTERSECT/EXCEPT over no columns.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 22 Dec 2017 17:08:18 +0000 (12:08 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 22 Dec 2017 17:08:18 +0000 (12:08 -0500)
commitc252ccda74295ad292c407a361c9d55ca0554e00
treea2456c51be098f6f22387e7834a3c2691519a29d
parentf3decdc94ea3dea05715325757db7b0295672bbe
Fix UNION/INTERSECT/EXCEPT over no columns.

Since 9.4, we've allowed the syntax "select union select" and variants
of that.  However, the planner wasn't expecting a no-column set operation
and ended up treating the set operation as if it were UNION ALL.

Turns out it's trivial to fix in v10 and later; we just need to be careful
about not generating a Sort node with no sort keys.  However, since a weird
corner case like this is never going to be exercised by developers, we'd
better have thorough regression tests if we want to consider it supported.

Per report from Victor Yegorov.

Discussion: https://postgr.es/m/CAGnEbojGJrRSOgJwNGM7JSJZpVAf8xXcVPbVrGdhbVEHZ-BUMw@mail.gmail.com
src/backend/optimizer/plan/createplan.c
src/backend/optimizer/prep/prepunion.c
src/test/regress/expected/union.out
src/test/regress/sql/union.sql