Skip to content

When sql_mode is empty, there is a problem creating default values for columns that are out of bounds #52972

@zimulala

Description

@zimulala

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

set @@sql_mode='';
drop table if exists t1;
create table t1(b tinyint default '11111111');
alter table t1 add column(c tinyint default '11111111');

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

MySQL 5.7.44 and MySQL 8.0.18

mysql> create table t1(c tinyint default '11111111');
ERROR 1067 (42000): Invalid default value for 'b'

create table t1(b tinyint);
mysql> alter table t1 add column(c tinyint default '11111111');
ERROR 1067 (42000): Invalid default value for 'c'

3. What did you see instead (Required)

tidb> create table t1(b tinyint default '11111111');
Query OK, 0 rows affected, 1 warning (0.01 sec)

tidb> show warnings;
+---------+------+-------------------------------------+
| Level   | Code | Message                             |
+---------+------+-------------------------------------+
| Warning | 1690 | constant 11111111 overflows tinyint |
+---------+------+-------------------------------------+
1 row in set (0.00 sec)

tidb> alter table t1 add column(c tinyint default '11111111');
Query OK, 0 rows affected, 1 warning (0.02 sec)

4. What is your TiDB version? (Required)

master

related #51320

Metadata

Metadata

Assignees

Labels

affects-6.5This bug affects the 6.5.x(LTS) versions.affects-7.1This bug affects the 7.1.x(LTS) versions.affects-7.5This bug affects the 7.5.x(LTS) versions.affects-8.1This bug affects the 8.1.x(LTS) versions.component/ddlThis issue is related to DDL of TiDB.severity/moderatetype/bugThe issue is confirmed as a bug.type/compatibility

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions