88 *
99 *
1010 * IDENTIFICATION
11- * $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.140 2003/01/10 21:08:15 tgl Exp $
11+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.141 2003/01/13 00:18:51 tgl Exp $
1212 *
1313 *-------------------------------------------------------------------------
1414 */
2020#include "miscadmin.h"
2121#include "nodes/makefuncs.h"
2222#include "nodes/params.h"
23+ #include "nodes/plannodes.h"
2324#include "parser/analyze.h"
2425#include "parser/gramparse.h"
2526#include "parser/parse.h"
@@ -962,6 +963,7 @@ exprType(Node *expr)
962963elog (ERROR ,"exprType: Cannot get type for untransformed sublink" );
963964tent = (TargetEntry * )lfirst (qtree -> targetList );
964965Assert (IsA (tent ,TargetEntry ));
966+ Assert (!tent -> resdom -> resjunk );
965967type = tent -> resdom -> restype ;
966968}
967969else
@@ -971,6 +973,32 @@ exprType(Node *expr)
971973}
972974}
973975break ;
976+ case T_SubPlan :
977+ {
978+ /*
979+ * Although the parser does not ever deal with already-planned
980+ * expression trees, we support SubPlan nodes in this routine
981+ * for the convenience of ruleutils.c.
982+ */
983+ SubPlan * subplan = (SubPlan * )expr ;
984+
985+ if (subplan -> subLinkType == EXPR_SUBLINK )
986+ {
987+ /* get the type of the subselect's first target column */
988+ TargetEntry * tent ;
989+
990+ tent = (TargetEntry * )lfirst (subplan -> plan -> targetlist );
991+ Assert (IsA (tent ,TargetEntry ));
992+ Assert (!tent -> resdom -> resjunk );
993+ type = tent -> resdom -> restype ;
994+ }
995+ else
996+ {
997+ /* for all other subplan types, result is boolean */
998+ type = BOOLOID ;
999+ }
1000+ }
1001+ break ;
9741002case T_FieldSelect :
9751003type = ((FieldSelect * )expr )-> resulttype ;
9761004break ;