Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bfe553f

Browse files
committed
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.
1 parent d19da98 commit bfe553f

File tree

3 files changed

+55
-5
lines changed

3 files changed

+55
-5
lines changed

src/backend/executor/execAmi.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/backend/executor/execAmi.c,v 1.90 2007/01/05 22:19:27 momjian Exp $
9+
* $PostgreSQL: pgsql/src/backend/executor/execAmi.c,v 1.91 2007/02/15 03:07:13 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -243,6 +243,10 @@ ExecMarkPos(PlanState *node)
243243
ExecSortMarkPos((SortState *) node);
244244
break;
245245

246+
case T_ResultState:
247+
ExecResultMarkPos((ResultState *) node);
248+
break;
249+
246250
default:
247251
/* don't make hard error unless caller asks to restore... */
248252
elog(DEBUG2, "unrecognized node type: %d", (int) nodeTag(node));
@@ -296,6 +300,10 @@ ExecRestrPos(PlanState *node)
296300
ExecSortRestrPos((SortState *) node);
297301
break;
298302

303+
case T_ResultState:
304+
ExecResultRestrPos((ResultState *) node);
305+
break;
306+
299307
default:
300308
elog(ERROR, "unrecognized node type: %d", (int) nodeTag(node));
301309
break;
@@ -328,6 +336,16 @@ ExecSupportsMarkRestore(NodeTag plantype)
328336
case T_Sort:
329337
return true;
330338

339+
case T_Result:
340+
/*
341+
* T_Result only supports mark/restore if it has a child plan
342+
* that does, so we do not have enough information to give a
343+
* really correct answer. However, for current uses it's
344+
* enough to always say "false", because this routine is not
345+
* asked about gating Result plans, only base-case Results.
346+
*/
347+
return false;
348+
331349
default:
332350
break;
333351
}

src/backend/executor/nodeResult.c

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
* Portions Copyright (c) 1994, Regents of the University of California
3939
*
4040
* IDENTIFICATION
41-
* $PostgreSQL: pgsql/src/backend/executor/nodeResult.c,v 1.37 2007/02/02 00:07:03 tgl Exp $
41+
* $PostgreSQL: pgsql/src/backend/executor/nodeResult.c,v 1.38 2007/02/15 03:07:13 tgl Exp $
4242
*
4343
*-------------------------------------------------------------------------
4444
*/
@@ -166,6 +166,36 @@ ExecResult(ResultState *node)
166166
return NULL;
167167
}
168168

169+
/* ----------------------------------------------------------------
170+
* ExecResultMarkPos
171+
* ----------------------------------------------------------------
172+
*/
173+
void
174+
ExecResultMarkPos(ResultState *node)
175+
{
176+
PlanState *outerPlan = outerPlanState(node);
177+
178+
if (outerPlan != NULL)
179+
ExecMarkPos(outerPlan);
180+
else
181+
elog(DEBUG2, "Result nodes do not support mark/restore");
182+
}
183+
184+
/* ----------------------------------------------------------------
185+
* ExecResultRestrPos
186+
* ----------------------------------------------------------------
187+
*/
188+
void
189+
ExecResultRestrPos(ResultState *node)
190+
{
191+
PlanState *outerPlan = outerPlanState(node);
192+
193+
if (outerPlan != NULL)
194+
ExecRestrPos(outerPlan);
195+
else
196+
elog(ERROR, "Result nodes do not support mark/restore");
197+
}
198+
169199
/* ----------------------------------------------------------------
170200
* ExecInitResult
171201
*
@@ -180,8 +210,8 @@ ExecInitResult(Result *node, EState *estate, int eflags)
180210
ResultState *resstate;
181211

182212
/* check for unsupported flags */
183-
Assert(!(eflags & EXEC_FLAG_MARK));
184-
Assert(!(eflags & EXEC_FLAG_BACKWARD) || outerPlan(node) != NULL);
213+
Assert(!(eflags & (EXEC_FLAG_MARK | EXEC_FLAG_BACKWARD)) ||
214+
outerPlan(node) != NULL);
185215

186216
/*
187217
* create state structure

src/include/executor/nodeResult.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/executor/nodeResult.h,v 1.23 2007/01/05 22:19:54 momjian Exp $
10+
* $PostgreSQL: pgsql/src/include/executor/nodeResult.h,v 1.24 2007/02/15 03:07:13 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -20,6 +20,8 @@ extern int ExecCountSlotsResult(Result *node);
2020
extern ResultState *ExecInitResult(Result *node, EState *estate, int eflags);
2121
extern TupleTableSlot *ExecResult(ResultState *node);
2222
extern void ExecEndResult(ResultState *node);
23+
extern void ExecResultMarkPos(ResultState *node);
24+
extern void ExecResultRestrPos(ResultState *node);
2325
extern void ExecReScanResult(ResultState *node, ExprContext *exprCtxt);
2426

2527
#endif /* NODERESULT_H */

0 commit comments

Comments
 (0)