[GRASS-SVN] r72993 - grass/trunk/db/db.execute

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Jul 17 09:26:41 PDT 2018


Author: mmetz
Date: 2018-07-17 09:26:40 -0700 (Tue, 17 Jul 2018)
New Revision: 72993

Modified:
   grass/trunk/db/db.execute/main.c
Log:
db.execute: check return code of db_execute_immediate() also for sql option

Modified: grass/trunk/db/db.execute/main.c
===================================================================
--- grass/trunk/db/db.execute/main.c	2018-07-16 12:57:48 UTC (rev 72992)
+++ grass/trunk/db/db.execute/main.c	2018-07-17 16:26:40 UTC (rev 72993)
@@ -80,6 +80,18 @@
         /* parms.sql */
         db_set_string(&stmt, parms.sql);
         ret = db_execute_immediate(driver, &stmt);
+
+	if (ret != DB_OK) {
+	    if (parms.i) {	/* ignore SQL errors */
+		G_warning(_("Error while executing: '%s'"),
+			  db_get_string(&stmt));
+		error++;
+	    }
+	    else {
+		G_fatal_error(_("Error while executing: '%s'"),
+			      db_get_string(&stmt));
+	    }
+	}
     }
     else { /* parms.input */
         while (get_stmt(fd, &stmt)) {



More information about the grass-commit mailing list