[GRASS-SVN] r62095 - grass/trunk/vector/v.select

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Sep 26 08:27:55 PDT 2014


Author: martinl
Date: 2014-09-26 08:27:55 -0700 (Fri, 26 Sep 2014)
New Revision: 62095

Modified:
   grass/trunk/vector/v.select/copy_tabs.c
Log:
fix r62093: close DB driver on failure (db_set_error_handler_driver)
            fix indentation


Modified: grass/trunk/vector/v.select/copy_tabs.c
===================================================================
--- grass/trunk/vector/v.select/copy_tabs.c	2014-09-26 14:04:35 UTC (rev 62094)
+++ grass/trunk/vector/v.select/copy_tabs.c	2014-09-26 15:27:55 UTC (rev 62095)
@@ -11,7 +11,6 @@
     int i, ttype, ntabs;
 
     struct field_info *IFi, *OFi;
-    dbDriver *Driver;
     
     ntabs = 0;
     
@@ -40,6 +39,8 @@
     
     for (i = 0; i < nfields; i++) {
 	int ret;
+        
+        dbDriver *Driver;
 
 	if (fields[i] == 0)
 	    continue;
@@ -68,18 +69,21 @@
 	    Vect_map_add_dblink(Out, OFi->number, OFi->name, OFi->table,
 				IFi->key, OFi->database, OFi->driver);
 	}
-    Driver = db_start_driver_open_database(OFi->driver,
-                                  Vect_subst_var(OFi->database, Out));
-    if (Driver == NULL)
-	    G_fatal_error(_("Unable to open database <%s> by driver <%s>"),
-                      OFi->database, OFi->driver);
-    
-    if (db_create_index2(Driver, OFi->table, OFi->key) != DB_OK)
-	    G_warning(_("Unable to create index"));
-    if (db_grant_on_table
+
+        /* create index on key column */
+        Driver = db_start_driver_open_database(OFi->driver,
+                                               Vect_subst_var(OFi->database, Out));
+        if (Driver == NULL)
+            G_fatal_error(_("Unable to open database <%s> by driver <%s>"),
+                          OFi->database, OFi->driver);
+        db_set_error_handler_driver(Driver);
+        
+        if (db_create_index2(Driver, OFi->table, OFi->key) != DB_OK)
+            G_warning(_("Unable to create index"));
+        if (db_grant_on_table
 	    (Driver, OFi->table, DB_PRIV_SELECT, DB_GROUP | DB_PUBLIC) != DB_OK)
-	    G_fatal_error(_("Unable to grant privileges on table <%s>"),
-	    	    OFi->table);
+            G_fatal_error(_("Unable to grant privileges on table <%s>"),
+                          OFi->table);
 	db_close_database_shutdown_driver(Driver);
     }
 }



More information about the grass-commit mailing list