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:
+14
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user