1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-17 06:41:09 +03:00

Extend code that deduces implied equality clauses to detect whether a

clause being added to a particular restriction-clause list is redundant
with those already in the list.  This avoids useless work at runtime,
and (perhaps more importantly) keeps the selectivity estimation routines
from generating too-small estimates of numbers of output rows.
Also some minor improvements in OPTIMIZER_DEBUG displays.
This commit is contained in:
Tom Lane
2001-10-18 16:11:42 +00:00
parent 5045004958
commit 6254465d06
9 changed files with 373 additions and 110 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/print.c,v 1.47 2001/03/22 03:59:32 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/print.c,v 1.48 2001/10/18 16:11:41 tgl Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
@ -20,10 +20,12 @@
#include "postgres.h"
#include "access/printtup.h"
#include "catalog/pg_type.h"
#include "nodes/print.h"
#include "optimizer/clauses.h"
#include "parser/parsetree.h"
#include "utils/lsyscache.h"
#include "utils/syscache.h"
static char *plannode_type(Plan *p);
@ -188,6 +190,36 @@ print_expr(Node *expr, List *rtable)
}
printf("%s.%s", relname, attname);
}
else if (IsA(expr, Const))
{
Const *c = (Const *) expr;
HeapTuple typeTup;
Oid typoutput;
Oid typelem;
char *outputstr;
if (c->constisnull)
{
printf("NULL");
return;
}
typeTup = SearchSysCache(TYPEOID,
ObjectIdGetDatum(c->consttype),
0, 0, 0);
if (!HeapTupleIsValid(typeTup))
elog(ERROR, "Cache lookup for type %u failed", c->consttype);
typoutput = ((Form_pg_type) GETSTRUCT(typeTup))->typoutput;
typelem = ((Form_pg_type) GETSTRUCT(typeTup))->typelem;
ReleaseSysCache(typeTup);
outputstr = DatumGetCString(OidFunctionCall3(typoutput,
c->constvalue,
ObjectIdGetDatum(typelem),
Int32GetDatum(-1)));
printf("%s", outputstr);
pfree(outputstr);
}
else if (IsA(expr, Expr))
{
Expr *e = (Expr *) expr;
@ -232,7 +264,7 @@ print_pathkeys(List *pathkeys, List *rtable)
if (lnext(k))
printf(", ");
}
printf(") ");
printf(")");
if (lnext(i))
printf(", ");
}