]> granicus.if.org Git - postgresql/commit
Fix handling of data-modifying CTE subplans in EvalPlanQual.
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 28 Jan 2012 22:44:03 +0000 (17:44 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 28 Jan 2012 22:44:03 +0000 (17:44 -0500)
commit0b1e1779533081f9d48c110a5e91ba122fc54461
treefaedb970914c2448263e7206913519a8680a393e
parent7c016e3f56e2a7d8e9dd00a6d2d80bdc2239424e
Fix handling of data-modifying CTE subplans in EvalPlanQual.

We can't just skip initializing such subplans, because the referencing CTE
node will expect to find the subplan available when it initializes.  That
in turn means that ExecInitModifyTable must allow the case (which actually
it needed to do anyway, since there's no guarantee that ModifyTable is
exactly at the top of the CTE plan tree).  So move the complaint about not
being allowed in EvalPlanQual mode to execution instead of initialization.
Testing turned up yet another problem, which is that we'd try to
re-initialize the result relation's index list, leading to leaks and
dangling pointers.

Per report from Phil Sorber.  Back-patch to 9.1 where data-modifying CTEs
were introduced.
src/backend/executor/execMain.c
src/backend/executor/nodeModifyTable.c