From: Stuart Rison <stuart@ludwig.ucl.ac.uk>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: mdalphin@amgen.com
Cc: pgsql-sql@postgreSQL.org
Cc: jwieck@debis.com
Subject: Re: [SQL] Anyone recognise this error from PL/pgSQL?
Date: Mon, 16 Aug 1999 15:57:27 +0100
Message-ID: <v04020a00b3ddd52e6167@[128.40.242.190]> (raw)
In-Reply-To: <632.934812731@sss.pgh.pa.us>
References: <v04020a03b3dd80db8fc9@[128.40.242.190]>
Hi Tom,
I think you are right in saying that PL/pgSQL transforms NEW into
"$something" but I don't think the lexical ambiguity is in plpgsql because:
CREATE FUNCTION test(int2) RETURNS int2 AS '
SELECT field2 FROM test
WHERE field1=$1;
' language 'sql';
ERROR: There is no operator '=$' for types 'int2' and 'int4'
You will either have to retype this query using an explicit cast,
or you will have to define the operator using CREATE OPERATOR
Same problem with SQL functions (this is with PG6.4).
I don't know what the standard syntax for operators is but -if it is not
compulsary to "bound" the operator with spaces- I guess it's a (minor) bug
with the SQL parser.
Cheers,
Stuart.
At 10:12 am -0400 16/8/99, Tom Lane wrote:
>Stuart Rison <stuart@ludwig.ucl.ac.uk> writes:
>> Yes, I remember a posting about this a little while ago, the solution was
>> so simple it made you want to kick yourself!
>> SELECT * INTO zhvt_row FROM zhvt
>> WHERE zhvtID=NEW.zhvtID;
>> Becomes:
>> SELECT * INTO zhvt_row FROM zhvt
>> WHERE zhvtID = NEW.zhvtID; --spaces on either side of the equal
>
>> I'm wondering if this is a bug that should be corrected in the parser or if
>> it is correct syntax for the operator to be bound by spaces?
>
>I thought it might be something like that ... probably plpgsql
>transforms "NEW" into something involving a "$" and then the parser
>misparses "=$" as a single operator. I'd argue that it's a plpgsql bug,
>if that's right --- if plpgsql is doing text transformations that create
>lexical ambiguities, it should be inserting spaces to prevent ambiguity.
>
> regards, tom lane
+--------------------------+--------------------------------------+
| Stuart C. G. Rison | Ludwig Institute for Cancer Research |
+--------------------------+ 91 Riding House Street |
| N.B. new phone code!! | London, W1P 8BT |
| Tel. +44 (0)207 878 4041 | UNITED KINGDOM |
| Fax. +44 (0)207 878 4040 | stuart@ludwig.ucl.ac.uk |
+--------------------------+--------------------------------------+
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: stuart@ludwig.ucl.ac.uk, tgl@sss.pgh.pa.us, mdalphin@amgen.com, jwieck@debis.com
Subject: Re: [SQL] Anyone recognise this error from PL/pgSQL?
In-Reply-To: <v04020a00b3ddd52e6167@[128.40.242.190]>
References: <v04020a03b3dd80db8fc9@[128.40.242.190]> <v04020a00b3ddd52e6167@[128.40.242.190]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox