[postgis-tickets] r16673 - Use user-provided CFLAGS in the topology module

Raul raul at rmr.ninja
Mon Jul 30 09:26:39 PDT 2018


Author: algunenano
Date: 2018-07-30 09:26:39 -0700 (Mon, 30 Jul 2018)
New Revision: 16673

Modified:
   trunk/NEWS
   trunk/liblwgeom/liblwgeom_topo.h
   trunk/topology/Makefile.in
   trunk/topology/postgis_topology.c
Log:
Use user-provided CFLAGS in the topology module

References #4140


Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2018-07-27 11:28:00 UTC (rev 16672)
+++ trunk/NEWS	2018-07-30 16:26:39 UTC (rev 16673)
@@ -8,6 +8,7 @@
     (Vinícius A.B. Schmidt, Darafei Praliaskouski)
   - #4109, Fix WKT parser accepting and interpreting numbers numbers with
     multiple dots (Raúl Marín, Paul Ramsey)
+  - #4140, Use user-provided CFLAGS in the topology module (Raúl Marín)
 
   See PostGIS 2.5.0 section for full details
 

Modified: trunk/liblwgeom/liblwgeom_topo.h
===================================================================
--- trunk/liblwgeom/liblwgeom_topo.h	2018-07-27 11:28:00 UTC (rev 16672)
+++ trunk/liblwgeom/liblwgeom_topo.h	2018-07-30 16:26:39 UTC (rev 16673)
@@ -188,6 +188,7 @@
    * @param ids an array of element identifiers
    * @param numelems input/output parameter, pass number of node identifiers
    *                 in the input array, gets number of node in output array.
+   *	TODO: Should be uint64 to match SPI_processed
    * @param fields fields to be filled in the returned structure, see
    *               LWT_COL_NODE_* macros
    *
@@ -212,6 +213,7 @@
    * @param numelems output parameter, gets number of elements found
    *                 if the return is not null, otherwise see @return
    *                 section for semantic.
+   *	TODO: Should be uint64 to match SPI_processed
    * @param fields fields to be filled in the returned structure, see
    *               LWT_COL_NODE_* macros
    * @param limit max number of nodes to return, 0 for no limit, -1
@@ -239,6 +241,7 @@
    * @param nodes the nodes to insert. Those with a node_id set to -1
    *              it will be replaced to an automatically assigned identifier
    * @param nelems number of elements in the nodes array
+   *	TODO: Should be uint64 to match SPI_processed
    *
    * @return 1 on success, 0 on error (@see lastErrorMessage)
    */
@@ -319,6 +322,7 @@
    * @param edges the edges to insert. Those with a edge_id set to -1
    *              it will be replaced to an automatically assigned identifier
    * @param nelems number of elements in the edges array
+   *	TODO: Should be uint64 to match SPI_processed
    *
    * @return number of inserted edges, or -1 (@see lastErrorMessage)
    */
@@ -555,6 +559,7 @@
    * @param faces the faces to insert. Those with a node_id set to -1
    *              it will be replaced to an automatically assigned identifier
    * @param nelems number of elements in the faces array
+   *	TODO: Should be uint64 to match SPI_processed
    *
    * @return number of inserted faces, or -1 (@see lastErrorMessage)
    */
@@ -571,6 +576,7 @@
    * @param faces an array of LWT_ISO_FACE object with selecting id
    *              and setting mbr.
    * @param numfaces number of faces in the "faces" array
+   *	TODO: Should be uint64 to match SPI_processed
    *
    * @return number of faces being updated or -1 on error
    *         (@see lastErroMessage)
@@ -598,6 +604,7 @@
    *             side (left if positive, right if negative)
    *             and direction (forward if positive, backward if negative).
    * @param numedges output parameter, gets the number of edges visited
+   *
    * @param limit max edges to return (to avoid an infinite loop in case
    *              of a corrupted topology). 0 is for unlimited.
    *              The function is expected to error out if the limit is hit.
@@ -618,6 +625,7 @@
    * @param edges an array of LWT_ISO_EDGE object with selecting id
    *              and updating fields.
    * @param numedges number of edges in the "edges" array
+   *	TODO: Should be uint64 to match SPI_processed
    * @param upd_fields fields to be updated for the selected edges,
    *                   see LWT_COL_EDGE_* macros
    *
