2
0

Allow recovery from failed transaction

rollback to savepoint can recover a failed transaction. Therefore we
shouldn't block any activities while the transaction is broken. Instead
we only have the Tx.Status() method return the information.

refs #421
This commit is contained in:
Jack Christensen
2018-05-12 19:53:53 -05:00
parent e096a14b3e
commit f114ec85a1
2 changed files with 19 additions and 19 deletions
+14
View File
@@ -369,6 +369,11 @@ func TestTxStatusErrorInTransactions(t *testing.T) {
t.Fatalf("Expected status to be %v, but it was %v", pgx.TxStatusInProgress, status)
}
_, err = tx.Exec("savepoint s")
if err != nil {
t.Fatal(err)
}
_, err = tx.Exec("syntax error")
if err == nil {
t.Fatal("expected an error but did not get one")
@@ -378,6 +383,15 @@ func TestTxStatusErrorInTransactions(t *testing.T) {
t.Fatalf("Expected status to be %v, but it was %v", pgx.TxStatusInFailure, status)
}
_, err = tx.Exec("rollback to s")
if err != nil {
t.Fatal(err)
}
if status := tx.Status(); status != pgx.TxStatusInProgress {
t.Fatalf("Expected status to be %v, but it was %v", pgx.TxStatusInProgress, status)
}
if err := tx.Rollback(); err != nil {
t.Fatal(err)
}