Обсуждение: Re: [HACKERS] Patch for user-defined C-language functions
> Postgresql operator with the following syntax > > CREATE FUNCTION mytype3 ( mytype2 ) > RETURNS mytype3 > AS 'mytypes.so', 'mytype2_to_mytype3' > LANGUAGE 'C' > > The syntax for the AS clause, which was 'AS <link-file>' becomes > > AS <link_file>[, <link_name>] Sounds great ! But I think the intuitive Syntax in SQL would use (): CREATE FUNCTION mytype3 ( mytype2 ) RETURNS mytype3 AS 'mytypes.so(mytype2_to_mytype3)' LANGUAGE 'C' Syntax:AS <link_file>[(symbol_name)] This is also how Illustra and now Informix does it. (Instead of AS they say EXTERNAL NAME) Andreas
Andreas Zeugswetter <andreas.zeugswetter@telecom.at> writes:
> But I think the intuitive Syntax in SQL would use ():
> CREATE FUNCTION mytype3 ( mytype2 )
> RETURNS mytype3
> AS 'mytypes.so(mytype2_to_mytype3)'
> LANGUAGE 'C'
> Syntax:
> AS <link_file>[(symbol_name)]
I think Bernard had the better solution --- the above presumes that
filenames won't ever have parens in them. (Which, admittedly, is a
bad idea under most Unix shells --- but that doesn't mean we should
perpetuate the problem.) Also, I'd rather see us keep the platform-
dependent ".so" extension at the end of its string, where it's easy
to spot and fix when needed.
regards, tom lane
Andreas Zeugswetter wrote:
>
> But I think the intuitive Syntax in SQL would use ():
>
> CREATE FUNCTION mytype3 ( mytype2 )
> RETURNS mytype3
> AS 'mytypes.so(mytype2_to_mytype3)'
> LANGUAGE 'C'
>
> Syntax:
> AS <link_file>[(symbol_name)]
>
> This is also how Illustra and now Informix does it.
> (Instead of AS they say EXTERNAL NAME)
>
The syntax
AS <link_file>[(symbol_name)]
would be easy to implement provided I could write your example as
CREATE FUNCTION mytype3 ( mytype2 ) RETURNS mytype3 AS 'mytypes.so'('mytype2_to_mytype3') LANGUAGE
'C'
That way link_file and symbol_name both look like string tokens to
the parser. If it is implemented the way you write in the example with
'mytypes.so(mytype2_to_mytype3)'
Then the parser sees the arguement of the AS clause as a single
string token which would have to be parsed separately. Also, there is
some ambiguity in this form as to whether the string
'mytypes.so(mytype2_to_mytype3)'
is a single filename, or a filename and a link symbol
Bernie