mirror of
https://github.com/postgres/postgres.git
synced 2025-07-31 22:04:40 +03:00
gram.y: ALL_SUBLINK type was returned for x Op (subquery).
parse_expr.c: only Op of bool type are supported currently...
This commit is contained in:
@ -10,7 +10,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.1 1998/02/11 04:11:19 thomas Exp $
|
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.2 1998/02/13 08:10:30 vadim Exp $
|
||||||
*
|
*
|
||||||
* HISTORY
|
* HISTORY
|
||||||
* AUTHOR DATE MAJOR EVENT
|
* AUTHOR DATE MAJOR EVENT
|
||||||
@ -2955,6 +2955,89 @@ row_expr: '(' row_descriptor ')' IN '(' SubSelect ')'
|
|||||||
n->subselect = $7;
|
n->subselect = $7;
|
||||||
$$ = (Node *)n;
|
$$ = (Node *)n;
|
||||||
}
|
}
|
||||||
|
| '(' row_descriptor ')' Op '(' SubSelect ')'
|
||||||
|
{
|
||||||
|
SubLink *n = makeNode(SubLink);
|
||||||
|
n->lefthand = $2;
|
||||||
|
n->oper = lcons($4, NIL);
|
||||||
|
if (strcmp($4,"<>") == 0)
|
||||||
|
n->useor = true;
|
||||||
|
else
|
||||||
|
n->useor = false;
|
||||||
|
n->subLinkType = EXPR_SUBLINK;
|
||||||
|
n->subselect = $6;
|
||||||
|
$$ = (Node *)n;
|
||||||
|
}
|
||||||
|
| '(' row_descriptor ')' '+' '(' SubSelect ')'
|
||||||
|
{
|
||||||
|
SubLink *n = makeNode(SubLink);
|
||||||
|
n->lefthand = $2;
|
||||||
|
n->oper = lcons("+", NIL);
|
||||||
|
n->useor = false;
|
||||||
|
n->subLinkType = EXPR_SUBLINK;
|
||||||
|
n->subselect = $6;
|
||||||
|
$$ = (Node *)n;
|
||||||
|
}
|
||||||
|
| '(' row_descriptor ')' '-' '(' SubSelect ')'
|
||||||
|
{
|
||||||
|
SubLink *n = makeNode(SubLink);
|
||||||
|
n->lefthand = $2;
|
||||||
|
n->oper = lcons("-", NIL);
|
||||||
|
n->useor = false;
|
||||||
|
n->subLinkType = EXPR_SUBLINK;
|
||||||
|
n->subselect = $6;
|
||||||
|
$$ = (Node *)n;
|
||||||
|
}
|
||||||
|
| '(' row_descriptor ')' '/' '(' SubSelect ')'
|
||||||
|
{
|
||||||
|
SubLink *n = makeNode(SubLink);
|
||||||
|
n->lefthand = $2;
|
||||||
|
n->oper = lcons("/", NIL);
|
||||||
|
n->useor = false;
|
||||||
|
n->subLinkType = EXPR_SUBLINK;
|
||||||
|
n->subselect = $6;
|
||||||
|
$$ = (Node *)n;
|
||||||
|
}
|
||||||
|
| '(' row_descriptor ')' '*' '(' SubSelect ')'
|
||||||
|
{
|
||||||
|
SubLink *n = makeNode(SubLink);
|
||||||
|
n->lefthand = $2;
|
||||||
|
n->oper = lcons("*", NIL);
|
||||||
|
n->useor = false;
|
||||||
|
n->subLinkType = EXPR_SUBLINK;
|
||||||
|
n->subselect = $6;
|
||||||
|
$$ = (Node *)n;
|
||||||
|
}
|
||||||
|
| '(' row_descriptor ')' '<' '(' SubSelect ')'
|
||||||
|
{
|
||||||
|
SubLink *n = makeNode(SubLink);
|
||||||
|
n->lefthand = $2;
|
||||||
|
n->oper = lcons("<", NIL);
|
||||||
|
n->useor = false;
|
||||||
|
n->subLinkType = EXPR_SUBLINK;
|
||||||
|
n->subselect = $6;
|
||||||
|
$$ = (Node *)n;
|
||||||
|
}
|
||||||
|
| '(' row_descriptor ')' '>' '(' SubSelect ')'
|
||||||
|
{
|
||||||
|
SubLink *n = makeNode(SubLink);
|
||||||
|
n->lefthand = $2;
|
||||||
|
n->oper = lcons(">", NIL);
|
||||||
|
n->useor = false;
|
||||||
|
n->subLinkType = EXPR_SUBLINK;
|
||||||
|
n->subselect = $6;
|
||||||
|
$$ = (Node *)n;
|
||||||
|
}
|
||||||
|
| '(' row_descriptor ')' '=' '(' SubSelect ')'
|
||||||
|
{
|
||||||
|
SubLink *n = makeNode(SubLink);
|
||||||
|
n->lefthand = $2;
|
||||||
|
n->oper = lcons("=", NIL);
|
||||||
|
n->useor = false;
|
||||||
|
n->subLinkType = EXPR_SUBLINK;
|
||||||
|
n->subselect = $6;
|
||||||
|
$$ = (Node *)n;
|
||||||
|
}
|
||||||
| '(' row_descriptor ')' Op ANY '(' SubSelect ')'
|
| '(' row_descriptor ')' Op ANY '(' SubSelect ')'
|
||||||
{
|
{
|
||||||
SubLink *n = makeNode(SubLink);
|
SubLink *n = makeNode(SubLink);
|
||||||
@ -3115,89 +3198,6 @@ row_expr: '(' row_descriptor ')' IN '(' SubSelect ')'
|
|||||||
n->subselect = $7;
|
n->subselect = $7;
|
||||||
$$ = (Node *)n;
|
$$ = (Node *)n;
|
||||||
}
|
}
|
||||||
| '(' row_descriptor ')' Op '(' SubSelect ')'
|
|
||||||
{
|
|
||||||
SubLink *n = makeNode(SubLink);
|
|
||||||
n->lefthand = $2;
|
|
||||||
n->oper = lcons($4, NIL);
|
|
||||||
if (strcmp($4,"<>") == 0)
|
|
||||||
n->useor = true;
|
|
||||||
else
|
|
||||||
n->useor = false;
|
|
||||||
n->subLinkType = EXPR_SUBLINK;
|
|
||||||
n->subselect = $6;
|
|
||||||
$$ = (Node *)n;
|
|
||||||
}
|
|
||||||
| '(' row_descriptor ')' '+' '(' SubSelect ')'
|
|
||||||
{
|
|
||||||
SubLink *n = makeNode(SubLink);
|
|
||||||
n->lefthand = $2;
|
|
||||||
n->oper = lcons("+", NIL);
|
|
||||||
n->useor = false;
|
|
||||||
n->subLinkType = EXPR_SUBLINK;
|
|
||||||
n->subselect = $6;
|
|
||||||
$$ = (Node *)n;
|
|
||||||
}
|
|
||||||
| '(' row_descriptor ')' '-' '(' SubSelect ')'
|
|
||||||
{
|
|
||||||
SubLink *n = makeNode(SubLink);
|
|
||||||
n->lefthand = $2;
|
|
||||||
n->oper = lcons("-", NIL);
|
|
||||||
n->useor = false;
|
|
||||||
n->subLinkType = EXPR_SUBLINK;
|
|
||||||
n->subselect = $6;
|
|
||||||
$$ = (Node *)n;
|
|
||||||
}
|
|
||||||
| '(' row_descriptor ')' '/' '(' SubSelect ')'
|
|
||||||
{
|
|
||||||
SubLink *n = makeNode(SubLink);
|
|
||||||
n->lefthand = $2;
|
|
||||||
n->oper = lcons("/", NIL);
|
|
||||||
n->useor = false;
|
|
||||||
n->subLinkType = EXPR_SUBLINK;
|
|
||||||
n->subselect = $6;
|
|
||||||
$$ = (Node *)n;
|
|
||||||
}
|
|
||||||
| '(' row_descriptor ')' '*' '(' SubSelect ')'
|
|
||||||
{
|
|
||||||
SubLink *n = makeNode(SubLink);
|
|
||||||
n->lefthand = $2;
|
|
||||||
n->oper = lcons("*", NIL);
|
|
||||||
n->useor = false;
|
|
||||||
n->subLinkType = EXPR_SUBLINK;
|
|
||||||
n->subselect = $6;
|
|
||||||
$$ = (Node *)n;
|
|
||||||
}
|
|
||||||
| '(' row_descriptor ')' '<' '(' SubSelect ')'
|
|
||||||
{
|
|
||||||
SubLink *n = makeNode(SubLink);
|
|
||||||
n->lefthand = $2;
|
|
||||||
n->oper = lcons("<", NIL);
|
|
||||||
n->useor = false;
|
|
||||||
n->subLinkType = EXPR_SUBLINK;
|
|
||||||
n->subselect = $6;
|
|
||||||
$$ = (Node *)n;
|
|
||||||
}
|
|
||||||
| '(' row_descriptor ')' '>' '(' SubSelect ')'
|
|
||||||
{
|
|
||||||
SubLink *n = makeNode(SubLink);
|
|
||||||
n->lefthand = $2;
|
|
||||||
n->oper = lcons(">", NIL);
|
|
||||||
n->useor = false;
|
|
||||||
n->subLinkType = EXPR_SUBLINK;
|
|
||||||
n->subselect = $6;
|
|
||||||
$$ = (Node *)n;
|
|
||||||
}
|
|
||||||
| '(' row_descriptor ')' '=' '(' SubSelect ')'
|
|
||||||
{
|
|
||||||
SubLink *n = makeNode(SubLink);
|
|
||||||
n->lefthand = $2;
|
|
||||||
n->oper = lcons("=", NIL);
|
|
||||||
n->useor = false;
|
|
||||||
n->subLinkType = EXPR_SUBLINK;
|
|
||||||
n->subselect = $6;
|
|
||||||
$$ = (Node *)n;
|
|
||||||
}
|
|
||||||
| '(' row_descriptor ')' Op '(' row_descriptor ')'
|
| '(' row_descriptor ')' Op '(' row_descriptor ')'
|
||||||
{
|
{
|
||||||
$$ = makeRowExpr($4, $2, $6);
|
$$ = makeRowExpr($4, $2, $6);
|
||||||
@ -3614,6 +3614,86 @@ a_expr: attr opt_indirection
|
|||||||
}
|
}
|
||||||
else $$ = $6;
|
else $$ = $6;
|
||||||
}
|
}
|
||||||
|
| a_expr Op '(' SubSelect ')'
|
||||||
|
{
|
||||||
|
SubLink *n = makeNode(SubLink);
|
||||||
|
n->lefthand = lcons($1, NULL);
|
||||||
|
n->oper = lcons($2,NIL);
|
||||||
|
n->useor = false;
|
||||||
|
n->subLinkType = EXPR_SUBLINK;
|
||||||
|
n->subselect = $4;
|
||||||
|
$$ = (Node *)n;
|
||||||
|
}
|
||||||
|
| a_expr '+' '(' SubSelect ')'
|
||||||
|
{
|
||||||
|
SubLink *n = makeNode(SubLink);
|
||||||
|
n->lefthand = lcons($1, NULL);
|
||||||
|
n->oper = lcons("+",NIL);
|
||||||
|
n->useor = false;
|
||||||
|
n->subLinkType = EXPR_SUBLINK;
|
||||||
|
n->subselect = $4;
|
||||||
|
$$ = (Node *)n;
|
||||||
|
}
|
||||||
|
| a_expr '-' '(' SubSelect ')'
|
||||||
|
{
|
||||||
|
SubLink *n = makeNode(SubLink);
|
||||||
|
n->lefthand = lcons($1, NULL);
|
||||||
|
n->oper = lcons("-",NIL);
|
||||||
|
n->useor = false;
|
||||||
|
n->subLinkType = EXPR_SUBLINK;
|
||||||
|
n->subselect = $4;
|
||||||
|
$$ = (Node *)n;
|
||||||
|
}
|
||||||
|
| a_expr '/' '(' SubSelect ')'
|
||||||
|
{
|
||||||
|
SubLink *n = makeNode(SubLink);
|
||||||
|
n->lefthand = lcons($1, NULL);
|
||||||
|
n->oper = lcons("/",NIL);
|
||||||
|
n->useor = false;
|
||||||
|
n->subLinkType = EXPR_SUBLINK;
|
||||||
|
n->subselect = $4;
|
||||||
|
$$ = (Node *)n;
|
||||||
|
}
|
||||||
|
| a_expr '*' '(' SubSelect ')'
|
||||||
|
{
|
||||||
|
SubLink *n = makeNode(SubLink);
|
||||||
|
n->lefthand = lcons($1, NULL);
|
||||||
|
n->oper = lcons("*",NIL);
|
||||||
|
n->useor = false;
|
||||||
|
n->subLinkType = EXPR_SUBLINK;
|
||||||
|
n->subselect = $4;
|
||||||
|
$$ = (Node *)n;
|
||||||
|
}
|
||||||
|
| a_expr '<' '(' SubSelect ')'
|
||||||
|
{
|
||||||
|
SubLink *n = makeNode(SubLink);
|
||||||
|
n->lefthand = lcons($1, NULL);
|
||||||
|
n->oper = lcons("<",NIL);
|
||||||
|
n->useor = false;
|
||||||
|
n->subLinkType = EXPR_SUBLINK;
|
||||||
|
n->subselect = $4;
|
||||||
|
$$ = (Node *)n;
|
||||||
|
}
|
||||||
|
| a_expr '>' '(' SubSelect ')'
|
||||||
|
{
|
||||||
|
SubLink *n = makeNode(SubLink);
|
||||||
|
n->lefthand = lcons($1, NULL);
|
||||||
|
n->oper = lcons(">",NIL);
|
||||||
|
n->useor = false;
|
||||||
|
n->subLinkType = EXPR_SUBLINK;
|
||||||
|
n->subselect = $4;
|
||||||
|
$$ = (Node *)n;
|
||||||
|
}
|
||||||
|
| a_expr '=' '(' SubSelect ')'
|
||||||
|
{
|
||||||
|
SubLink *n = makeNode(SubLink);
|
||||||
|
n->lefthand = lcons($1, NULL);
|
||||||
|
n->oper = lcons("=",NIL);
|
||||||
|
n->useor = false;
|
||||||
|
n->subLinkType = EXPR_SUBLINK;
|
||||||
|
n->subselect = $4;
|
||||||
|
$$ = (Node *)n;
|
||||||
|
}
|
||||||
| a_expr Op ANY '(' SubSelect ')'
|
| a_expr Op ANY '(' SubSelect ')'
|
||||||
{
|
{
|
||||||
SubLink *n = makeNode(SubLink);
|
SubLink *n = makeNode(SubLink);
|
||||||
@ -3774,86 +3854,6 @@ a_expr: attr opt_indirection
|
|||||||
n->subselect = $5;
|
n->subselect = $5;
|
||||||
$$ = (Node *)n;
|
$$ = (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 '+' '(' SubSelect ')'
|
|
||||||
{
|
|
||||||
SubLink *n = makeNode(SubLink);
|
|
||||||
n->lefthand = lcons($1, NULL);
|
|
||||||
n->oper = lcons("+",NIL);
|
|
||||||
n->useor = false;
|
|
||||||
n->subLinkType = ALL_SUBLINK;
|
|
||||||
n->subselect = $4;
|
|
||||||
$$ = (Node *)n;
|
|
||||||
}
|
|
||||||
| a_expr '-' '(' SubSelect ')'
|
|
||||||
{
|
|
||||||
SubLink *n = makeNode(SubLink);
|
|
||||||
n->lefthand = lcons($1, NULL);
|
|
||||||
n->oper = lcons("-",NIL);
|
|
||||||
n->useor = false;
|
|
||||||
n->subLinkType = ALL_SUBLINK;
|
|
||||||
n->subselect = $4;
|
|
||||||
$$ = (Node *)n;
|
|
||||||
}
|
|
||||||
| a_expr '/' '(' SubSelect ')'
|
|
||||||
{
|
|
||||||
SubLink *n = makeNode(SubLink);
|
|
||||||
n->lefthand = lcons($1, NULL);
|
|
||||||
n->oper = lcons("/",NIL);
|
|
||||||
n->useor = false;
|
|
||||||
n->subLinkType = ALL_SUBLINK;
|
|
||||||
n->subselect = $4;
|
|
||||||
$$ = (Node *)n;
|
|
||||||
}
|
|
||||||
| a_expr '*' '(' SubSelect ')'
|
|
||||||
{
|
|
||||||
SubLink *n = makeNode(SubLink);
|
|
||||||
n->lefthand = lcons($1, NULL);
|
|
||||||
n->oper = lcons("*",NIL);
|
|
||||||
n->useor = false;
|
|
||||||
n->subLinkType = ALL_SUBLINK;
|
|
||||||
n->subselect = $4;
|
|
||||||
$$ = (Node *)n;
|
|
||||||
}
|
|
||||||
| a_expr '<' '(' SubSelect ')'
|
|
||||||
{
|
|
||||||
SubLink *n = makeNode(SubLink);
|
|
||||||
n->lefthand = lcons($1, NULL);
|
|
||||||
n->oper = lcons("<",NIL);
|
|
||||||
n->useor = false;
|
|
||||||
n->subLinkType = ALL_SUBLINK;
|
|
||||||
n->subselect = $4;
|
|
||||||
$$ = (Node *)n;
|
|
||||||
}
|
|
||||||
| a_expr '>' '(' SubSelect ')'
|
|
||||||
{
|
|
||||||
SubLink *n = makeNode(SubLink);
|
|
||||||
n->lefthand = lcons($1, NULL);
|
|
||||||
n->oper = lcons(">",NIL);
|
|
||||||
n->useor = false;
|
|
||||||
n->subLinkType = ALL_SUBLINK;
|
|
||||||
n->subselect = $4;
|
|
||||||
$$ = (Node *)n;
|
|
||||||
}
|
|
||||||
| a_expr '=' '(' SubSelect ')'
|
|
||||||
{
|
|
||||||
SubLink *n = makeNode(SubLink);
|
|
||||||
n->lefthand = lcons($1, NULL);
|
|
||||||
n->oper = lcons("=",NIL);
|
|
||||||
n->useor = false;
|
|
||||||
n->subLinkType = ALL_SUBLINK;
|
|
||||||
n->subselect = $4;
|
|
||||||
$$ = (Node *)n;
|
|
||||||
}
|
|
||||||
| a_expr AND a_expr
|
| a_expr AND a_expr
|
||||||
{ $$ = makeA_Expr(AND, NULL, $1, $3); }
|
{ $$ = makeA_Expr(AND, NULL, $1, $3); }
|
||||||
| a_expr OR a_expr
|
| a_expr OR a_expr
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.20 1998/02/13 03:41:23 vadim Exp $
|
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.21 1998/02/13 08:10:33 vadim Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -264,7 +264,7 @@ transformExpr(ParseState *pstate, Node *expr, int precedence)
|
|||||||
|
|
||||||
if (length(left_expr) !=
|
if (length(left_expr) !=
|
||||||
length(right_expr))
|
length(right_expr))
|
||||||
elog(ERROR,"Subselect has too many or too few fields.");
|
elog(ERROR,"parser: Subselect has too many or too few fields.");
|
||||||
|
|
||||||
sublink->oper = NIL;
|
sublink->oper = NIL;
|
||||||
foreach(elist, left_expr)
|
foreach(elist, left_expr)
|
||||||
@ -275,6 +275,17 @@ transformExpr(ParseState *pstate, Node *expr, int precedence)
|
|||||||
Expr *op_expr;
|
Expr *op_expr;
|
||||||
|
|
||||||
op_expr = make_op(op, lexpr, tent->expr);
|
op_expr = make_op(op, lexpr, tent->expr);
|
||||||
|
/*
|
||||||
|
* HACK! Second IF is more valid but currently
|
||||||
|
* we don't support EXPR subqueries inside
|
||||||
|
* expressions generally, only in WHERE clauses.
|
||||||
|
* After fixing this, first IF must be removed.
|
||||||
|
*/
|
||||||
|
if (op_expr->typeOid != BOOLOID)
|
||||||
|
elog (ERROR, "parser: '%s' must return 'bool' to be used with subquery", op);
|
||||||
|
if (op_expr->typeOid != BOOLOID &&
|
||||||
|
sublink->subLinkType != EXPR_SUBLINK)
|
||||||
|
elog (ERROR, "parser: '%s' must return 'bool' to be used with quantified predicate subquery", op);
|
||||||
sublink->oper = lappend(sublink->oper, op_expr);
|
sublink->oper = lappend(sublink->oper, op_expr);
|
||||||
right_expr = lnext(right_expr);
|
right_expr = lnext(right_expr);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user