authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-21 20:16:07 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-21 20:16:07 -07:00
logc6169eba24ddab92c70731cb57c2017526fcb27e
treefa2f55641edfecff1e0d4e125fd10b6cc094ec05
parent80e34e73bbaed04800ff5e7ee44416606c3039f8
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

postgresql: clean up logs


1 files changed, 4 insertions(+), 10 deletions(-)

src/postgresql.zig+4-10
......@@ -22,9 +22,9 @@ bufw: nio.BufferedWriter(4096, net.Stream),
2222bufr: nio.BufferedReader(4096, net.Stream),
2323
2424pub fn connect(allocator: std.mem.Allocator, connect_s: [:0]const u8) !Driver {
25 std.log.scoped(.zorm).info("connecting to {s} @ {s}", .{ "postgresql", connect_s });
2625 const connect_url = try url.URL.parse(allocator, connect_s, null);
2726 defer allocator.free(connect_url.href);
27 std.log.scoped(.zorm).info("connecting to {s} @ postgresql://{s}{s}", .{ "postgresql", connect_url.hostname, connect_url.pathname });
2828
2929 const addr: net.Address = try .fromUrl(&connect_url, allocator);
3030 const conn = try addr.tcpConnect();
......@@ -64,9 +64,7 @@ pub fn connect(allocator: std.mem.Allocator, connect_s: [:0]const u8) !Driver {
6464 const t: BackendMessageType = @enumFromInt(try bufr.readByte());
6565 std.debug.assert(t == .Authentication);
6666 const auth_len = try bufr.readInt(u32, .big);
67 std.log.warn("auth_len={d}", .{auth_len});
6867 const auth = try bufr.readInt(u32, .big);
69 std.log.warn("auth={d}", .{auth});
7068 switch (auth) {
7169 10 => { // AuthenticationSASL
7270 const methods = try bufr.readAlloc(allocator, auth_len - 4 - 4);
......@@ -76,7 +74,6 @@ pub fn connect(allocator: std.mem.Allocator, connect_s: [:0]const u8) !Driver {
7674 while (methods_iter.next()) |method| {
7775 const method_z = method.ptr[0..method.len :0];
7876 if (method_z.len == 0) break;
79 std.log.warn("method={s}", .{method_z});
8077
8178 // https://datatracker.ietf.org/doc/html/rfc7677
8279 // https://datatracker.ietf.org/doc/html/rfc5802
......@@ -198,7 +195,6 @@ pub fn connect(allocator: std.mem.Allocator, connect_s: [:0]const u8) !Driver {
198195 std.debug.assert(ok == 12);
199196 const data = try bufr.readAlloc(allocator, len - 8);
200197 defer allocator.free(data);
201 std.log.warn("AuthenticationSASLFinal = {s}", .{data});
202198 }
203199 { //<-AuthenticationOk
204200 const t2: BackendMessageType = @enumFromInt(try bufr.readByte());
......@@ -208,7 +204,6 @@ pub fn connect(allocator: std.mem.Allocator, connect_s: [:0]const u8) !Driver {
208204 std.debug.assert(len == 8);
209205 const ok = try bufr.readInt(u32, .big);
210206 std.debug.assert(ok == 0);
211 std.log.warn("AuthenticationOk", .{});
212207 }
213208 }
214209 }
......@@ -267,10 +262,9 @@ pub fn collect(driver: *Driver, alloc: std.mem.Allocator, comptime T: type, comp
267262//
268263
269264pub fn doesTableExist(driver: *Driver, alloc: std.mem.Allocator, name: []const u8) !bool {
270 _ = driver;
271 _ = alloc;
272 _ = name;
273 @panic("TODO");
265 const t = tracer.trace(@src(), " {s}", .{name});
266 defer t.end();
267 return try driver.first(alloc, bool, "SELECT EXISTS ( SELECT FROM pg_tables WHERE schemaname = ? AND tablename = ? )", .{ "public", name }) orelse unreachable;
274268}
275269
276270pub fn hasColumnWithName(driver: *Driver, alloc: std.mem.Allocator, comptime table: []const u8, comptime column: []const u8) !bool {