You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/* without alias*/select*from view0;
/* with alias*/select v0c0 as alias_v0c0, v0c1 as alias_v0c1, v0c2 as alias_v0c2 from view0;
2. What did you expect to see? (Required)
Output in MySQL
ResultSetMetaData.getColumnName returns the name of a column defined in the view, and ResultSetMetaData.getColumnLabel returns the alias given in the query.
8.0.23-0ubuntu0.20.10.1
SELECT WITHOUT ALIAS
Index ColName ColLabel
1 v0c0 v0c0
2 v0c1 v0c1
3 v0c2 v0c2
SELECT WITH ALIAS
Index ColName ColLabel
1 v0c0 alias_v0c0
2 v0c1 alias_v0c1
3 v0c2 alias_v0c2
3. What did you see instead (Required)
Output in TiDB
ResultSetMetaData.getColumnName returns the name of a column defined in the table instead of in the view, while ResultSetMetaData.getColumnLabel returns the alias given in the query.
However, considering that when users query a view, they treat it as an abstract table, and do not care whether it is a table or a view. Perhaps it is more reasonable to return the name of the attribute listed in the view definition. This is the behavior of MySQL.
Moreover, if the user uses the as keyword to alias a attribute when querying the view, it seems that the attribute name defined in the view cannot be obtained from ResultSetMetaData.
5.7.25-TiDB-v5.0.0
SELECT WITHOUT ALIAS
Index ColName ColLabel
1 t0c0 v0c0
2 t0c1 v0c1
3 t0c2 v0c2
SELECT WITH ALIAS
Index ColName ColLabel
1 t0c0 alias_v0c0
2 t0c1 alias_v0c1
3 t0c2 alias_v0c2
4. What is your TiDB version? (Required)
Release Version: v5.0.0
Edition: Community
Git Commit Hash: bdac0885cd11bdf571aad9353bfc24e13554b91c
Git Branch: heads/refs/tags/v5.0.0
UTC Build Time: 2021-04-06 16:36:29
GoVersion: go1.13
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
The text was updated successfully, but these errors were encountered:
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
Just query a view with renamed attribute and print
ResultSetMetaData.getColumnName
.Code for reproduce
The sample code is as follows, and you can get it from https://github.com/lpypl/RSMDTest.git.
Table and View defination
Query SQL
2. What did you expect to see? (Required)
Output in MySQL
ResultSetMetaData.getColumnName
returns the name of a column defined in the view, andResultSetMetaData.getColumnLabel
returns the alias given in the query.3. What did you see instead (Required)
Output in TiDB
ResultSetMetaData.getColumnName
returns the name of a column defined in the table instead of in the view, whileResultSetMetaData.getColumnLabel
returns the alias given in the query.However, considering that when users query a view, they treat it as an abstract table, and do not care whether it is a table or a view. Perhaps it is more reasonable to return the name of the attribute listed in the view definition. This is the behavior of MySQL.
Moreover, if the user uses the as keyword to alias a attribute when querying the view, it seems that the attribute name defined in the view cannot be obtained from ResultSetMetaData.
4. What is your TiDB version? (Required)
The text was updated successfully, but these errors were encountered: