diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2006-05-02 04:34:18 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2006-05-02 04:34:18 +0000 |
commit | 427c6b5b984928972e955f4477c6ba64edbb66cc (patch) | |
tree | 7db5950589106f9a5ad6b1c83b5d48796c9b646d /src/backend/utils/adt/selfuncs.c | |
parent | a65a49429f1a6722a6be4a9784b4e08fab8ca380 (diff) | |
download | postgresql-427c6b5b984928972e955f4477c6ba64edbb66cc.tar.gz postgresql-427c6b5b984928972e955f4477c6ba64edbb66cc.zip |
Avoid assuming that statistics for a parent relation reflect the properties of
the union of its child relations as well. This might have been a good idea
when it was originally coded, but it's a fatally bad idea when inheritance is
being used for partitioning. It's better to have no stats at all than
completely misleading stats. Per report from Mark Liberman.
The bug arguably exists all the way back, but I've only patched HEAD and 8.1
because we weren't particularly trying to support partitioning before 8.1.
Eventually we ought to look at deriving union statistics instead of just
punting, but for now the drop kick looks good.
Diffstat (limited to 'src/backend/utils/adt/selfuncs.c')
-rw-r--r-- | src/backend/utils/adt/selfuncs.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c index 082089b9f11..5f830ef0cd3 100644 --- a/src/backend/utils/adt/selfuncs.c +++ b/src/backend/utils/adt/selfuncs.c @@ -15,7 +15,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.203 2006/04/27 17:52:40 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.204 2006/05/02 04:34:18 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -3265,19 +3265,27 @@ examine_variable(PlannerInfo *root, Node *node, int varRelid, (varRelid == 0 || varRelid == ((Var *) basenode)->varno)) { Var *var = (Var *) basenode; - Oid relid; + RangeTblEntry *rte; vardata->var = basenode; /* return Var without relabeling */ vardata->rel = find_base_rel(root, var->varno); vardata->atttype = var->vartype; vardata->atttypmod = var->vartypmod; - relid = getrelid(var->varno, root->parse->rtable); + rte = rt_fetch(var->varno, root->parse->rtable); - if (OidIsValid(relid)) + if (rte->inh) + { + /* + * XXX This means the Var represents a column of an append relation. + * Later add code to look at the member relations and try to derive + * some kind of combined statistics? + */ + } + else if (rte->rtekind == RTE_RELATION) { vardata->statsTuple = SearchSysCache(STATRELATT, - ObjectIdGetDatum(relid), + ObjectIdGetDatum(rte->relid), Int16GetDatum(var->varattno), 0, 0); } |