Pull the stats object from the PgSQL system catalogs.
Used by the selectivity functions and the debugging functions.
809{
810 HeapTuple stats_tuple = NULL;
812
813
814 if ( ! only_parent )
815 {
816 POSTGIS_DEBUGF(2, "searching whole tree stats for \"%s\"", get_rel_name(table_oid)? get_rel_name(table_oid) : "NULL");
817 stats_tuple = SearchSysCache3(STATRELATTINH, ObjectIdGetDatum(table_oid), Int16GetDatum(att_num), BoolGetDatum(true));
818 if ( stats_tuple )
819 POSTGIS_DEBUGF(2, "found whole tree stats for \"%s\"", get_rel_name(table_oid)? get_rel_name(table_oid) : "NULL");
820 }
821
822 if ( only_parent || ! stats_tuple )
823 {
824 POSTGIS_DEBUGF(2, "searching parent table stats for \"%s\"", get_rel_name(table_oid)? get_rel_name(table_oid) : "NULL");
825 stats_tuple = SearchSysCache3(STATRELATTINH, ObjectIdGetDatum(table_oid), Int16GetDatum(att_num), BoolGetDatum(false));
826 if ( stats_tuple )
827 POSTGIS_DEBUGF(2, "found parent table stats for \"%s\"", get_rel_name(table_oid)? get_rel_name(table_oid) : "NULL");
828 }
829 if ( ! stats_tuple )
830 {
831 POSTGIS_DEBUGF(2, "stats for \"%s\" do not exist", get_rel_name(table_oid)? get_rel_name(table_oid) : "NULL");
832 return NULL;
833 }
834
836 ReleaseSysCache(stats_tuple);
837 if ( ! nd_stats )
838 {
839 POSTGIS_DEBUGF(2,
840 "histogram for attribute %d of table \"%s\" does not exist?",
841 att_num, get_rel_name(table_oid));
842 }
843
844 return nd_stats;
845}
static ND_STATS * pg_nd_stats_from_tuple(HeapTuple stats_tuple, int mode)