hello-stephen commented on code in PR #71241:
URL: https://github.com/apache/doris/pull/71241#discussion_r4779573140


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/CollectRelation.java:
##########
@@ -147,12 +151,57 @@ private Plan collectFromAny(MatchingContext<Plan> ctx) {
                     
subqueryContext.keepOrShowPlanProcess(ctx.cascadesContext.showPlanProcess(),
                             () -> 
subqueryContext.newTableCollector(true).collect());
                     
ctx.cascadesContext.addPlanProcesses(subqueryContext.getPlanProcesses());
+                } else if (e instanceof UnboundFunction) {
+                    collectFromIvmPlanSignatureFunction((UnboundFunction) e, 
ctx.cascadesContext);
                 }
             });
         }
         return null;
     }
 
+    private void collectFromIvmPlanSignatureFunction(UnboundFunction func, 
CascadesContext cascadesContext) {
+        if (!"ivm_plan_signature".equalsIgnoreCase(func.getName())
+                || func.arity() != 1
+                || !(func.child(0) instanceof StringLikeLiteral)) {

Review Comment:
   [P2] Collect bound MV-name parameters before taking table locks
   
   For an existing unique-key IVM `mv` and an unrelated OLAP table `b`, prepare 
`SELECT ivm_plan_signature(?) FROM b`, bind the parameter to `mv`, and execute 
it. The retained input is:
   
   ```text
   Project(ivm_plan_signature(Placeholder(0)))
     Scan(b)
   ```
   
   `ExecuteCommand` keeps the placeholder in the plan and carries its bound 
string in `StatementContext`. This guard therefore skips collecting the MV and 
its dependencies, while `StatementContext.lock()` still locks `b`. Only 
subsequent analysis substitutes the actual string in 
`ExpressionAnalyzer.visitPlaceholder`; FE folding then calls 
`verifyLockOrderSafety`, which throws “cannot evaluate a non-literal MV name” 
because the MV was never collected. Thus an ordinary projection prepares 
successfully but cannot execute even with a valid constant binding.
   
   Please resolve already-bound placeholder values during pre-lock dependency 
collection and cover this PREPARE/EXECUTE case. Deferring prepare-stage 
evaluation for the separately reported GROUP BY case does not fix this 
execution-stage failure.
   



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


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

Reply via email to