Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 0a844e8

Browse files
committed
transformForUpdate() mustn't assume rowMarks list is initially empty.
It could be recursing into a sub-query where there was already a FOR UPDATE clause.
1 parent 73d2a35 commit 0a844e8

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/backend/parser/analyze.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: analyze.c,v 1.171 2000/12/06 23:55:19 tgl Exp $
9+
* $Id: analyze.c,v 1.172 2000/12/07 01:12:08 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -2503,6 +2503,7 @@ transformAlterTableStmt(ParseState *pstate, AlterTableStmt *stmt)
25032503
return qry;
25042504
}
25052505

2506+
/* exported so planner can check again after rewriting, query pullup, etc */
25062507
void
25072508
CheckSelectForUpdate(Query *qry)
25082509
{
@@ -2519,7 +2520,7 @@ CheckSelectForUpdate(Query *qry)
25192520
static void
25202521
transformForUpdate(Query *qry, List *forUpdate)
25212522
{
2522-
List *rowMarks = NIL;
2523+
List *rowMarks = qry->rowMarks;
25232524
List *l;
25242525
List *rt;
25252526
Index i;
@@ -2542,7 +2543,8 @@ transformForUpdate(Query *qry, List *forUpdate)
25422543
}
25432544
else
25442545
{
2545-
rowMarks = lappendi(rowMarks, i);
2546+
if (!intMember(i, rowMarks)) /* avoid duplicates */
2547+
rowMarks = lappendi(rowMarks, i);
25462548
rte->checkForWrite = true;
25472549
}
25482550
}

0 commit comments

Comments
 (0)