| author | |
| committer | |
| log | f2443019d035e6e913acb01a7ebd79239c305b94 |
| tree | 01479a1ecb696de1065ae160c7670067393b19c7 |
| parent | 0a6e76199ea3cd2165fd41f4e8330e445b5f2800 |
| signature |
4 files changed, 4 insertions(+), 35 deletions(-)
README.md+1-1| ... | ... | @@ -3,7 +3,7 @@ |
| 3 | 3 |  |
| 4 | 4 | [](https://github.com/nektro/zig-zorm/blob/master/LICENSE) |
| 5 | 5 | [](https://github.com/sponsors/nektro) |
| 6 | [](https://ziglang.org/) | |
| 6 | [](https://ziglang.org/) | |
| 7 | 7 | [](https://github.com/nektro/zigmod) |
| 8 | 8 | |
| 9 | 9 | The database library for Zig. |
src/lib.zig-12| ... | ... | @@ -28,18 +28,6 @@ pub const Engine = union(DriverType) { |
| 28 | 28 | }; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | pub fn lock(engine: *Engine) void { | |
| 32 | return switch (engine.*) { | |
| 33 | inline else => |*e| e.lock(), | |
| 34 | }; | |
| 35 | } | |
| 36 | ||
| 37 | pub fn unlock(engine: *Engine) void { | |
| 38 | return switch (engine.*) { | |
| 39 | inline else => |*e| e.unlock(), | |
| 40 | }; | |
| 41 | } | |
| 42 | ||
| 43 | 31 | pub fn exec(engine: *Engine, alloc: std.mem.Allocator, comptime query: []const u8, args: anytype) !void { |
| 44 | 32 | return switch (engine.*) { |
| 45 | 33 | inline else => |*e| e.exec(alloc, query, args), |
src/postgresql.zig+3-12| ... | ... | @@ -16,7 +16,6 @@ const sys = switch (builtin.target.os.tag) { |
| 16 | 16 | |
| 17 | 17 | const Driver = @This(); |
| 18 | 18 | |
| 19 | mutex: std.Thread.Mutex, | |
| 20 | 19 | conn: net.Stream, |
| 21 | 20 | bufw: nio.BufferedWriter(4096, net.Stream), |
| 22 | 21 | bufr: nio.BufferedReader(4096, net.Stream), |
| ... | ... | @@ -178,7 +177,8 @@ pub fn connect(allocator: std.mem.Allocator, connect_s: [:0]const u8) !Driver { |
| 178 | 177 | const client_signature = hmacv(Hmac, &stored_key, auth_messagev); |
| 179 | 178 | const client_proof = xor(client_key, client_signature); |
| 180 | 179 | try fbs.writeAll(",p="); |
| 181 | try Base64Enc.encodeWriter(&fbs, &client_proof); | |
| 180 | var stdw: std.Io.Writer = .fixed(fbs.written()); | |
| 181 | try Base64Enc.encodeWriter(&stdw, &client_proof); | |
| 182 | 182 | |
| 183 | 183 | try proto.SASLResponse.write( |
| 184 | 184 | &bufw, |
| ... | ... | @@ -214,7 +214,6 @@ pub fn connect(allocator: std.mem.Allocator, connect_s: [:0]const u8) !Driver { |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | return .{ |
| 217 | .mutex = .{}, | |
| 218 | 217 | .conn = conn, |
| 219 | 218 | .bufw = bufw, |
| 220 | 219 | .bufr = bufr, |
| ... | ... | @@ -225,14 +224,6 @@ pub fn close(driver: *Driver) void { |
| 225 | 224 | driver.conn.close(); |
| 226 | 225 | } |
| 227 | 226 | |
| 228 | pub fn lock(driver: *Driver) void { | |
| 229 | driver.mutex.lock(); | |
| 230 | } | |
| 231 | ||
| 232 | pub fn unlock(driver: *Driver) void { | |
| 233 | driver.mutex.unlock(); | |
| 234 | } | |
| 235 | ||
| 236 | 227 | // |
| 237 | 228 | |
| 238 | 229 | 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 |
| 442 | 433 | defer allocator.free(data); |
| 443 | 434 | var iter = std.mem.splitScalar(u8, data, 0); |
| 444 | 435 | while (iter.next()) |f| if (f.len > 0) std.log.err("{c}: {s}", .{ f[0], f[1..] }); |
| 445 | std.posix.exit(1); | |
| 436 | std.process.exit(1); | |
| 446 | 437 | } |
src/sqlite3.zig-10| ... | ... | @@ -7,7 +7,6 @@ const extras = @import("extras"); |
| 7 | 7 | const Self = @This(); |
| 8 | 8 | |
| 9 | 9 | db: sqlite.Db = undefined, |
| 10 | mutex: std.Thread.Mutex, | |
| 11 | 10 | |
| 12 | 11 | pub fn connect(allocator: std.mem.Allocator, path: [:0]const u8) !Self { |
| 13 | 12 | 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 { |
| 21 | 20 | }, |
| 22 | 21 | .threading_mode = .SingleThread, |
| 23 | 22 | }), |
| 24 | .mutex = std.Thread.Mutex{}, | |
| 25 | 23 | }; |
| 26 | 24 | } |
| 27 | 25 | |
| ... | ... | @@ -29,14 +27,6 @@ pub fn close(self: *Self) void { |
| 29 | 27 | self.db.deinit(); |
| 30 | 28 | } |
| 31 | 29 | |
| 32 | pub fn lock(self: *Self) void { | |
| 33 | self.mutex.lock(); | |
| 34 | } | |
| 35 | ||
| 36 | pub fn unlock(self: *Self) void { | |
| 37 | self.mutex.unlock(); | |
| 38 | } | |
| 39 | ||
| 40 | 30 | fn prepare(self: *Self, comptime query: string) !sqlite.StatementType(.{}, query) { |
| 41 | 31 | return self.db.prepare(query) catch |err| switch (err) { |
| 42 | 32 | error.SQLiteError => std.debug.panic("{f}", .{self.db.getDetailedError()}), |