pgsql: Fix "cannot accept a set" error when only some arms of a CASE re

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix "cannot accept a set" error when only some arms of a CASE re
Date: 2014-01-09 01:19:17
Message-ID: E1W14HF-0002TS-1h@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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.

Branch
------
REL9_0_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/6ca712fb906776818ba46e2dfc26ffc4592a64fa

Modified Files
--------------
src/backend/executor/execQual.c | 55 +++++++++++++++++++++---------
src/test/regress/expected/rangefuncs.out | 14 ++++++++
src/test/regress/sql/rangefuncs.sql | 9 +++++
3 files changed, 61 insertions(+), 17 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2014-01-09 01:58:29 pgsql: We don't need to include pg_sema.h in s_lock.h anymore.
Previous Message Tom Lane 2014-01-09 01:19:16 pgsql: Fix "cannot accept a set" error when only some arms of a CASE re