From: Vik Fearing <vik@postgresfriends.org>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-bugs@lists.postgresql.org, Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Subject: Re: BUG #17723: cache lookup failed for type 0
Date: Fri, 16 Dec 2022 20:36:27 +0100
Message-ID: <deb5b865-25de-b894-2d3d-44470eb86a88@postgresfriends.org> (raw)
In-Reply-To: <3697954.1671210656@sss.pgh.pa.us>
References: <17723-2c4985ff111e7bba@postgresql.org>
<3697954.1671210656@sss.pgh.pa.us>
On 12/16/22 18:10, Tom Lane wrote:
> PG Bug reporting form <noreply@postgresql.org> writes:
>> This query:
>
>> WITH RECURSIVE
>
>> run(x, y) AS (
>> SELECT 0, 0
>> UNION ALL
>> SELECT x, y FROM run AS r WHERE r.is_cycle
>> )
>> CYCLE x, y SET is_cycle USING path
>
>> TABLE run
>> ;
>
>> in which I mistakenly tried to access the is_cycle column from inside the
>> wle, provokes the following error:
>
>> ERROR: XX000: cache lookup failed for type 0
>> LOCATION: typeOrDomainTypeRelid, parse_type.c:699
>
> Yeah. We are calling addRangeTableEntryForCTE inside parse analysis of
> the CTE's query, and it's generating a ParseNamespaceItem with p_vartype = 0
> because analyzeCTE hasn't yet identified the cycle_mark_type. That
> eventually results in a Var with vartype 0, confusing later parse analysis.
>
> It looks to me like we can just move that part of the code up to before
> we recurse to parse_sub_analyze, though. AFAICS, identification of the
> cycle column type needn't (and had better not) depend on any
> characteristics of the CTE's query.
Indeed, it should only depend on the TO and DEFAULT subclauses (not
shown here).
Thanks for the fix!
--
Vik Fearing
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: vik@postgresfriends.org, tgl@sss.pgh.pa.us, peter.eisentraut@enterprisedb.com
Subject: Re: BUG #17723: cache lookup failed for type 0
In-Reply-To: <deb5b865-25de-b894-2d3d-44470eb86a88@postgresfriends.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox