pingcap / pingcap/tidb

Support for default value as column

Open
#61,475 2 comments 0 reactions 0 assignees View on GitHub
component/ddl severity/minor type/bug type/compatibility
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 default_from_other_col (
id bigint unsigned NOT NULL AUTO_INCREMENT,
src_col timestamp NULL DEFAULT NULL,
new_col timestamp NULL DEFAULT(src_col),
PRIMARY KEY (id)
)
```

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

```
mysql> CREATE TABLE default_from_other_col (
-> id bigint unsigned NOT NULL AUTO_INCREMENT,
-> src_col timestamp NULL DEFAULT NULL,
-> new_col timestamp NULL DEFAULT(src_col),
-> PRIMARY KEY (id)
-> );
Query OK, 0 rows affected (0.005 sec)

mysql> select version();
+-----------+
| version() |
+-----------+
| 8.0.32 |
+-----------+
1 row in set (0.001 sec)
```

### 3. What did you see instead (Required)

```
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 4 column 42 near "),
PRIMARY KEY (id)
)"
```

### 4. What is your TiDB version? (Required)

```
mysql> SELECT tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v9.0.0-beta.1.pre-422-g3ccc5aa001
Edition: Community
Git Commit Hash: 3ccc5aa001ec485b1219ea9df9c7e0b3dde4f995
Git Branch: HEAD
UTC Build Time: 2025-03-14 20:26:34
GoVersion: go1.23.7
Race Enabled: false
Check Table Before Drop: false
Store: tikv
1 row in set (0.001 sec)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.