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

Lists: pgsql-generalpgsql-hackers
From: "Todd A(dot) Cook" <tcook(at)blackducksoftware(dot)com>
To: Postgresql-General mailing list <pgsql-general(at)postgresql(dot)org>
Subject: Is "query" a reserved word in 8.3 plpgsql?
Date: 2007-11-09 22:06:33
Message-ID: 4734D9E9.2070101@blackducksoftware.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general Postg사설 토토 사이트SQL

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


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Todd A(dot) Cook" <tcook(at)blackducksoftware(dot)com>
Cc: pgsql-general(at)postgreSQL(dot)org, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Is "query" a reserved word in 8.3 plpgsql?
Date: 2007-11-09 23:14:16
Message-ID: 4149.1194650056@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

"Todd A. Cook" <tcook(at)blackducksoftware(dot)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


From: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Todd A(dot) Cook" <tcook(at)blackducksoftware(dot)com>, pgsql-general(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Is "query" a reserved word in 8.3 plpgsql?
Date: 2007-11-09 23:43:43
Message-ID: dcc563d10711091543j263f9495r8b6e12ba618a2557@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

On Nov 9, 2007 5:14 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> "Todd A. Cook" <tcook(at)blackducksoftware(dot)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'


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>
Cc: "Todd A(dot) Cook" <tcook(at)blackducksoftware(dot)com>, pgsql-general(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [HACKERS] Is "query" a reserved word in 8.3 plpgsql?
Date: 2007-11-10 00:07:17
Message-ID: 6089.1194653237@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

"Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com> writes:
> On Nov 9, 2007 5:14 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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


From: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Todd A(dot) Cook" <tcook(at)blackducksoftware(dot)com>, pgsql-general(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [HACKERS] Is "query" a reserved word in 8.3 plpgsql?
Date: 2007-11-10 01:14:59
Message-ID: dcc563d10711091714y10ca7947qce8d308d95f89fab@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

On Nov 9, 2007 6:07 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com> writes:
> > On Nov 9, 2007 5:14 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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!


From: "Todd A(dot) Cook" <tcook(at)blackducksoftware(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: [HACKERS] Is "query" a reserved word in 8.3 plpgsql?
Date: 2007-11-12 18:42:23
Message-ID: 47389E8F.3030408@blackducksoftware.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

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