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.
This commit is contained in:
parent
cd243d27ce
commit
fc43696d1a
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.52 1999/09/26 02:28:33 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.53 1999/10/02 04:37:52 tgl Exp $
|
||||||
*
|
*
|
||||||
* HISTORY
|
* HISTORY
|
||||||
* AUTHOR DATE MAJOR EVENT
|
* AUTHOR DATE MAJOR EVENT
|
||||||
@ -48,29 +48,31 @@ static Node *eval_const_expressions_mutator (Node *node, void *context);
|
|||||||
|
|
||||||
Expr *
|
Expr *
|
||||||
make_clause(int type, Node *oper, List *args)
|
make_clause(int type, Node *oper, List *args)
|
||||||
{
|
|
||||||
if (type == AND_EXPR || type == OR_EXPR || type == NOT_EXPR ||
|
|
||||||
type == OP_EXPR || type == FUNC_EXPR)
|
|
||||||
{
|
{
|
||||||
Expr *expr = makeNode(Expr);
|
Expr *expr = makeNode(Expr);
|
||||||
|
|
||||||
/*
|
switch (type)
|
||||||
* assume type checking already done and we don't need the type of
|
{
|
||||||
* the expr any more.
|
case AND_EXPR:
|
||||||
*/
|
case OR_EXPR:
|
||||||
expr->typeOid = InvalidOid;
|
case NOT_EXPR:
|
||||||
|
expr->typeOid = BOOLOID;
|
||||||
|
break;
|
||||||
|
case OP_EXPR:
|
||||||
|
expr->typeOid = ((Oper *) oper)->opresulttype;
|
||||||
|
break;
|
||||||
|
case FUNC_EXPR:
|
||||||
|
expr->typeOid = ((Func *) oper)->functype;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
elog(ERROR, "make_clause: unsupported type %d", type);
|
||||||
|
break;
|
||||||
|
}
|
||||||
expr->opType = type;
|
expr->opType = type;
|
||||||
expr->oper = oper; /* ignored for AND, OR, NOT */
|
expr->oper = oper; /* ignored for AND, OR, NOT */
|
||||||
expr->args = args;
|
expr->args = args;
|
||||||
return expr;
|
return expr;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
elog(ERROR, "make_clause: unsupported type %d", type);
|
|
||||||
/* will this ever happen? translated from lispy C code - ay 10/94 */
|
|
||||||
return (Expr *) args;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
@ -107,7 +109,7 @@ make_opclause(Oper *op, Var *leftop, Var *rightop)
|
|||||||
{
|
{
|
||||||
Expr *expr = makeNode(Expr);
|
Expr *expr = makeNode(Expr);
|
||||||
|
|
||||||
expr->typeOid = InvalidOid; /* assume type checking done */
|
expr->typeOid = op->opresulttype;
|
||||||
expr->opType = OP_EXPR;
|
expr->opType = OP_EXPR;
|
||||||
expr->oper = (Node *) op;
|
expr->oper = (Node *) op;
|
||||||
if (rightop)
|
if (rightop)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user