summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vincent Rischmann2022-08-13 23:23:39 +0200
committerGravatar Vincent Rischmann2022-08-14 00:48:40 +0200
commit0c7f6f3944b16b279523623d5d2ff8058173ca25 (patch)
treed0b38432cba2a7bfacf5334d6426e9f2ce6d5da5
parentci: only run the workflow on a push to master (diff)
downloadzig-sqlite-0c7f6f3944b16b279523623d5d2ff8058173ca25.tar.gz
zig-sqlite-0c7f6f3944b16b279523623d5d2ff8058173ca25.tar.xz
zig-sqlite-0c7f6f3944b16b279523623d5d2ff8058173ca25.zip
require SQLite >= 3.21.0
After some testing it turns out we need at least SQLite 3.21.0 to compile. We _could_ work around this and make zig-sqlite work with older SQLite versions but I don't think it's necessary because: * "old" distributions like Debian Buster, RHEL 8 ship with SQLite > 3.21.0 * in any case if people want to build for OSes where SQLite is too old they can use the bundled source code.
Diffstat (limited to '')
-rw-r--r--c.zig11
-rw-r--r--errors.zig3
-rw-r--r--sqlite.zig6
3 files changed, 13 insertions, 7 deletions
diff --git a/c.zig b/c.zig
index a346a3a..c15b987 100644
--- a/c.zig
+++ b/c.zig
@@ -1,3 +1,14 @@
1pub const c = @cImport({ 1pub const c = @cImport({
2 @cInclude("sqlite3.h"); 2 @cInclude("sqlite3.h");
3}); 3});
4
5// versionGreaterThanOrEqualTo returns true if the SQLite version is >= to the major.minor.patch provided.
6pub fn versionGreaterThanOrEqualTo(major: u8, minor: u8, patch: u8) bool {
7 return c.SQLITE_VERSION_NUMBER >= @as(u32, major) * 1000000 + @as(u32, minor) * 1000 + @as(u32, patch);
8}
9
10comptime {
11 if (!versionGreaterThanOrEqualTo(3, 21, 0)) {
12 @compileError("must use SQLite >= 3.21.0");
13 }
14}
diff --git a/errors.zig b/errors.zig
index 2beef5f..add4b37 100644
--- a/errors.zig
+++ b/errors.zig
@@ -2,8 +2,7 @@ const std = @import("std");
2const mem = std.mem; 2const mem = std.mem;
3 3
4const c = @import("c.zig").c; 4const c = @import("c.zig").c;
5 5const versionGreaterThanOrEqualTo = @import("c.zig").versionGreaterThanOrEqualTo;
6const versionGreaterThanOrEqualTo = @import("sqlite.zig").versionGreaterThanOrEqualTo;
7 6
8pub const SQLiteExtendedIOError = error{ 7pub const SQLiteExtendedIOError = error{
9 SQLiteIOErrRead, 8 SQLiteIOErrRead,
diff --git a/sqlite.zig b/sqlite.zig
index 89ddd67..7af98b8 100644
--- a/sqlite.zig
+++ b/sqlite.zig
@@ -8,6 +8,7 @@ const mem = std.mem;
8const testing = std.testing; 8const testing = std.testing;
9 9
10const c = @import("c.zig").c; 10const c = @import("c.zig").c;
11const versionGreaterThanOrEqualTo = @import("c.zig").versionGreaterThanOrEqualTo;
11 12
12pub const ParsedQuery = @import("query.zig").ParsedQuery; 13pub const ParsedQuery = @import("query.zig").ParsedQuery;
13 14
@@ -20,11 +21,6 @@ const getDetailedErrorFromResultCode = errors.getDetailedErrorFromResultCode;
20 21
21const logger = std.log.scoped(.sqlite); 22const logger = std.log.scoped(.sqlite);
22 23
23// versionGreaterThanOrEqualTo returns true if the SQLite version is >= to the major.minor.patch provided.
24pub fn versionGreaterThanOrEqualTo(major: u8, minor: u8, patch: u8) bool {
25 return c.SQLITE_VERSION_NUMBER >= @as(u32, major) * 1000000 + @as(u32, minor) * 1000 + @as(u32, patch);
26}
27
28/// Text is used to represent a SQLite TEXT value when binding a parameter or reading a column. 24/// Text is used to represent a SQLite TEXT value when binding a parameter or reading a column.
29pub const Text = struct { data: []const u8 }; 25pub const Text = struct { data: []const u8 };
30 26