PostGIS  3.3.9dev-r@@SVN_REVISION@@

◆ pg_nd_stats_from_tuple()

static ND_STATS* pg_nd_stats_from_tuple ( HeapTuple  stats_tuple,
int  mode 
)
static

Definition at line 901 of file gserialized_estimate.c.

902 {
903  int stats_kind = STATISTIC_KIND_ND;
904  int rv;
905  ND_STATS *nd_stats;
906 
907  /* If we're in 2D mode, set the kind appropriately */
908  if ( mode == 2 ) stats_kind = STATISTIC_KIND_2D;
909 
910  /* Then read the geom status histogram from that */
911 
912 #if POSTGIS_PGSQL_VERSION < 100
913  {
914  float4 *floatptr;
915  int nvalues;
916 
917  rv = get_attstatsslot(stats_tuple, 0, 0, stats_kind, InvalidOid,
918  NULL, NULL, NULL, &floatptr, &nvalues);
919 
920  if ( ! rv ) {
921  POSTGIS_DEBUGF(2, "no slot of kind %d in stats tuple", stats_kind);
922  return NULL;
923  }
924 
925  /* Clone the stats here so we can release the attstatsslot immediately */
926  nd_stats = palloc(sizeof(float) * nvalues);
927  memcpy(nd_stats, floatptr, sizeof(float) * nvalues);
928 
929  /* Clean up */
930  free_attstatsslot(0, NULL, 0, floatptr, nvalues);
931  }
932 #else /* PostgreSQL 10 or higher */
933  {
934  AttStatsSlot sslot;
935  rv = get_attstatsslot(&sslot, stats_tuple, stats_kind, InvalidOid,
936  ATTSTATSSLOT_NUMBERS);
937  if ( ! rv ) {
938  POSTGIS_DEBUGF(2, "no slot of kind %d in stats tuple", stats_kind);
939  return NULL;
940  }
941 
942  /* Clone the stats here so we can release the attstatsslot immediately */
943  nd_stats = palloc(sizeof(float4) * sslot.nnumbers);
944  memcpy(nd_stats, sslot.numbers, sizeof(float4) * sslot.nnumbers);
945 
946  free_attstatsslot(&sslot);
947  }
948 #endif
949 
950  return nd_stats;
951 }
#define STATISTIC_KIND_2D
#define STATISTIC_KIND_ND
N-dimensional statistics structure.

References STATISTIC_KIND_2D, and STATISTIC_KIND_ND.

Referenced by gserialized_sel_internal(), and pg_get_nd_stats().

Here is the caller graph for this function: