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 1hgHW1-0005Ck-Jq for pgsql-bugs@arkaria.postgresql.org; Wed, 26 Jun 2019 23:39:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hgHW0-0001gz-Fv for pgsql-bugs@arkaria.postgresql.org; Wed, 26 Jun 2019 23:39:48 +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 1hgHW0-0001ev-5V for pgsql-bugs@lists.postgresql.org; Wed, 26 Jun 2019 23:39:48 +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 1hgHVx-0006rs-Tu for pgsql-bugs@lists.postgresql.org; Wed, 26 Jun 2019 23:39:47 +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 x5QNdhL5018553; Wed, 26 Jun 2019 19:39:43 -0400 From: Tom Lane To: Paul Ramsey cc: Etsuro Fujita , Jeff Janes , Joao Ferreira , "pgsql-bugs@lists.postgresql.org" Subject: Re: =?utf-8?Q?Re=3A_Querying_foreign_table_with_SP-GiST_index_results?= =?utf-8?Q?_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> <12443.1561583207@sss.pgh.pa.us> Comments: In-reply-to Paul Ramsey message dated "Wed, 26 Jun 2019 14:31:40 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <18551.1561592383.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 26 Jun 2019 19:39:43 -0400 Message-ID: <18552.1561592383@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Paul Ramsey writes: >> On Jun 26, 2019, at 2:06 PM, Tom Lane wrote: >> 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. > We had a similar problem, if I recall correctly, doing lookups of spatia= l reference information, for similar reasons: calling over FDW the search_= path was so limited the internal lookup functions couldn=E2=80=99t find th= e spatial_ref_sys table. I just looked up the work-around, and it looks li= ke we infer that the table we=E2=80=99re looking for (part of PostGIS) res= ides in the same schema as the calling function (part of PostGIS), and the= n cache that schema name for future use. Yeah. The variant I was thinking about was to look up the namespace of the geometry type (which in this example you could get from attType of the spgConfigIn parameter struct) and assume that box2df is in that schema. But working from the function's own schema might be better because you could do the same thing in all these places, rather than needing to find an associated object in some call-site-specific way. regards, tom lane