PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ pg_nd_stats_from_tuple()

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

Definition at line 887 of file gserialized_estimate.c.

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