aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser/parse_expr.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2003-01-10 21:08:15 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2003-01-10 21:08:15 +0000
commite69785debfcca308a5999946bbf4cfefd0ab5e3c (patch)
tree067093f426b8034288590a71f538650b3c53d485 /src/backend/parser/parse_expr.c
parent36ea26793a14d016059de2f1c83a05cf87a8bb92 (diff)
downloadpostgresql-e69785debfcca308a5999946bbf4cfefd0ab5e3c.tar.gz
postgresql-e69785debfcca308a5999946bbf4cfefd0ab5e3c.zip
Further tweaking of parsetree & plantree representation of SubLinks.
Simplify SubLink by storing just a List of operator OIDs, instead of a list of incomplete OpExprs --- that was a bizarre and bulky choice, with no redeeming social value since we have to build new OpExprs anyway when forming the plan tree.
Diffstat (limited to 'src/backend/parser/parse_expr.c')
-rw-r--r--src/backend/parser/parse_expr.c43
1 files changed, 14 insertions, 29 deletions
diff --git a/src/backend/parser/parse_expr.c b/src/backend/parser/parse_expr.c
index 3701f41dca0..adf45bbeef5 100644
--- a/src/backend/parser/parse_expr.c
+++ b/src/backend/parser/parse_expr.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.139 2003/01/09 20:50:52 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.140 2003/01/10 21:08:15 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -366,8 +366,8 @@ transformExpr(ParseState *pstate, Node *expr)
* These fields should be NIL already, but make sure.
*/
sublink->lefthand = NIL;
- sublink->oper = NIL;
- sublink->operIsEquals = FALSE;
+ sublink->operName = NIL;
+ sublink->operOids = NIL;
sublink->useOr = FALSE;
}
else if (sublink->subLinkType == EXPR_SUBLINK)
@@ -392,8 +392,8 @@ transformExpr(ParseState *pstate, Node *expr)
* fields should be NIL already, but make sure.
*/
sublink->lefthand = NIL;
- sublink->oper = NIL;
- sublink->operIsEquals = FALSE;
+ sublink->operName = NIL;
+ sublink->operOids = NIL;
sublink->useOr = FALSE;
}
else
@@ -403,20 +403,14 @@ transformExpr(ParseState *pstate, Node *expr)
List *right_list = qtree->targetList;
int row_length = length(left_list);
bool needNot = false;
- List *op;
- char *opname;
+ List *op = sublink->operName;
+ char *opname = strVal(llast(op));
List *elist;
/* transform lefthand expressions */
foreach(elist, left_list)
lfirst(elist) = transformExpr(pstate, lfirst(elist));
- /* get the combining-operator name */
- Assert(IsA(sublink->oper, A_Expr));
- op = ((A_Expr *) sublink->oper)->name;
- opname = strVal(llast(op));
- sublink->oper = NIL;
-
/*
* If the expression is "<> ALL" (with unqualified opname)
* then convert it to "NOT IN". This is a hack to improve
@@ -428,15 +422,10 @@ transformExpr(ParseState *pstate, Node *expr)
sublink->subLinkType = ANY_SUBLINK;
opname = pstrdup("=");
op = makeList1(makeString(opname));
+ sublink->operName = op;
needNot = true;
}
- /* Set operIsEquals if op is unqualified "=" */
- if (length(op) == 1 && strcmp(opname, "=") == 0)
- sublink->operIsEquals = TRUE;
- else
- sublink->operIsEquals = FALSE;
-
/* Set useOr if op is "<>" (possibly qualified) */
if (strcmp(opname, "<>") == 0)
sublink->useOr = TRUE;
@@ -451,19 +440,21 @@ transformExpr(ParseState *pstate, Node *expr)
opname);
/*
- * Scan subquery's targetlist to find values that will
+ * To build the list of combining operator OIDs, we must
+ * scan subquery's targetlist to find values that will
* be matched against lefthand values. We need to
* ignore resjunk targets, so doing the outer
* iteration over right_list is easier than doing it
* over left_list.
*/
+ sublink->operOids = NIL;
+
while (right_list != NIL)
{
TargetEntry *tent = (TargetEntry *) lfirst(right_list);
Node *lexpr;
Operator optup;
Form_pg_operator opform;
- OpExpr *newop;
right_list = lnext(right_list);
if (tent->resdom->resjunk)
@@ -496,14 +487,8 @@ transformExpr(ParseState *pstate, Node *expr)
" to be used with quantified predicate subquery",
opname);
- newop = makeNode(OpExpr);
- newop->opno = oprid(optup);
- newop->opfuncid = InvalidOid;
- newop->opresulttype = opform->oprresult;
- newop->opretset = false;
- newop->args = NIL; /* for now */
-
- sublink->oper = lappend(sublink->oper, newop);
+ sublink->operOids = lappendi(sublink->operOids,
+ oprid(optup));
ReleaseSysCache(optup);
}