Native PostgreSQL driver / client for Zig
0

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'master' into dev

Karl Seguin (Aug 21, 2025, 8:10 AM +0800) f6c06098 032cc0a4

+33 -6
+1
build.zig
··· 68 68 .test_runner = .{ .path = b.path("test_runner.zig"), .mode = .simple }, 69 69 }); 70 70 addLibs(lib_test, modules); 71 + lib_test.linkLibC(); 71 72 lib_test.addLibraryPath(std.Build.LazyPath{ .cwd_relative = "/opt/openssl/lib" }); 72 73 lib_test.addIncludePath(std.Build.LazyPath{ .cwd_relative = "/opt/openssl/include" }); 73 74 lib_test.linkSystemLibrary("crypto");
+11
src/result.zig
··· 1252 1252 try t.expectSlice(u8, &.{ 174, 47, 71, 95, 128, 112, 65, 183, 186, 51, 134, 187, 168, 137, 123, 222 }, row.get([]u8, 1)); 1253 1253 } 1254 1254 1255 + test "Result: lsn" { 1256 + var c = t.connect(.{}); 1257 + defer c.deinit(); 1258 + const sql = "select $1::pg_lsn + 1"; 1259 + var result = try c.query(sql, .{ 32788447688 }); 1260 + defer result.deinit(); 1261 + 1262 + const row = (try result.next()).?; 1263 + try t.expectEqual(32788447689, row.get(i64, 0)); 1264 + } 1265 + 1255 1266 test "Row: column names" { 1256 1267 var c = t.connect(.{}); 1257 1268 defer c.deinit();
+21 -6
src/types.zig
··· 93 93 } 94 94 95 95 pub fn decode(data: []const u8, data_oid: i32) i32 { 96 - lib.assertDecodeType(i32, &.{Int32.oid.decimal}, data_oid); 96 + lib.assertDecodeType(i32, &.{Int32.oid.decimal, Xid.oid.decimal}, data_oid); 97 97 return Int32.decodeKnown(data); 98 98 } 99 99 ··· 119 119 120 120 pub fn decode(data: []const u8, data_oid: i32) i64 { 121 121 switch (data_oid) { 122 - Timestamp.oid.decimal, TimestampTz.oid.decimal => return Timestamp.decode(data, data_oid), 122 + Timestamp.oid.decimal, TimestampTz.oid.decimal => return Timestamp.decodeKnown(data), 123 123 else => { 124 - lib.assertDecodeType(i64, &.{Int64.oid.decimal}, data_oid); 124 + lib.assertDecodeType(i64, &.{Int64.oid.decimal, PgLSN.oid.decimal, Xid8.oid.decimal}, data_oid); 125 125 return Int64.decodeKnown(data); 126 126 }, 127 127 } ··· 366 366 } 367 367 return out; 368 368 } 369 + }; 370 + 371 + pub const PgLSN = struct { 372 + pub const oid = OID.make(3220); 373 + const encoding = &binary_encoding; 374 + }; 375 + 376 + pub const Xid = struct { 377 + pub const oid = OID.make(28); 378 + const encoding = &binary_encoding; 379 + }; 380 + 381 + pub const Xid8 = struct { 382 + pub const oid = OID.make(5069); 383 + const encoding = &binary_encoding; 369 384 }; 370 385 371 386 pub const MacAddr = struct { ··· 1141 1156 if (value > 255 or value < 0) return error.IntWontFit; 1142 1157 return Char.encode(@intCast(value), buf, format_pos); 1143 1158 }, 1144 - Int64.oid.decimal => return Int64.encode(@intCast(value), buf, format_pos), 1159 + Int64.oid.decimal, PgLSN.oid.decimal, Xid8.oid.decimal => return Int64.encode(@intCast(value), buf, format_pos), 1145 1160 else => return error.BindWrongType, 1146 1161 }, 1147 1162 .int => switch (oid) { ··· 1149 1164 if (value > 32767 or value < -32768) return error.IntWontFit; 1150 1165 return Int16.encode(@intCast(value), buf, format_pos); 1151 1166 }, 1152 - Int32.oid.decimal => { 1167 + Int32.oid.decimal, Xid.oid.decimal => { 1153 1168 if (value > 2147483647 or value < -2147483648) return error.IntWontFit; 1154 1169 return Int32.encode(@intCast(value), buf, format_pos); 1155 1170 }, ··· 1159 1174 if (value > 255 or value < 0) return error.IntWontFit; 1160 1175 return Char.encode(@intCast(value), buf, format_pos); 1161 1176 }, 1162 - Int64.oid.decimal => { 1177 + Int64.oid.decimal, PgLSN.oid.decimal, Xid8.oid.decimal => { 1163 1178 if (value > 9223372036854775807 or value < -9223372036854775808) { 1164 1179 return error.IntWontFit; 1165 1180 }