authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-08-20 13:08:42-07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-08-20 13:08:42-07:00
log65e9877c4d65eb4fb5bf9f2863f695afca7ff8fb
tree2c561adf62ae07d492f8ac03a9492a753035c705
parent3808c55d4ca3ef25fd865c530b458fdc2dff5a4f
signature Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

sqlite3: wrap sqlite3_bind_blob64 too


1 files changed, 11 insertions(+), 1 deletions(-)

src/sqlite3.zig+11-1
......@@ -321,7 +321,7 @@ pub const Statement = struct {
321321 return bindText(stmt, idx, value, SQLITE_STATIC);
322322 }
323323 if (comptime extras.isArrayOf(u8)(T)) {
324 return s.please_d(stmt.db, c.sqlite3_bind_blob64(stmt.stmt, @intCast(idx), &value, value.len, SQLITE_TRANSIENT));
324 return bindBlob(stmt, idx, &value, SQLITE_TRANSIENT);
325325 }
326326 switch (@typeInfo(T)) {
327327 .@"struct" => |info| {
......@@ -384,6 +384,16 @@ pub const Statement = struct {
384384 return s.please_d(stmt.db, c.sqlite3_bind_text64(stmt.stmt, @intCast(idx), value.ptr, value.len, destructor_real, c.SQLITE_UTF8));
385385 }
386386
387 fn bindBlob(stmt: Statement, idx: usize, value: []const u8, destructor: *allowzero anyopaque) !void {
388 const destructor_real: c.sqlite3_destructor_type = blk: {
389 // https://github.com/ziglang/translate-c/issues/128
390 @setRuntimeSafety(false);
391 const ptr: c.sqlite3_destructor_type = @ptrCast(@alignCast(destructor));
392 break :blk ptr;
393 };
394 return s.please_d(stmt.db, c.sqlite3_bind_blob64(stmt.stmt, @intCast(idx), value.ptr, value.len, destructor_real));
395 }
396
387397 pub fn exec(stmt: Statement, allocator: std.mem.Allocator) !void {
388398 const iter = stmt.iterate();
389399 errdefer iter.reset();