Re: [HACKERS] subquery syntax broken - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: [HACKERS] subquery syntax broken
Date
Msg-id 199802030317.WAA19375@candle.pha.pa.us
Whole thread Raw
In response to Re: [HACKERS] subquery syntax broken  ("Vadim B. Mikheev" <vadim@sable.krasnoyarsk.su>)
List pgsql-hackers
I believe it has to do with the fact that '=' has right precedence.
Thomas, can you comment.  Maybe we need to %right 'Op' at that point so
it doesn't shift too early?

>
> Bruce Momjian wrote:
> >
> > > vac=> select * from x where y = (select max(y) from x);
> > > ERROR:  parser: parse error at or near "select"
> > > vac=> select * from x where y <> (select max(y) from x);
> > > ERROR:  parser: parse error at or near "select"
> >
> > Sorry I missed that most obvious option.  Here is the patch.  I will
> > apply it today.
>
> It doesn't work for =, >, etc:
>
> vac=> select * from x where y = (select max(y) from x);
> ERROR:  parser: parse error at or near "select"
>
> but work for others:
>
> vac=> select * from x where y @ (select max(y) from x);
> ERROR:  There is no operator '@' for types 'int4' and 'int4'
>         You will either have to retype this query using an explicit cast,
>         or you will have to define the operator using CREATE OPERATOR
>
> Also:
>
> > +               | a_expr Op '(' SubSelect ')'
> > +                               {
> > +                                       SubLink *n = makeNode(SubLink);
> > +                                       n->lefthand = lcons($1, NULL);
> > +                                       n->oper = lcons($2,NIL);
> > +                                       n->useor = false;
> > +                                       n->subLinkType = ALL_SUBLINK;
>                                                            ^^^^^^^^^^^
>                    should be EXPR_SUBLINK
> > +                                       n->subselect = $4;
> > +                                       $$ = (Node *)n;
> > +                               }
>
> Vadim
>


--
Bruce Momjian
maillist@candle.pha.pa.us

pgsql-hackers by date:

Previous
From: "Vadim B. Mikheev"
Date:
Subject: Re: [HACKERS] subquery syntax broken
Next
From: "Vadim B. Mikheev"
Date:
Subject: vacuum analyze syntax in psql' help