jrgemignani commented on code in PR #2592:
URL: https://github.com/apache/age/pull/2592#discussion_r4250953846


##########
src/backend/utils/adt/age_global_graph.c:
##########
@@ -786,18 +863,196 @@ static bool insert_vertex_edge(GRAPH_global_context 
*ggctx,
     return false;
 }
 
+/* checker for check_functions_in_node: a function that is not IMMUTABLE */
+static bool rls_function_not_immutable(Oid func_id, void *context)
+{
+    return (func_volatile(func_id) != PROVOLATILE_IMMUTABLE);
+}
+
+/*
+ * PostgreSQL's contain_mutable_functions_walker, except for the SQL value
+ * functions whose result cannot change during a statement without the reuse
+ * check noticing: the date and time ones are fixed for the transaction,
+ * CURRENT_ROLE, CURRENT_USER and USER are the current role, which the reuse
+ * check compares, and CURRENT_CATALOG is fixed for the session. SESSION_USER
+ * and CURRENT_SCHEMA can change within a statement.
+ */
+static bool rls_quals_vary_walker(Node *node, void *context)
+{
+    if (node == NULL)
+    {
+        return false;
+    }
+
+    if (check_functions_in_node(node, rls_function_not_immutable, context))
+    {
+        return true;
+    }
+
+    if (IsA(node, JsonConstructorExpr))
+    {
+        JsonConstructorExpr *ctor = (JsonConstructorExpr *) node;
+        bool is_jsonb = (ctor->returning->format->format_type ==

Review Comment:
   Thanks. PostgreSQL guarantees that a transformed JsonConstructorExpr has a
   JsonReturning and JsonFormat; transformJsonOutput() creates defaults when no
   RETURNING clause is specified. PostgreSQL's optimizer and executor use the
   same unconditional access. I also tested JSON_OBJECT and JSON_ARRAY without
   RETURNING in an RLS policy on an assertion build, and the traversal completed
   successfully. No change is needed here.



-- 
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