[GRASS-SVN] r65131 - grass/trunk/lib/vector/Vlib

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Apr 25 03:28:41 PDT 2015


Author: martinl
Date: 2015-04-25 03:28:41 -0700 (Sat, 25 Apr 2015)
New Revision: 65131

Modified:
   grass/trunk/lib/vector/Vlib/read_pg.c
Log:
vlib: fix Vect__execute_pg() to handle long SQL statements on failure


Modified: grass/trunk/lib/vector/Vlib/read_pg.c
===================================================================
--- grass/trunk/lib/vector/Vlib/read_pg.c	2015-04-24 17:52:23 UTC (rev 65130)
+++ grass/trunk/lib/vector/Vlib/read_pg.c	2015-04-25 10:28:41 UTC (rev 65131)
@@ -1505,9 +1505,14 @@
     G_debug(3, "Vect__execute_pg(): %s", stmt);
     result = PQexec(conn, stmt);
     if (!result || PQresultStatus(result) != PGRES_COMMAND_OK) {
+        size_t stmt_len;
+        char stmt_prt[512];
+        
         PQclear(result);
-        
-        G_warning(_("Execution failed: %s\nReason: %s"), stmt,
+        stmt_len = strlen(stmt);
+        strncpy(stmt_prt, stmt, stmt_len > 511 ? 511 : stmt_len);
+        stmt_prt[stmt_len > 511 ? 511 : stmt_len] = '\0';
+        G_warning(_("Execution failed: %s (...)\nReason: %s"), stmt_prt,
                   PQerrorMessage(conn));
         return -1;
     }



More information about the grass-commit mailing list