jrgemignani opened a new pull request, #2593:
URL: https://github.com/apache/age/pull/2593

   Since #2592, a query reuses an RLS-filtered graph across its traversals when 
a walker over the planned row-security quals judges that the policies cannot 
change during the statement. The walker copies PostgreSQL's 
contain_mutable_functions_walker, treats SQL value functions such as 
CURRENT_DATE and current_user as fixed, and reads the quals through 
SPI_plan_get_plan_sources(), which PostgreSQL leaves undocumented.
   
   The classification is not reliable. CURRENT_DATE, CURRENT_TIME, LOCALTIME 
and LOCALTIMESTAMP depend on the session TimeZone, which a statement can change 
with set_config(), and the inspected quals do not contain function default 
arguments, which the planner inserts later. A policy comparing CURRENT_DATE 
with an immutable date expression showed 5 links to the first of two traversals 
and, after the second switched the time zone, the same 5 links to the second, 
where two scans of the label return 5 and 0. The walker also uses node types 
that PostgreSQL 16 and earlier do not have, so it cannot be backported 
unchanged, and every new node type must be tracked by hand.
   
   Remove the walker and reuse a graph loaded through RLS only for the 
traversal that loaded it, as already done for policies the walker classified as 
varying. A traversal still loads the graph once instead of once per row, so the 
400-edge workload from the #2561 review still evaluates its policy 400 times 
instead of 160,000. A query with several traversals of one RLS-protected graph 
loads it once per traversal. Graphs loaded without RLS are unaffected.
   
   In rls_vle 8.3, two traversals with an immutable policy, alone and with 
current_user, now evaluate it 40 times instead of 20; the other counts are 
unchanged.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to