@@ -641,6 +649,7 @@
    *                 in the input array, gets number of edges in output array
    *                 if the return is not null, otherwise see @return
    *                 section for semantic.
+   *	TODO: Should be uint64 to match SPI_processed
    * @param fields fields to be filled in the returned structure, see
    *               LWT_COL_EDGE_* macros
    * @param box optional bounding box to further restrict matches, use
@@ -665,6 +674,7 @@
    *                 identifiers in the input array, gets number of
    *                 nodes in output array if the return is not null,
    *                 otherwise see @return section for semantic.
+   *	TODO: Should be uint64 to match SPI_processed
    * @param fields fields to be filled in the returned structure, see
    *               LWT_COL_NODE_* macros
    * @param box optional bounding box to further restrict matches, use
@@ -687,6 +697,7 @@
    * @param nodes an array of LWT_ISO_EDGE objects with selecting id
    *              and updating fields.
    * @param numnodes number of nodes in the "nodes" array
+   *	TODO: Should be uint64 to match SPI_processed
    * @param upd_fields fields to be updated for the selected edges,
    *                   see LWT_COL_NODE_* macros
    *
@@ -705,6 +716,7 @@
    * @param topo the topology to act upon
    * @param ids an array of face identifiers
    * @param numelems number of face identifiers in the ids array
+   *	TODO: Should be uint64 to match SPI_processed
    *
    * @return number of faces being deleted or -1 on error
    *         (@see lastErrorMessage)
@@ -744,6 +756,7 @@
    * @param topo the topology to act upon
    * @param ids an array of node identifiers
    * @param numelems number of node identifiers in the ids array
+   *	TODO: Should be uint64 to match SPI_processed
    *
    * @return number of nodes being deleted or -1 on error
    *         (@see lastErrorMessage)
@@ -847,10 +860,11 @@
    * @param numelems output parameter, gets number of elements found
    *                 if the return is not null, otherwise see @return
    *                 section for semantic.
+   *	TODO: Should be uint64 to match SPI_processed
    * @param fields fields to be filled in the returned structure, see
    *               LWT_COL_FACE_* macros
    * @param limit max number of faces to return, 0 for no limit, -1
-   *              to only check for existance if a matching row.
+   *              to only check for existence if a matching row.
    *
    * @return an array of faces or null in the following cases:
    *         - limit=-1 ("numelems" is set to 1 if found, 0 otherwise)

Modified: trunk/topology/Makefile.in
===================================================================
--- trunk/topology/Makefile.in	2018-07-27 11:28:00 UTC (rev 16672)
+++ trunk/topology/Makefile.in	2018-07-30 16:26:39 UTC (rev 16673)
@@ -44,7 +44,7 @@
 # to an existing liblwgeom.so in the PostgreSQL $libdir supplied by an
 # older version of PostGIS, rather than with the static liblwgeom.a
 # supplied with newer versions of PostGIS
-PG_CPPFLAGS += -I../liblwgeom -I../libpgcommon @CPPFLAGS@ -fPIC
+PG_CPPFLAGS += -I../liblwgeom @CFLAGS@ -I../libpgcommon @CPPFLAGS@ -fPIC
 SHLIB_LINK_F = ../libpgcommon/libpgcommon.a ../liblwgeom/.libs/liblwgeom.a @SHLIB_LINK@
 
 # Add SFCGAL Flags if defined

Modified: trunk/topology/postgis_topology.c
===================================================================
--- trunk/topology/postgis_topology.c	2018-07-27 11:28:00 UTC (rev 16672)
+++ trunk/topology/postgis_topology.c	2018-07-30 16:26:39 UTC (rev 16673)
@@ -962,8 +962,8 @@
     return NULL;
   }
 
-  edges = palloc( sizeof(LWT_ISO_EDGE) * SPI_processed );
-  for ( i=0; i<SPI_processed; ++i )
+  edges = palloc( sizeof(LWT_ISO_EDGE) * *numelems );
+  for ( i=0; i<*numelems; ++i )
   {
     HeapTuple row = SPI_tuptable->vals[i];
     fillEdgeFields(&edges[i], row, SPI_tuptable->tupdesc, fields);
@@ -1025,8 +1025,8 @@
     return NULL;
   }
 
