[MDEV-19941] Error "Duplicate column name" while using VALUES table constructor Created: 2019-07-03  Updated: 2023-11-28

Status: Open
Project: MariaDB Server
Component/s: None
Affects Version/s: 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9
Fix Version/s: 10.4, 10.5, 10.6

Type: Bug Priority: Major
Reporter: Alice Sherepa Assignee: Igor Babaev
Resolution: Unresolved Votes: 1
Labels: None


 Description   

If the table, constructed via VALUES() has multiple columns and some values are identical, then we get the same column names:

 
MariaDB [test]> SELECT *  from  (VALUES (1,1),(2,2)) t;
ERROR 1060 (42S21): Duplicate column name '1'
 
MariaDB [test]> SELECT *  from  (VALUES (1,2),(2,2)) t;
+---+---+
| 1 | 2 |
+---+---+
| 1 | 2 |
| 2 | 2 |
+---+---+
2 rows in set (0.000 sec)



 Comments   
Comment by Yitzchak [ 2022-08-01 ]

Note that mysql uses column_0, column_1, etc as values table constructor column names.

Comment by Sergei Golubchik [ 2022-08-07 ]

Note, the standard says that "column names are implementation-dependent", so we indeed can generate unique column names if needed

Generated at Thu Feb 08 08:55:31 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.