Different beheviors when performing `add column` in adding expression default values feature
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## 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
Contributor guide
Assessment
This issue has not been assessed yet.