Skip to content

Wrong default value for integer type #34881

@Lloyd-Pottiger

Description

@Lloyd-Pottiger

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

Wrong default value for integer type cause error in tiflash: pingcap/tiflash#3157

mysql test> create table t (a int);
-- The type of column i is int, but the default value is set to "0.00"
mysql test> alter table t add column i int not null default 0.00; 
mysql test> show create table t;

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

+-------+-------------------------------------------------------------+
| Table | Create Table                                                |
+-------+-------------------------------------------------------------+
| t     | CREATE TABLE `t` (                                          |
|       |   `a` int(11) DEFAULT NULL,                                 |
|       |   `i` int(11) NOT NULL DEFAULT '0'                       |
|       | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
+-------+-------------------------------------------------------------+

3. What did you see instead (Required)

+-------+-------------------------------------------------------------+
| Table | Create Table                                                |
+-------+-------------------------------------------------------------+
| t     | CREATE TABLE `t` (                                          |
|       |   `a` int(11) DEFAULT NULL,                                 |
|       |   `i` int(11) NOT NULL DEFAULT '0.00'                       |
|       | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
+-------+-------------------------------------------------------------+

4. What is your TiDB version? (Required)

master

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions