|
7 | 7 | *
|
8 | 8 | *
|
9 | 9 | * IDENTIFICATION
|
10 |
| - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.52 1999/09/26 02:28:33 tgl Exp $ |
| 10 | + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.53 1999/10/02 04:37:52 tgl Exp $ |
11 | 11 | *
|
12 | 12 | * HISTORY
|
13 | 13 | * AUTHOR DATE MAJOR EVENT
|
@@ -49,27 +49,29 @@ static Node *eval_const_expressions_mutator (Node *node, void *context);
|
49 | 49 | Expr *
|
50 | 50 | make_clause(int type, Node *oper, List *args)
|
51 | 51 | {
|
52 |
| - if (type == AND_EXPR || type == OR_EXPR || type == NOT_EXPR || |
53 |
| - type == OP_EXPR || type == FUNC_EXPR) |
54 |
| - { |
55 |
| - Expr *expr = makeNode(Expr); |
| 52 | + Expr *expr = makeNode(Expr); |
56 | 53 |
|
57 |
| - /* |
58 |
| - * assume type checking already done and we don't need the type of |
59 |
| - * the expr any more. |
60 |
| - */ |
61 |
| - expr->typeOid = InvalidOid; |
62 |
| - expr->opType = type; |
63 |
| - expr->oper = oper; /* ignored for AND, OR, NOT */ |
64 |
| - expr->args = args; |
65 |
| - return expr; |
66 |
| - } |
67 |
| - else |
| 54 | + switch (type) |
68 | 55 | {
|
69 |
| - elog(ERROR, "make_clause: unsupported type %d", type); |
70 |
| - /* will this ever happen? translated from lispy C code - ay 10/94 */ |
71 |
| - return (Expr *) args; |
| 56 | + case AND_EXPR: |
| 57 | + case OR_EXPR: |
| 58 | + case NOT_EXPR: |
| 59 | + expr->typeOid = BOOLOID; |
| 60 | + break; |
| 61 | + case OP_EXPR: |
| 62 | + expr->typeOid = ((Oper *) oper)->opresulttype; |
| 63 | + break; |
| 64 | + case FUNC_EXPR: |
| 65 | + expr->typeOid = ((Func *) oper)->functype; |
| 66 | + break; |
| 67 | + default: |
| 68 | + elog(ERROR, "make_clause: unsupported type %d", type); |
| 69 | + break; |
72 | 70 | }
|
| 71 | + expr->opType = type; |
| 72 | + expr->oper = oper; /* ignored for AND, OR, NOT */ |
| 73 | + expr->args = args; |
| 74 | + return expr; |
73 | 75 | }
|
74 | 76 |
|
75 | 77 |
|
@@ -107,7 +109,7 @@ make_opclause(Oper *op, Var *leftop, Var *rightop)
|
107 | 109 | {
|
108 | 110 | Expr *expr = makeNode(Expr);
|
109 | 111 |
|
110 |
| - expr->typeOid = InvalidOid; /* assume type checking done */ |
| 112 | + expr->typeOid = op->opresulttype; |
111 | 113 | expr->opType = OP_EXPR;
|
112 | 114 | expr->oper = (Node *) op;
|
113 | 115 | if (rightop)
|
|
0 commit comments