Re: BUG #17408: Duplicate aliases silently fail

From: John Naylor <john(dot)naylor(at)enterprisedb(dot)com>
To: porturpotgieter(at)gmail(dot)com, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #17408: Duplicate aliases silently fail
Date: 2022-02-16 12:08:36
Message-ID: CAFBsxsGV77vUbxHWJYE6RE9UZeLLYpZePk2Pu3Qw3a8QhSrQJg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, Feb 16, 2022 at 5:46 PM PG Bug reporting form
<noreply(at)postgresql(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message John Naylor 2022-02-16 12:23:43 Re: BUG #17406: Segmentation fault on GiST index after 14.2 upgrade
Previous Message Kevin Potgieter 2022-02-16 12:05:13 Re: BUG #17408: Duplicate aliases silently fail