aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Ashby <martin@ashbysoft.com>2024-02-01 14:21:13 +0000
committerMartin Ashby <martin@ashbysoft.com>2024-02-01 14:21:13 +0000
commitbf5dfce3b5e49259ef7b11dea2ea364347d459d6 (patch)
tree7eb465d077c99388b02ed2ab5ed8aa742ab1d947
parent6625fd0ab6c544d0402df2c7ffce2719697ca3d8 (diff)
downloadpq-zig-bf5dfce3b5e49259ef7b11dea2ea364347d459d6.tar.gz
pq-zig-bf5dfce3b5e49259ef7b11dea2ea364347d459d6.tar.bz2
pq-zig-bf5dfce3b5e49259ef7b11dea2ea364347d459d6.tar.xz
pq-zig-bf5dfce3b5e49259ef7b11dea2ea364347d459d6.zip
update for zig master
-rw-r--r--build.zig2
-rw-r--r--build.zig.zon1
-rw-r--r--src/main.zig7
3 files changed, 6 insertions, 4 deletions
diff --git a/build.zig b/build.zig
index 37ceb1d..bf8170b 100644
--- a/build.zig
+++ b/build.zig
@@ -15,7 +15,7 @@ pub fn build(b: *std.Build) void {
lib.addIncludePath(.{ .path = "/usr/include" });
// for zig package manager
- _ = b.addModule("pq", .{ .source_file = .{ .path = "src/main.zig" } });
+ _ = b.addModule("pq", .{ .root_source_file = .{ .path = "src/main.zig" } });
b.installArtifact(lib);
diff --git a/build.zig.zon b/build.zig.zon
index c1e91ab..275ae8d 100644
--- a/build.zig.zon
+++ b/build.zig.zon
@@ -1,4 +1,5 @@
.{
.name = "pq",
.version = "0.0.1",
+ .paths = .{""},
} \ No newline at end of file
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;
}
+