This is an automated email from the ASF dual-hosted git repository.

avamingli pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git


The following commit(s) were added to refs/heads/main by this push:
     new e7d36f85163 [AQUMV] Remove mutable checks during answering query.
e7d36f85163 is described below

commit e7d36f851637ceee518bbb336ffed2922d29d0ae
Author: Zhang Mingli <[email protected]>
AuthorDate: Tue Jun 10 11:32:11 2025 +0800

    [AQUMV] Remove mutable checks during answering query.
    
    The mutable checks are redundant at this stage since
    we already perform this validation during gp_matview_aux entity
    insertion.
    
    Authored-by: Zhang Mingli [email protected]
---
 src/backend/catalog/gp_matview_aux.c |  9 ++++++++-
 src/backend/optimizer/plan/aqumv.c   | 13 -------------
 2 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/catalog/gp_matview_aux.c 
b/src/backend/catalog/gp_matview_aux.c
index e62486f2488..9e1c224019c 100644
--- a/src/backend/catalog/gp_matview_aux.c
+++ b/src/backend/catalog/gp_matview_aux.c
@@ -98,7 +98,14 @@ GetViewBaseRelids(const Query *viewQuery, bool *has_foreign)
                return NIL;
        }
 
-       /* As we will use views, make it strict to unmutable. */
+       /*
+        * Use immutable functions for views to ensure strict immutability.
+        * While STABLE functions don't modify the database and return 
consistent
+        * results for the same arguments within a statement, AQUMV rewrites
+        * the query to new SQL. The behavior with STABLE functions isn't 
entirely
+        * clear in this context, so we're conservatively requiring IMMUTABLE
+        * functions for now.
+        */
        if (contain_mutable_functions((Node*)viewQuery))
                return NIL;
 
diff --git a/src/backend/optimizer/plan/aqumv.c 
b/src/backend/optimizer/plan/aqumv.c
index 59d133d8af4..63e82d759b0 100644
--- a/src/backend/optimizer/plan/aqumv.c
+++ b/src/backend/optimizer/plan/aqumv.c
@@ -353,19 +353,6 @@ answer_query_using_materialized_views(PlannerInfo *root, 
AqumvContext aqumv_cont
                subroot->tuple_fraction = root->tuple_fraction;
                subroot->limit_tuples = root->limit_tuples;
 
-               /*
-                * AQUMV_FIXME_MVP
-                * Are stable functions OK?
-                * A STABLE function cannot modify the database and is 
guaranteed to
-                * return the same results given the same arguments for all rows
-                * within a single statement.
-                * But AQUMV rewrites the query to a new SQL actually, though 
the same
-                * results is guaranteed.
-                * Its's unclear whether STABLE is OK, let's be conservative 
for now.
-                */
-               if(contain_mutable_functions((Node *)viewQuery))
-                       continue;
-
                context = aqumv_init_context(viewQuery->targetList, 
matviewRel->rd_att);
 
                if (!parse->hasAggs && viewQuery->hasAggs)


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to