changeset 2480:242104c338ff octree-diff

Wrap writing of iso-lines of differences into a transaction.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 28 Feb 2019 17:28:54 +0100
parents c85b16db8a02
children 3cf5d27a6c8b
files cmd/octreediff/main.go
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/cmd/octreediff/main.go	Thu Feb 28 15:55:32 2019 +0100
+++ b/cmd/octreediff/main.go	Thu Feb 28 17:28:54 2019 +0100
@@ -226,6 +226,11 @@
 		}
 		defer conn.Close()
 
+		tx, err := conn.BeginTx(ctx, nil)
+		if err != nil {
+			return err
+		}
+
 		type load struct {
 			date time.Time
 			data []byte
@@ -261,7 +266,7 @@
 			{date: secondDate, dst: &second, err: &secondErr},
 		} {
 			var data []byte
-			if err := conn.QueryRowContext(
+			if err := tx.QueryRowContext(
 				ctx,
 				loadOctreeSQL,
 				bottleneck,
@@ -358,7 +363,7 @@
 
 		var tin octree.Tin
 
-		if err := conn.QueryRowContext(
+		if err := tx.QueryRowContext(
 			ctx,
 			triangulateSQL,
 			bottleneck,
@@ -414,7 +419,7 @@
 
 		var dataSize int
 
-		stmt, err := conn.PrepareContext(ctx, insertContourSQL)
+		stmt, err := tx.PrepareContext(ctx, insertContourSQL)
 		if err != nil {
 			return err
 		}
@@ -445,7 +450,7 @@
 		log.Printf("generating iso lines took %v\n", now.Sub(last))
 		last = now
 
-		return nil
+		return tx.Commit()
 	})
 }