Re: BUG #17723: cache lookup failed for type 0

From: Vik Fearing <vik(at)postgresfriends(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org, Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
Subject: Re: BUG #17723: cache lookup failed for type 0
Date: 2022-12-16 19:36:27
Message-ID: deb5b865-25de-b894-2d3d-44470eb86a88@postgresfriends.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 12/16/22 18:10, Tom Lane wrote:
> PG Bug reporting form <noreply(at)postgresql(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2022-12-16 20:33:33 Re: BUG #17717: Regression in vacuumdb (15 is slower than 10/11 and possible memory issue)
Previous Message Peter Geoghegan 2022-12-16 18:47:07 Re: BUG #17717: Regression in vacuumdb (15 is slower than 10/11 and possible memory issue)