diff --git a/pkg/planner/core/rule_predicate_simplification.go b/pkg/planner/core/rule_predicate_simplification.go index dde7dd725fdd5..3ab9bec94b266 100644 --- a/pkg/planner/core/rule_predicate_simplification.go +++ b/pkg/planner/core/rule_predicate_simplification.go @@ -55,6 +55,9 @@ func findPredicateType(expr expression.Expression) (*expression.Column, predicat return nil, orPredicate } args := v.GetArgs() + if len(args) == 0 { + return nil, otherPredicate + } col, colOk := args[0].(*expression.Column) if !colOk { return nil, otherPredicate diff --git a/tests/integrationtest/r/planner/core/issuetest/planner_issue.result b/tests/integrationtest/r/planner/core/issuetest/planner_issue.result index db2849b3767fb..fae189720819b 100644 --- a/tests/integrationtest/r/planner/core/issuetest/planner_issue.result +++ b/tests/integrationtest/r/planner/core/issuetest/planner_issue.result @@ -750,6 +750,7 @@ NULL NULL 2 2 4 2 show warnings; Level Code Message drop table if exists t1, t2, t3, t4; +<<<<<<< HEAD drop table if exists tl6e913fb9; CREATE TABLE `tl6e913fb9` ( `col_36` varchar(175) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'asMF', @@ -759,3 +760,11 @@ KEY `idx_65` (`col_36`(5)) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; with cte_192 ( col_1101,col_1102,col_1103,col_1104 ) AS ( select /*+ use_index_merge( tl6e913fb9 ) */ replace( tl6e913fb9.col_36 , tl6e913fb9.col_36 , tl6e913fb9.col_36 ) as r0 , space( 0 ) as r1 , min( distinct tl6e913fb9.col_36 ) as r2 , count( distinct tl6e913fb9.col_36 ) as r3 from tl6e913fb9 where tl6e913fb9.col_36 between 'n92ok$B%W#UU%O' and '()c=KVQ=T%-vzGJ' and tl6e913fb9.col_36 in ( 'T+kf' ,'Lvluod2H' ,'3#Omx@pC^fFkeH' ,'=b$z' ) group by tl6e913fb9.col_36 having tl6e913fb9.col_36 = 'xjV@' or IsNull( tl6e913fb9.col_36 ) ) ( select 1,col_1101,col_1102,col_1103,col_1104 from cte_192 where not( IsNull( cte_192.col_1102 ) ) order by 1,2,3,4,5 limit 72850972 ); 1 col_1101 col_1102 col_1103 col_1104 +======= +drop table if exists t0, v0; +drop view if exists v0; +CREATE TABLE t0(c0 INTEGER); +CREATE VIEW v0(c0) AS SELECT 'a' FROM t0 WHERE (CASE t0.c0 WHEN t0.c0 THEN false END ); +SELECT t0.c0 FROM v0, t0 WHERE RAND(); +c0 +>>>>>>> ed2d749bc1f (planner: Fix predicate simplification panic caused by zero-argument expressions like rand() (#56947)) diff --git a/tests/integrationtest/t/planner/core/issuetest/planner_issue.test b/tests/integrationtest/t/planner/core/issuetest/planner_issue.test index b1802c7089860..72a8da7fd5ae7 100644 --- a/tests/integrationtest/t/planner/core/issuetest/planner_issue.test +++ b/tests/integrationtest/t/planner/core/issuetest/planner_issue.test @@ -518,6 +518,7 @@ SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b show warnings; drop table if exists t1, t2, t3, t4; +<<<<<<< HEAD # TestIssue56479 drop table if exists tl6e913fb9; CREATE TABLE `tl6e913fb9` ( @@ -526,4 +527,12 @@ CREATE TABLE `tl6e913fb9` ( PRIMARY KEY (`col_36`) /*T![clustered_index] NONCLUSTERED */, KEY `idx_65` (`col_36`(5)) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -with cte_192 ( col_1101,col_1102,col_1103,col_1104 ) AS ( select /*+ use_index_merge( tl6e913fb9 ) */ replace( tl6e913fb9.col_36 , tl6e913fb9.col_36 , tl6e913fb9.col_36 ) as r0 , space( 0 ) as r1 , min( distinct tl6e913fb9.col_36 ) as r2 , count( distinct tl6e913fb9.col_36 ) as r3 from tl6e913fb9 where tl6e913fb9.col_36 between 'n92ok$B%W#UU%O' and '()c=KVQ=T%-vzGJ' and tl6e913fb9.col_36 in ( 'T+kf' ,'Lvluod2H' ,'3#Omx@pC^fFkeH' ,'=b$z' ) group by tl6e913fb9.col_36 having tl6e913fb9.col_36 = 'xjV@' or IsNull( tl6e913fb9.col_36 ) ) ( select 1,col_1101,col_1102,col_1103,col_1104 from cte_192 where not( IsNull( cte_192.col_1102 ) ) order by 1,2,3,4,5 limit 72850972 ); \ No newline at end of file +with cte_192 ( col_1101,col_1102,col_1103,col_1104 ) AS ( select /*+ use_index_merge( tl6e913fb9 ) */ replace( tl6e913fb9.col_36 , tl6e913fb9.col_36 , tl6e913fb9.col_36 ) as r0 , space( 0 ) as r1 , min( distinct tl6e913fb9.col_36 ) as r2 , count( distinct tl6e913fb9.col_36 ) as r3 from tl6e913fb9 where tl6e913fb9.col_36 between 'n92ok$B%W#UU%O' and '()c=KVQ=T%-vzGJ' and tl6e913fb9.col_36 in ( 'T+kf' ,'Lvluod2H' ,'3#Omx@pC^fFkeH' ,'=b$z' ) group by tl6e913fb9.col_36 having tl6e913fb9.col_36 = 'xjV@' or IsNull( tl6e913fb9.col_36 ) ) ( select 1,col_1101,col_1102,col_1103,col_1104 from cte_192 where not( IsNull( cte_192.col_1102 ) ) order by 1,2,3,4,5 limit 72850972 ); +======= +# TestIssue56270 +drop table if exists t0, v0; +drop view if exists v0; +CREATE TABLE t0(c0 INTEGER); +CREATE VIEW v0(c0) AS SELECT 'a' FROM t0 WHERE (CASE t0.c0 WHEN t0.c0 THEN false END ); +SELECT t0.c0 FROM v0, t0 WHERE RAND(); +>>>>>>> ed2d749bc1f (planner: Fix predicate simplification panic caused by zero-argument expressions like rand() (#56947))