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

Invalid column type decimal(0,0) can be created unexpectedly #53779

Closed
JaySon-Huang opened this issue Jun 4, 2024 · 3 comments · Fixed by #54028
Closed

Invalid column type decimal(0,0) can be created unexpectedly #53779

JaySon-Huang opened this issue Jun 4, 2024 · 3 comments · Fixed by #54028
Assignees
Labels
affects-5.4 This bug affects 5.4.x versions. affects-6.1 affects-6.5 affects-7.1 affects-7.5 affects-8.1 component/ddl This issue is related to DDL of TiDB. report/community The community has encountered this bug. severity/major type/bug The issue is confirmed as a bug.

Comments

@JaySon-Huang
Copy link
Contributor

JaySon-Huang commented Jun 4, 2024

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

-- If we create a column with decimal(0,0), then tidb will automatically fix it as decimal(10,0)
-- But when we create a column with decimal(0), then tidb will create  decimal(0,0), which is not as expected
TiDB test> create table a(b decimal(0,0), c decimal(0));
TiDB test> show create table a;
+-------+-------------------------------------------------------------+
| Table | Create Table                                                |
+-------+-------------------------------------------------------------+
| a     | CREATE TABLE `a` (                                          |
|       |   `b` decimal(10,0) DEFAULT NULL,                           |
|       |   `c` decimal(0,0) DEFAULT NULL                             |
|       | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
+-------+-------------------------------------------------------------+

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

TiDB test> create table a(b decimal(0,0), c decimal(0));
TiDB test> show create table a;
+-------+-------------------------------------------------------------+
| Table | Create Table                                                |
+-------+-------------------------------------------------------------+
| a     | CREATE TABLE `a` (                                          |
|       |   `b` decimal(10,0) DEFAULT NULL,                           |
|       |   `c` decimal(10,0) DEFAULT NULL                            |
|       | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
+-------+-------------------------------------------------------------+

3. What did you see instead (Required)

TiDB test> create table a(b decimal(0,0), c decimal(0));
TiDB test> show create table a;
+-------+-------------------------------------------------------------+
| Table | Create Table                                                |
+-------+-------------------------------------------------------------+
| a     | CREATE TABLE `a` (                                          |
|       |   `b` decimal(10,0) DEFAULT NULL,                           |
|       |   `c` decimal(0,0) DEFAULT NULL                             |
|       | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
+-------+-------------------------------------------------------------+

And this will lead to tiflash failed to sync the schema and cause queries error or failed to start tiflash-server. Reported from asktug: https://asktug.com/t/topic/1027023/16

4. What is your TiDB version? (Required)

select tidb_version() \G
***************************[ 1. row ]***************************
tidb_version() | Release Version: v6.5.4
Edition: Community
Git Commit Hash: d7ce2f2faa1da3177a0f0a7e825f6e8fccd13ec8
Git Branch: heads/refs/tags/v6.5.4
UTC Build Time: 2023-08-23 08:32:40
GoVersion: go1.19.12
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: tikv
@JaySon-Huang JaySon-Huang added the type/bug The issue is confirmed as a bug. label Jun 4, 2024
@JaySon-Huang
Copy link
Contributor Author

/label component/ddl

Copy link

ti-chi-bot bot commented Jun 4, 2024

@JaySon-Huang: The label(s) component/ddl cannot be applied. These labels are supported: fuzz/sqlancer, challenge-program, compatibility-breaker, first-time-contributor, contribution, good first issue, correctness, duplicate, proposal, security, ok-to-test, needs-ok-to-test, needs-more-info, needs-cherry-pick-release-5.4, needs-cherry-pick-release-6.1, needs-cherry-pick-release-6.5, needs-cherry-pick-release-7.1, needs-cherry-pick-release-7.5, needs-cherry-pick-release-8.1, affects-5.4, affects-6.1, affects-6.5, affects-7.1, affects-7.5, affects-8.1, may-affects-5.4, may-affects-6.1, may-affects-6.5, may-affects-7.1, may-affects-7.5, may-affects-8.1.

In response to this:

/label component/ddl

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@seiya-annie
Copy link

/report community

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-5.4 This bug affects 5.4.x versions. affects-6.1 affects-6.5 affects-7.1 affects-7.5 affects-8.1 component/ddl This issue is related to DDL of TiDB. report/community The community has encountered this bug. severity/major type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants