Mercurial > gemma
diff pkg/controllers/report.go @ 5333:6c0f40676984 extented-report
Run xlsx templating in a read-only transaction.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 01 Jun 2021 00:37:03 +0200 |
parents | 348d91848278 |
children | 699048c86848 |
line wrap: on
line diff
--- a/pkg/controllers/report.go Tue Jun 01 00:23:25 2021 +0200 +++ b/pkg/controllers/report.go Tue Jun 01 00:37:03 2021 +0200 @@ -14,6 +14,7 @@ package controllers import ( + "database/sql" "fmt" "log" "net/http" @@ -157,7 +158,10 @@ ctx := req.Context() conn := middleware.GetDBConn(req) - if err := action.Execute(ctx, conn, template); err != nil { + tx, err := conn.BeginTx(ctx, &sql.TxOptions{ReadOnly: true}) + defer tx.Rollback() + + if err := action.Execute(ctx, tx, template); err != nil { log.Printf("error: %v\n", err) http.Error(rw, "Error: "+err.Error(), http.StatusInternalServerError) return