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

Wrong result when using index-merge #30913

Closed
zyguan opened this issue Dec 21, 2021 · 2 comments · Fixed by #30982
Closed

Wrong result when using index-merge #30913

zyguan opened this issue Dec 21, 2021 · 2 comments · Fixed by #30982
Assignees
Labels
affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. severity/major sig/execution SIG execution type/bug The issue is confirmed as a bug.

Comments

@zyguan
Copy link
Contributor

zyguan commented Dec 21, 2021

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

/* test */ drop table if exists t1, t2;
/* test */ create table t1  (c_int int, c_str varchar(40), c_datetime datetime, c_decimal decimal(12, 6), primary key(c_int), key(c_int), key(c_str), unique key(c_decimal), key(c_datetime));
/* test */ create table t2  like t1 ;
/* test */ insert into t1 (c_int, c_str, c_datetime, c_decimal) values (6, 'sharp payne', '2020-06-07 10:40:39', 6.117000) , (7, 'objective kare', '2020-02-05 18:47:26', 1.053000) , (8, 'thirsty pasteur', '2020-01-02 13:06:56', 2.506000) , (9, 'blissful wilbur', '2020-06-04 11:34:04', 9.144000) , (10, 'reverent mclean', '2020-02-12 07:36:26', 7.751000) ;
/* test */ insert into t2 (c_int, c_str, c_datetime, c_decimal) values (6, 'beautiful joliot', '2020-01-16 01:44:37', 5.627000) , (7, 'hopeful blackburn', '2020-05-23 21:44:20', 7.890000) , (8, 'ecstatic davinci', '2020-02-01 12:27:17', 5.648000) , (9, 'hopeful lewin', '2020-05-05 05:58:25', 7.288000) , (10, 'sharp jennings', '2020-01-28 04:35:03', 9.758000) ;
/* test */ select * from t1 where c_decimal < all (select c_decimal from t2 where t1.c_int = t2.c_int and t1.c_datetime > t2.c_datetime and t2.c_decimal = 9.060 or t2.c_str <= 'interesting shtern' and t1.c_int = t2.c_int); -- flags: QUERY

2. What did you expect to see? (Required)

/* test */ select * from t1 where c_decimal < all (select c_decimal from t2 where t1.c_int = t2.c_int and t1.c_datetime > t2.c_datetime and t2.c_decimal = 9.060 or t2.c_str <= 'interesting shtern' and t1.c_int = t2.c_int); -- flags: QUERY
-- test >> +-------+-----------------+---------------------+-----------+
-- test    | c_int |      c_str      |     c_datetime      | c_decimal |
-- test    +-------+-----------------+---------------------+-----------+
-- test    |     7 | objective kare  | 2020-02-05 18:47:26 |  1.053000 |
-- test    |     8 | thirsty pasteur | 2020-01-02 13:06:56 |  2.506000 |
-- test    |    10 | reverent mclean | 2020-02-12 07:36:26 |  7.751000 |
-- test    +-------+-----------------+---------------------+-----------+

3. What did you see instead (Required)

/* test */ select * from t1 where c_decimal < all (select c_decimal from t2 where t1.c_int = t2.c_int and t1.c_datetime > t2.c_datetime and t2.c_decimal = 9.060 or t2.c_str <= 'interesting shtern' and t1.c_int = t2.c_int); -- flags: QUERY
-- test >> +-------+-----------------+---------------------+-----------+
-- test    | c_int |      c_str      |     c_datetime      | c_decimal |
-- test    +-------+-----------------+---------------------+-----------+
-- test    |     6 | sharp payne     | 2020-06-07 10:40:39 |  6.117000 |
-- test    |     7 | objective kare  | 2020-02-05 18:47:26 |  1.053000 |
-- test    |     8 | thirsty pasteur | 2020-01-02 13:06:56 |  2.506000 |
-- test    |     9 | blissful wilbur | 2020-06-04 11:34:04 |  9.144000 |
-- test    |    10 | reverent mclean | 2020-02-12 07:36:26 |  7.751000 |
-- test    +-------+-----------------+---------------------+-----------+

4. What is your TiDB version? (Required)

master @ f1e5877

@zyguan zyguan added type/bug The issue is confirmed as a bug. sig/execution SIG execution severity/major labels Dec 21, 2021
@guo-shaoge
Copy link
Collaborator

guo-shaoge commented Dec 23, 2021

Looks like we forgot to rebuild range/dagPB when got correlated columns. Really thanks for your issue @zyguan .

@github-actions
Copy link

Please check whether the issue should be labeled with 'affects-x.y' or 'fixes-x.y.z', and then remove 'needs-more-info' label.

@guo-shaoge guo-shaoge added affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. labels Dec 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. severity/major sig/execution SIG execution type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants