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