From f2443019d035e6e913acb01a7ebd79239c305b94 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Wed, 10 Jun 2026 01:41:36 -0700 Subject: [PATCH] update to zig 0.16.0 --- README.md | 2 +- src/lib.zig | 12 ------------ src/postgresql.zig | 15 +++------------ src/sqlite3.zig | 10 ---------- 4 files changed, 4 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 9e5889ddf39bf5d47102a69fbb85a3e8f7d322e0..520dd5b004a86e9a5b4696ce01899158e4a860ab 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ![loc](https://sloc.xyz/github/nektro/zig-zorm) [![license](https://img.shields.io/github/license/nektro/zig-zorm.svg)](https://github.com/nektro/zig-zorm/blob/master/LICENSE) [![nektro @ github sponsors](https://img.shields.io/badge/sponsors-nektro-purple?logo=github)](https://github.com/sponsors/nektro) -[![Zig](https://img.shields.io/badge/Zig-0.15-f7a41d)](https://ziglang.org/) +[![Zig](https://img.shields.io/badge/Zig-0.16-f7a41d)](https://ziglang.org/) [![Zigmod](https://img.shields.io/badge/Zigmod-latest-f7a41d)](https://github.com/nektro/zigmod) The database library for Zig. diff --git a/src/lib.zig b/src/lib.zig index 3aed2d7a9ee06cf061ae65aef0e913bf2d7d1a15..f74f4330c9ae08df23f5d963261bf19c4011ebfa 100644 --- a/src/lib.zig +++ b/src/lib.zig @@ -28,18 +28,6 @@ pub const Engine = union(DriverType) { }; } - pub fn lock(engine: *Engine) void { - return switch (engine.*) { - inline else => |*e| e.lock(), - }; - } - - pub fn unlock(engine: *Engine) void { - return switch (engine.*) { - inline else => |*e| e.unlock(), - }; - } - pub fn exec(engine: *Engine, alloc: std.mem.Allocator, comptime query: []const u8, args: anytype) !void { return switch (engine.*) { inline else => |*e| e.exec(alloc, query, args), diff --git a/src/postgresql.zig b/src/postgresql.zig index e0f57f00ede89a4700e7cdacd30fe7ce26478a48..26506964778e166bf95800b0df88e6c4e8af64f9 100644 --- a/src/postgresql.zig +++ b/src/postgresql.zig @@ -16,7 +16,6 @@ const sys = switch (builtin.target.os.tag) { const Driver = @This(); -mutex: std.Thread.Mutex, conn: net.Stream, bufw: nio.BufferedWriter(4096, net.Stream), bufr: nio.BufferedReader(4096, net.Stream), @@ -178,7 +177,8 @@ pub fn connect(allocator: std.mem.Allocator, connect_s: [:0]const u8) !Driver { const client_signature = hmacv(Hmac, &stored_key, auth_messagev); const client_proof = xor(client_key, client_signature); try fbs.writeAll(",p="); - try Base64Enc.encodeWriter(&fbs, &client_proof); + var stdw: std.Io.Writer = .fixed(fbs.written()); + try Base64Enc.encodeWriter(&stdw, &client_proof); try proto.SASLResponse.write( &bufw, @@ -214,7 +214,6 @@ pub fn connect(allocator: std.mem.Allocator, connect_s: [:0]const u8) !Driver { } return .{ - .mutex = .{}, .conn = conn, .bufw = bufw, .bufr = bufr, @@ -225,14 +224,6 @@ pub fn close(driver: *Driver) void { driver.conn.close(); } -pub fn lock(driver: *Driver) void { - driver.mutex.lock(); -} - -pub fn unlock(driver: *Driver) void { - driver.mutex.unlock(); -} - // pub fn exec(driver: *Driver, alloc: std.mem.Allocator, comptime query: []const u8, args: anytype) !void { @@ -442,5 +433,5 @@ fn printError(bufr: *nio.BufferedReader(4096, net.Stream), allocator: std.mem.Al defer allocator.free(data); var iter = std.mem.splitScalar(u8, data, 0); while (iter.next()) |f| if (f.len > 0) std.log.err("{c}: {s}", .{ f[0], f[1..] }); - std.posix.exit(1); + std.process.exit(1); } diff --git a/src/sqlite3.zig b/src/sqlite3.zig index 0f302325bb81f58dc5d6ba4f231d51e5fe835c42..9f4ddb51e5f8f84a324b8225431f008d3b9df706 100644 --- a/src/sqlite3.zig +++ b/src/sqlite3.zig @@ -7,7 +7,6 @@ const extras = @import("extras"); const Self = @This(); db: sqlite.Db = undefined, -mutex: std.Thread.Mutex, pub fn connect(allocator: std.mem.Allocator, path: [:0]const u8) !Self { std.log.scoped(.zorm).info("connecting to {s} @ {s}", .{ "sqlite3", path }); @@ -21,7 +20,6 @@ pub fn connect(allocator: std.mem.Allocator, path: [:0]const u8) !Self { }, .threading_mode = .SingleThread, }), - .mutex = std.Thread.Mutex{}, }; } @@ -29,14 +27,6 @@ pub fn close(self: *Self) void { self.db.deinit(); } -pub fn lock(self: *Self) void { - self.mutex.lock(); -} - -pub fn unlock(self: *Self) void { - self.mutex.unlock(); -} - fn prepare(self: *Self, comptime query: string) !sqlite.StatementType(.{}, query) { return self.db.prepare(query) catch |err| switch (err) { error.SQLiteError => std.debug.panic("{f}", .{self.db.getDetailedError()}), -- 2.54.0