mirror of
https://github.com/postgres/postgres.git
synced 2025-07-18 17:42:25 +03:00
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 change to put table updating into a ModifyTable plan node, this increases planning flexibility by allowing the operations to occur below the top level of the plan tree. It's necessary in any case to restore the previous behavior of having FOR UPDATE locking occur before ModifyTable does. This partially refactors EvalPlanQual to allow multiple rows-under-test to 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 plans that return multiple rows per test row, though. Since this patch is mostly about getting some plan node infrastructure in place and not about fixing ten-year-old bugs, I will leave EPQ improvements for another day. Another behavioral change that we could now think about is doing FOR UPDATE before LIMIT, but that too seems like it should be treated as a followon patch.
This commit is contained in:
@ -17,7 +17,7 @@
|
||||
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.391 2009/09/09 03:32:52 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.392 2009/10/12 18:10:48 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -1388,7 +1388,7 @@ transformSetOperationTree(ParseState *pstate, SelectStmt *stmt,
|
||||
errmsg("SELECT FOR UPDATE/SHARE is not allowed with UNION/INTERSECT/EXCEPT")));
|
||||
|
||||
/*
|
||||
* If an internal node of a set-op tree has ORDER BY, UPDATE, or LIMIT
|
||||
* If an internal node of a set-op tree has ORDER BY, LIMIT, or FOR UPDATE
|
||||
* clauses attached, we need to treat it like a leaf node to generate an
|
||||
* independent sub-Query tree. Otherwise, it can be represented by a
|
||||
* SetOperationStmt node underneath the parent Query.
|
||||
@ -2251,6 +2251,7 @@ applyLockingClause(Query *qry, Index rtindex, bool forUpdate, bool noWait)
|
||||
rc = makeNode(RowMarkClause);
|
||||
rc->rti = rtindex;
|
||||
rc->prti = rtindex;
|
||||
rc->rowmarkId = 0; /* not used until plan time */
|
||||
rc->forUpdate = forUpdate;
|
||||
rc->noWait = noWait;
|
||||
rc->isParent = false;
|
||||
|
Reference in New Issue
Block a user