PostGIS  2.5.7dev-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 894 of file gserialized_estimate.c.

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

References STATISTIC_KIND_2D, and STATISTIC_KIND_ND.

Referenced by gserialized_gist_sel(), and pg_get_nd_stats().

Here is the caller graph for this function: