pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Joao Ferreira <jpgferreira@yahoo.com>
To: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Subject: Querying foreign table with SP-GiST index results in “ERROR: cache lookup failed for type 0”
Date: Tue, 18 Jun 2019 11:28:35 +0000 (UTC)
Message-ID: <1407840601.3022762.1560857315693@mail.yahoo.com> (raw)
References: <1407840601.3022762.1560857315693.ref@mail.yahoo.com>

Greetings,
I'm using PostgreSQL 11.3 and I want to access a table in another Postgres database using postgres_fdw but since the original table has an SP-GiST index on a geometry column, the query on the foreign table 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 remote table (Steps 3 and 6) or if the remote table doesn't have the index (Steps 3 and 4).

OS: Windows Server 2016 StandardRAM: 16GB
Postgres installer: postgresql-11.3-1-windows-x64.exePostgis installer: postgis-bundle-pg11x64-setup-2.5.2-1.exePostgres version (using 'SELECT version()'): PostgreSQL 11.3, compiled by Visual C++ build 1914, 64-bit Postgis version (using 'SELECT postgis_version()'): 2.5 USE_GEOS=1 USE_PROJ=1 USE_STATS=1
DBA StackExchange: https://dba.stackexchange.com/questions/240718/querying-foreign-table-with-sp-gist-index-results-in-...

Bug reproduction steps:
1) Create remote database: psql -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.locations" remote postgres
Output: id | name | lonlat----+------+--------(0 rows)
4) Select through foreign table: psql -c "SELECT * FROM localdb.locations" localdb postgres
Output: id | name | lonlat----+------+--------(0 rows)
5) Add SP-GiST index to remote database:psql -c "CREATE INDEX remote_locations_lonlat_idx ON remote.locations USING spgist (lonlat)" remote postgres
Output:CREATE INDEX

6) Select directly on remote database:psql -c "SELECT * FROM remote.locations" remote postgres
Output: id | 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.locations;" localdb postgres
Output: ERROR:  cache lookup failed for type 0CONTEXT:  remote SQL command: SELECT id, name, lonlat FROM remote.locations

view thread (9+ messages)  latest in thread

Message-ID: <1407840601.3022762.1560857315693@mail.yahoo.com>
Permalink:  ../1407840601.3022762.1560857315693@mail.yahoo.com/
Also on:    postgresql.org/message-id/1407840601.3022762.1560857315693@mail.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: jpgferreira@yahoo.com
  Subject: Re: Querying foreign table with SP-GiST index results in “ERROR: cache lookup failed for type 0”
  In-Reply-To: <1407840601.3022762.1560857315693@mail.yahoo.com>
  References: <1407840601.3022762.1560857315693.ref@mail.yahoo.com> <1407840601.3022762.1560857315693@mail.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox