diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2001-10-18 16:11:42 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2001-10-18 16:11:42 +0000 |
commit | 6254465d0621f724cdc9a1e99da24fa8a29f579d (patch) | |
tree | 84bd08321ce84de9daf6ab5264c889e5b5a92e4e /src/backend/nodes/print.c | |
parent | 50450049581566ed47016cd89ba03b90be7ea1d0 (diff) | |
download | postgresql-6254465d0621f724cdc9a1e99da24fa8a29f579d.tar.gz postgresql-6254465d0621f724cdc9a1e99da24fa8a29f579d.zip |
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.
Diffstat (limited to 'src/backend/nodes/print.c')
-rw-r--r-- | src/backend/nodes/print.c | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/src/backend/nodes/print.c b/src/backend/nodes/print.c index 932f55ab885..98347695622 100644 --- a/src/backend/nodes/print.c +++ b/src/backend/nodes/print.c @@ -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(", "); } |