Pull the stats object from the PgSQL system catalogs.
Used by the selectivity functions and the debugging functions.
945{
946 HeapTuple stats_tuple = NULL;
948
949
950 if ( ! only_parent )
951 {
952 POSTGIS_DEBUGF(2, "searching whole tree stats for \"%s\"", get_rel_name(table_oid)? get_rel_name(table_oid) : "NULL");
953 stats_tuple = SearchSysCache3(STATRELATTINH, ObjectIdGetDatum(table_oid), Int16GetDatum(att_num), BoolGetDatum(true));
954 if ( stats_tuple )
955 POSTGIS_DEBUGF(2, "found whole tree stats for \"%s\"", get_rel_name(table_oid)? get_rel_name(table_oid) : "NULL");
956 }
957
958 if ( only_parent || ! stats_tuple )
959 {
960 POSTGIS_DEBUGF(2, "searching parent table stats for \"%s\"", get_rel_name(table_oid)? get_rel_name(table_oid) : "NULL");
961 stats_tuple = SearchSysCache3(STATRELATTINH, ObjectIdGetDatum(table_oid), Int16GetDatum(att_num), BoolGetDatum(false));
962 if ( stats_tuple )
963 POSTGIS_DEBUGF(2, "found parent table stats for \"%s\"", get_rel_name(table_oid)? get_rel_name(table_oid) : "NULL");
964 }
965 if ( ! stats_tuple )
966 {
967 POSTGIS_DEBUGF(2, "stats for \"%s\" do not exist", get_rel_name(table_oid)? get_rel_name(table_oid) : "NULL");
968 return NULL;
969 }
970
972 ReleaseSysCache(stats_tuple);
973 if ( ! nd_stats )
974 {
975 POSTGIS_DEBUGF(2,
976 "histogram for attribute %d of table \"%s\" does not exist?",
977 att_num, get_rel_name(table_oid));
978 }
979
980 return nd_stats;
981}
static ND_STATS * pg_nd_stats_from_tuple(HeapTuple stats_tuple, int mode)
N-dimensional statistics structure.