Re: BUG #19003: A SELECT that does not return a valid table

From: Vik Fearing <vik(at)postgresfriends(dot)org>
To: Alexandre Bailly <alexandrebailly1955(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19003: A SELECT that does not return a valid table
Date: 2025-07-31 13:10:09
Message-ID: 7c12b589-2b59-4a37-b1de-ee2d906c6d7a@postgresfriends.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


On 31/07/2025 12:50, Alexandre Bailly wrote:
>
> WITH customer AS
> (SELECT 'John' AS name,'James' AS name)
> SELECT name FROM customer;
>
> returns ERROR: column reference "name" is ambiguous
>
> I can improve into
>
> WITH customer(name1,name2) AS
> (SELECT 'John' AS name,'James' AS name)
> SELECT name2 FROM customer;
>
> that returns name2 James.
>

Yes, a <with list element> is an inlined viewed table.

> I am OK with SELECT 'John' AS name,'James' AS name returning 2
> columns with the same name.
>
> I am not OK with the same query used as a sub-select.
>

Then don't do it?

Anyway, you have your answer to this bug report and that is: it is not a
bug and we are not going to change it.

--

Vik Fearing

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Peter Eisentraut 2025-07-31 15:43:18 Re: BUG #19000: gist index returns inconsistent result with gist_inet_ops
Previous Message Dilip Kumar 2025-07-31 11:59:43 Re: BUG #18988: DROP SUBSCRIPTION locks not-yet-accessed database