Skip to content
Snippets Groups Projects
Commit bfe553fb authored by Tom Lane's avatar Tom Lane
Browse files

Repair oversight in 8.2 change that improved the handling of "pseudoconstant"

WHERE clauses.  createplan.c is now willing to stick a gating Result node
almost anywhere in the plan tree, and in particular one can wind up directly
underneath a MergeJoin node.  This means it had better be willing to handle
Mark/Restore.  Fortunately, that's trivial in such cases, since we can just
pass off the call to the input node (which the planner has previously ensured
can handle Mark/Restore).  Per report from Phil Frost.
parent d19da98a
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/backend/executor/execAmi.c,v 1.90 2007/01/05 22:19:27 momjian Exp $ * $PostgreSQL: pgsql/src/backend/executor/execAmi.c,v 1.91 2007/02/15 03:07:13 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -243,6 +243,10 @@ ExecMarkPos(PlanState *node) ...@@ -243,6 +243,10 @@ ExecMarkPos(PlanState *node)
ExecSortMarkPos((SortState *) node); ExecSortMarkPos((SortState *) node);
break; break;
case T_ResultState:
ExecResultMarkPos((ResultState *) node);
break;
default: default:
/* don't make hard error unless caller asks to restore... */ /* don't make hard error unless caller asks to restore... */
elog(DEBUG2, "unrecognized node type: %d", (int) nodeTag(node)); elog(DEBUG2, "unrecognized node type: %d", (int) nodeTag(node));
...@@ -296,6 +300,10 @@ ExecRestrPos(PlanState *node) ...@@ -296,6 +300,10 @@ ExecRestrPos(PlanState *node)
ExecSortRestrPos((SortState *) node); ExecSortRestrPos((SortState *) node);
break; break;
case T_ResultState:
ExecResultRestrPos((ResultState *) node);
break;
default: default:
elog(ERROR, "unrecognized node type: %d", (int) nodeTag(node)); elog(ERROR, "unrecognized node type: %d", (int) nodeTag(node));
break; break;
...@@ -328,6 +336,16 @@ ExecSupportsMarkRestore(NodeTag plantype) ...@@ -328,6 +336,16 @@ ExecSupportsMarkRestore(NodeTag plantype)
case T_Sort: case T_Sort:
return true; return true;
case T_Result:
/*
* T_Result only supports mark/restore if it has a child plan
* that does, so we do not have enough information to give a
* really correct answer. However, for current uses it's
* enough to always say "false", because this routine is not
* asked about gating Result plans, only base-case Results.
*/
return false;
default: default:
break; break;
} }
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/nodeResult.c,v 1.37 2007/02/02 00:07:03 tgl Exp $ * $PostgreSQL: pgsql/src/backend/executor/nodeResult.c,v 1.38 2007/02/15 03:07:13 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -166,6 +166,36 @@ ExecResult(ResultState *node) ...@@ -166,6 +166,36 @@ ExecResult(ResultState *node)
return NULL; return NULL;
} }
/* ----------------------------------------------------------------
* ExecResultMarkPos
* ----------------------------------------------------------------
*/
void
ExecResultMarkPos(ResultState *node)
{
PlanState *outerPlan = outerPlanState(node);
if (outerPlan != NULL)
ExecMarkPos(outerPlan);
else
elog(DEBUG2, "Result nodes do not support mark/restore");
}
/* ----------------------------------------------------------------
* ExecResultRestrPos
* ----------------------------------------------------------------
*/
void
ExecResultRestrPos(ResultState *node)
{
PlanState *outerPlan = outerPlanState(node);
if (outerPlan != NULL)
ExecRestrPos(outerPlan);
else
elog(ERROR, "Result nodes do not support mark/restore");
}
/* ---------------------------------------------------------------- /* ----------------------------------------------------------------
* ExecInitResult * ExecInitResult
* *
...@@ -180,8 +210,8 @@ ExecInitResult(Result *node, EState *estate, int eflags) ...@@ -180,8 +210,8 @@ ExecInitResult(Result *node, EState *estate, int eflags)
ResultState *resstate; ResultState *resstate;
/* check for unsupported flags */ /* check for unsupported flags */
Assert(!(eflags & EXEC_FLAG_MARK)); Assert(!(eflags & (EXEC_FLAG_MARK | EXEC_FLAG_BACKWARD)) ||
Assert(!(eflags & EXEC_FLAG_BACKWARD) || outerPlan(node) != NULL); outerPlan(node) != NULL);
/* /*
* create state structure * create state structure
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/executor/nodeResult.h,v 1.23 2007/01/05 22:19:54 momjian Exp $ * $PostgreSQL: pgsql/src/include/executor/nodeResult.h,v 1.24 2007/02/15 03:07:13 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -20,6 +20,8 @@ extern int ExecCountSlotsResult(Result *node); ...@@ -20,6 +20,8 @@ extern int ExecCountSlotsResult(Result *node);
extern ResultState *ExecInitResult(Result *node, EState *estate, int eflags); extern ResultState *ExecInitResult(Result *node, EState *estate, int eflags);
extern TupleTableSlot *ExecResult(ResultState *node); extern TupleTableSlot *ExecResult(ResultState *node);
extern void ExecEndResult(ResultState *node); extern void ExecEndResult(ResultState *node);
extern void ExecResultMarkPos(ResultState *node);
extern void ExecResultRestrPos(ResultState *node);
extern void ExecReScanResult(ResultState *node, ExprContext *exprCtxt); extern void ExecReScanResult(ResultState *node, ExprContext *exprCtxt);
#endif /* NODERESULT_H */ #endif /* NODERESULT_H */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment