pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #17408: Duplicate aliases silently fail
5+ messages / 5 participants
[nested] [flat]

* BUG #17408: Duplicate aliases silently fail
@ 2022-02-16 10:36  PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 2 replies; 5+ messages in thread

From: PG Bug reporting form @ 2022-02-16 10:36 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: porturpotgieter@gmail.com

The following bug has been logged on the website:

Bug reference:      17408
Logged by:          Kevin Potgieter
Email address:      porturpotgieter@gmail.com
PostgreSQL version: 13.6
Operating system:   Not related
Description:        

Hi,

Assigning aliases to columns works perfectly.

eg. "SELECT name AS customer_name FROM customers"

However you are able to assign duplicate aliases which does not cause a
conflict

eg. "SELECT name AS customer_name, surname AS customer_name FROM
customers"

The expectation here is that duplicate aliases would cause the query to fail
due to duplicate column names in the result, however there is no error or
warning.

Regards
Kevin



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #17408: Duplicate aliases silently fail
@ 2022-02-16 12:02  Pantelis Theodosiou <ypercube@gmail.com>
  parent: PG Bug reporting form <noreply@postgresql.org>
  1 sibling, 1 reply; 5+ messages in thread

From: Pantelis Theodosiou @ 2022-02-16 12:02 UTC (permalink / raw)
  To: porturpotgieter@gmail.com, PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>

On Wed, Feb 16, 2022 at 10:46 AM PG Bug reporting form
<noreply@postgresql.org> wrote:
>
> The following bug has been logged on the website:
>
> Bug reference:      17408
> Logged by:          Kevin Potgieter
> Email address:      porturpotgieter@gmail.com
> PostgreSQL version: 13.6
> Operating system:   Not related
> Description:
>
> Hi,
>
> Assigning aliases to columns works perfectly.
>
> eg. "SELECT name AS customer_name FROM customers"
>
> However you are able to assign duplicate aliases which does not cause a
> conflict
>
> eg. "SELECT name AS customer_name, surname AS customer_name FROM
> customers"
>
> The expectation here is that duplicate aliases would cause the query to fail
> due to duplicate column names in the result, however there is no error or
> warning.

This may look weird but the SQL standard allows it. Postgres is only
following what the standard dictates.

Best regards,
Pantelis Theodosiou

>
> Regards
> Kevin
>





^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #17408: Duplicate aliases silently fail
@ 2022-02-16 12:05  Kevin Potgieter <porturpotgieter@gmail.com>
  parent: Pantelis Theodosiou <ypercube@gmail.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Kevin Potgieter @ 2022-02-16 12:05 UTC (permalink / raw)
  To: Pantelis Theodosiou <ypercube@gmail.com>; +Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>

Is it perhaps and option that postgres could warn you in the same way it
warns you when you do an update without a where clause?

On Wed, 16 Feb 2022, 2:02 pm Pantelis Theodosiou, <ypercube@gmail.com>
wrote:

> On Wed, Feb 16, 2022 at 10:46 AM PG Bug reporting form
> <noreply@postgresql.org> wrote:
> >
> > The following bug has been logged on the website:
> >
> > Bug reference:      17408
> > Logged by:          Kevin Potgieter
> > Email address:      porturpotgieter@gmail.com
> > PostgreSQL version: 13.6
> > Operating system:   Not related
> > Description:
> >
> > Hi,
> >
> > Assigning aliases to columns works perfectly.
> >
> > eg. "SELECT name AS customer_name FROM customers"
> >
> > However you are able to assign duplicate aliases which does not cause a
> > conflict
> >
> > eg. "SELECT name AS customer_name, surname AS customer_name FROM
> > customers"
> >
> > The expectation here is that duplicate aliases would cause the query to
> fail
> > due to duplicate column names in the result, however there is no error or
> > warning.
>
> This may look weird but the SQL standard allows it. Postgres is only
> following what the standard dictates.
>
> Best regards,
> Pantelis Theodosiou
>
> >
> > Regards
> > Kevin
> >
>

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #17408: Duplicate aliases silently fail
@ 2022-02-16 12:08  John Naylor <john.naylor@enterprisedb.com>
  parent: PG Bug reporting form <noreply@postgresql.org>
  1 sibling, 0 replies; 5+ messages in thread

From: John Naylor @ 2022-02-16 12:08 UTC (permalink / raw)
  To: porturpotgieter@gmail.com, PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>

On Wed, Feb 16, 2022 at 5:46 PM PG Bug reporting form
<noreply@postgresql.org> wrote:

> Assigning aliases to columns works perfectly.
>
> eg. "SELECT name AS customer_name FROM customers"
>
> However you are able to assign duplicate aliases which does not cause a
> conflict
>
> eg. "SELECT name AS customer_name, surname AS customer_name FROM
> customers"
>
> The expectation here is that duplicate aliases would cause the query to fail
> due to duplicate column names in the result, however there is no error or
> warning.

FWIW, if the aliases are referenced higher up in a query, it does
result in error:

WITH dupe_cols AS (SELECT name AS customer_name, surname AS customer_name FROM
customers) SELECT customer_name FROM dupe_cols;
ERROR:  column reference "customer_name" is ambiguous
LINE 2: customers) select customer_name from dupe_cols;

-- 
John Naylor
EDB: http://www.enterprisedb.com





^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #17408: Duplicate aliases silently fail
@ 2022-02-16 13:23  David G. Johnston <david.g.johnston@gmail.com>
  parent: Kevin Potgieter <porturpotgieter@gmail.com>
  0 siblings, 0 replies; 5+ messages in thread

From: David G. Johnston @ 2022-02-16 13:23 UTC (permalink / raw)
  To: Kevin Potgieter <porturpotgieter@gmail.com>; +Cc: Pantelis Theodosiou <ypercube@gmail.com>; PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>

On Wednesday, February 16, 2022, Kevin Potgieter <porturpotgieter@gmail.com>
wrote:

> Is it perhaps and option that postgres could warn you in the same way it
> warns you when you do an update without a where clause?
>
>>
>>
We do?

Even if that is true I don’t see the point forma select query.

David J.

^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2022-02-16 13:23 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-02-16 10:36 BUG #17408: Duplicate aliases silently fail PG Bug reporting form <noreply@postgresql.org>
2022-02-16 12:02 ` Pantelis Theodosiou <ypercube@gmail.com>
2022-02-16 12:05   ` Kevin Potgieter <porturpotgieter@gmail.com>
2022-02-16 13:23     ` David G. Johnston <david.g.johnston@gmail.com>
2022-02-16 12:08 ` John Naylor <john.naylor@enterprisedb.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox