Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0adaf4c

Browse files
committed
Move the handling of SELECT FOR UPDATE locking and rechecking out of
execMain.c and into a new plan node type LockRows. Like the recent changeto put table updating into a ModifyTable plan node, this increases planningflexibility by allowing the operations to occur below the top level of theplan tree. It's necessary in any case to restore the previous behavior ofhaving FOR UPDATE locking occur before ModifyTable does.This partially refactors EvalPlanQual to allow multiple rows-under-testto be inserted into the EPQ machinery before starting an EPQ test query.That isn't sufficient to fix EPQ's general bogosity in the face of plansthat return multiple rows per test row, though. Since this patch ismostly about getting some plan node infrastructure in place and not aboutfixing ten-year-old bugs, I will leave EPQ improvements for another day.Another behavioral change that we could now think about is doing FOR UPDATEbefore LIMIT, but that too seems like it should be treated as a followonpatch.
1 parent05d2497 commit0adaf4c

32 files changed

+879
-317
lines changed

‎src/backend/commands/explain.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994-5, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.191 2009/10/10 01:43:45 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.192 2009/10/12 18:10:41 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -718,6 +718,9 @@ ExplainNode(Plan *plan, PlanState *planstate,
718718
break;
719719
}
720720
break;
721+
caseT_LockRows:
722+
pname=sname="LockRows";
723+
break;
721724
caseT_Limit:
722725
pname=sname="Limit";
723726
break;

‎src/backend/executor/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Makefile for executor
55
#
66
# IDENTIFICATION
7-
# $PostgreSQL: pgsql/src/backend/executor/Makefile,v 1.30 2009/10/10 01:43:45 tgl Exp $
7+
# $PostgreSQL: pgsql/src/backend/executor/Makefile,v 1.31 2009/10/12 18:10:41 tgl Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -17,12 +17,12 @@ OBJS = execAmi.o execCurrent.o execGrouping.o execJunk.o execMain.o \
1717
execUtils.o functions.o instrument.o nodeAppend.o nodeAgg.o\
1818
nodeBitmapAnd.o nodeBitmapOr.o\
1919
nodeBitmapHeapscan.o nodeBitmapIndexscan.o nodeHash.o\
20-
nodeHashjoin.o nodeIndexscan.onodeMaterial.onodeMergejoin.o\
21-
nodeModifyTable.o\
20+
nodeHashjoin.o nodeIndexscan.onodeLimit.onodeLockRows.o\
21+
nodeMaterial.o nodeMergejoin.onodeModifyTable.o\
2222
nodeNestloop.o nodeFunctionscan.o nodeRecursiveunion.o nodeResult.o\
2323
nodeSeqscan.o nodeSetOp.o nodeSort.o nodeUnique.o\
2424
nodeValuesscan.o nodeCtescan.o nodeWorktablescan.o\
25-
nodeLimit.onodeGroup.o nodeSubplan.o nodeSubqueryscan.o nodeTidscan.o\
25+
nodeGroup.o nodeSubplan.o nodeSubqueryscan.o nodeTidscan.o\
2626
nodeWindowAgg.o tstoreReceiver.o spi.o
2727

2828
include$(top_srcdir)/src/backend/common.mk

‎src/backend/executor/README

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$PostgreSQL: pgsql/src/backend/executor/README,v 1.9 2009/10/10 01:43:45 tgl Exp $
1+
$PostgreSQL: pgsql/src/backend/executor/README,v 1.10 2009/10/12 18:10:41 tgl Exp $
22

33
The Postgres Executor
44
=====================
@@ -157,7 +157,8 @@ if need be) and re-evaluate the query qualifications to see if it would
157157
still meet the quals. If so, we regenerate the updated tuple (if we are
158158
doing an UPDATE) from the modified tuple, and finally update/delete the
159159
modified tuple. SELECT FOR UPDATE/SHARE behaves similarly, except that its
160-
action is just to lock the modified tuple.
160+
action is just to lock the modified tuple and return results based on that
161+
version of the tuple.
161162

162163
To implement this checking, we actually re-run the entire query from scratch
163164
for each modified tuple, but with the scan node that sourced the original
@@ -195,5 +196,5 @@ It should be noted also that UPDATE/DELETE expect at most one tuple to
195196
result from the modified query, whereas in the FOR UPDATE case it's possible
196197
for multiple tuples to result (since we could be dealing with a join in
197198
which multiple tuples join to the modified tuple). We want FOR UPDATE to
198-
lock all relevant tuples, so wepass all tuples output by all the stacked
199-
recheck queries back to the executor toplevel for locking.
199+
lock all relevant tuples, so weprocess all tuples output by all the stacked
200+
recheck queries.

‎src/backend/executor/execAmi.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2009, 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.105 2009/10/10 01:43:45 tgl Exp $
9+
*$PostgreSQL: pgsql/src/backend/executor/execAmi.c,v 1.106 2009/10/12 18:10:41 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -28,6 +28,7 @@
2828
#include"executor/nodeHashjoin.h"
2929
#include"executor/nodeIndexscan.h"
3030
#include"executor/nodeLimit.h"
31+
#include"executor/nodeLockRows.h"
3132
#include"executor/nodeMaterial.h"
3233
#include"executor/nodeMergejoin.h"
3334
#include"executor/nodeModifyTable.h"
@@ -232,6 +233,10 @@ ExecReScan(PlanState *node, ExprContext *exprCtxt)
232233
ExecReScanSetOp((SetOpState*)node,exprCtxt);
233234
break;
234235

236+
caseT_LockRowsState:
237+
ExecReScanLockRows((LockRowsState*)node,exprCtxt);
238+
break;
239+
235240
caseT_LimitState:
236241
ExecReScanLimit((LimitState*)node,exprCtxt);
237242
break;
@@ -444,8 +449,9 @@ ExecSupportsBackwardScan(Plan *node)
444449
/* these don't evaluate tlist */
445450
return true;
446451

452+
caseT_LockRows:
447453
caseT_Limit:
448-
/*doesn't evaluate tlist */
454+
/*these don't evaluate tlist */
449455
returnExecSupportsBackwardScan(outerPlan(node));
450456

451457
default:

‎src/backend/executor/execCurrent.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
*$PostgreSQL: pgsql/src/backend/executor/execCurrent.c,v 1.10 2009/06/11 14:48:56 momjian Exp $
9+
*$PostgreSQL: pgsql/src/backend/executor/execCurrent.c,v 1.11 2009/10/12 18:10:41 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -155,8 +155,7 @@ execCurrentOf(CurrentOfExpr *cexpr,
155155
* scan node. Fail if it's not there or buried underneath
156156
* aggregation.
157157
*/
158-
scanstate=search_plan_tree(ExecGetActivePlanTree(queryDesc),
159-
table_oid);
158+
scanstate=search_plan_tree(queryDesc->planstate,table_oid);
160159
if (!scanstate)
161160
ereport(ERROR,
162161
(errcode(ERRCODE_INVALID_CURSOR_STATE),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp