pgsql: Fix handling of data-modifying CTE subplans in EvalPlanQual.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix handling of data-modifying CTE subplans in EvalPlanQual.
Date: 2012-01-28 22:55:30
Message-ID: E1RrHBC-0005wg-EB@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/7c1719bc68ec1c347e7c80c3735bf3373e765f35

Modified Files
--------------
src/backend/executor/execMain.c | 13 ++-----------
src/backend/executor/nodeModifyTable.c | 26 +++++++++++++++++---------
2 files changed, 19 insertions(+), 20 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2012-01-29 01:25:02 pgsql: Fix handling of init_plans list in inheritance_planner().
Previous Message Magnus Hagander 2012-01-28 09:04:11 pgsql: Prevent logging "failed to stat file: success" for temp files