pingcap / pingcap/tidb

The "Default" field in the result of "show columns" with `views'` is not processed

Open
#51,478 0 comments 0 reactions 0 assignees View on GitHub
component/ddl severity/minor type/bug
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)
Related issue:https://github.com/pingcap/tidb/issues/50936
```
create table t1 (c int, c1 varchar(32) default "abc");
create view v1 as select c, c1 from t1;
show columns from test.v1 where field='c1';

create table t2 (c int, c1 double default (rand(1)));
create view v2 as select c, c1 from t2;
show columns from test.v2 where field='c1';
```

### 2. What did you expect to see? (Required)
```
mysql> show columns from test.v1 where field='c1';
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| c1 | varchar(32) | YES | | abc | |
+-------+-------------+------+-----+---------+-------+
1 row in set (0.01 sec)

mysql> show columns from test.v2 where field='c1';
+-------+--------+------+-----+---------+-------------------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------+------+-----+---------+-------------------+
| c1 | double | YES | | rand(1) | DEFAULT_GENERATED |
+-------+--------+------+-----+---------+-------------------+
1 row in set (0.00 sec)
```

### 3. What did you see instead (Required)
```
tidb> show columns from test.v1 where field='c1';
+-------+-------------+------+------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+------+---------+-------+
| c1 | varchar(32) | YES | | NULL | |
+-------+-------------+------+------+---------+-------+
1 row in set (0.00 sec)

tidb> show columns from test.v2 where field='c1';
+-------+--------+------+------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------+------+------+---------+-------+
| c1 | double | YES | | NULL | |
+-------+--------+------+------+---------+-------+
1 row in set (0.00 sec)
```

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

master

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.