From: Regina Obe Date: Sun, 21 May 2017 03:15:45 +0000 (+0000) Subject: PostgreSQL 10 beta1 fails compile in gserialized_estimate X-Git-Tag: 2.4.0alpha~96 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f5464f615055a37d571d9cdf7825c32b53fd2d7b;p=postgis PostgreSQL 10 beta1 fails compile in gserialized_estimate Revise to use new api for get_attstatsslot function for PostgreSQL >= 10 References #3758 git-svn-id: http://svn.osgeo.org/postgis/trunk@15398 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/postgis/gserialized_estimate.c b/postgis/gserialized_estimate.c index 06180a7f1..760b521d2 100644 --- a/postgis/gserialized_estimate.c +++ b/postgis/gserialized_estimate.c @@ -817,29 +817,50 @@ nd_increment(ND_IBOX *ibox, int ndims, int *counter) static ND_STATS* pg_nd_stats_from_tuple(HeapTuple stats_tuple, int mode) { - int stats_kind = STATISTIC_KIND_ND; - int rv, nvalues; - float4 *floatptr; + int stats_kind = STATISTIC_KIND_ND; + int rv; ND_STATS *nd_stats; - /* If we're in 2D mode, set the kind appropriately */ - if ( mode == 2 ) stats_kind = STATISTIC_KIND_2D; + /* If we're in 2D mode, set the kind appropriately */ + if ( mode == 2 ) stats_kind = STATISTIC_KIND_2D; /* Then read the geom status histogram from that */ - rv = get_attstatsslot(stats_tuple, 0, 0, stats_kind, InvalidOid, - NULL, NULL, NULL, &floatptr, &nvalues); - if ( ! rv ) { - POSTGIS_DEBUGF(2, - "no slot of kind %d in stats tuple", stats_kind); - return NULL; - } + +#if POSTGIS_PGSQL_VERSION < 100 + float4 *floatptr; + int nvalues; - /* Clone the stats here so we can release the attstatsslot immediately */ - nd_stats = palloc(sizeof(float) * nvalues); - memcpy(nd_stats, floatptr, sizeof(float) * nvalues); - - /* Clean up */ - free_attstatsslot(0, NULL, 0, floatptr, nvalues); + rv = get_attstatsslot(stats_tuple, 0, 0, stats_kind, InvalidOid, + NULL, NULL, NULL, &floatptr, &nvalues); + + if ( ! rv ) { + POSTGIS_DEBUGF(2, + "no slot of kind %d in stats tuple", stats_kind); + return NULL; + } + + /* Clone the stats here so we can release the attstatsslot immediately */ + nd_stats = palloc(sizeof(float) * nvalues); + memcpy(nd_stats, floatptr, sizeof(float) * nvalues); + + /* Clean up */ + free_attstatsslot(0, NULL, 0, floatptr, nvalues); +#else /**10 or higher **/ + AttStatsSlot sslot; + rv = get_attstatsslot(&sslot,stats_tuple, stats_kind, InvalidOid, + ATTSTATSSLOT_NUMBERS); + if ( ! rv ) { + POSTGIS_DEBUGF(2, + "no slot of kind %d in stats tuple", stats_kind); + return NULL; + } + + /* Clone the stats here so we can release the attstatsslot immediately */ + nd_stats = palloc(sizeof(float) * sslot.nnumbers); + memcpy(nd_stats, sslot.numbers, sizeof(float) * sslot.nnumbers); + + free_attstatsslot(&sslot); +#endif return nd_stats; }