CREATE FOREIGN TABLE difficulties

From: Paul Lavoie <rootbeerrail(dot)ml(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: CREATE FOREIGN TABLE difficulties
Date: 2017-06-15 16:49:28
Message-ID: 7C4921A2-5192-4C17-B14C-3446C9065122@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

Long time user, new poster…

For assorted reasons I’ve decided to shard a database across multiple instances of postgresql running on the same machine. I’ve set up a lot of children servers with a ‘fdw’ user to work with the foreign data wrapper and created the child database along with a schema, and then on the main database go thru the process of:

CREATE SCHEMA myschema;
CREATE TABLE mytable (mycol TEXT);

CREATE EXTENSION postgres_fdw;
CREATE SERVER db001 FOREIGN DATA WRAPPER postgres_fdw OPTIONS (host ‘localhost’, port ‘8001’, dbname = ‘db001’);
CREATE USER MAPPING FOR myuser SERVER db001 OPTIONS (user ‘fdw’, password ‘XXX’);
CREATE FOREIGN TABLE myschema.mytable () INHERITS (mytable) SERVER db001 OPTIONS (schema_name ‘myschema’, table_name ‘mytable’);

Attempts to SELECT from myschema.mytable then fail with a “relation “myschema.mytable” does not exist” error, and going into the child database shows no signs of any tables whatsoever.

This is under Postgresql 9.6.3, with the software being tested on servers running MacOS, NetBSD/amd64, & Solaris/x86_64 (various combinations). I’ve tried removing the schema qualifications, redoing the host as properly remote rather than localhost, removing the port number, all without any signs of success. Oddly, the inverse of IMPORT FOREIGN SCHEMA appears to work.

I’m particularly curious as to how one would troubleshoot this scenario. I’m somewhat surprised at the CREATE FOREIGN TABLE returning success when it doesn’t appear to have done all the work - the Postgreql instance must be present, but it doesn’t complain if the database, never mind the schema, doesn’t exist.

If this turns out to be a bug, I’ll happily move to the bug mailing list to discuss further. But under the possibility I’m missing the obvious, I’d thought I’d try here first.

I’m going to go try the 10.0 beta now…

Thanks!

- Paul

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alexander Kuzmenkov 2017-06-15 17:09:37 Re: Index-only scan on GIN index for COUNT() queries
Previous Message Seamus Abshere 2017-06-15 14:43:58 Index-only scan on GIN index for COUNT() queries