diff options
Diffstat (limited to '')
| -rw-r--r-- | errors.zig | 6 | ||||
| -rw-r--r-- | sqlite.zig | 5 |
2 files changed, 7 insertions, 4 deletions
| @@ -3,6 +3,8 @@ const mem = std.mem; | |||
| 3 | 3 | ||
| 4 | const c = @import("c.zig").c; | 4 | const c = @import("c.zig").c; |
| 5 | 5 | ||
| 6 | const versionGreaterThanOrEqualTo = @import("sqlite.zig").versionGreaterThanOrEqualTo; | ||
| 7 | |||
| 6 | pub const SQLiteExtendedIOError = error{ | 8 | pub const SQLiteExtendedIOError = error{ |
| 7 | SQLiteIOErrRead, | 9 | SQLiteIOErrRead, |
| 8 | SQLiteIOErrShortRead, | 10 | SQLiteIOErrShortRead, |
| @@ -127,10 +129,6 @@ pub const Error = SQLiteError || | |||
| 127 | SQLiteExtendedReadOnlyError || | 129 | SQLiteExtendedReadOnlyError || |
| 128 | SQLiteExtendedConstraintError; | 130 | SQLiteExtendedConstraintError; |
| 129 | 131 | ||
| 130 | fn versionGreaterThanOrEqualTo(major: u8, minor: u8, patch: u8) bool { | ||
| 131 | return c.SQLITE_VERSION_NUMBER >= @as(u32, major) * 1000000 + @as(u32, minor) * 1000 + @as(u32, patch); | ||
| 132 | } | ||
| 133 | |||
| 134 | pub fn errorFromResultCode(code: c_int) Error { | 132 | pub fn errorFromResultCode(code: c_int) Error { |
| 135 | // These errors are only available since 3.22.0. | 133 | // These errors are only available since 3.22.0. |
| 136 | if (comptime versionGreaterThanOrEqualTo(3, 22, 0)) { | 134 | if (comptime versionGreaterThanOrEqualTo(3, 22, 0)) { |
| @@ -20,6 +20,11 @@ const getDetailedErrorFromResultCode = errors.getDetailedErrorFromResultCode; | |||
| 20 | 20 | ||
| 21 | const logger = std.log.scoped(.sqlite); | 21 | const logger = std.log.scoped(.sqlite); |
| 22 | 22 | ||
| 23 | // versionGreaterThanOrEqualTo returns true if the SQLite version is >= to the major.minor.patch provided. | ||
| 24 | pub 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 | |||
| 23 | /// Text is used to represent a SQLite TEXT value when binding a parameter or reading a column. | 28 | /// Text is used to represent a SQLite TEXT value when binding a parameter or reading a column. |
| 24 | pub const Text = struct { data: []const u8 }; | 29 | pub const Text = struct { data: []const u8 }; |
| 25 | 30 | ||