Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nqCRJ-00073m-G5 for pgsql-bugs@arkaria.postgresql.org; Sun, 15 May 2022 11:29:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nqCRG-0005bZ-VJ for pgsql-bugs@arkaria.postgresql.org; Sun, 15 May 2022 11:29:30 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nqCRF-0005bP-Tn for pgsql-bugs@lists.postgresql.org; Sun, 15 May 2022 11:29:30 +0000 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nqCR8-0004TK-Av for pgsql-bugs@lists.postgresql.org; Sun, 15 May 2022 11:29:28 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id D6AD6320077A; Sun, 15 May 2022 07:29:19 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Sun, 15 May 2022 07:29:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1652614159; x=1652700559; bh=Qn8MhgC05SwjdiBCfHhpUFCORgxz lh+caSwuzcANDeU=; b=B4G4OWkxc3u/INZirtD5mr6TTUra2HaxuR66o4xPe8dS I03Q2/V2tzLoiwrD9NsHQ51zxXNxTVeuvzTZPSbA4nQcBrbgeoPjPvWA7ckii0pE 2u23YUdwB1l91v8BciF//Il5fMIaqBbRElqGVvo46qYgakGLOaZDCHReGTPfKwFF PBlGH43Y58G7hqQcGtmWRtzV0uf7P+hg7H24lF4z1iuaEK2aX5xHE3chTUp8t/4L qqrF4Byf5DxBKa8P4XEZ4PHerh5yEsStYWmIEZ42QIsFxbPbsGcFv4bFAVx7/xe1 Y6IHf6oTHEB3gGPXoKGNzFuXhhg2R5dv8vCD8vgs5g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrheefgdegtdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepfffhvfevuffkgggtugfgjgesmhekre ertddtjeenucfhrhhomheptehlvhgrrhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgv segrlhhvhhdrnhhoqdhiphdrohhrgheqnecuggftrfgrthhtvghrnhepudelkeekgfdttd ettdekgfduvdeiffelteegjeeihfetheekveeftedtuddvhfeunecuffhomhgrihhnpegv nhhtvghrphhrihhsvggusgdrtghomhenucevlhhushhtvghrufhiiigvpedtnecurfgrrh grmhepmhgrihhlfhhrohhmpegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 15 May 2022 07:29:18 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 183B52A6B52; Sun, 15 May 2022 12:42:10 +0200 (CEST) Date: Sun, 15 May 2022 12:42:10 +0200 From: Alvaro Herrera To: Tom Lane Cc: krking@zju.edu.cn, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17480: Assertion failure in parse_relation.c Message-ID: <202205151042.jjhnmhpsanbl@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="qd36axs4je6zvcce" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <27736.1652227455@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --qd36axs4je6zvcce Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On 2022-May-10, Tom Lane wrote: > Looking at the other addRangeTableEntry* functions, > addRangeTableEntryForJoin seems to similarly lack a defense > against too many aliases. Testing shows that the case is covered > elsewhere: > > regression=# select * from (int8_tbl i cross join int4_tbl j) ss(a,b,c,d) limit 2; > ERROR: column alias list for "ss" has too many entries > regression=# \errverbose > ERROR: 42601: column alias list for "ss" has too many entries > LOCATION: transformFromClauseItem, parse_clause.c:1458 > > but this is randomly different both in the message wording and in the > choice of ERRCODE. I wonder if we shouldn't harmonize that, and maybe > move detection of the case to addRangeTableEntryForJoin for consistency > with the other cases. That makes sense; I ended up with the attached patch, in which I also attempt to add regression test cases to cover all the cases. I find that the check in addRangeTableEntryForValues is dead code, because both callers pass a NULL Alias. I find no way to give VALUES an alias directly. This has annoyed me in the past (not a big deal tbh), but that makes me refrain from suggesting to removing the code. We do get the correct error with this query, select * from (values (1)) as f (a, b); but that is coming from addRangeTableEntryForSubquery. This is backpatchable (sans the JSON_TABLE bits). I'll attempt to get it pushed later today. -- Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/ "People get annoyed when you try to debug them." (Larry Wall) --qd36axs4je6zvcce Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0001-Enforce-column-list-length-in-XMLTABLE-JSON_TABLE.patch"