On Fri, Jan 12, 2018 at 02:29:53PM -0500, Corey Huinker wrote: > > > > > > > > It goes on from there, but I think there's a reasonable interpretation > > of this which allows us to use the same syntax as CREATE > > (FUNCTION|PROCEDURE), apart from the body, e.g.: > > > > CREATE ROUTINE MAPPING local_routine_name > > FOR (FUNCTION | PROCEDURE) remote_routine_name ( [ [ argmode ] [ argname ] > > argtype [ { DEFAULT | = } default_expr ] [, ...] ] ) > > [ RETURNS rettype > > | RETURNS TABLE ( column_name column_type [, ...] ) ] > > SERVER foreign_server_name > > [ (option [, ...]) ] > > > > Does that seem like too broad an interpretation? > > > > That's really interesting. I didn't think to look in the definition of > CREATE FUNCTION to see if a SERVER option popped in there, but seems like a > more accessible way to introduce the notion of remote functions,
It does indeed. Adding the functionality to CREATE (FUNCTION|PROCEDURE) seems like a *much* better idea than trying to wedge it into the CREATE ROUTINE MAPPING syntax. > because I talked to a few developers about this before posting to > the list, and only one had ever heard of ROUTINE MAPPING and had no > clear recollection of it. An option on CREATE FUNCTION is going to > get noticed (and used!) a lot sooner. +1 > Having said that, I think syntactically we have to implement CREATE ROUTINE > MAPPING, even if it is just translated to a CREATE FUNCTION call. > > In either case, I suspected that pg_proc would need a nullable srvid column > pointing to pg_foreign_server, and possibly a new row in pg_language for > 'external'. Makes a lot of sense. > I had entertained having a pg_routine_mappings table like > pg_user_mappings, and we still could, if the proc's language of > 'external' clued the planner to look for the mapping. I can see > arguments for either approach. It would be good to have them in the catalog somehow if we make CREATE ROUTINE MAPPING a DDL. If I've read the standard correctly, there are parts of information_schema which come into play for those routine mappings. > Before anyone asks, I looked for, and did not find, any suggestion of > IMPORT FOREIGN ROUTINE a la IMPORT FOREIGN SCHEMA, so as of yet there > wouldn't be any way to grab all the functions that .a foreign server is > offering up. How about making an option to IMPORT FOREIGN SCHEMA do it? Best, David. -- David Fetter <david(at)fetter(dot)org> http://fetter.org/ Phone: +1 415 235 3778 Remember to vote! Consider donating to Postgres: http://www.postgresql.org/about/donate