瀏覽代碼

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 年之前
父節點
當前提交
404642d6a7
共有 3 個文件被更改,包括 14 次插入2 次删除
  1. 1 0
      lib/python/temporal/abstract_space_time_dataset.py
  2. 11 0
      lib/python/temporal/core.py
  3. 2 2
      lib/python/temporal/mapcalc.py

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

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

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

@@ -370,6 +370,17 @@ class SQLDatabaseInterfaceConnection():
             self.dbmi = sqlite3
             self.dbmi = sqlite3
         else:
         else:
             self.dbmi = psycopg2
             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):
     def connect(self):
         """!Connect to the DBMI to execute SQL statements
         """!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_list[proc_count].start()
             proc_count += 1
             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
                 proc_count = 0
                 exitcodes = 0
                 exitcodes = 0
-                proc.join()
                 for proc in proc_list:
                 for proc in proc_list:
+                    proc.join()
                     exitcodes += proc.exitcode
                     exitcodes += proc.exitcode
 
 
                 if exitcodes != 0:
                 if exitcodes != 0: