[postgis-tickets] r15372 - Cast smaller integer types to the destination type

bjorn at wololo.org bjorn at wololo.org
Tue Apr 25 14:39:58 PDT 2017


Author: bjornharrtell
Date: 2017-04-25 14:39:58 -0700 (Tue, 25 Apr 2017)
New Revision: 15372

Modified:
   trunk/postgis/mvt.c
   trunk/regress/mvt.sql
   trunk/regress/mvt_expected
Log:
Cast smaller integer types to the destination type
Fixes #3741 and #3742

Modified: trunk/postgis/mvt.c
===================================================================
--- trunk/postgis/mvt.c	2017-04-25 21:14:25 UTC (rev 15371)
+++ trunk/postgis/mvt.c	2017-04-25 21:39:58 UTC (rev 15372)
@@ -368,11 +368,13 @@
 { \
 	type value = datumfunc(datum); \
 	if (value >= 0) { \
-		MVT_PARSE_VALUE(value, mvt_kv_uint_value, \
+		uint64_t cvalue = value; \
+		MVT_PARSE_VALUE(cvalue, mvt_kv_uint_value, \
 				uint_values_hash, uint_value, \
 				sizeof(uint64_t)) \
 	} else { \
-		MVT_PARSE_VALUE(value, mvt_kv_sint_value, \
+		int64_t cvalue = value; \
+		MVT_PARSE_VALUE(cvalue, mvt_kv_sint_value, \
 				sint_values_hash, sint_value, \
 				sizeof(int64_t)) \
 	} \

Modified: trunk/regress/mvt.sql
===================================================================
--- trunk/regress/mvt.sql	2017-04-25 21:14:25 UTC (rev 15371)
+++ trunk/regress/mvt.sql	2017-04-25 21:39:58 UTC (rev 15372)
@@ -96,20 +96,15 @@
     UNION
     SELECT 'othertest' AS c1, ST_AsMVTGeom(ST_GeomFromText('POINT(26 18)'),
     ST_MakeBox2D(ST_Point(0, 0), ST_Point(4096, 4096)), 4096, 0, false) AS geom) AS q;
--- TA8 results in incorrect encoding (redundant values) except in debug builds with specific logging
--- Memory allocation issues are suspected
---SELECT 'TA8', encode(ST_AsMVT('test', 4096, 'geom', q), 'base64') FROM (
---    SELECT 1 AS c1, ST_AsMVTGeom(ST_GeomFromText('POINT(25 17)'),
---    ST_MakeBox2D(ST_Point(0, 0), ST_Point(4096, 4096)), 4096, 0, false) AS geom
---    UNION
---    SELECT 1 AS c1, ST_AsMVTGeom(ST_GeomFromText('POINT(26 18)'),
---    ST_MakeBox2D(ST_Point(0, 0), ST_Point(4096, 4096)), 4096, 0, false) AS geom
---    UNION
---    SELECT 2 AS c1, ST_AsMVTGeom(ST_GeomFromText('POINT(26 18)'),
---    ST_MakeBox2D(ST_Point(0, 0), ST_Point(4096, 4096)), 4096, 0, false) AS geom) AS q;
--- Expected output:
--- TA8|GkEKBHRlc3QSDBICAAAYASIECTLePxIMEgIAABgBIgQJNNw/EgwSAgABGAEiBAk03D8aAmMxIgIo
--- ASICKAIogCB4Ag==
+SELECT 'TA8', encode(ST_AsMVT('test', 4096, 'geom', q), 'base64') FROM (
+    SELECT 1::int AS c1, ST_AsMVTGeom(ST_GeomFromText('POINT(25 17)'),
+    ST_MakeBox2D(ST_Point(0, 0), ST_Point(4096, 4096)), 4096, 0, false) AS geom
+    UNION
+    SELECT 1::int AS c1, ST_AsMVTGeom(ST_GeomFromText('POINT(26 18)'),
+    ST_MakeBox2D(ST_Point(0, 0), ST_Point(4096, 4096)), 4096, 0, false) AS geom
+    UNION
+    SELECT 2::int AS c1, ST_AsMVTGeom(ST_GeomFromText('POINT(26 18)'),
+    ST_MakeBox2D(ST_Point(0, 0), ST_Point(4096, 4096)), 4096, 0, false) AS geom) AS q;
 
 -- unsupported input
 SELECT 'TU2';

Modified: trunk/regress/mvt_expected
===================================================================
--- trunk/regress/mvt_expected	2017-04-25 21:14:25 UTC (rev 15371)
+++ trunk/regress/mvt_expected	2017-04-25 21:39:58 UTC (rev 15372)
@@ -25,6 +25,8 @@
 TA6|GisKBHRlc3QSDhIEAAABARgBIgQJMt4/GgJjMRoCYzIiAigBIgIwASiAIHgC
 TA7|Gk4KBHRlc3QSDBICAAAYASIECTTcPxIMEgIAARgBIgQJMt4/EgwSAgABGAEiBAk03D8aAmMxIgsK
 CW90aGVydGVzdCIGCgR0ZXN0KIAgeAI=
+TA8|GkEKBHRlc3QSDBICAAAYASIECTLePxIMEgIAABgBIgQJNNw/EgwSAgABGAEiBAk03D8aAmMxIgIo
+ASICKAIogCB4Ag==
 TU2
 ERROR:  pgis_asmvt_transfn: parameter row cannot be other than a rowtype
 TU3



More information about the postgis-tickets mailing list