Skip to content

modify column on partitioned table does not give warning about truncated rows. #38669

@mjonss

Description

@mjonss

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

drop table if exists t;
set sql_mode = default;
create table t (a varchar(255)) partition by range columns (a) (partition p1 values less than ("0"), partition p2 values less than ("zzzzzz"));
insert into t values ("123456");
alter table t modify a varchar(5);
set sql_mode = '';
alter table t modify a varchar(5);
show warnings;

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

Note the change in p1 partition definition, leading to the truncated value is in first partition!

tidb> create table t (a varchar(255)) partition by range columns (a) (partition p1 values less than ("2"), partition p2 values less than ("zzzzzz"));
--------------
create table t (a varchar(255)) partition by range columns (a) (partition p1 values less than ("2"), partition p2 values less than ("zzzzzz"))
--------------

Query OK, 0 rows affected (0.16 sec)

tidb> insert into t values ("123456");
--------------
insert into t values ("123456")
--------------

Query OK, 1 row affected (0.02 sec)

tidb> alter table t modify a varchar(5);
--------------
alter table t modify a varchar(5)
--------------

ERROR 1265 (01000): Data truncated for column 'a', value is '123456'
tidb> set sql_mode = '';
--------------
set sql_mode = ''
--------------

Query OK, 0 rows affected (0.00 sec)

tidb> alter table t modify a varchar(5);
--------------
alter table t modify a varchar(5)
--------------

Query OK, 0 rows affected, 1 warning (2.96 sec)

tidb> show warnings;
--------------
show warnings
--------------

+---------+------+--------------------------------------------------+
| Level   | Code | Message                                          |
+---------+------+--------------------------------------------------+
| Warning | 1265 | Data truncated for column 'a', value is '123456' |
+---------+------+--------------------------------------------------+
1 row in set (0.00 sec)

3. What did you see instead (Required)

tidb> create table t (a varchar(255)) partition by range columns (a) (partition p1 values less than ("0"), partition p2 values less than ("zzzzzz"));
--------------
create table t (a varchar(255)) partition by range columns (a) (partition p1 values less than ("0"), partition p2 values less than ("zzzzzz"))
--------------

Query OK, 0 rows affected (0.12 sec)

tidb> insert into t values ("123456");
--------------
insert into t values ("123456")
--------------

Query OK, 1 row affected (0.05 sec)

tidb> alter table t modify a varchar(5);
--------------
alter table t modify a varchar(5)
--------------

ERROR 1265 (01000): Data truncated for column 'a', value is '123456'
tidb> set sql_mode = '';
--------------
set sql_mode = ''
--------------

Query OK, 0 rows affected (0.00 sec)

tidb> alter table t modify a varchar(5);
--------------
alter table t modify a varchar(5)
--------------

Query OK, 0 rows affected (3.06 sec)

tidb> show warnings;
--------------
show warnings
--------------

Empty set (0.00 sec)

4. What is your TiDB version? (Required)

tidb_version(): Release Version: v6.4.0-alpha
Edition: Community
Git Commit Hash: 753e3da
Git Branch: heads/refs/tags/v6.4.0-alpha
UTC Build Time: 2022-10-26 14:24:52
GoVersion: go1.19
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: tikv

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions