Index: src/backend/optimizer/util/plancat.c =================================================================== RCS file: /home/sriggs/pg/REPOSITORY/pgsql/src/backend/optimizer/util/plancat.c,v retrieving revision 1.146 diff -c -r1.146 plancat.c *** src/backend/optimizer/util/plancat.c 12 May 2008 00:00:49 -0000 1.146 --- src/backend/optimizer/util/plancat.c 30 Jun 2008 19:52:27 -0000 *************** *** 27,32 **** --- 27,33 ---- #include "nodes/makefuncs.h" #include "optimizer/clauses.h" #include "optimizer/plancat.h" + #include "optimizer/planhook.h" #include "optimizer/predtest.h" #include "optimizer/prep.h" #include "parser/parse_expr.h" *************** *** 45,52 **** /* GUC parameter */ bool constraint_exclusion = false; ! /* Hook for plugins to get control in get_relation_info() */ ! get_relation_info_hook_type get_relation_info_hook = NULL; static List *get_relation_constraints(PlannerInfo *root, --- 46,55 ---- /* GUC parameter */ bool constraint_exclusion = false; ! /* Hook for plugins to get planner info, defined in planhook.h */ ! get_relation_info_hook_type get_relation_info_hook = NULL; ! get_relation_stats_hook_type get_relation_stats_hook = NULL; ! get_relation_avg_width_hook_type get_relation_avg_width_hook = NULL; static List *get_relation_constraints(PlannerInfo *root, Index: src/backend/utils/adt/selfuncs.c =================================================================== RCS file: /home/sriggs/pg/REPOSITORY/pgsql/src/backend/utils/adt/selfuncs.c,v retrieving revision 1.249 diff -c -r1.249 selfuncs.c *** src/backend/utils/adt/selfuncs.c 12 May 2008 00:00:51 -0000 1.249 --- src/backend/utils/adt/selfuncs.c 30 Jun 2008 19:52:52 -0000 *************** *** 87,92 **** --- 87,93 ---- #include "optimizer/pathnode.h" #include "optimizer/paths.h" #include "optimizer/plancat.h" + #include "optimizer/planhook.h" #include "optimizer/predtest.h" #include "optimizer/restrictinfo.h" #include "optimizer/var.h" *************** *** 3749,3755 **** } else if (rte->rtekind == RTE_RELATION) { ! vardata->statsTuple = SearchSysCache(STATRELATT, ObjectIdGetDatum(rte->relid), Int16GetDatum(var->varattno), 0, 0); --- 3750,3761 ---- } else if (rte->rtekind == RTE_RELATION) { ! if (get_relation_stats_hook) ! vardata->statsTuple = (*get_relation_stats_hook) ! (ObjectIdGetDatum(rte->relid), ! Int16GetDatum(var->varattno)); ! else ! vardata->statsTuple = SearchSysCache(STATRELATT, ObjectIdGetDatum(rte->relid), Int16GetDatum(var->varattno), 0, 0); *************** *** 3869,3878 **** index->indpred == NIL) vardata->isunique = true; /* Has it got stats? */ ! vardata->statsTuple = SearchSysCache(STATRELATT, ! ObjectIdGetDatum(index->indexoid), ! Int16GetDatum(pos + 1), ! 0, 0); if (vardata->statsTuple) break; } --- 3875,3889 ---- index->indpred == NIL) vardata->isunique = true; /* Has it got stats? */ ! if (get_relation_stats_hook) ! vardata->statsTuple = (*get_relation_stats_hook) ! (ObjectIdGetDatum(index->indexoid), ! Int16GetDatum(pos + 1)); ! else ! vardata->statsTuple = SearchSysCache(STATRELATT, ! ObjectIdGetDatum(index->indexoid), ! Int16GetDatum(pos + 1), ! 0, 0); if (vardata->statsTuple) break; } *************** *** 5507,5516 **** colnum = 1; } ! tuple = SearchSysCache(STATRELATT, ! ObjectIdGetDatum(relid), ! Int16GetDatum(colnum), ! 0, 0); if (HeapTupleIsValid(tuple)) { --- 5518,5532 ---- colnum = 1; } ! if (get_relation_stats_hook) ! tuple = (*get_relation_stats_hook) ( ! ObjectIdGetDatum(relid), ! Int16GetDatum(colnum)); ! else ! tuple = SearchSysCache(STATRELATT, ! ObjectIdGetDatum(relid), ! Int16GetDatum(colnum), ! 0, 0); if (HeapTupleIsValid(tuple)) { Index: src/backend/utils/cache/lsyscache.c =================================================================== RCS file: /home/sriggs/pg/REPOSITORY/pgsql/src/backend/utils/cache/lsyscache.c,v retrieving revision 1.157 diff -c -r1.157 lsyscache.c *** src/backend/utils/cache/lsyscache.c 13 Apr 2008 20:51:21 -0000 1.157 --- src/backend/utils/cache/lsyscache.c 30 Jun 2008 19:54:46 -0000 *************** *** 27,32 **** --- 27,33 ---- #include "catalog/pg_proc.h" #include "catalog/pg_statistic.h" #include "catalog/pg_type.h" + #include "optimizer/planhook.h" #include "miscadmin.h" #include "nodes/makefuncs.h" #include "utils/array.h" *************** *** 2457,2462 **** --- 2458,2468 ---- { HeapTuple tp; + if (get_relation_avg_width_hook) + return (*get_relation_avg_width_hook) ( + ObjectIdGetDatum(relid), + Int16GetDatum(attnum)); + tp = SearchSysCache(STATRELATT, ObjectIdGetDatum(relid), Int16GetDatum(attnum), Index: src/include/optimizer/plancat.h =================================================================== RCS file: /home/sriggs/pg/REPOSITORY/pgsql/src/include/optimizer/plancat.h,v retrieving revision 1.49 diff -c -r1.49 plancat.h *** src/include/optimizer/plancat.h 1 Apr 2008 00:48:33 -0000 1.49 --- src/include/optimizer/plancat.h 30 Jun 2008 13:41:48 -0000 *************** *** 17,30 **** #include "nodes/relation.h" #include "utils/rel.h" - /* Hook for plugins to get control in get_relation_info() */ - typedef void (*get_relation_info_hook_type) (PlannerInfo *root, - Oid relationObjectId, - bool inhparent, - RelOptInfo *rel); - extern PGDLLIMPORT get_relation_info_hook_type get_relation_info_hook; - - extern void get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent, RelOptInfo *rel); --- 17,22 ----