]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix "cannot accept a set" error when only some arms of a CASE return a set.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 9 Jan 2014 01:18:24 +0000 (20:18 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 9 Jan 2014 01:18:24 +0000 (20:18 -0500)
commit57ac7d8a713de2cd95344d0c4ac5aff50d153639
tree0b6ae37030937b31b1615e70b5377bf8c7dbfb9a
parent75c02a31e064dbc7737a5b109abb6e836288d96f
Fix "cannot accept a set" error when only some arms of a CASE return a set.

In commit c1352052ef1d4eeb2eb1d822a207ddc2d106cb13, I implemented an
optimization that assumed that a function's argument expressions would
either always return a set (ie multiple rows), or always not.  This is
wrong however: we allow CASE expressions in which some arms return a set
of some type and others just return a scalar of that type.  There may be
other examples as well.  To fix, replace the run-time test of whether an
argument returned a set with a static precheck (expression_returns_set).
This adds a little bit of query startup overhead, but it seems barely
measurable.

Per bug #8228 from David Johnston.  This has been broken since 8.0,
so patch all supported branches.
src/backend/executor/execQual.c
src/test/regress/expected/rangefuncs.out
src/test/regress/sql/rangefuncs.sql