Re: Re: Querying foreign table with SP-GiST index results in “ERROR: cache lookup failed for type 0”

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Etsuro Fujita <etsuro(dot)fujita(at)gmail(dot)com>
Cc: Paul Ramsey <pramsey(at)cleverelephant(dot)ca>, Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, Joao Ferreira <jpgferreira(at)yahoo(dot)com>, "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: Re: Querying foreign table with SP-GiST index results in “ERROR: cache lookup failed for type 0”
Date: 2019-06-26 21:06:47
Message-ID: 12443.1561583207@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Etsuro Fujita <etsuro(dot)fujita(at)gmail(dot)com> writes:
> I found that this error is thrown by index_can_return()
> (spgcanreturn()) called from get_relation_info() for the SP-GiST index
> on the locations table.

> PGDLLEXPORT Datum gserialized_spgist_config_2d(PG_FUNCTION_ARGS)
> {
> spgConfigOut *cfg = (spgConfigOut *)PG_GETARG_POINTER(1);

> --> Oid boxoid = TypenameGetTypid("box2df");
> cfg->prefixType = boxoid;
> cfg->labelType = VOIDOID; /* We don't need node labels. */
> cfg->leafType = boxoid;
> cfg->canReturnData = false;
> cfg->longValuesOK = false;

> PG_RETURN_VOID();
> }

> I'm a newbie to PostGIS, so maybe I'm missing something, but isn't it
> a bit fragile to use TypenameGetTypid() here?

More than a bit :-(. That's guaranteed to fail if type box2df isn't
in the search path, which it likely won't be during a remote query,
since postgres_fdw locks down the search path to just pg_catalog.

This is a Postgis bug. It's probably not quite trivial to solve,
since this code can't know what schema the type is installed in
at runtime. This seems related to the discussions we had awhile
ago about how planner support functions can find out the OIDs of
extension objects reliably. I'm not sure where Paul is on that...

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Paul Ramsey 2019-06-26 21:31:40 Re: Querying foreign table with SP-GiST index results in “ERROR: cache lookup failed for type 0”
Previous Message Alvaro Herrera 2019-06-26 20:18:43 Re: BUG #15724: Can't create foreign table as partition