1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-27 23:21:58 +03:00

Clean up handling of FOR UPDATE inside views and subselects ... make it

work where we can (given that the executor only handles it at top level)
and generate an error where we can't.  Note that while the parser has
been allowing views to say SELECT FOR UPDATE for a few weeks now, that
hasn't actually worked until just now.
This commit is contained in:
Tom Lane
2000-12-06 23:55:19 +00:00
parent db0de2241d
commit 73d2a3595a
5 changed files with 85 additions and 42 deletions

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteManip.c,v 1.52 2000/12/05 19:15:09 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteManip.c,v 1.53 2000/12/06 23:55:18 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -169,8 +169,29 @@ OffsetVarNodes(Node *node, int offset, int sublevels_up)
* sublevels_up doesn't get incremented prematurely.
*/
if (node && IsA(node, Query))
query_tree_walker((Query *) node, OffsetVarNodes_walker,
{
Query *qry = (Query *) node;
List *l;
/*
* If we are starting at a Query, and sublevels_up is zero, then we
* must also fix rangetable indexes in the Query itself --- namely
* resultRelation and rowMarks entries. sublevels_up cannot be zero
* when recursing into a subquery, so there's no need to have the
* same logic inside OffsetVarNodes_walker.
*/
if (sublevels_up == 0)
{
if (qry->resultRelation)
qry->resultRelation += offset;
foreach(l, qry->rowMarks)
{
lfirsti(l) += offset;
}
}
query_tree_walker(qry, OffsetVarNodes_walker,
(void *) &context, true);
}
else
OffsetVarNodes_walker(node, &context);
}
@ -252,8 +273,30 @@ ChangeVarNodes(Node *node, int rt_index, int new_index, int sublevels_up)
* sublevels_up doesn't get incremented prematurely.
*/
if (node && IsA(node, Query))
query_tree_walker((Query *) node, ChangeVarNodes_walker,
{
Query *qry = (Query *) node;
List *l;
/*
* If we are starting at a Query, and sublevels_up is zero, then we
* must also fix rangetable indexes in the Query itself --- namely
* resultRelation and rowMarks entries. sublevels_up cannot be zero
* when recursing into a subquery, so there's no need to have the
* same logic inside ChangeVarNodes_walker.
*/
if (sublevels_up == 0)
{
if (qry->resultRelation == rt_index)
qry->resultRelation = new_index;
foreach(l, qry->rowMarks)
{
if (lfirsti(l) == rt_index)
lfirsti(l) = new_index;
}
}
query_tree_walker(qry, ChangeVarNodes_walker,
(void *) &context, true);
}
else
ChangeVarNodes_walker(node, &context);
}