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 1noZr3-0001ul-ON for pgsql-bugs@arkaria.postgresql.org; Wed, 11 May 2022 00:05:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1noZq4-0003iu-0C for pgsql-bugs@arkaria.postgresql.org; Wed, 11 May 2022 00:04:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1noZq3-0003il-Nz for pgsql-bugs@lists.postgresql.org; Wed, 11 May 2022 00:04:23 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1noZq1-0006B9-NS for pgsql-bugs@lists.postgresql.org; Wed, 11 May 2022 00:04:23 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 24B04FK4027737; Tue, 10 May 2022 20:04:15 -0400 From: Tom Lane To: Alvaro Herrera cc: krking@zju.edu.cn, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17480: Assertion failure in parse_relation.c In-reply-to: <202205101050.sepjyffoevsy@alvherre.pgsql> References: <202205101050.sepjyffoevsy@alvherre.pgsql> Comments: In-reply-to Alvaro Herrera message dated "Tue, 10 May 2022 12:50:57 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <27735.1652227455.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 10 May 2022 20:04:15 -0400 Message-ID: <27736.1652227455@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Alvaro Herrera writes: > and with this it is clear that the problem is that the alias list is too > long for the COLUMNS specification of the XMLTABLE function. Check. > This can be avoided by throwing an error: +1, but you should match the ERRCODE thrown by buildRelationAliases, that is ERRCODE_INVALID_COLUMN_REFERENCE. 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=3D# 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=3D# \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. regards, tom lane