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

fix(tianmu): fix query syntax (WHERE NOT IN ) is not supported. (#767) #912

Merged
merged 1 commit into from
Nov 30, 2022

Conversation

lujiashun
Copy link

@lujiashun lujiashun commented Nov 9, 2022

Summary about this PR

Issue Number: ref #767

[summary]
1 'sub_select' item is the left argument,not the right argument of 'item_func';
2 5.7 use 'item_func_not' class to represent the meaning of the syntax "not", while 8.0 use a variable 'value_transform';
3 porting new join code from 5.7 for this case;
3.1 solve throwing exception ”select * from t1 where val not in (select * from t2 where val2 >= 10);“
4 porting ChooseJoinAlgorithm from 5.7 for this case;
4.1 solve incorrect result set for some sql in the mtr(which one is forgotton...)
5 porting ResetToTemplate modification from 5.7 for this case;
5.1 solve incorrect result set "select * from t1 where val not in (select * from t2 where val2 > t1.val);"

Tests Check List

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Changelog

  • New Feature
  • Bug Fix
  • Improvement
  • Performance Improvement
  • Build/Testing/CI/CD
  • Documentation
  • Not for changelog (changelog entry is not required)

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features

@mergify
Copy link
Contributor

mergify bot commented Nov 9, 2022

Thanks for the contribution!
I have applied any labels matching special text in your PR Changelog.

Please review the labels and make any necessary changes.

@mergify mergify bot added the PR-bug bug for pull request label Nov 9, 2022
@lujiashun lujiashun marked this pull request as draft November 9, 2022 15:54
@lujiashun
Copy link
Author

mysql> select count(*) from tt where 42 not in (NULL);
+----------+
| count(*) |
+----------+
|        0 |
+----------+
1 row in set (0.02 sec)

mysql> select count(*) from tt where 42 not in (43);
+----------+
| count(*) |
+----------+
|        1 |
+----------+
1 row in set (0.02 sec)

@lujiashun lujiashun force-pushed the fix-767-stonedb80 branch 2 times, most recently from c40dc17 to f566a1b Compare November 11, 2022 05:54
@lujiashun lujiashun marked this pull request as ready for review November 11, 2022 06:34
storage/tianmu/core/query.cpp Show resolved Hide resolved
storage/tianmu/core/query.cpp Outdated Show resolved Hide resolved
@lujiashun
Copy link
Author

select * from t1 where val not in (select * from t2 where val2 >= 10);
In function Query_route_to Query::Compile, sl->join is nullptr in line 975

970  for (Query_block *sl = selects_list; sl; sl = sl->next_query_block()) {
971    int64_t limit_value = -1;
972    int64_t offset_value = -1;
973
974    // according the meaning of `part`, which describs in JOIN::optimize
975    if (!sl->join) {
976      TIANMU_LOG(LogCtl_Level::ERROR, "sl->join is nil!!!!");
977    }
978    if (JudgeErrors(sl) == Query_route_to::TO_MYSQL)
979      return Query_route_to::TO_MYSQL;

@lujiashun lujiashun marked this pull request as draft November 16, 2022 06:00
@lujiashun
Copy link
Author

The result set is incorrect in the clause dependent subquery

mysql> select * from t1;
+------+
| val  |
+------+
|    0 |
|    1 |
|   10 |
|   11 |
|   20 |
|   21 |
|   42 |
|   43 |
+------+
8 rows in set (0.00 sec)

mysql> select * from t2;
+------+
| val2 |
+------+
|    0 |
|    1 |
|   10 |
|   11 |
|   20 |
|   21 |
|   42 |
|   43 |
+------+
8 rows in set (0.00 sec)

mysql> select * from t1 where val not in (select * from t2 where val2 > t1.val);
+------+
| val  |
+------+
|    0 |
+------+
1 row in set (0.01 sec)

@lujiashun lujiashun force-pushed the fix-767-stonedb80 branch 2 times, most recently from 96407c7 to 9a249c6 Compare November 17, 2022 06:29
@lujiashun lujiashun marked this pull request as ready for review November 17, 2022 06:59
@lujiashun lujiashun requested a review from RingsC November 17, 2022 07:00
@lujiashun lujiashun marked this pull request as draft November 17, 2022 08:42
Copy link
Contributor

@RingsC RingsC left a comment

Choose a reason for hiding this comment

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

LGTM

@lujiashun lujiashun marked this pull request as ready for review November 21, 2022 07:26
Copy link
Collaborator

@DandreChen DandreChen left a comment

Choose a reason for hiding this comment

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

LGTM

@lujiashun lujiashun marked this pull request as draft November 30, 2022 02:57
@lujiashun lujiashun marked this pull request as ready for review November 30, 2022 02:58
…eatom#767)

[summary]
1 'sub_select' item is the left argument,not the right argument of 'item_func';
2 5.7 use 'item_func_not' class to represent the meaning of the syntax "not", while 8.0 use a variable 'value_transform';
3 porting new join code from 5.7 for this case;
3.1 solve throwing exception ”select * from t1 where val not in (select * from t2 where val2 >= 10);"
4 porting ChooseJoinAlgorithm from 5.7 for this case;
4.1 solve incorrect result set for some sql in the mtr(which one is forgotton...)
5 porting ResetToTemplate modification from 5.7 for this case;
5.1 solve incorrect result set "select * from t1 where val not in (select * from t2 where val2 > t1.val);"
@mergify mergify bot merged commit 2d82933 into stoneatom:stonedb-8.0-dev Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-bug bug for pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants