Unix Technical Forum

BUG #2889: Syntax error: WHERE ANY(arrayfield) = N

This is a discussion on BUG #2889: Syntax error: WHERE ANY(arrayfield) = N within the pgsql Bugs forums, part of the PostgreSQL category; --> The following bug has been logged online: Bug reference: 2889 Logged by: David Email address: higgsd@gmail.com PostgreSQL version: 8.1.5 ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Bugs

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-10-2008, 11:31 AM
David
 
Posts: n/a
Default BUG #2889: Syntax error: WHERE ANY(arrayfield) = N


The following bug has been logged online:

Bug reference: 2889
Logged by: David
Email address: higgsd@gmail.com
PostgreSQL version: 8.1.5
Operating system: OpenBSD 3.9
Description: Syntax error: WHERE ANY(arrayfield) = N
Details:

In reference to the array documentation at:
http://www.postgresql.org/docs/8.1/s...s.html#AEN5698

This statement works:
=> SELECT * FROM sal_emp WHERE 10000 = ANY (pay_by_quarter);

But this does not:
=> SELECT * FROM sal_emp WHERE ANY (pay_by_quarter) = 10000;
ERROR: syntax error at or near "ANY" at character ...

The ANY operator has the same problem, others may as well.

While trivial to work around, it is certainly annoying and I can't think of
a good reason why it shouldn't work either way.

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-10-2008, 11:31 AM
Tom Lane
 
Posts: n/a
Default Re: BUG #2889: Syntax error: WHERE ANY(arrayfield) = N

"David" <higgsd@gmail.com> writes:
> This statement works:
> => SELECT * FROM sal_emp WHERE 10000 = ANY (pay_by_quarter);


> But this does not:
> => SELECT * FROM sal_emp WHERE ANY (pay_by_quarter) = 10000;
> ERROR: syntax error at or near "ANY" at character ...


This is not a bug, it's the way the syntax works per SQL spec.
ANY must immediately follow the operator it relates to. See
<quantified comparison predicate> syntax in the spec.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-10-2008, 11:31 AM
David Higgs
 
Posts: n/a
Default Re: BUG #2889: Syntax error: WHERE ANY(arrayfield) = N

On 1/13/07, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> "David" <higgsd@gmail.com> writes:
> > This statement works:
> > => SELECT * FROM sal_emp WHERE 10000 = ANY (pay_by_quarter);

>
> > But this does not:
> > => SELECT * FROM sal_emp WHERE ANY (pay_by_quarter) = 10000;
> > ERROR: syntax error at or near "ANY" at character ...

>
> This is not a bug, it's the way the syntax works per SQL spec.
> ANY must immediately follow the operator it relates to. See
> <quantified comparison predicate> syntax in the spec.
>
> regards, tom lane
>


Aha, I see it in the docs now, although it's still rather unintuitive.
Could the appropriate section on arrays be crosslinked to the ANY/ALL
page, to preempt this question in the future?

Thanks.

--david

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-10-2008, 11:32 AM
Bruce Momjian
 
Posts: n/a
Default Re: BUG #2889: Syntax error: WHERE ANY(arrayfield) = N

David Higgs wrote:
> On 1/13/07, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> > "David" <higgsd@gmail.com> writes:
> > > This statement works:
> > > => SELECT * FROM sal_emp WHERE 10000 = ANY (pay_by_quarter);

> >
> > > But this does not:
> > > => SELECT * FROM sal_emp WHERE ANY (pay_by_quarter) = 10000;
> > > ERROR: syntax error at or near "ANY" at character ...

> >
> > This is not a bug, it's the way the syntax works per SQL spec.
> > ANY must immediately follow the operator it relates to. See
> > <quantified comparison predicate> syntax in the spec.
> >
> > regards, tom lane
> >

>
> Aha, I see it in the docs now, although it's still rather unintuitive.
> Could the appropriate section on arrays be crosslinked to the ANY/ALL
> page, to preempt this question in the future?


I researched this and found this line right above the example you quoted
above:

An alternative method is described in Section 9.17. The above query
could be replaced by:

SELECT * FROM sal_emp WHERE 10000 = ANY (pay_by_quarter);

and section 9.17 is 9.17. Row and Array Comparisons. Not sure we can do
any better than that.

--
Bruce Momjian bruce@momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:01 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com