Lists: | pgsql-bugs |
---|
From: | "David" <higgsd(at)gmail(dot)com> |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Subject: | BUG #2889: Syntax error: WHERE ANY(arrayfield) = N |
Date: | 2007-01-13 05:49:28 |
Message-ID: | 200701130549.l0D5nSZl054595@wwwmaster.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-bugs |
The following bug has been logged online:
Bug reference: 2889
Logged by: David
Email address: higgsd(at)gmail(dot)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/static/arrays.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.
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "David" <higgsd(at)gmail(dot)com> |
Cc: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #2889: Syntax error: WHERE ANY(arrayfield) = N |
Date: | 2007-01-13 18:46:15 |
Message-ID: | 25968.1168713975@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-bugs |
"David" <higgsd(at)gmail(dot)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
From: | "David Higgs" <higgsd(at)gmail(dot)com> |
---|---|
To: | "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #2889: Syntax error: WHERE ANY(arrayfield) = N |
Date: | 2007-01-13 19:39:41 |
Message-ID: | ac8e3f230701131139p3997a2f7j53eba52b355382@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-bugs |
On 1/13/07, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> "David" <higgsd(at)gmail(dot)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
From: | Bruce Momjian <bruce(at)momjian(dot)us> |
---|---|
To: | David Higgs <higgsd(at)gmail(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #2889: Syntax error: WHERE ANY(arrayfield) = N |
Date: | 2007-01-20 02:14:17 |
Message-ID: | 200701200214.l0K2EHd22649@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-bugs |
David Higgs wrote:
> On 1/13/07, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> > "David" <higgsd(at)gmail(dot)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(at)momjian(dot)us
EnterpriseDB http://www.enterprisedb.com
+ If your life is a hard drive, Christ can be your backup. +