Re: IMPORT FOREIGN SCHEMA statement - Mailing list pgsql-hackers

From Stephen Frost
Subject Re: IMPORT FOREIGN SCHEMA statement
Date
Msg-id 20140527134106.GG2556@tamriel.snowman.net
Whole thread Raw
In response to Re: IMPORT FOREIGN SCHEMA statement  (David Fetter <david@fetter.org>)
Responses Re: IMPORT FOREIGN SCHEMA statement
List pgsql-hackers
* David Fetter (david@fetter.org) wrote:
> - We make type mappings settable at the level of:
>     - FDW
>     - Instance (a.k.a. cluster)
>     - Database
>     - Schema
>     - Table
>     - Column

While I like the general idea, you seem to be making this appear much
more complex than it actually is.  For example, I see no value in a
table-level "uint4 -> int8" definition.  If you want something which is
not the default, just set it on the individual columns of the foreign
table, exactly how we handle column name differences.

There might be some value in being able to redefine what the default is
at the FOREIGN SERVER level, as perhaps MySQL DB X and MySQL DB Y could
have different default mappings for some reason, but adding in the rest
of those levels doesn't add value imv.

>     This would consist of:
>     - The remote type
>     - The local type to which it maps
>     - The inbound transformation (default identity)
>     - The outbound transformation (default identity)

The remote type and the local type are known already to the FDW, no?
The FDW will need to know how to do whatever conversions we're talking
about also, right?  (If you want to do it in core PG instead of the FDW
then I'm thinking you should probably use a view over top of the
foreign table..).  What's nice is that this all falls under what an FDW
can do *already*, if it wants (and, actually, it could do it on the
table-level technically too, if the FDW supports that, but schema?
database?  these things don't make sense...).

For the IMPORT bit, it should just be doing whatever the defaults are
unless you've set some different defaults for a given foreign server
(also something which could be set using our existing system...).

>     ALTER FOREIGN TABLE foo ADD (mapping '{
>         "datetime": "text",
>         "inbound": "IDENTITY",
>         outbound: "IDENTITY"
>     }')

I'm very much against having two different command languages where one
is used "when convenient".  If we wanted to do this, we should build a
full-spec mapping from whatever JSON language you come up with for our
utility commands to what we actually implement in the grammar.
Thanks,
    Stephen

pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: Spreading full-page writes
Next
From: Stephen Frost
Date:
Subject: Re: IMPORT FOREIGN SCHEMA statement