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 1hdCoK-00019d-2d for pgsql-bugs@arkaria.postgresql.org; Tue, 18 Jun 2019 12:02: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 1hdCoI-0002H6-UH for pgsql-bugs@arkaria.postgresql.org; Tue, 18 Jun 2019 12:01: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 1hdCIC-000327-9z for pgsql-bugs@lists.postgresql.org; Tue, 18 Jun 2019 11:28:48 +0000 Received: from sonic314-20.consmr.mail.ne1.yahoo.com ([66.163.189.146]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hdCI9-0002GJ-CI for pgsql-bugs@lists.postgresql.org; Tue, 18 Jun 2019 11:28:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1560857323; bh=LnZaD9JnXjh4ANYD8cypz9yQgj0uERHxTu2OM+DuqUM=; h=Date:From:To:Subject:References:From:Subject; b=eeIXq7qznlBHLp8gNpVjaw4Cq0O8TqqpKKdcwXH81QiPuUrzNbZmCCPjDrdXLVDJ4AjVToknnFqDkRXNw4hvZNYxRRxfvCpSG+oHlUF8RHmDWsbCCHzvNXaCM40clIdQuclK48udd8nRvwbULzeojVBFwdEacnSEmrUP8apMd83KmE/7Js0/0P0Xr0C/KE0T5PaKzDqbNuKjLaIGWkIFBzJS6tSz4HgZPO4ZyOlhKZBO0GCw0P3s4/svxFKoYJaO2VIGlOL2A9xmBJdlVu81udVX2ki7OnQ5rkh+C1V1MnFy/UUMBS0lnlPaR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jD9BjiK64ite.QVPqpogPOGM7KOJhiC_yjgk8ER2 D93E1t1BD2Dz_VOQo0_fDcWOAhIxGEnNHH0N3idtunoxaYWoViG.VuFC3ghYqcDgDF.WT3YVIoSC Qs45KrAOM2pt1GcP5dUT2tG.TIBpCpdV93RDSs2fB0D6BCkTb0bZzdVdgQNlJmJ8AfquQr2xrYzM shxDLXkncq_AJklyVQDepv.30zaFvlV6JOyLXxxGZrueeijH_UVxibYZnSloxARzQQDZkNgNn5ya qUhNyErGxVVJ8R7zVhrP4HvAezI7dt4Hr6W50wqAFpTX8EQzAbM2SUZwWAt0xpo0.MOc8dZcOs.G pDPkPioGG2RPO0RBceUC9fDOlUqQ.1k3zqfvmNrq4ZvNf Received: from sonic.gate.mail.ne1.yahoo.com by sonic314.consmr.mail.ne1.yahoo.com with HTTP; Tue, 18 Jun 2019 11:28:43 +0000 Date: Tue, 18 Jun 2019 11:28:35 +0000 (UTC) From: Joao Ferreira To: "pgsql-bugs@lists.postgresql.org" Message-ID: <1407840601.3022762.1560857315693@mail.yahoo.com> Subject: =?UTF-8?Q?Querying_foreign_table_with_SP-GiST_index_resu?= =?UTF-8?Q?lts_in_=E2=80=9CERROR:_cache_lookup_failed_for_type_0=E2=80=9D?= MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_3022761_2021760537.1560857315693" References: <1407840601.3022762.1560857315693.ref@mail.yahoo.com> X-Mailer: WebService/1.1.13837 YMailNorrin Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 Safari/537.36 Content-Length: 23807 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------=_Part_3022761_2021760537.1560857315693 Content-Type: multipart/alternative; boundary="----=_Part_3022757_369711416.1560857315645" ------=_Part_3022757_369711416.1560857315645 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Greetings, I'm using PostgreSQL 11.3 and I want to access a table in another Postgres = database using=C2=A0postgres_fdw=C2=A0but since the original table has an= =C2=A0SP-GiST=C2=A0index on a geometry column, the query on the foreign tab= le fails with "ERROR: cache lookup failed for type 0", even if the table is= empty (Step 7). This doesn't happen if the query is done directly to the r= emote table (Steps 3 and 6)=C2=A0or if the remote table doesn't have the in= dex (Steps 3 and 4). OS: Windows Server 2016 StandardRAM: 16GB Postgres installer:=C2=A0postgresql-11.3-1-windows-x64.exePostgis installer= :=C2=A0postgis-bundle-pg11x64-setup-2.5.2-1.exePostgres version (using 'SEL= ECT version()'):=C2=A0PostgreSQL 11.3, compiled by Visual C++ build 1914, 6= 4-bit=C2=A0Postgis version (using 'SELECT postgis_version()'):=C2=A02.5 USE= _GEOS=3D1 USE_PROJ=3D1 USE_STATS=3D1 DBA StackExchange:=C2=A0https://dba.stackexchange.com/questions/240718/quer= ying-foreign-table-with-sp-gist-index-results-in-error-cache-lookup-failed Bug reproduction steps: 1) Create remote database:=C2=A0psql -f remote_db.sql postgres postgres 2) Create local database:psql -f local_db.sql postgres postgres 3) Select directly on remote database: psql -c "SELECT * FROM remote.locati= ons" remote postgres Output:=C2=A0id | name | lonlat----+------+--------(0 rows) 4) Select through foreign table: psql -c "SELECT * FROM localdb.locations" = localdb postgres Output:=C2=A0id | name | lonlat----+------+--------(0 rows) 5) Add SP-GiST index to remote database:psql -c "CREATE INDEX remote_locati= ons_lonlat_idx ON remote.locations USING spgist (lonlat)" remote postgres Output:CREATE INDEX 6) Select directly on remote database:psql -c "SELECT * FROM remote.locatio= ns" remote postgres Output:=C2=A0id | name | lonlat----+------+--------(0 rows) 7) Select through foreign table (with log error verbosity set to verbose): = psql -c "SET log_error_verbosity TO verbose; SELECT * FROM localdb.location= s;" localdb postgres Output: ERROR:=C2=A0 cache lookup failed for type 0CONTEXT:=C2=A0 remote SQ= L command: SELECT id, name, lonlat FROM remote.locations