Re: BUG #19003: A SELECT that does not return a valid table
Vik Fearing <vik@postgresfriends.org>
From: Vik Fearing <vik@postgresfriends.org>
To: Alexandre Bailly <alexandrebailly1955@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, pgsql-bugs@lists.postgresql.org
Date: 2025-07-31T13:10:09Z
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