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 panic in expression rewriter caused by asScalar #20956

Closed
wants to merge 5 commits into from

Conversation

time-and-fate
Copy link
Member

What problem does this PR solve?

Issue Number: close #20552

Problem Summary:

SQLs like SELECT * FROM t1 WHERE ISNULL(t1.a IN (SELECT t3.a FROM t1 t3)); and SELECT * FROM t1 WHERE CASE (1 IN (SELECT a FROM t1)) WHEN 0 THEN 0 END; will cause panic.

What is changed and how it works?

What's Changed:

Set asScalar to true in (*expressionRewriter).Enter() when meet FuncCallExpr or CaseExpr.

How it Works:

FuncCallExpr and CaseExpr need args be put on ctxStack, which means that asScalar should be true, however it wasn't set to true.

Related changes

  • Need to cherry-pick to the release branch

Check List

Tests

  • Unit test
  • Integration test

Release note

  • no release note

@time-and-fate time-and-fate requested a review from a team as a code owner November 10, 2020 06:44
@time-and-fate time-and-fate requested review from eurekaka and removed request for a team November 10, 2020 06:44
@time-and-fate
Copy link
Member Author

/run-check_dev_2

@ichn-hu ichn-hu mentioned this pull request Nov 10, 2020
@time-and-fate
Copy link
Member Author

/run-check_dev_2

@time-and-fate
Copy link
Member Author

/cc winoros

tk.MustExec("INSERT INTO t1 VALUES(1,1),(2,2),(3,3);")
tk.MustExec("ANALYZE TABLE t1;")
tk.MustExec("SELECT * FROM t1 WHERE ISNULL(t1.a IN (SELECT t3.a FROM t1 t3));")
tk.MustExec("SELECT * FROM t1 WHERE CASE (1 IN (SELECT a FROM t1)) WHEN 0 THEN 0 END;")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the results of these 2 queries as well.

@time-and-fate
Copy link
Member Author

Closed it because #19797 has done the same fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

panic because of slice bounds out of range
2 participants