Skip to content

Commit fc43696

Browse files
committed
Fix make_clause and make_opclause to record valid type info
in the Expr nodes they produce. This fixes a few cases of errors like 'typeidTypeRelid: Invalid type - oid = 0' caused by calling parser-related routines on expression trees that have already been processed by planner- related routines.
1 parent cd243d2 commit fc43696

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

src/backend/optimizer/util/clauses.c

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* 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 $
1111
*
1212
* HISTORY
1313
* AUTHOR DATE MAJOR EVENT
@@ -49,27 +49,29 @@ static Node *eval_const_expressions_mutator (Node *node, void *context);
4949
Expr *
5050
make_clause(int type, Node *oper, List *args)
5151
{
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);
5653

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)
6855
{
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;
7270
}
71+
expr->opType = type;
72+
expr->oper = oper; /* ignored for AND, OR, NOT */
73+
expr->args = args;
74+
return expr;
7375
}
7476

7577

@@ -107,7 +109,7 @@ make_opclause(Oper *op, Var *leftop, Var *rightop)
107109
{
108110
Expr *expr = makeNode(Expr);
109111

110-
expr->typeOid = InvalidOid; /* assume type checking done */
112+
expr->typeOid = op->opresulttype;
111113
expr->opType = OP_EXPR;
112114
expr->oper = (Node *) op;
113115
if (rightop)

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