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

the query results for enum column is wrong #33214

Closed
ChenPeng2013 opened this issue Mar 17, 2022 · 2 comments · Fixed by #33219
Closed

the query results for enum column is wrong #33214

ChenPeng2013 opened this issue Mar 17, 2022 · 2 comments · Fixed by #33219
Labels
affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.0 component/executor severity/major type/bug The issue is confirmed as a bug.

Comments

@ChenPeng2013
Copy link
Contributor

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

use test;
source  [test.txt](https://github.com/pingcap/tidb/files/8285072/test.txt);

alter table IDT_MULTI15863STROBJSTROBJ cache;
# please execute many times to reporduce
 select col1 from IDT_MULTI15863STROBJSTROBJ t1 where (select count(*) from IDT_MULTI15863STROBJSTROBJ t2 where t2.col1 in (t1.col1, "none")) > 1;

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

MySQL [test]> select col1 from IDT_MULTI15863STROBJSTROBJ t1 where (select count(*) from IDT_MULTI15863STROBJSTROBJ t2 where t2.col1 in (t1.col1, "none")) > 1;
+------+
| col1 |
+------+
...
+------+
58 rows in set (0.03 sec)

3. What did you see instead (Required)


MySQL [test]> select col1 from IDT_MULTI15863STROBJSTROBJ t1 where (select count(*) from IDT_MULTI15863STROBJSTROBJ t2 where t2.col1 in (t1.col1, "none")) > 1;
+------+
| col1 |
+------+
...
+------+
60 rows in set (0.03 sec)

4. What is your TiDB version? (Required)

Release Version: v6.0.0-alpha-122-g46c43fe
Edition: Community
Git Commit Hash: 46c43febcac0e24bc9f0872e93cf6125db69d93d
Git Branch: master
UTC Build Time: 2022-03-17 01:02:30
GoVersion: go1.17.6
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
@ChenPeng2013 ChenPeng2013 added the type/bug The issue is confirmed as a bug. label Mar 17, 2022
@ti-chi-bot ti-chi-bot added may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. labels Mar 18, 2022
@tiancaiamao
Copy link
Contributor

I've found the root cause.
When there is a Apply executor, it will Open / Close its children executor several times.
And when UnionScan->TableReader open and close for reuse, it's not fully clean the state.

This bug affects only table cache and temporary table.

@tiancaiamao
Copy link
Contributor

The simplified reproduce case:

create table t (col enum('a', 'b', 'c')) default null;
insert into t values ('a'), ('b'), ('c'), (null), ('c');
alter table t cache;
select col from t t1 where (select count(*) from t t2 where t2.col = t1.col or t2.col =  'sdf') > 1;

Expect:

mysql> select col from t t1 where (select count(*) from t t2 where t2.col = t1.col or t2.col =  'sdf') > 1;
+------+
| col  |
+------+
| c    |
| c    |
+------+
2 rows in set (0.00 sec)

But got when repeat several times:

mysql> select col from t t1 where (select count(*) from t t2 where t2.col = t1.col or t2.col =  'sdf') > 1;
+------+
| col  |
+------+
| b    |
| c    |
| c    |
+------+
2 rows in set (0.00 sec)

@tiancaiamao tiancaiamao added component/executor affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. and removed may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. labels Mar 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.0 component/executor severity/major type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants