diff options
author | Martin Ashby <martin@ashbysoft.com> | 2024-02-01 14:21:13 +0000 |
---|---|---|
committer | Martin Ashby <martin@ashbysoft.com> | 2024-02-01 14:21:13 +0000 |
commit | bf5dfce3b5e49259ef7b11dea2ea364347d459d6 (patch) | |
tree | 7eb465d077c99388b02ed2ab5ed8aa742ab1d947 /src | |
parent | 6625fd0ab6c544d0402df2c7ffce2719697ca3d8 (diff) | |
download | pq-zig-bf5dfce3b5e49259ef7b11dea2ea364347d459d6.tar.gz pq-zig-bf5dfce3b5e49259ef7b11dea2ea364347d459d6.tar.bz2 pq-zig-bf5dfce3b5e49259ef7b11dea2ea364347d459d6.tar.xz pq-zig-bf5dfce3b5e49259ef7b11dea2ea364347d459d6.zip |
update for zig master
Diffstat (limited to 'src')
-rw-r--r-- | src/main.zig | 7 |
1 files changed, 4 insertions, 3 deletions
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; } + |