Skip to content

Commit d1686b4

Browse files
committed
Recent changes in sublink representation require exprType() to accept
SubPlan nodes, else explaining queries containing sublinks may fail.
1 parent d4ce5a4 commit d1686b4

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

src/backend/parser/parse_expr.c

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
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
*/
@@ -20,6 +20,7 @@
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)
962963
elog(ERROR, "exprType: Cannot get type for untransformed sublink");
963964
tent = (TargetEntry *) lfirst(qtree->targetList);
964965
Assert(IsA(tent, TargetEntry));
966+
Assert(!tent->resdom->resjunk);
965967
type = tent->resdom->restype;
966968
}
967969
else
@@ -971,6 +973,32 @@ exprType(Node *expr)
971973
}
972974
}
973975
break;
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;
9741002
case T_FieldSelect:
9751003
type = ((FieldSelect *) expr)->resulttype;
9761004
break;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy