Re: PL/PgSQL "bare" function calls - Mailing list pgsql-hackers

From Neil Conway
Subject Re: PL/PgSQL "bare" function calls
Date
Msg-id 1095294886.31400.72.camel@localhost.localdomain
Whole thread Raw
In response to Re: PL/PgSQL "bare" function calls  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Thu, 2004-09-16 at 01:05, Tom Lane wrote:
> That seems fairly unworkable.  For example
> 
>     SELECT (2,3,4);
> 
> is valid SQL.

Good point. The disambiguation algorithm I suggested isn't sufficient,
but I think there ought to be _some_ reasonable algorithm.

>From glancing over the SQL commands, I believe SELECT is the only case
where a SQL statement starts with a T_WORD token followed by a left
parenthesis (correct me if I'm mistaken). If that's the case, one
solution would be to just special-case SELECT: if the name of the
"function" is 'select', we treat it as a SQL statement and not a
function call. Of course, this wouldn't apply if the function name is
double-quoted or schema-qualified.

Another technique would be to delay distinguishing between these two
cases until the function is first invoked; then lookup the function name
in pg_proc, and if a candidate function with that name is found, assume
it's a function call. I don't really like this technique, though.

> Also I'm not sure if you can extend this to cope with
> schema-qualified function names.

Sorry, I forgot to mention that -- yes, that is intended.

-Neil




pgsql-hackers by date:

Previous
From: Chris Dunlop
Date:
Subject: Re: Statement parsing problem ?
Next
From: Gaetano Mendola
Date:
Subject: Re: PostgreSQL Core Committee Welcomes New Member