1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-14 08:21:07 +03:00

Inheritance overhaul by Chris Bitmead <chris@bitmead.com>

This commit is contained in:
Bruce Momjian
2000-06-09 01:44:34 +00:00
parent fb070464c1
commit 8c1d09d591
32 changed files with 484 additions and 204 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.80 2000/05/30 00:49:47 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.81 2000/06/09 01:44:14 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -106,6 +106,9 @@ planner(Query *parse)
Plan *
subquery_planner(Query *parse, double tuple_fraction)
{
List *l;
List *rangetable = parse->rtable;
RangeTblEntry *rangeTblEntry;
/*
* A HAVING clause without aggregates is equivalent to a WHERE clause
@ -138,6 +141,18 @@ subquery_planner(Query *parse, double tuple_fraction)
parse->qual = eval_const_expressions(parse->qual);
parse->havingQual = eval_const_expressions(parse->havingQual);
/*
* If the query is going to look for subclasses, but no subclasses
* actually exist, then we can optimise away the union that would
* otherwise happen and thus save some time.
*/
foreach(l, rangetable)
{
rangeTblEntry = (RangeTblEntry *)lfirst(l);
if (rangeTblEntry->inh && !has_subclass(rangeTblEntry->relid))
rangeTblEntry->inh = FALSE;
}
/*
* Canonicalize the qual, and convert it to implicit-AND format.
*

View File

@ -9,7 +9,11 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.53 2000/05/30 04:24:48 tgl Exp $
<<<<<<< plancat.c
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.54 2000/06/09 01:44:16 momjian Exp $
=======
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.54 2000/06/09 01:44:16 momjian Exp $
>>>>>>> 1.53
*
*-------------------------------------------------------------------------
*/
@ -278,6 +282,25 @@ find_inheritance_children(Oid inhparent)
return list;
}
/*
* has_subclass -
* In the current implementation, has_subclass returns whether a
* particular class *might* have a subclass. It will not return the
* correct result if a class had a subclass which was later dropped.
* This is because relhassubclass in pg_class is not updated,
* possibly because of efficiency and/or concurrency concerns.
* Currently has_subclass is only used as an efficiency hack, so this
* is ok.
*/
bool has_subclass(Oid relationId)
{
HeapTuple tuple =
SearchSysCacheTuple(RELOID,
ObjectIdGetDatum(relationId),
0, 0, 0);
return ((Form_pg_class) GETSTRUCT(tuple))->relhassubclass;
}
#ifdef NOT_USED
/*
* VersionGetParents