Обсуждение: Is "query" a reserved word in 8.3 plpgsql?

Поиск
Список
Период
Сортировка

Is "query" a reserved word in 8.3 plpgsql?

От
"Todd A. Cook"
Дата:
Hi,

I saw the item in the release notes about the new "return query" syntax in pl/pgsql,
but I didn't see any note about "query" being reserved now.  Perhaps an explicit
mention should be added?

I loaded a dump from 8.2.4 into 8.3b2 without error.  However, every function that
uses "query" as a variable name now fails with a syntax error when it is executed:

     ERROR:  syntax error at or near "query" at character 151

My workaround will be to extract the functions from the dump, edit them to rename
the variable, and load them into the new db.

-- todd

Re: Is "query" a reserved word in 8.3 plpgsql?

От
Tom Lane
Дата:
"Todd A. Cook" <tcook@blackducksoftware.com> writes:
> I saw the item in the release notes about the new "return query"
> syntax in pl/pgsql, but I didn't see any note about "query" being
> reserved now.  Perhaps an explicit mention should be added?

Yeah, I got burnt by that too.  I have a bad feeling that that keyword
is going to cause trouble for a lot of people.

[ thinks for a bit... ]  It might be possible to get rid of the keyword
and have RETURN QUERY be recognized by an ad-hoc strcmp test, much like
the various direction keywords in FETCH have been handled without making
them real keywords.  It'd be a bit uglier but it'd avoid making QUERY
be effectively a reserved word.

            regards, tom lane

Re: Is "query" a reserved word in 8.3 plpgsql?

От
"Scott Marlowe"
Дата:
On Nov 9, 2007 5:14 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> "Todd A. Cook" <tcook@blackducksoftware.com> writes:
> > I saw the item in the release notes about the new "return query"
> > syntax in pl/pgsql, but I didn't see any note about "query" being
> > reserved now.  Perhaps an explicit mention should be added?
>
> Yeah, I got burnt by that too.  I have a bad feeling that that keyword
> is going to cause trouble for a lot of people.
>
> [ thinks for a bit... ]  It might be possible to get rid of the keyword
> and have RETURN QUERY be recognized by an ad-hoc strcmp test, much like
> the various direction keywords in FETCH have been handled without making
> them real keywords.  It'd be a bit uglier but it'd avoid making QUERY
> be effectively a reserved word.

It's not uncommon to have auditing triggers store things in tables
with fields named query in them.  I know I have a few places that do
this...

Just sayin'

Re: [HACKERS] Is "query" a reserved word in 8.3 plpgsql?

От
Tom Lane
Дата:
"Scott Marlowe" <scott.marlowe@gmail.com> writes:
> On Nov 9, 2007 5:14 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> [ thinks for a bit... ]  It might be possible to get rid of the keyword
>> and have RETURN QUERY be recognized by an ad-hoc strcmp test, much like
>> the various direction keywords in FETCH have been handled without making
>> them real keywords.  It'd be a bit uglier but it'd avoid making QUERY
>> be effectively a reserved word.

> It's not uncommon to have auditing triggers store things in tables
> with fields named query in them.  I know I have a few places that do
> this...

It turned out to be a very easy change, so it's done: QUERY isn't a
reserved word anymore.

            regards, tom lane

Re: [HACKERS] Is "query" a reserved word in 8.3 plpgsql?

От
"Scott Marlowe"
Дата:
On Nov 9, 2007 6:07 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> "Scott Marlowe" <scott.marlowe@gmail.com> writes:
> > On Nov 9, 2007 5:14 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> >> [ thinks for a bit... ]  It might be possible to get rid of the keyword
> >> and have RETURN QUERY be recognized by an ad-hoc strcmp test, much like
> >> the various direction keywords in FETCH have been handled without making
> >> them real keywords.  It'd be a bit uglier but it'd avoid making QUERY
> >> be effectively a reserved word.
>
> > It's not uncommon to have auditing triggers store things in tables
> > with fields named query in them.  I know I have a few places that do
> > this...
>
> It turned out to be a very easy change, so it's done: QUERY isn't a
> reserved word anymore.

Thanks!

Re: [HACKERS] Is "query" a reserved word in 8.3 plpgsql?

От
"Todd A. Cook"
Дата:
Tom Lane wrote:
>
> It turned out to be a very easy change, so it's done: QUERY isn't a
> reserved word anymore.

Thanks for your help. :)

-- todd