Selaa lähdekoodia

Implemented the rollback function of postgresql, fixed t.*.mapcalc bug

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@56516 15284696-431f-4ddb-bdfa-cd5b030d7da7
Soeren Gebbert 12 vuotta sitten
vanhempi
commit
404642d6a7

+ 1 - 0
lib/python/temporal/abstract_space_time_dataset.py

@@ -1017,6 +1017,7 @@ class AbstractSpaceTimeDataset(AbstractDataset):
                 where, order, dbif)
         except:
             try:
+                dbif.rollback()
                 rows = self.get_registered_maps(
                     "id,start_time,end_time", 
                     where, order, dbif)

+ 11 - 0
lib/python/temporal/core.py

@@ -370,6 +370,17 @@ class SQLDatabaseInterfaceConnection():
             self.dbmi = sqlite3
         else:
             self.dbmi = psycopg2
+            
+    def rollback(self):
+        """
+            Roll back the last transaction. This must be called 
+            in case a new query should be performed after a db error.
+            
+            This is only relevant for postgresql database.
+        """
+        if self.dbmi.__name__ == "psycopg2":
+            if self.connected:
+                self.connection.rollback()
 
     def connect(self):
         """!Connect to the DBMI to execute SQL statements

+ 2 - 2
lib/python/temporal/mapcalc.py

@@ -300,11 +300,11 @@ def dataset_mapcalculator(inputs, output, type, expression, base, method,
             proc_list[proc_count].start()
             proc_count += 1
 
-            if proc_count == nprocs or proc_count == num:
+            if proc_count == nprocs or proc_count == num or count == num:
                 proc_count = 0
                 exitcodes = 0
-                proc.join()
                 for proc in proc_list:
+                    proc.join()
                     exitcodes += proc.exitcode
 
                 if exitcodes != 0: