diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2003-01-13 00:18:51 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2003-01-13 00:18:51 +0000 |
commit | d1686b42ab58ce29777557f52b941fa9b927b2a6 (patch) | |
tree | 9158be781a3e068014095905264cec83544711c2 /src/backend/parser/parse_expr.c | |
parent | d4ce5a4f4c3516e88fa34c53bcc7313db90a3c08 (diff) | |
download | postgresql-d1686b42ab58ce29777557f52b941fa9b927b2a6.tar.gz postgresql-d1686b42ab58ce29777557f52b941fa9b927b2a6.zip |
Recent changes in sublink representation require exprType() to accept
SubPlan nodes, else explaining queries containing sublinks may fail.
Diffstat (limited to 'src/backend/parser/parse_expr.c')
-rw-r--r-- | src/backend/parser/parse_expr.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/backend/parser/parse_expr.c b/src/backend/parser/parse_expr.c index adf45bbeef5..5ee64cf38ee 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.140 2003/01/10 21:08:15 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.141 2003/01/13 00:18:51 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -20,6 +20,7 @@ #include "miscadmin.h" #include "nodes/makefuncs.h" #include "nodes/params.h" +#include "nodes/plannodes.h" #include "parser/analyze.h" #include "parser/gramparse.h" #include "parser/parse.h" @@ -962,6 +963,7 @@ exprType(Node *expr) elog(ERROR, "exprType: Cannot get type for untransformed sublink"); tent = (TargetEntry *) lfirst(qtree->targetList); Assert(IsA(tent, TargetEntry)); + Assert(!tent->resdom->resjunk); type = tent->resdom->restype; } else @@ -971,6 +973,32 @@ exprType(Node *expr) } } break; + case T_SubPlan: + { + /* + * Although the parser does not ever deal with already-planned + * expression trees, we support SubPlan nodes in this routine + * for the convenience of ruleutils.c. + */ + SubPlan *subplan = (SubPlan *) expr; + + if (subplan->subLinkType == EXPR_SUBLINK) + { + /* get the type of the subselect's first target column */ + TargetEntry *tent; + + tent = (TargetEntry *) lfirst(subplan->plan->targetlist); + Assert(IsA(tent, TargetEntry)); + Assert(!tent->resdom->resjunk); + type = tent->resdom->restype; + } + else + { + /* for all other subplan types, result is boolean */ + type = BOOLOID; + } + } + break; case T_FieldSelect: type = ((FieldSelect *) expr)->resulttype; break; |