[postgis-tickets] r15398 - PostgreSQL 10 beta1 fails compile in gserialized_estimate

Regina Obe lr at pcorp.us
Sat May 20 20:15:46 PDT 2017


Author: robe
Date: 2017-05-20 20:15:45 -0700 (Sat, 20 May 2017)
New Revision: 15398

Modified:
   trunk/postgis/gserialized_estimate.c
Log:
PostgreSQL 10 beta1 fails compile in gserialized_estimate
Revise to use new api for get_attstatsslot function for PostgreSQL >= 10
References #3758

Modified: trunk/postgis/gserialized_estimate.c
===================================================================
--- trunk/postgis/gserialized_estimate.c	2017-05-20 17:49:52 UTC (rev 15397)
+++ trunk/postgis/gserialized_estimate.c	2017-05-21 03:15:45 UTC (rev 15398)
@@ -817,30 +817,51 @@
 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);
+	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
 
-  /* Clean up */
-  free_attstatsslot(0, NULL, 0, floatptr, nvalues);
-
   return nd_stats;
 }
 



More information about the postgis-tickets mailing list