Skip to content

Error when Column definition is modified (ALTER...MODIFY)from NULL to NOT NULL #29328

@ramanich1

Description

@ramanich1

Bug Report

Please answer these questions before submitting your issue. Thanks!

set sql_mode=default;
drop table if exists t1;
create table t1 (a bigint);
insert into t1 values (NULL);
alter table t1 modify a timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ;

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

Query 1 of 5, Rows read: 0, Elapsed time (seconds) - Total: 0, SQL query: 0, Reading results: 0

Query 2 of 5, Rows read: 0, Elapsed time (seconds) - Total: 0.005, SQL query: 0.005, Reading results: 0

Query 3 of 5, Rows read: 0, Elapsed time (seconds) - Total: 0.005, SQL query: 0.005, Reading results: 0
1 Row(s) Inserted
Query 4 of 5, Rows read: 0, Elapsed time (seconds) - Total: 0.001, SQL query: 0.001, Reading results: 0

Query 5 of 5, Rows read: 0, Elapsed time (seconds) - Total: 0.012, SQL query: 0.012, Reading results: 0

3. What did you see instead (Required)

Query 1 of 5, Rows read: 0, Elapsed time (seconds) - Total: 0.001, SQL query: 0.001, Reading results: 0

Query 2 of 5, Rows read: 0, Elapsed time (seconds) - Total: 0.272, SQL query: 0.272, Reading results: 0

Query 3 of 5, Rows read: 0, Elapsed time (seconds) - Total: 0.08, SQL query: 0.08, Reading results: 0
1 Row(s) Inserted
Query 4 of 5, Rows read: 0, Elapsed time (seconds) - Total: 0.007, SQL query: 0.007, Reading results: 0
Error: Data truncated for column 'a' at row 1
SQLState:  01000
ErrorCode: 1265
Error occurred in:
alter table t1 modify a timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP

4. What is your TiDB version? (Required)

+-------------------------+--------------------------------------------------------------------------+
| Variable_name           | Value                                                                    |
+-------------------------+--------------------------------------------------------------------------+
| innodb_version          | 5.6.25                                                                   |
| protocol_version        | 10                                                                       |
| tidb_analyze_version    | 2                                                                        |
| tidb_row_format_version | 2                                                                        |
| tls_version             | TLSv1,TLSv1.1,TLSv1.2                                                    |
| version                 | 5.7.25-TiDB-v5.2.1                                                       |
| version_comment         | TiDB Server (Apache License 2.0) Community Edition, MySQL 5.7 compatible |
| version_compile_machine | x86_64                                                                   |
| version_compile_os      | osx10.8                                                                  |
+-------------------------+--------------------------------------------------------------------------+

Metadata

Metadata

Assignees

Labels

affects-5.1This bug affects 5.1.x versions.affects-5.2This bug affects 5.2.x versions.affects-5.3This bug affects 5.3.x versions.severity/majorsig/sql-infraSIG: SQL Infratype/bugThe issue is confirmed as a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions