Re: BUG #15088: Can create subquery with duplicate column names - Mailing list pgsql-bugs

From David G. Johnston
Subject Re: BUG #15088: Can create subquery with duplicate column names
Date
Msg-id CAKFQuwa74o+ZTe6mhY3bRRqdMa6kup8gfnzaudzF96wFEZYGpg@mail.gmail.com
Whole thread Raw
In response to BUG #15088: Can create subquery with duplicate column names  (PG Bug reporting form <noreply@postgresql.org>)
List pgsql-bugs
On Sunday, February 25, 2018, PG Bug reporting form <noreply@postgresql.org> wrote:
The following bug has been logged on the website:

Bug reference:      15088
Logged by:          Tudor Bosman
Email address:      tudorb@gmail.com
PostgreSQL version: 9.5.11
Operating system:   Ubuntu 16.04
Description:

This may not be a bug, but you can create a subquery that has ambiguous
column names, and then you have no way to disambiguate between them, as the
originating table names are no longer in scope.


[...] 
... and the result now has two columns named x, and I can't tell them
apart:


That is correct, though with a result you (in client software) can target a column number in lieu of a name so all hope is not lost.  PostgreSQL won't let you create table or create view from such a result though, only a result set.

At this point backward compatibility will prevent changing the behavior regardless of its individual merit.  And its (usually) obvious and easy to fix if you do get presented with said error.

David J.

pgsql-bugs by date:

Previous
From: Tomas Vondra
Date:
Subject: Re: BUG #15088: Can create subquery with duplicate column names
Next
From: Greg Clough
Date:
Subject: RE: BUG #15067: Documentation or behaviour bug with autovacuumthresholds?