Re: Updated CREATE FUNCTION syntax - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Updated CREATE FUNCTION syntax
Date
Msg-id 23258.1021677779@sss.pgh.pa.us
Whole thread Raw
In response to Re: Updated CREATE FUNCTION syntax  (Peter Eisentraut <peter_e@gmx.net>)
Responses Re: Updated CREATE FUNCTION syntax
List pgsql-hackers
Peter Eisentraut <peter_e@gmx.net> writes:
> Joel Burton writes:
>> Is there any standardized way of handling the single-quotes within function
>> definition? Rather than doubling them up (which can make for very messy code
>> when your scripting language uses single quotes!), allowing another symbol
>> to be used, with that symbol be declared in the CREATE FUNCTION line?
>> Interbase uses a system like this: you can set the delimiter to anything you
>> want and use that instead of '.

> I think we need something like that.  How exactly does Interbase "set" the
> delimiter?  Keep in mind that our lexer and parser are static.

Seems like the only way to do that in the backend would be to find a way
of slipping the function text past the lexer/parser entirely.  While I
can imagine ways of doing that, I think it'd be a *whole* lot cleaner
to fix things on the client side.

How do you feel about a psql hack that provides a "function definition"
mode?  More generally it could be a mode to enter random text and have
it be converted to an SQL literal string.  Perhaps
psql=> create function foo (int) returns int aspsql-> \beginliteralpsql-LIT> beginpsql-LIT> x := $1;psql-LIT>
...psql-LIT>end;psql-LIT> \endliteralpsql-> language plpgsql;
 

Essentially, \beginliteral and \endliteral each convert to a quote
mark, and everywhere in between quotes and backslashes get doubled.
We might want to specify that the leading and trailing newlines get
dropped, too, though for function-definition applications that would
not matter.
        regards, tom lane


pgsql-hackers by date:

Previous
From: "Dann Corbit"
Date:
Subject: Re: Error on PQputline()
Next
From: Tom Lane
Date:
Subject: Re: Error on PQputline()