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

Commit2ba9e2b

Browse files
committed
Ensure locks are acquired on RLS-added relations
During fireRIRrules(), get_row_security_policies can add tosecurityQuals and withCheckOptions. Make sure to lock any relationsadded at that point and before firing RIR rules on those expressions.Back-patch to 9.5 where RLS was added.
1 parentc0f0d80 commit2ba9e2b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

‎src/backend/rewrite/rewriteHandler.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,6 +1794,8 @@ fireRIRrules(Query *parsetree, List *activeRIRs, bool forUpdatePushedDown)
17941794
{
17951795
if (hasSubLinks)
17961796
{
1797+
acquireLocksOnSubLinks_contextcontext;
1798+
17971799
/*
17981800
* Recursively process the new quals, checking for infinite
17991801
* recursion.
@@ -1806,6 +1808,23 @@ fireRIRrules(Query *parsetree, List *activeRIRs, bool forUpdatePushedDown)
18061808

18071809
activeRIRs=lcons_oid(RelationGetRelid(rel),activeRIRs);
18081810

1811+
/*
1812+
* get_row_security_policies just passed back securityQuals
1813+
* and/or withCheckOptions, and there were SubLinks, make sure
1814+
* we lock any relations which are referenced.
1815+
*
1816+
* These locks would normally be acquired by the parser, but
1817+
* securityQuals and withCheckOptions are added post-parsing.
1818+
*/
1819+
context.for_execute= true;
1820+
(void)acquireLocksOnSubLinks((Node*)securityQuals,&context);
1821+
(void)acquireLocksOnSubLinks((Node*)withCheckOptions,
1822+
&context);
1823+
1824+
/*
1825+
* Now that we have the locks on anything added by
1826+
* get_row_security_policies, fire any RIR rules for them.
1827+
*/
18091828
expression_tree_walker((Node*)securityQuals,
18101829
fireRIRonSubLink, (void*)activeRIRs);
18111830

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp