|
8 | 8 | * |
9 | 9 | * |
10 | 10 | * IDENTIFICATION |
11 | | - * $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.39 2000/03/20 15:42:45 momjian Exp $ |
| 11 | + * $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.40 2000/03/23 07:36:03 tgl Exp $ |
12 | 12 | * |
13 | 13 | *------------------------------------------------------------------------- |
14 | 14 | */ |
@@ -38,8 +38,9 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId, |
38 | 38 | { |
39 | 39 | Node*result; |
40 | 40 |
|
41 | | -if (targetTypeId==InvalidOid|| |
42 | | -targetTypeId==inputTypeId) |
| 41 | +if (targetTypeId==inputTypeId|| |
| 42 | +targetTypeId==InvalidOid|| |
| 43 | +node==NULL) |
43 | 44 | { |
44 | 45 | /* no conversion needed */ |
45 | 46 | result=node; |
@@ -141,8 +142,13 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId, |
141 | 142 | * |
142 | 143 | * Note that no folding will occur if the conversion function is |
143 | 144 | * not marked 'iscachable'. |
| 145 | + * |
| 146 | + * HACK: if constant is NULL, don't fold it here. This is needed |
| 147 | + * by make_subplan(), which calls this routine on placeholder Const |
| 148 | + * nodes that mustn't be collapsed. (It'd be a lot cleaner to make |
| 149 | + * a separate node type for that purpose...) |
144 | 150 | */ |
145 | | -if (IsA(node,Const)) |
| 151 | +if (IsA(node,Const)&& ! ((Const*)node)->constisnull) |
146 | 152 | result=eval_const_expressions(result); |
147 | 153 | } |
148 | 154 |
|
@@ -614,7 +620,6 @@ PromoteLesserType(Oid inType1, Oid inType2, Oid *newType1, Oid *newType2) |
614 | 620 | { |
615 | 621 | case (BPCHAROID): |
616 | 622 | case (VARCHAROID): |
617 | | -case (BYTEA): |
618 | 623 | case (TEXTOID): |
619 | 624 |
|
620 | 625 | case (INT2OID): |
|