summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vincent Rischmann2021-04-17 23:10:26 +0200
committerGravatar Vincent Rischmann2021-04-17 23:10:26 +0200
commita6057f9ab1b0fa0fabd9af014093f1c285237d8c (patch)
tree43bba1e105be6fc769478e069e2f819e6e47b9c5
parentfix DetailedError and Diagnostics formatting (diff)
downloadzig-sqlite-a6057f9ab1b0fa0fabd9af014093f1c285237d8c.tar.gz
zig-sqlite-a6057f9ab1b0fa0fabd9af014093f1c285237d8c.tar.xz
zig-sqlite-a6057f9ab1b0fa0fabd9af014093f1c285237d8c.zip
improve logs in Statement.deinit and Statement.reset
-rw-r--r--sqlite.zig9
1 files changed, 6 insertions, 3 deletions
diff --git a/sqlite.zig b/sqlite.zig
index b0576ec..15898e2 100644
--- a/sqlite.zig
+++ b/sqlite.zig
@@ -946,7 +946,8 @@ pub fn Statement(comptime opts: StatementOptions, comptime query: ParsedQuery) t
946 pub fn deinit(self: *Self) void { 946 pub fn deinit(self: *Self) void {
947 const result = c.sqlite3_finalize(self.stmt); 947 const result = c.sqlite3_finalize(self.stmt);
948 if (result != c.SQLITE_OK) { 948 if (result != c.SQLITE_OK) {
949 logger.err("unable to finalize prepared statement, result: {}", .{result}); 949 const detailed_error = getLastDetailedErrorFromDb(self.db);
950 logger.err("unable to finalize prepared statement, result: {}, detailed error: {}", .{ result, detailed_error });
950 } 951 }
951 } 952 }
952 953
@@ -954,12 +955,14 @@ pub fn Statement(comptime opts: StatementOptions, comptime query: ParsedQuery) t
954 pub fn reset(self: *Self) void { 955 pub fn reset(self: *Self) void {
955 const result = c.sqlite3_clear_bindings(self.stmt); 956 const result = c.sqlite3_clear_bindings(self.stmt);
956 if (result != c.SQLITE_OK) { 957 if (result != c.SQLITE_OK) {
957 logger.err("unable to clear prepared statement bindings, result: {}", .{result}); 958 const detailed_error = getLastDetailedErrorFromDb(self.db);
959 logger.err("unable to clear prepared statement bindings, result: {}, detailed error: {}", .{ result, detailed_error });
958 } 960 }
959 961
960 const result2 = c.sqlite3_reset(self.stmt); 962 const result2 = c.sqlite3_reset(self.stmt);
961 if (result2 != c.SQLITE_OK) { 963 if (result2 != c.SQLITE_OK) {
962 logger.err("unable to reset prepared statement, result: {}", .{result2}); 964 const detailed_error = getLastDetailedErrorFromDb(self.db);
965 logger.err("unable to reset prepared statement, result: {}, detailed error: {}", .{ result2, detailed_error });
963 } 966 }
964 } 967 }
965 968