Re: [HACKERS] subquery syntax broken

From: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
To: lockhart(at)alumni(dot)caltech(dot)edu (Thomas G(dot) Lockhart)
Cc: vadim(at)sable(dot)krasnoyarsk(dot)su, hackers(at)postgresql(dot)org
Subject: Re: [HACKERS] subquery syntax broken
Date: 1998-02-03 19:26:40
Message-ID: 199802031926.OAA21751@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Done. Patch applied. Makes the grammar bigger, though.

>
> > 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?
>
> No, the single-character operators each need their own code in the parser.
> Check near line 2980 in the parser for examples from the "a_expr" syntax. You
> just need to replicate the subselect "Op" definition blocks and substitute
> each of '=', '<', and '>' in the copies. The existing "Op" code handles the
> multi-character operators such as '<=' and '>='...
>
> - Tom
>
> > > 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(at)candle(dot)pha(dot)pa(dot)us
>
>
>
>

--
Bruce Momjian
maillist(at)candle(dot)pha(dot)pa(dot)us

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 1998-02-03 19:28:26 Re: [HACKERS] VACUUM ANALYZE Problem
Previous Message Bruce Momjian 1998-02-03 19:26:13 Re: [HACKERS] VACUUM ANALYZE Problem