From 6de632a41bdd127e92de68d61a18dfee91b8b188 Mon Sep 17 00:00:00 2001 From: Martin Ashby Date: Thu, 28 Sep 2023 20:33:07 +0100 Subject: Bring Query message up to latest thinking --- src/conn/conn.zig | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'src/conn') diff --git a/src/conn/conn.zig b/src/conn/conn.zig index db5084c..9d5a8e1 100644 --- a/src/conn/conn.zig +++ b/src/conn/conn.zig @@ -184,21 +184,34 @@ pub const MultiResultIterator = struct { // returns the next result iterator, or null if we've reached the end of the results pub fn next_result(self: *MultiResultIterator) !?*ResultIterator { - if (self.cri != null) { - try self.cri.?.skip_to_end(); - } + _ = self; + // if (self.cri != null) { + // try self.cri.?.skip_to_end(); + // } + return error.NotImplemented; } fn receive_message(self: *MultiResultIterator) !BackendMessage { - var msg = try self.conn.receive_message(); - switch (msg) {} - return msg; + _ = self; + // var msg = try self.conn.receive_message(); + // switch (msg) {} + // return msg; + return error.NotImplemented; } }; -// pub fn exec(self: *Conn) { - -// } +// Execute some SQL using postgres' simple query protocol +pub fn exec(self: *Conn, query: []const u8) !ResultIterator { + const qr = proto.Query{ + .query = query, + }; + var writer = self.stream.writer(); + try qr.write(self.allocator, writer); + // TODO multi result iterator since query could contain multiple queries + return ResultIterator{ + .conn = self, + }; +} test "connect unix" { // must have a local postgres runnning -- cgit v1.2.3-ZIG