From eae70d9b9c2deec2ab74852d4ebb0b06cb8ff119 Mon Sep 17 00:00:00 2001 From: jaina heartles Date: Sat, 10 Dec 2022 01:41:26 -0800 Subject: [PATCH] Fix transaction cleanup --- src/sql/lib.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sql/lib.zig b/src/sql/lib.zig index a3a900c..776b159 100644 --- a/src/sql/lib.zig +++ b/src/sql/lib.zig @@ -420,7 +420,7 @@ fn Tx(comptime tx_level: u8) type { if (tx_level != 0) @compileError("close must be called on root db"); if (self.conn.current_tx_level != 0) { std.log.warn("Database released while transaction in progress!", .{}); - self.rollbackUnchecked() catch {}; + self.rollbackUnchecked() catch {}; // TODO: Burn database connection } if (!self.conn.in_use.swap(false, .AcqRel)) @panic("Double close on db conection"); @@ -719,6 +719,7 @@ fn Tx(comptime tx_level: u8) type { fn rollbackUnchecked(self: Self) !void { try self.execInternal("ROLLBACK", {}, .{}, false); + self.conn.current_tx_level = 0; } }; }