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

Commit83d0049

Browse files
committed
Lock all relations referred to in updatable views
Even views considered "simple" enough to be automatically updatable mayhave mulitple relations involved (eg: in a where clause). We need tomake sure and lock those relations when rewriting the query.Back-patch to 9.3 where updatable views were added.Pointed out by Andres, patch thanks to Dean Rasheed.
1 parentb74af40 commit83d0049

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

‎src/backend/rewrite/rewriteHandler.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2626,6 +2626,21 @@ rewriteTargetView(Query *parsetree, Relation view)
26262626

26272627
heap_close(base_rel,NoLock);
26282628

2629+
/*
2630+
* If the view query contains any sublink subqueries then we need to also
2631+
* acquire locks on any relations they refer to. We know that there won't
2632+
* be any subqueries in the range table or CTEs, so we can skip those, as
2633+
* in AcquireRewriteLocks.
2634+
*/
2635+
if (viewquery->hasSubLinks)
2636+
{
2637+
acquireLocksOnSubLinks_contextcontext;
2638+
2639+
context.for_execute= true;
2640+
query_tree_walker(viewquery,acquireLocksOnSubLinks,&context,
2641+
QTW_IGNORE_RC_SUBQUERIES);
2642+
}
2643+
26292644
/*
26302645
* Create a new target RTE describing the base relation, and add it to the
26312646
* outer query's rangetable. (What's happening in the next few steps is

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp