Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uhT31-000KS7-St for pgsql-bugs@arkaria.postgresql.org; Thu, 31 Jul 2025 13:10:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uhT30-000cov-S0 for pgsql-bugs@arkaria.postgresql.org; Thu, 31 Jul 2025 13:10:14 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uhT30-000con-GB for pgsql-bugs@lists.postgresql.org; Thu, 31 Jul 2025 13:10:14 +0000 Received: from relay4-d.mail.gandi.net ([217.70.183.196]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uhT2x-0001Rx-2m for pgsql-bugs@lists.postgresql.org; Thu, 31 Jul 2025 13:10:14 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id D16B7443D5; Thu, 31 Jul 2025 13:10:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=postgresfriends.org; s=gm1; t=1753967410; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=fQ7iVA2k5eZhykQ/l98vcNwK0THgqoptINyfm4/Np4M=; b=Nx9hBBy3V0W9C/8Gu/SxqnVf8qW648pyl9PBlaf1sk2Wtzb88MXp+I/3mVJAJVvXWa1oD8 3KcoeFndfy7cDxvDm63hE6p2Nseaqpv1v67dWBcbmm2Vvb1nCU/yZ5/CiwgSZBiJVTKc5l KL/hVeLEn70bH3aBa1/K2R2Yd19ijXi4xBGRlYG25sFsQG279NVCw3p5yVCoA6tIu2NL3G 76eaJ+OSNDskvEX1JBippJeSRdnMH/fcZzbPTzE2YNuv4DVSZVkbMJ0tnOZlsqTeVFe8mb 6mlSzbyIc5WaLkGJRoz2ZE1YilzUs+d2iIjIDuDm3E7S/5WfZgkTlrdjbvvvVg== Content-Type: multipart/alternative; boundary="------------7QBLD0djOdAI3EYOLjI2Uqsb" Message-ID: <7c12b589-2b59-4a37-b1de-ee2d906c6d7a@postgresfriends.org> Date: Thu, 31 Jul 2025 15:10:09 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: BUG #19003: A SELECT that does not return a valid table To: Alexandre Bailly Cc: Tom Lane , pgsql-bugs@lists.postgresql.org References: <19003-17a559220b959ea1@postgresql.org> <1675174.1753911281@sss.pgh.pa.us> Content-Language: en-US From: Vik Fearing In-Reply-To: X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgddutddtkeelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpegtkfffgggfuffvvehfhfgjsegrtderredtvdejnecuhfhrohhmpeggihhkucfhvggrrhhinhhguceovhhikhesphhoshhtghhrvghsfhhrihgvnhgushdrohhrgheqnecuggftrfgrthhtvghrnhepgfejfeduffffleejuedtjeffffetjeeuhfetkeehheektdejkedtgeejgefghfdtnecukfhppedvrgdtvdemkeegvdekmeduudgvtdemvdejtddumeejudeifeemleekjedvmegrtdduvdemuddvleefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvdgrtddvmeekgedvkeemudduvgdtmedvjedtudemjeduieefmeelkeejvdemrgdtuddvmeduvdelfedphhgvlhhopeglkffrggeimedvrgdtvdemkeegvdekmeduudgvtdemvdejtddumeejudeifeemleekjedvmegrtdduvdemuddvleefngdpmhgrihhlfhhrohhmpehvihhksehpohhsthhgrhgvshhfrhhivghnughsrdhorhhgpdhnsggprhgtphhtthhopeefpdhrtghpthhtoheprghlvgigrghnughrvggsrghilhhlhiduleehheesghhmrghilhdrtghomhdprhgtphhtthhopehtghhlsehsshhsrdhpghhhrdhprgdruhhspdhrtghpthhto hepphhgshhqlhdqsghughhssehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh X-GND-Sasl: vik@postgresfriends.org List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------7QBLD0djOdAI3EYOLjI2Uqsb Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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 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 --------------7QBLD0djOdAI3EYOLjI2Uqsb Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit


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

--------------7QBLD0djOdAI3EYOLjI2Uqsb--