duplicate column names in a table alias should be prevented.
nicktobey opened this issue · 0 comments
nicktobey commented
Repro steps:
drop table if exists ab;
create table ab (a int, b int);
insert into ab values (1, 1), (2, 2);
drop table if exists bc;
create table bc (b int, c int);
insert into bc values (1, 1), (2, 2);
SELECT * FROM (SELECT * FROM ab join bc on ab.b != bc.b) as abc;
SELECT b FROM (SELECT * FROM ab join bc on ab.b != bc.b) as abc;
MySQL results:
ERROR 1060 (42S21) at line 10: Duplicate column name 'b'
go-mysql-server results:
+---+---+---+---+
| a | b | b | c |
+---+---+---+---+
| 2 | 2 | 1 | 1 |
| 1 | 1 | 2 | 2 |
+---+---+---+---+
+---+
| b |
+---+
| 2 |
| 1 |
+---+
In this example, the table alias has two columns named b
, and one of them appears to be selected arbitrarily. We should be consistent with MySQL and reject this.