Re: pl/pgSQL variable substitution - Mailing list pgsql-general

From Tom Lane
Subject Re: pl/pgSQL variable substitution
Date
Msg-id 6478.1297954355@sss.pgh.pa.us
Whole thread Raw
In response to pl/pgSQL variable substitution  (Jeremy Palmer <JPalmer@linz.govt.nz>)
List pgsql-general
Jeremy Palmer <JPalmer@linz.govt.nz> writes:
> When I have a query that uses DESC reserved word within the function the following variable substitution occurs:

> ERROR:  syntax error at or near "$1"
> LINE 1:  SELECT foo.bar, foo."desc"   FROM foo."desc" ORDER BY  foo."desc"   $1
>                                                                              ^

The other two responses seem to have missed the point, which is that
plpgsql is substituting for something that couldn't possibly be a
variable name.  That is fixed as of 9.0.  I'm not sure whether it
solves your issue completely, though.  In general, using identifiers
that look like reserved words is painful --- and don't forget that
in plpgsql, you have *two* sets of reserved words to worry about,
the core SQL language's plus plpgsql's own.

            regards, tom lane

pgsql-general by date:

Previous
From: Steven Elliott
Date:
Subject: The efficiency of the WAL log writer
Next
From: Tom Lane
Date:
Subject: Re: The efficiency of the WAL log writer