[GRASS-SVN] r64280 - grass/trunk/vector/v.reclass

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jan 22 01:50:42 PST 2015


Author: mmetz
Date: 2015-01-22 01:50:42 -0800 (Thu, 22 Jan 2015)
New Revision: 64280

Modified:
   grass/trunk/vector/v.reclass/main.c
Log:
v.reclass: accommodate SQLite

Modified: grass/trunk/vector/v.reclass/main.c
===================================================================
--- grass/trunk/vector/v.reclass/main.c	2015-01-22 09:38:42 UTC (rev 64279)
+++ grass/trunk/vector/v.reclass/main.c	2015-01-22 09:50:42 UTC (rev 64280)
@@ -171,12 +171,22 @@
 	    Vect_map_add_dblink(&Out, field, NULL, NewFi->table, GV_KEY_COLUMN,
 				NewFi->database, NewFi->driver);
 
-	    Driver2 = db_start_driver_open_database(NewFi->driver,
-						    Vect_subst_var(NewFi->
-								   database,
-								   &Out));
-            db_set_error_handler_driver(Driver2);
 
+	    /* Open output driver and database */
+	    if (strcmp(Fi->driver, NewFi->driver) == 0
+		&& strcmp(Fi->database,
+		          Vect_subst_var(NewFi->database, &Out)) == 0) {
+		G_debug(3, "Use the same driver");
+		Driver2 = Driver;
+	    }
+	    else {
+		Driver2 = db_start_driver_open_database(NewFi->driver,
+							Vect_subst_var(NewFi->
+								       database,
+								       &Out));
+		db_set_error_handler_driver(Driver2);
+	    }
+
 	    /* get string column length */
 	    db_set_string(&stmt, Fi->table);
 	    if (db_describe_table(Driver, &stmt, &table) != DB_OK) {
@@ -317,7 +327,8 @@
 		G_fatal_error(_("Unable to grant privileges on table <%s>"),
 			      NewFi->table);
 	    }
-	    db_close_database_shutdown_driver(Driver2);
+	    if (Driver2 != Driver)
+		db_close_database_shutdown_driver(Driver2);
 
 	    qsort((void *)cvarr.value, nrows, sizeof(dbCatVal), cmpcat);
 	}



More information about the grass-commit mailing list