From bf5dfce3b5e49259ef7b11dea2ea364347d459d6 Mon Sep 17 00:00:00 2001 From: Martin Ashby Date: Thu, 1 Feb 2024 14:21:13 +0000 Subject: update for zig master --- src/main.zig | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/main.zig b/src/main.zig index a4fc382..df6b2c9 100644 --- a/src/main.zig +++ b/src/main.zig @@ -14,7 +14,7 @@ pub const Db = struct { std.log.err("PQisthreadsafe returned 0, can't use libpq in this program", .{}); return PqError.PqError; } - var maybe_conn: ?*pq.PGconn = pq.PQconnectdb(connect_url); + const maybe_conn: ?*pq.PGconn = pq.PQconnectdb(connect_url); if (maybe_conn == null) { std.log.err("PQconnectdb returned null", .{}); return PqError.PqError; @@ -37,9 +37,9 @@ pub const Db = struct { } pub fn exec(self: Db, query: [:0]const u8) !void { - var res: ?*pq.PGresult = pq.PQexec(self.c_conn, query); + const res: ?*pq.PGresult = pq.PQexec(self.c_conn, query); defer pq.PQclear(res); - var est: pq.ExecStatusType = pq.PQresultStatus(res); + const est: pq.ExecStatusType = pq.PQresultStatus(res); if (est != pq.PGRES_COMMAND_OK) { std.log.err("PQexec error code {} message {s}", .{ est, pq.PQerrorMessage(self.c_conn) }); return PqError.PqError; @@ -149,3 +149,4 @@ pub fn addZ(comptime length: usize, value: [length]u8) [length:0]u8 { @memcpy(&terminated_value, &value); return terminated_value; } + -- cgit v1.2.3-ZIG