From: | Peter Swartz <peter(dot)goodings(dot)swartz(at)gmail(dot)com> |
---|---|
To: | Ian Barwick <ian(at)2ndquadrant(dot)com> |
Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Enum in foreign table: error and correct way to handle. |
Date: | 2015-05-23 15:48:55 |
Message-ID: | CAGhmnP2vG06NdHk9nWFN0go3YmF025eutQfrp8mBLQCi5n3mjw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Thank you for the note Ian. I definitely see your point about the onus
being on the local database to maintain the definition of the remote
table. Do you or anyone have this list have any experience with the
resulting behavior if the definition of the enum were to become out of sync
between the local database and the foreign database? In other words,
suppose the foreign database adds a value to the enum, and the foreign
table now has rows with this new value, while the local definition of the
enum remains unchanged. Obviously, the appropriate action on my part is to
maintain consistency of enum definition between the foreign and local
database, but I'm curious about what behavior would result if there was an
error in this manual updating process.
I may dig into this a bit further myself in a few test databases, to see
what happens. Will post a response if I do.
With regards,
Peter
On Thu, May 21, 2015 at 8:06 PM, Ian Barwick <ian(at)2ndquadrant(dot)com> wrote:
> On 21/05/15 04:23, Peter Swartz wrote:
> > I'm creating a foreign table (foo_table) in database_a. foo_table lives
> in
> > database_b.foo_table has an enum (bar_type) as one of its columns.
> Because
> > this enum is in database_b, the creation of the foreign table fails in
> > database_a. database_a doesn't understand the column type. Running the
> > following in database_a
> >
> > CREATE FOREIGN TABLE foo_table (id integer NOT NULL, bar bar_type) SERVER
> > database_b
> >
> > One gets the error:
> >
> > ERROR: type "bar_type" does not exist
> >
> > I could just create a copy of bar_type in database_a, but this feels
> > duplicative and possibly a future cause of inconsistency / trouble. Would
> > anyone have thoughts on best practices for handling?
>
> A foreign table is basically an ad-hoc remote data source for the local
> database,
> so the onus is on the local database to maintain its definition of the
> remote table, whether it's in another (or even the same) PostgreSQL server
> or a completely different data source, especially as the local definition
> can
> be different from the remote one.
>
> This does mean that there's no simple way of ensuring any remote
> dependencies are
> present on the local server. PostgreSQL 9.5 will provide the IMPORT
> FOREIGN SCHEMA
> command, however this is limited to table/view definitions.
>
>
> Regards
>
> Ian Barwick
>
>
>
> --
> Ian Barwick http://www.2ndQuadrant.com/
> PostgreSQL Development, 24x7 Support, Training & Services
>
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2015-05-23 16:35:58 | Re: Enum in foreign table: error and correct way to handle. |
Previous Message | twoflower | 2015-05-23 15:23:51 | Re: Server tries to read a different config file than it is supposed to |