[GRASS-SVN] r64282 - grass/trunk/vector/v.vect.stats

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jan 22 03:02:12 PST 2015


Author: mmetz
Date: 2015-01-22 03:02:11 -0800 (Thu, 22 Jan 2015)
New Revision: 64282

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

Modified: grass/trunk/vector/v.vect.stats/main.c
===================================================================
--- grass/trunk/vector/v.vect.stats/main.c	2015-01-22 10:26:46 UTC (rev 64281)
+++ grass/trunk/vector/v.vect.stats/main.c	2015-01-22 11:02:11 UTC (rev 64282)
@@ -371,11 +371,20 @@
 	    G_fatal_error(_("Database connection not defined for layer %d"),
 			  point_field);
 
-	Pdriver = db_start_driver_open_database(PFi->driver, PFi->database);
-	if (Pdriver == NULL)
-	    G_fatal_error(_("Unable to open database <%s> with driver <%s>"),
-			  PFi->database, PFi->driver);
 
+	/* Open points map driver and database */
+	if (Adriver && strcmp(AFi->driver, PFi->driver) == 0
+	    && strcmp(AFi->database, PFi->database) == 0) {
+	    G_debug(3, "Use the same driver");
+	    Pdriver = Adriver;
+	}
+	else {
+	    Pdriver = db_start_driver_open_database(PFi->driver, PFi->database);
+	    if (Pdriver == NULL)
+		G_fatal_error(_("Unable to open database <%s> with driver <%s>"),
+			      PFi->database, PFi->driver);
+	}
+
 	/* check if point column exists */
 	db_get_column(Pdriver, PFi->table, point_column_opt->answer, &column);
 	if (column) {
@@ -402,7 +411,9 @@
 	nrec = db_select_CatValArray(Pdriver, PFi->table, PFi->key,
 				     point_column_opt->answer, NULL, &cvarr);
 	G_debug(1, "selected values = %d", nrec);
-	db_close_database_shutdown_driver(Pdriver);
+
+	if (Pdriver != Adriver)
+	    db_close_database_shutdown_driver(Pdriver);
     }
 
     Points = Vect_new_line_struct();



More information about the grass-commit mailing list