-  edges = palloc( sizeof(LWT_ISO_EDGE) * SPI_processed );
-  for ( i=0; i<SPI_processed; ++i )
+  edges = palloc( sizeof(LWT_ISO_EDGE) * *numelems );
+  for ( i=0; i<*numelems; ++i )
   {
     HeapTuple row = SPI_tuptable->vals[i];
     fillEdgeFields(&edges[i], row, SPI_tuptable->tupdesc, fields);
@@ -1106,8 +1106,8 @@
     return NULL;
   }
 
-  edges = palloc( sizeof(LWT_ISO_EDGE) * SPI_processed );
-  for ( i=0; i<SPI_processed; ++i )
+  edges = palloc( sizeof(LWT_ISO_EDGE) * *numelems );
+  for ( i=0; i<*numelems; ++i )
   {
     HeapTuple row = SPI_tuptable->vals[i];
     fillEdgeFields(&edges[i], row, SPI_tuptable->tupdesc, fields);
@@ -1162,8 +1162,8 @@
     return NULL;
   }
 
-  faces = palloc( sizeof(LWT_ISO_EDGE) * SPI_processed );
-  for ( i=0; i<SPI_processed; ++i )
+  faces = palloc( sizeof(LWT_ISO_EDGE) * *numelems );
+  for ( i=0; i<*numelems; ++i )
   {
     HeapTuple row = SPI_tuptable->vals[i];
     fillFaceFields(&faces[i], row, SPI_tuptable->tupdesc, fields);
@@ -1223,7 +1223,7 @@
   {
     return NULL;
   }
-  if ( limit && SPI_processed == limit )
+  if ( limit && *numelems == limit )
   {
     cberror(topo->be_data, "Max traversing limit hit: %d", limit-1);
     *numelems = -1;
@@ -1230,9 +1230,9 @@
     return NULL;
   }
 
-  edges = palloc( sizeof(LWT_ELEMID) * SPI_processed );
+  edges = palloc( sizeof(LWT_ELEMID) * *numelems );
   rowdesc = SPI_tuptable->tupdesc;
-  for ( i=0; i<SPI_processed; ++i )
+  for ( i=0; i<*numelems; ++i )
   {
     HeapTuple row = SPI_tuptable->vals[i];
     bool isnull;
@@ -1299,8 +1299,8 @@
     return NULL;
   }
 
-  nodes = palloc( sizeof(LWT_ISO_NODE) * SPI_processed );
-  for ( i=0; i<SPI_processed; ++i )
+  nodes = palloc( sizeof(LWT_ISO_NODE) * *numelems );
+  for ( i=0; i<*numelems; ++i )
   {
     HeapTuple row = SPI_tuptable->vals[i];
     fillNodeFields(&nodes[i], row, SPI_tuptable->tupdesc, fields);
@@ -1361,8 +1361,8 @@
     return NULL;
   }
 
-  nodes = palloc( sizeof(LWT_ISO_NODE) * SPI_processed );
-  for ( i=0; i<SPI_processed; ++i )
+  nodes = palloc( sizeof(LWT_ISO_NODE) * *numelems );
+  for ( i=0; i<*numelems; ++i )
   {
     HeapTuple row = SPI_tuptable->vals[i];
     fillNodeFields(&nodes[i], row, SPI_tuptable->tupdesc, fields);
@@ -1456,8 +1456,8 @@
     return NULL;
   }
 
-  edges = palloc( sizeof(LWT_ISO_EDGE) * SPI_processed );
-  for ( i=0; i<SPI_processed; ++i )
+  edges = palloc( sizeof(LWT_ISO_EDGE) * *numelems );
+  for ( i=0; i<*numelems; ++i )
   {
     HeapTuple row = SPI_tuptable->vals[i];
     fillEdgeFields(&edges[i], row, SPI_tuptable->tupdesc, fields);
@@ -1559,13 +1559,13 @@
   }
   else
   {
-    nodes = palloc( sizeof(LWT_ISO_EDGE) * SPI_processed );
-    for ( i=0; i<SPI_processed; ++i )
+    *numelems = SPI_processed;
+    nodes = palloc( sizeof(LWT_ISO_EDGE) * *numelems );
+    for ( i=0; i<*numelems; ++i )
     {
       HeapTuple row = SPI_tuptable->vals[i];
       fillNodeFields(&nodes[i], row, SPI_tuptable->tupdesc, fields);
     }
-    *numelems = SPI_processed;
 
     SPI_freetuptable(SPI_tuptable);
 
@@ -1610,7 +1610,8 @@
 
   if ( SPI_processed ) topo->be_data->data_changed = true;
 
-  if ( SPI_processed != numelems )
+  // TODO: Remove cast when numelems uses uint64 instead of int
+  if ( SPI_processed != (uint64) numelems )
   {
     cberror(topo->be_data, "processed " UINT64_FORMAT " rows, expected %d",
             (uint64)SPI_processed, numelems);
@@ -1619,7 +1620,7 @@
 
   /* Set node_id (could skip this if none had it set to -1) */
   /* TODO: check for -1 values in the first loop */
-  for ( i=0; i<SPI_processed; ++i )
+  for ( i=0; i<numelems; ++i )
   {
     if ( nodes[i].node_id != -1 ) continue;
     fillNodeFields(&nodes[i], SPI_tuptable->vals[i],
@@ -1669,7 +1670,7 @@
   pfree(sqldata.data);
   if ( SPI_processed ) topo->be_data->data_changed = true;
   POSTGIS_DEBUGF(1, "cb_insertEdges query processed %d rows", SPI_processed);
-  if ( SPI_processed != numelems )
+  if ( SPI_processed != (uint64) numelems )
   {
     cberror(topo->be_data, "processed " UINT64_FORMAT " rows, expected %d",
             (uint64)SPI_processed, numelems);
@@ -1679,7 +1680,7 @@
   if ( needsEdgeIdReturn )
   {
     /* Set node_id for items that need it */
-    for ( i=0; i<SPI_processed; ++i )
+    for ( i=0; i<(int)SPI_processed; ++i )
     {
       if ( edges[i].edge_id != -1 ) continue;
       fillEdgeFields(&edges[i], SPI_tuptable->vals[i],
@@ -1729,7 +1730,7 @@
   pfree(sqldata.data);
   if ( SPI_processed ) topo->be_data->data_changed = true;
   POSTGIS_DEBUGF(1, "cb_insertFaces query processed %d rows", SPI_processed);
-  if ( SPI_processed != numelems )
+  if ( SPI_processed != (uint64) numelems )
   {
     cberror(topo->be_data, "processed " UINT64_FORMAT " rows, expected %d",
             (uint64)SPI_processed, numelems);
@@ -1739,7 +1740,7 @@
   if ( needsFaceIdReturn )
   {
     /* Set node_id for items that need it */
-    for ( i=0; i<SPI_processed; ++i )
+    for ( i=0; i<numelems; ++i )
     {
       if ( faces[i].face_id != -1 ) continue;
       fillFaceFields(&faces[i], SPI_tuptable->vals[i],
@@ -2966,8 +2967,8 @@
     return NULL;
   }
 
-  nodes = palloc( sizeof(LWT_ISO_EDGE) * SPI_processed );
-  for ( i=0; i<SPI_processed; ++i )
+  nodes = palloc( sizeof(LWT_ISO_EDGE) * *numelems );
+  for ( i=0; i<*numelems; ++i )
   {
     HeapTuple row = SPI_tuptable->vals[i];
     fillNodeFields(&nodes[i], row, SPI_tuptable->tupdesc, fields);
@@ -3055,8 +3056,8 @@
     return NULL;
   }
 
-  edges = palloc( sizeof(LWT_ISO_EDGE) * SPI_processed );
-  for ( i=0; i<SPI_processed; ++i )
+  edges = palloc( sizeof(LWT_ISO_EDGE) * *numelems );
+  for ( i=0; i<*numelems; ++i )
   {
     HeapTuple row = SPI_tuptable->vals[i];
     fillEdgeFields(&edges[i], row, SPI_tuptable->tupdesc, fields);
@@ -3141,8 +3142,8 @@
     return NULL;
   }
 
-  faces = palloc( sizeof(LWT_ISO_EDGE) * SPI_processed );
-  for ( i=0; i<SPI_processed; ++i )
+  faces = palloc( sizeof(LWT_ISO_EDGE) * *numelems );
+  for ( i=0; i<*numelems; ++i )
   {
     HeapTuple row = SPI_tuptable->vals[i];
     fillFaceFields(&faces[i], row, SPI_tuptable->tupdesc, fields);



More information about the postgis-tickets mailing list