pingcap/tidb
View on GitHubType consistency with MySQL: by creating view and describing it
Open
#25,701 opened on Jun 23, 2021
help wantedseverity/moderatesig/sql-infratype/bugtype/question
Description
Bug Report
I would like to know if there is any documentation describing the type compatibility with mysql.
1. Minimal reproduce step (Required)
create view v1 as select 1;
desc v1;
create view v2 as select 'a';
desc v2;
create view v3 as select 'a' union select 'bc';
desc v3;
create view v4 as select 'a' union select 1;
desc v4;
2. What did you expect to see? (Required)
In MySQL:
+-------+------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------+------+-----+---------+-------+
| 1 | int | NO | | 0 | |
+-------+------+------+-----+---------+-------+
1 row in set (0.01 sec)
+-------+------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------------+------+-----+---------+-------+
| a | varchar(1) | NO | | | |
+-------+------------+------+-----+---------+-------+
1 row in set (0.03 sec)
+-------+------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------------+------+-----+---------+-------+
| a | varchar(2) | NO | | | |
+-------+------------+------+-----+---------+-------+
1 row in set (0.03 sec)
+-------+------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------------+------+-----+---------+-------+
| a | varchar(1) | NO | | | |
+-------+------------+------+-----+---------+-------+
1 row in set (0.00 sec)
3. What did you see instead (Required)
In TiDB:
+-------+-----------+------+------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-----------+------+------+---------+-------+
| 1 | bigint(1) | NO | | NULL | |
+-------+-----------+------+------+---------+-------+
1 row in set (0.03 sec)
+-------+------------+------+------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------------+------+------+---------+-------+
| a | varchar(1) | NO | | NULL | |
+-------+------------+------+------+---------+-------+
1 row in set (0.03 sec)
+-------+------------+------+------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------------+------+------+---------+-------+
| a | varchar(2) | YES | | NULL | |
+-------+------------+------+------+---------+-------+
1 row in set (0.01 sec)
+-------+-------------+------+------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+------+---------+-------+
| a | varchar(20) | YES | | NULL | |
+-------+-------------+------+------+---------+-------+
1 row in set (0.00 sec)
4. What is your TiDB version? (Required)
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()
|
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v5.2.0-alpha-88-ged52601e6
Edition: Community
Git Commit Hash: ed52601e6eb560138db8cdccdfa1b5e2d33a11f0
Git Branch: master
UTC Build Time: 2021-06-16 13:03:48
GoVersion: go1.16.4
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.03 sec)