pgsql: Fix possible crash with nested SubLinks.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix possible crash with nested SubLinks.
Date: 2013-12-10 21:11:06
Message-ID: E1VqUaA-00059t-DS@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix possible crash with nested SubLinks.

An expression such as WHERE (... x IN (SELECT ...) ...) IN (SELECT ...)
could produce an invalid plan that results in a crash at execution time,
if the planner attempts to flatten the outer IN into a semi-join.
This happens because convert_testexpr() was not expecting any nested
SubLinks and would wrongly replace any PARAM_SUBLINK Params belonging
to the inner SubLink. (I think the comment denying that this case could
happen was wrong when written; it's certainly been wrong for quite a long
time, since very early versions of the semijoin flattening logic.)

Per report from Teodor Sigaev. Back-patch to all supported branches.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/9ec6199d18d6235cc4b4d5e4e8986e73b55b14d8

Modified Files
--------------
src/backend/optimizer/plan/subselect.c | 27 ++++++++++++++++++++++-----
src/test/regress/expected/subselect.out | 29 +++++++++++++++++++++++++++++
src/test/regress/sql/subselect.sql | 11 +++++++++++
3 files changed, 62 insertions(+), 5 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Robert Haas 2013-12-11 00:07:23 pgsql: Add new wal_level, logical, sufficient for logical decoding.
Previous Message Noah Misch 2013-12-10 14:36:30 pgsql: Rename TABLE() to ROWS FROM().