]> granicus.if.org Git - postgresql/commit
Fix possible crash with nested SubLinks.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 10 Dec 2013 21:10:20 +0000 (16:10 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 10 Dec 2013 21:10:20 +0000 (16:10 -0500)
commit9d2e07fecd4bd37fc9e231bd706bc0c9ce0f17a7
tree854ca0c45dc2707e148b92360fe4772b1fcd1cd6
parent0ec530625f1cc0a17d975f925fed5d3ab469c6f8
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.
src/backend/optimizer/plan/subselect.c
src/test/regress/expected/subselect.out
src/test/regress/sql/subselect.sql