mirror of
https://github.com/postgres/postgres.git
synced 2025-05-09 18:21:05 +03:00
Gram.y cleanup.
This commit is contained in:
parent
b37bc65f44
commit
53622d66d2
@ -10,7 +10,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.92 1998/01/17 04:53:16 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.93 1998/01/17 05:01:34 momjian Exp $
|
||||||
*
|
*
|
||||||
* HISTORY
|
* HISTORY
|
||||||
* AUTHOR DATE MAJOR EVENT
|
* AUTHOR DATE MAJOR EVENT
|
||||||
@ -63,6 +63,7 @@ extern List *parsetree;
|
|||||||
|
|
||||||
static char *xlateSqlType(char *);
|
static char *xlateSqlType(char *);
|
||||||
static Node *makeA_Expr(int oper, char *opname, Node *lexpr, Node *rexpr);
|
static Node *makeA_Expr(int oper, char *opname, Node *lexpr, Node *rexpr);
|
||||||
|
static Node *makeRowExpr(char *opr, List *largs, List *rargs);
|
||||||
void mapTargetColumns(List *source, List *target);
|
void mapTargetColumns(List *source, List *target);
|
||||||
static List *makeConstantList( A_Const *node);
|
static List *makeConstantList( A_Const *node);
|
||||||
static char *FlattenStringList(List *list);
|
static char *FlattenStringList(List *list);
|
||||||
@ -2882,7 +2883,6 @@ row_expr: '(' row_descriptor ')' IN '(' SubSelect ')'
|
|||||||
n->subselect = $7;
|
n->subselect = $7;
|
||||||
$$ = (Node *)n;
|
$$ = (Node *)n;
|
||||||
}
|
}
|
||||||
/* We accept all Operators? */
|
|
||||||
| '(' row_descriptor ')' Op '(' SubSelect ')'
|
| '(' row_descriptor ')' Op '(' SubSelect ')'
|
||||||
{
|
{
|
||||||
SubLink *n = makeNode(SubLink);
|
SubLink *n = makeNode(SubLink);
|
||||||
@ -2892,17 +2892,10 @@ row_expr: '(' row_descriptor ')' IN '(' SubSelect ')'
|
|||||||
n->subselect = $6;
|
n->subselect = $6;
|
||||||
$$ = (Node *)n;
|
$$ = (Node *)n;
|
||||||
}
|
}
|
||||||
/* Do we need this?
|
|
||||||
| '(' row_descriptor ')' Op '(' row_descriptor ')'
|
| '(' row_descriptor ')' Op '(' row_descriptor ')'
|
||||||
{
|
{
|
||||||
SubLink *n = makeNode(SubLink);
|
$$ = makeRowExpr($4, $2, $6);
|
||||||
n->lefthand = $2;
|
|
||||||
n->subLinkType = OPER_SUBLINK;
|
|
||||||
n->oper = lcons($4, NIL);
|
|
||||||
n->subselect = $6;
|
|
||||||
$$ = (Node *)n;
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
;
|
;
|
||||||
|
|
||||||
row_descriptor: row_list ',' a_expr
|
row_descriptor: row_list ',' a_expr
|
||||||
@ -3841,6 +3834,68 @@ makeA_Expr(int oper, char *opname, Node *lexpr, Node *rexpr)
|
|||||||
return (Node *)a;
|
return (Node *)a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* makeRowExpr()
|
||||||
|
* Generate separate operator nodes for a single row descriptor expression.
|
||||||
|
* Perhaps this should go deeper in the parser someday... - thomas 1997-12-22
|
||||||
|
*/
|
||||||
|
static Node *
|
||||||
|
makeRowExpr(char *opr, List *largs, List *rargs)
|
||||||
|
{
|
||||||
|
Node *expr = NULL;
|
||||||
|
Node *larg, *rarg;
|
||||||
|
|
||||||
|
if (length(largs) != length(rargs))
|
||||||
|
elog(ERROR,"Unequal number of entries in row expression");
|
||||||
|
|
||||||
|
if (lnext(largs) != NIL)
|
||||||
|
expr = makeRowExpr(opr,lnext(largs),lnext(rargs));
|
||||||
|
|
||||||
|
larg = lfirst(largs);
|
||||||
|
rarg = lfirst(rargs);
|
||||||
|
|
||||||
|
if ((strcmp(opr, "=") == 0)
|
||||||
|
|| (strcmp(opr, "<") == 0)
|
||||||
|
|| (strcmp(opr, "<=") == 0)
|
||||||
|
|| (strcmp(opr, ">") == 0)
|
||||||
|
|| (strcmp(opr, ">=") == 0))
|
||||||
|
{
|
||||||
|
if (expr == NULL)
|
||||||
|
expr = makeA_Expr(OP, opr, larg, rarg);
|
||||||
|
else
|
||||||
|
expr = makeA_Expr(AND, NULL, expr, makeA_Expr(OP, opr, larg, rarg));
|
||||||
|
}
|
||||||
|
else if (strcmp(opr, "<>") == 0)
|
||||||
|
{
|
||||||
|
if (expr == NULL)
|
||||||
|
expr = makeA_Expr(OP, opr, larg, rarg);
|
||||||
|
else
|
||||||
|
expr = makeA_Expr(OR, NULL, expr, makeA_Expr(OP, opr, larg, rarg));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
elog(ERROR,"Operator '%s' not implemented for row expressions",opr);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if FALSE
|
||||||
|
while ((largs != NIL) && (rargs != NIL))
|
||||||
|
{
|
||||||
|
larg = lfirst(largs);
|
||||||
|
rarg = lfirst(rargs);
|
||||||
|
|
||||||
|
if (expr == NULL)
|
||||||
|
expr = makeA_Expr(OP, opr, larg, rarg);
|
||||||
|
else
|
||||||
|
expr = makeA_Expr(AND, NULL, expr, makeA_Expr(OP, opr, larg, rarg));
|
||||||
|
|
||||||
|
largs = lnext(largs);
|
||||||
|
rargs = lnext(rargs);
|
||||||
|
}
|
||||||
|
pprint(expr);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return expr;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
mapTargetColumns(List *src, List *dst)
|
mapTargetColumns(List *src, List *dst)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user