Re: CREATE ROUTINE MAPPING - Mailing list pgsql-hackers

From Corey Huinker
Subject Re: CREATE ROUTINE MAPPING
Date
Msg-id CADkLM=fVcC0W2=TvOn-BMTN2n=REz1YmSqxY1dKcLZSc+WjZsg@mail.gmail.com
Whole thread Raw
In response to Re: CREATE ROUTINE MAPPING  (David Fetter <david@fetter.org>)
Responses Re: CREATE ROUTINE MAPPING
List pgsql-hackers


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, 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.

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'. 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.

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.

pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: [Sender Address Forgery]Re: [Sender Address Forgery]Re: [HACKERS]path toward faster partition pruning
Next
From: Alvaro Herrera
Date:
Subject: Re: [HACKERS] GSoC 2017: Foreign Key Arrays