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

select sum(case when 1 then a end) from t group by a causes schema change #19387

Closed
wjhuang2016 opened this issue Aug 24, 2020 · 5 comments · Fixed by #19857 or #20095
Closed

select sum(case when 1 then a end) from t group by a causes schema change #19387

wjhuang2016 opened this issue Aug 24, 2020 · 5 comments · Fixed by #19857 or #20095
Assignees
Labels
Milestone

Comments

@wjhuang2016
Copy link
Member

wjhuang2016 commented Aug 24, 2020

Description

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

mysql> create table t4(a decimal(16, 2));
OK, 0 row affected

mysql> select sum(case when 1 then a end) from t4 group by a;
OK, 0 row in set (0.00 sec)

mysql> show create table t4;
+-------+------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                     |
+-------+------------------------------------------------------------------------------------------------------------------+
| t4    | CREATE TABLE `t4` (
  `a` decimal(65,2) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
+-------+------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

create index idx on t4(a);
insert into t4 values (12.34);

... restart TiDB server ...

mysql> select * from t4 use index(idx) where a=12.34;
Empty set (0.00 sec)

mysql> select * from t4 use index() where a=12.34;
+-------+
| a     |
+-------+
| 12.34 |
+-------+
1 row in set (0.00 sec)

This bug can be fixed by #19083.

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

decimal(16,2) in show create table, that is, the schema won't change after executing the SQL.

3. What did you see instead (Required)

decimal(16,2) in show create table, that is, the schema changes after executing the SQL.
Because of that, the index is wrong because it does not match the schema.

4. What is your TiDB version? (Required)

v3.0.16, master

SIG slack channel

#sig-exec

Score

  • 300

Mentor

@wjhuang2016 wjhuang2016 added the type/bug The issue is confirmed as a bug. label Aug 24, 2020
@wjhuang2016 wjhuang2016 changed the title insert select causes schema change select sum(case when 1 then a end) from t group by a causes schema change Aug 24, 2020
@time-and-fate
Copy link
Member

/label sig/ddl

@ti-srebot ti-srebot added the sig/sql-infra SIG: SQL Infra label Aug 24, 2020
@bb7133 bb7133 added sig/execution SIG execution sig/planner SIG: Planner severity/critical and removed sig/sql-infra SIG: SQL Infra sig/execution SIG execution labels Aug 24, 2020
@AilinKid AilinKid pinned this issue Aug 25, 2020
@lzmhhh123 lzmhhh123 unpinned this issue Aug 25, 2020
@fzhedu fzhedu added the priority/P1 The issue has P1 priority. label Aug 27, 2020
@zz-jason
Copy link
Member

zz-jason commented Sep 6, 2020

@wjhuang2016 why release 4.0 is not affected?

@wjhuang2016
Copy link
Member Author

@wjhuang2016 why release 4.0 is not affected?

Release 4.0 is also affected.
What is your TiDB version? doesn't mean affected version?

@bb7133
Copy link
Member

bb7133 commented Oct 10, 2020

Close this issue since it is fixed by #20095

@lzmhhh123
Copy link
Contributor

can not reproduce.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment