Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

planner: Fix predicate simplification panic caused by zero-argument expressions like rand() (#56947) #57618

Open
wants to merge 1 commit into
base: release-8.5
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/planner/core/rule_predicate_simplification.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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))
Original file line number Diff line number Diff line change
Expand Up @@ -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` (
Expand All @@ -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 );
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))