Re: [HACKERS] subquery syntax broken

Bruce Momjian <maillist@candle.pha.pa.us>

From: Bruce Momjian <maillist@candle.pha.pa.us>
To: vadim@sable.krasnoyarsk.su (Vadim B. Mikheev)
Cc: hackers@postgreSQL.org
Date: 1998-02-02T17:00:14Z
Lists: pgsql-hackers
> 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.

---------------------------------------------------------------------------

*** ./backend/parser/gram.y.orig	Mon Feb  2 11:51:05 1998
--- ./backend/parser/gram.y	Mon Feb  2 11:59:12 1998
***************
*** 3330,3335 ****
--- 3330,3345 ----
  					n->subselect = $5;
  					$$ = (Node *)n;
  				}
+ 		| 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;
+ 					n->subselect = $4;
+ 					$$ = (Node *)n;
+ 				}
  		| a_expr AND a_expr
  				{	$$ = makeA_Expr(AND, NULL, $1, $3); }
  		| a_expr OR a_expr

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