Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hgF88-0006gS-7c for pgsql-bugs@arkaria.postgresql.org; Wed, 26 Jun 2019 21:07:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hgF86-0005gO-Ls for pgsql-bugs@arkaria.postgresql.org; Wed, 26 Jun 2019 21:06:58 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hgF86-0005gH-Aq for pgsql-bugs@lists.postgresql.org; Wed, 26 Jun 2019 21:06:58 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hgF80-0005as-0A for pgsql-bugs@lists.postgresql.org; Wed, 26 Jun 2019 21:06:57 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x5QL6lUu012444; Wed, 26 Jun 2019 17:06:47 -0400 From: Tom Lane To: Etsuro Fujita cc: Paul Ramsey , Jeff Janes , Joao Ferreira , "pgsql-bugs@lists.postgresql.org" Subject: Re: =?UTF-8?Q?Re=3A_Querying_foreign_table_with_SP=2DGiST_index_result?= =?UTF-8?Q?s_in_=E2=80=9CERROR=3A_cache_lookup_failed_for_type_0=E2=80=9D?= In-reply-to: References: <1407840601.3022762.1560857315693.ref@mail.yahoo.com> <1407840601.3022762.1560857315693@mail.yahoo.com> Comments: In-reply-to Etsuro Fujita message dated "Mon, 24 Jun 2019 20:06:05 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <12442.1561583207.1@sss.pgh.pa.us> Date: Wed, 26 Jun 2019 17:06:47 -0400 Message-ID: <12443.1561583207@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Etsuro Fujita 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