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

Different beheviors when performing add column in adding expression default values feature #52693

Open
zimulala opened this issue Apr 18, 2024 · 1 comment
Labels
compatibility-mysql8 This is a compatibility issue with MySQL 8.0(but NOT 5.7) component/ddl This issue is related to DDL of TiDB.

Comments

@zimulala
Copy link
Contributor

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

create table tt(a int);
alter table tt add column b datetime default (date_format(now(),'%Y-%m'));


create table t(a int);
insert into t value(1);
alter table t add column b datetime default (date_format(now(),'%Y-%m'));

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

mysql> create table tt(a int);
Query OK, 0 rows affected (0.01 sec)
mysql> alter table tt add column b datetime default (date_format(now(),'%Y-%m'));
Query OK, 0 rows affected (0.03 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> create table t(a int);
Query OK, 0 rows affected (0.02 sec)
mysql> insert into t value(1);
Query OK, 1 row affected (0.00 sec)
mysql> alter table t add column b datetime default (date_format(now(),'%Y-%m'));
ERROR 1292 (22007): Incorrect datetime value: '2024-04' for column 'b' at row 1

3. What did you see instead (Required)


tidb> create table tt(a int);
Query OK, 0 rows affected (0.01 sec)
tidb> alter table tt add column b datetime default (date_format(now(),'%Y-%m'));
ERROR 1292 (22007): Incorrect datetime value: '2024-04'

tidb> create table t(a int);
Query OK, 0 rows affected (0.01 sec)
tidb> insert into t value(1);
Query OK, 1 row affected (0.00 sec)
tidb> alter table t add column b datetime default (date_format(now(),'%Y-%m'));
ERROR 1292 (22007): Incorrect datetime value: '2024-04'

4. What is your TiDB version? (Required)

master

@zimulala zimulala added compatibility-mysql8 This is a compatibility issue with MySQL 8.0(but NOT 5.7) component/ddl This issue is related to DDL of TiDB. labels Apr 18, 2024
@zimulala
Copy link
Contributor Author

At the moment I don't think this is a bug, but the behavior is inconsistent with MySQL:
This is just for the record. If you have other ideas, you can also make comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility-mysql8 This is a compatibility issue with MySQL 8.0(but NOT 5.7) component/ddl This issue is related to DDL of TiDB.
Projects
None yet
Development

No branches or pull requests

1 participant