aboutsummaryrefslogtreecommitdiff
path: root/src/conn/conn.zig
diff options
context:
space:
mode:
authorMartin Ashby <martin@ashbysoft.com>2023-09-28 20:33:07 +0100
committerMartin Ashby <martin@ashbysoft.com>2023-09-28 20:59:36 +0100
commit6de632a41bdd127e92de68d61a18dfee91b8b188 (patch)
tree62da46d109d442de5691da7816ac976fd429563d /src/conn/conn.zig
parentc00a7cd57be154b5a770a397319c8c8ad35c98b6 (diff)
downloadpgz-6de632a41bdd127e92de68d61a18dfee91b8b188.tar.gz
pgz-6de632a41bdd127e92de68d61a18dfee91b8b188.tar.bz2
pgz-6de632a41bdd127e92de68d61a18dfee91b8b188.tar.xz
pgz-6de632a41bdd127e92de68d61a18dfee91b8b188.zip
Bring Query message up to latest thinking
Diffstat (limited to 'src/conn/conn.zig')
-rw-r--r--src/conn/conn.zig31
1 files changed, 22 insertions, 9 deletions
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