Re: PL/PgSQL "bare" function calls

From: Neil Conway <neilc(at)samurai(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PL/PgSQL "bare" function calls
Date: 2004-09-16 00:34:46
Message-ID: 1095294886.31400.72.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Gaetano Mendola 2004-09-16 00:50:19 Re: PostgreSQL Core Committee Welcomes New Member
Previous Message Chris Dunlop 2004-09-15 23:46:06 Re: Statement parsing problem ?