PostGIS  3.1.6dev-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 906 of file gserialized_estimate.c.

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