Re: BUG #17480: Assertion failure in parse_relation.c

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: krking(at)zju(dot)edu(dot)cn, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #17480: Assertion failure in parse_relation.c
Date: 2022-05-15 10:42:10
Message-ID: 202205151042.jjhnmhpsanbl@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

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)

Attachment Content-Type Size
0001-Enforce-column-list-length-in-XMLTABLE-JSON_TABLE.patch text/x-diff 9.1 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Devrim Gündüz 2022-05-16 01:05:10 Re: postgresql11-11.14-1PGDG.rhel8.x86_64.rpm reports incorrect name
Previous Message PG Bug reporting form 2022-05-15 02:37:22 BUG #17481: sometime pg_stat_statements coredump