diff options
Diffstat (limited to '')
| -rw-r--r-- | build.zig | 35 | ||||
| -rw-r--r-- | build/Preprocessor.zig | 22 | ||||
| -rw-r--r-- | c/loadable_extension.zig | 106 | ||||
| -rw-r--r-- | errors.zig | 5 | ||||
| -rw-r--r-- | examples/zigcrypto.zig | 2 | ||||
| -rw-r--r-- | examples/zigcrypto_test.zig | 4 | ||||
| -rw-r--r-- | sqlite.zig | 37 | ||||
| -rw-r--r-- | vtab.zig | 38 |
8 files changed, 132 insertions, 117 deletions
| @@ -110,10 +110,15 @@ fn computeTestTargets(isNative: bool, ci: ?bool) ?[]const TestTarget { | |||
| 110 | 110 | ||
| 111 | // This creates a SQLite static library from the SQLite dependency code. | 111 | // This creates a SQLite static library from the SQLite dependency code. |
| 112 | fn makeSQLiteLib(b: *std.Build, dep: *std.Build.Dependency, c_flags: []const []const u8, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, sqlite_c: enum { with, without }) *std.Build.Step.Compile { | 112 | fn makeSQLiteLib(b: *std.Build, dep: *std.Build.Dependency, c_flags: []const []const u8, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, sqlite_c: enum { with, without }) *std.Build.Step.Compile { |
| 113 | const lib = b.addStaticLibrary(.{ | 113 | const mod = b.addModule("lib-sqlite", .{ |
| 114 | .name = "sqlite", | ||
| 115 | .target = target, | 114 | .target = target, |
| 116 | .optimize = optimize, | 115 | .optimize = optimize, |
| 116 | .link_libc = true, | ||
| 117 | }); | ||
| 118 | const lib = b.addLibrary(.{ | ||
| 119 | .name = "sqlite", | ||
| 120 | .linkage = .dynamic, | ||
| 121 | .root_module = mod, | ||
| 117 | }); | 122 | }); |
| 118 | 123 | ||
| 119 | lib.addIncludePath(dep.path(".")); | 124 | lib.addIncludePath(dep.path(".")); |
| @@ -128,7 +133,6 @@ fn makeSQLiteLib(b: *std.Build, dep: *std.Build.Dependency, c_flags: []const []c | |||
| 128 | .file = b.path("c/workaround.c"), | 133 | .file = b.path("c/workaround.c"), |
| 129 | .flags = c_flags, | 134 | .flags = c_flags, |
| 130 | }); | 135 | }); |
| 131 | lib.linkLibC(); | ||
| 132 | 136 | ||
| 133 | return lib; | 137 | return lib; |
| 134 | } | 138 | } |
| @@ -225,13 +229,17 @@ pub fn build(b: *std.Build) !void { | |||
| 225 | 229 | ||
| 226 | const test_sqlite_lib = makeSQLiteLib(b, sqlite_dep, c_flags, cross_target, optimize, .with); | 230 | const test_sqlite_lib = makeSQLiteLib(b, sqlite_dep, c_flags, cross_target, optimize, .with); |
| 227 | 231 | ||
| 228 | const tests = b.addTest(.{ | 232 | const mod = b.addModule(test_name, .{ |
| 229 | .name = test_name, | ||
| 230 | .target = cross_target, | 233 | .target = cross_target, |
| 231 | .optimize = optimize, | 234 | .optimize = optimize, |
| 232 | .root_source_file = b.path("sqlite.zig"), | 235 | .root_source_file = b.path("sqlite.zig"), |
| 233 | .single_threaded = test_target.single_threaded, | 236 | .single_threaded = test_target.single_threaded, |
| 234 | }); | 237 | }); |
| 238 | |||
| 239 | const tests = b.addTest(.{ | ||
| 240 | .name = test_name, | ||
| 241 | .root_module = mod, | ||
| 242 | }); | ||
| 235 | tests.addIncludePath(b.path("c")); | 243 | tests.addIncludePath(b.path("c")); |
| 236 | tests.addIncludePath(sqlite_dep.path(".")); | 244 | tests.addIncludePath(sqlite_dep.path(".")); |
| 237 | tests.linkLibrary(test_sqlite_lib); | 245 | tests.linkLibrary(test_sqlite_lib); |
| @@ -282,13 +290,17 @@ fn addPreprocessStep(b: *std.Build, sqlite_dep: *std.Build.Dependency) void { | |||
| 282 | } | 290 | } |
| 283 | 291 | ||
| 284 | fn addZigcrypto(b: *std.Build, sqlite_mod: *std.Build.Module, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode) *std.Build.Step.InstallArtifact { | 292 | fn addZigcrypto(b: *std.Build, sqlite_mod: *std.Build.Module, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode) *std.Build.Step.InstallArtifact { |
| 285 | const exe = b.addSharedLibrary(.{ | 293 | const mod = b.addModule("zigcryto", .{ |
| 286 | .name = "zigcrypto", | ||
| 287 | .root_source_file = b.path("examples/zigcrypto.zig"), | 294 | .root_source_file = b.path("examples/zigcrypto.zig"), |
| 288 | .version = null, | ||
| 289 | .target = getTarget(target), | 295 | .target = getTarget(target), |
| 290 | .optimize = optimize, | 296 | .optimize = optimize, |
| 291 | }); | 297 | }); |
| 298 | const exe = b.addLibrary(.{ | ||
| 299 | .name = "zigcrypto", | ||
| 300 | .root_module = mod, | ||
| 301 | .version = null, | ||
| 302 | .linkage = .dynamic, | ||
| 303 | }); | ||
| 292 | exe.root_module.addImport("sqlite", sqlite_mod); | 304 | exe.root_module.addImport("sqlite", sqlite_mod); |
| 293 | 305 | ||
| 294 | const install_artifact = b.addInstallArtifact(exe, .{}); | 306 | const install_artifact = b.addInstallArtifact(exe, .{}); |
| @@ -298,12 +310,15 @@ fn addZigcrypto(b: *std.Build, sqlite_mod: *std.Build.Module, target: std.Build. | |||
| 298 | } | 310 | } |
| 299 | 311 | ||
| 300 | fn addZigcryptoTestRun(b: *std.Build, sqlite_mod: *std.Build.Module, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode) *std.Build.Step.Run { | 312 | fn addZigcryptoTestRun(b: *std.Build, sqlite_mod: *std.Build.Module, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode) *std.Build.Step.Run { |
| 301 | const zigcrypto_test = b.addExecutable(.{ | 313 | const mod = b.addModule("zigcryto-test", .{ |
| 302 | .name = "zigcrypto-test", | ||
| 303 | .root_source_file = b.path("examples/zigcrypto_test.zig"), | 314 | .root_source_file = b.path("examples/zigcrypto_test.zig"), |
| 304 | .target = getTarget(target), | 315 | .target = getTarget(target), |
| 305 | .optimize = optimize, | 316 | .optimize = optimize, |
| 306 | }); | 317 | }); |
| 318 | const zigcrypto_test = b.addExecutable(.{ | ||
| 319 | .name = "zigcrypto-test", | ||
| 320 | .root_module = mod, | ||
| 321 | }); | ||
| 307 | zigcrypto_test.root_module.addImport("sqlite", sqlite_mod); | 322 | zigcrypto_test.root_module.addImport("sqlite", sqlite_mod); |
| 308 | 323 | ||
| 309 | const install = b.addInstallArtifact(zigcrypto_test, .{}); | 324 | const install = b.addInstallArtifact(zigcrypto_test, .{}); |
diff --git a/build/Preprocessor.zig b/build/Preprocessor.zig index a069523..f3d0dc6 100644 --- a/build/Preprocessor.zig +++ b/build/Preprocessor.zig | |||
| @@ -27,10 +27,10 @@ const mem = std.mem; | |||
| 27 | fn readOriginalData(allocator: mem.Allocator, path: []const u8) ![]const u8 { | 27 | fn readOriginalData(allocator: mem.Allocator, path: []const u8) ![]const u8 { |
| 28 | var file = try std.fs.cwd().openFile(path, .{}); | 28 | var file = try std.fs.cwd().openFile(path, .{}); |
| 29 | defer file.close(); | 29 | defer file.close(); |
| 30 | var buf: [1024]u8 = undefined; | ||
| 31 | var reader = file.reader(&buf); | ||
| 30 | 32 | ||
| 31 | var reader = file.reader(); | 33 | const data = reader.interface.readAlloc(allocator, 1024 * 1024); |
| 32 | |||
| 33 | const data = reader.readAllAlloc(allocator, 1024 * 1024); | ||
| 34 | return data; | 34 | return data; |
| 35 | } | 35 | } |
| 36 | 36 | ||
| @@ -127,13 +127,13 @@ const Processor = struct { | |||
| 127 | switch (range) { | 127 | switch (range) { |
| 128 | .delete => |dr| { | 128 | .delete => |dr| { |
| 129 | const to_write = self.data[pos..dr.start]; | 129 | const to_write = self.data[pos..dr.start]; |
| 130 | try writer.writeAll(to_write); | 130 | try writer.interface.writeAll(to_write); |
| 131 | pos = dr.end; | 131 | pos = dr.end; |
| 132 | }, | 132 | }, |
| 133 | .replace => |rr| { | 133 | .replace => |rr| { |
| 134 | const to_write = self.data[pos..rr.start]; | 134 | const to_write = self.data[pos..rr.start]; |
| 135 | try writer.writeAll(to_write); | 135 | try writer.interface.writeAll(to_write); |
| 136 | try writer.writeAll(rr.replacement); | 136 | try writer.interface.writeAll(rr.replacement); |
| 137 | pos = rr.end; | 137 | pos = rr.end; |
| 138 | }, | 138 | }, |
| 139 | } | 139 | } |
| @@ -148,7 +148,7 @@ const Processor = struct { | |||
| 148 | // Finally append the remaining data in the buffer (the last range will probably not be the end of the file) | 148 | // Finally append the remaining data in the buffer (the last range will probably not be the end of the file) |
| 149 | if (pos < self.data.len) { | 149 | if (pos < self.data.len) { |
| 150 | const remaining_data = self.data[pos..]; | 150 | const remaining_data = self.data[pos..]; |
| 151 | try writer.writeAll(remaining_data); | 151 | try writer.interface.writeAll(remaining_data); |
| 152 | } | 152 | } |
| 153 | } | 153 | } |
| 154 | }; | 154 | }; |
| @@ -196,7 +196,9 @@ pub fn sqlite3(allocator: mem.Allocator, input_path: []const u8, output_path: [] | |||
| 196 | defer output_file.close(); | 196 | defer output_file.close(); |
| 197 | 197 | ||
| 198 | try output_file.writeAll("/* sqlite3.h edited by the zig-sqlite build script */\n"); | 198 | try output_file.writeAll("/* sqlite3.h edited by the zig-sqlite build script */\n"); |
| 199 | try processor.dump(output_file.writer()); | 199 | var buf: [1024]u8 = undefined; |
| 200 | var out_writer = output_file.writer(&buf); | ||
| 201 | try processor.dump(&out_writer); | ||
| 200 | } | 202 | } |
| 201 | 203 | ||
| 202 | pub fn sqlite3ext(allocator: mem.Allocator, input_path: []const u8, output_path: []const u8) !void { | 204 | pub fn sqlite3ext(allocator: mem.Allocator, input_path: []const u8, output_path: []const u8) !void { |
| @@ -232,5 +234,7 @@ pub fn sqlite3ext(allocator: mem.Allocator, input_path: []const u8, output_path: | |||
| 232 | defer output_file.close(); | 234 | defer output_file.close(); |
| 233 | 235 | ||
| 234 | try output_file.writeAll("/* sqlite3ext.h edited by the zig-sqlite build script */\n"); | 236 | try output_file.writeAll("/* sqlite3ext.h edited by the zig-sqlite build script */\n"); |
| 235 | try processor.dump(output_file.writer()); | 237 | var buf: [1024]u8 = undefined; |
| 238 | var out_writer = output_file.writer(&buf); | ||
| 239 | try processor.dump(&out_writer); | ||
| 236 | } | 240 | } |
diff --git a/c/loadable_extension.zig b/c/loadable_extension.zig index fdfe15e..dfce56c 100644 --- a/c/loadable_extension.zig +++ b/c/loadable_extension.zig | |||
| @@ -1,10 +1,8 @@ | |||
| 1 | const c = @cImport({ | 1 | pub const c = @cImport({ |
| 2 | @cInclude("loadable-ext-sqlite3ext.h"); | 2 | @cInclude("loadable-ext-sqlite3ext.h"); |
| 3 | @cInclude("workaround.h"); | 3 | @cInclude("workaround.h"); |
| 4 | }); | 4 | }); |
| 5 | 5 | ||
| 6 | pub usingnamespace c; | ||
| 7 | |||
| 8 | pub var sqlite3_api: [*c]c.sqlite3_api_routines = null; | 6 | pub var sqlite3_api: [*c]c.sqlite3_api_routines = null; |
| 9 | 7 | ||
| 10 | pub const sqlite3_transfer_bindings = @compileError("sqlite3_transfer_bindings is deprecated"); | 8 | pub const sqlite3_transfer_bindings = @compileError("sqlite3_transfer_bindings is deprecated"); |
| @@ -23,16 +21,16 @@ pub const sqlite3_uri_vsnprintf = @compileError("sqlite3_uri_vsnprintf can't be | |||
| 23 | pub const sqlite3_str_appendf = @compileError("sqlite3_str_appendf can't be implemented in Zig"); | 21 | pub const sqlite3_str_appendf = @compileError("sqlite3_str_appendf can't be implemented in Zig"); |
| 24 | pub const sqlite3_str_vappendf = @compileError("sqlite3_str_vappendf can't be implemented in Zig"); | 22 | pub const sqlite3_str_vappendf = @compileError("sqlite3_str_vappendf can't be implemented in Zig"); |
| 25 | 23 | ||
| 26 | pub export fn sqlite3_aggregate_context(p: ?*c.sqlite3_context, nBytes: c_int) callconv(.C) ?*anyopaque { | 24 | pub export fn sqlite3_aggregate_context(p: ?*c.sqlite3_context, nBytes: c_int) callconv(.c) ?*anyopaque { |
| 27 | return sqlite3_api.*.aggregate_context.?(p, nBytes); | 25 | return sqlite3_api.*.aggregate_context.?(p, nBytes); |
| 28 | } | 26 | } |
| 29 | pub export fn sqlite3_bind_blob(pStmt: ?*c.sqlite3_stmt, i: c_int, zData: ?*const anyopaque, nData: c_int, xDel: ?*const fn (?*anyopaque) callconv(.C) void) c_int { | 27 | pub export fn sqlite3_bind_blob(pStmt: ?*c.sqlite3_stmt, i: c_int, zData: ?*const anyopaque, nData: c_int, xDel: ?*const fn (?*anyopaque) callconv(.c) void) c_int { |
| 30 | return sqlite3_api.*.bind_blob.?(pStmt, i, zData, nData, xDel); | 28 | return sqlite3_api.*.bind_blob.?(pStmt, i, zData, nData, xDel); |
| 31 | } | 29 | } |
| 32 | pub export fn sqlite3_bind_double(pStmt: ?*c.sqlite3_stmt, i: c_int, rValue: f64) callconv(.C) c_int { | 30 | pub export fn sqlite3_bind_double(pStmt: ?*c.sqlite3_stmt, i: c_int, rValue: f64) callconv(.c) c_int { |
| 33 | return sqlite3_api.*.bind_double.?(pStmt, i, rValue); | 31 | return sqlite3_api.*.bind_double.?(pStmt, i, rValue); |
| 34 | } | 32 | } |
| 35 | pub export fn sqlite3_bind_int(pStmt: ?*c.sqlite3_stmt, i: c_int, iValue: c_int) callconv(.C) c_int { | 33 | pub export fn sqlite3_bind_int(pStmt: ?*c.sqlite3_stmt, i: c_int, iValue: c_int) callconv(.c) c_int { |
| 36 | return sqlite3_api.*.bind_int.?(pStmt, i, iValue); | 34 | return sqlite3_api.*.bind_int.?(pStmt, i, iValue); |
| 37 | } | 35 | } |
| 38 | pub export fn sqlite3_bind_int64(pStmt: ?*c.sqlite3_stmt, i: c_int, iValue: c.sqlite3_int64) c_int { | 36 | pub export fn sqlite3_bind_int64(pStmt: ?*c.sqlite3_stmt, i: c_int, iValue: c.sqlite3_int64) c_int { |
| @@ -50,16 +48,16 @@ pub export fn sqlite3_bind_parameter_index(pStmt: ?*c.sqlite3_stmt, zName: [*c]c | |||
| 50 | pub export fn sqlite3_bind_parameter_name(pStmt: ?*c.sqlite3_stmt, i: c_int) [*c]const u8 { | 48 | pub export fn sqlite3_bind_parameter_name(pStmt: ?*c.sqlite3_stmt, i: c_int) [*c]const u8 { |
| 51 | return sqlite3_api.*.bind_parameter_name.?(pStmt, i); | 49 | return sqlite3_api.*.bind_parameter_name.?(pStmt, i); |
| 52 | } | 50 | } |
| 53 | pub export fn sqlite3_bind_text(pStmt: ?*c.sqlite3_stmt, i: c_int, zData: [*c]const u8, nData: c_int, xDel: ?*const fn (?*anyopaque) callconv(.C) void) c_int { | 51 | pub export fn sqlite3_bind_text(pStmt: ?*c.sqlite3_stmt, i: c_int, zData: [*c]const u8, nData: c_int, xDel: ?*const fn (?*anyopaque) callconv(.c) void) c_int { |
| 54 | return sqlite3_api.*.bind_text.?(pStmt, i, zData, nData, xDel); | 52 | return sqlite3_api.*.bind_text.?(pStmt, i, zData, nData, xDel); |
| 55 | } | 53 | } |
| 56 | pub export fn sqlite3_bind_text16(pStmt: ?*c.sqlite3_stmt, i: c_int, zData: ?*const anyopaque, nData: c_int, xDel: ?*const fn (?*anyopaque) callconv(.C) void) c_int { | 54 | pub export fn sqlite3_bind_text16(pStmt: ?*c.sqlite3_stmt, i: c_int, zData: ?*const anyopaque, nData: c_int, xDel: ?*const fn (?*anyopaque) callconv(.c) void) c_int { |
| 57 | return sqlite3_api.*.bind_text16.?(pStmt, i, zData, nData, xDel); | 55 | return sqlite3_api.*.bind_text16.?(pStmt, i, zData, nData, xDel); |
| 58 | } | 56 | } |
| 59 | pub export fn sqlite3_bind_value(pStmt: ?*c.sqlite3_stmt, i: c_int, pValue: ?*const c.sqlite3_value) c_int { | 57 | pub export fn sqlite3_bind_value(pStmt: ?*c.sqlite3_stmt, i: c_int, pValue: ?*const c.sqlite3_value) c_int { |
| 60 | return sqlite3_api.*.bind_value.?(pStmt, i, pValue); | 58 | return sqlite3_api.*.bind_value.?(pStmt, i, pValue); |
| 61 | } | 59 | } |
| 62 | pub export fn sqlite3_busy_handler(db: ?*c.sqlite3, xBusy: ?*const fn (?*anyopaque, c_int) callconv(.C) c_int, pArg: ?*anyopaque) c_int { | 60 | pub export fn sqlite3_busy_handler(db: ?*c.sqlite3, xBusy: ?*const fn (?*anyopaque, c_int) callconv(.c) c_int, pArg: ?*anyopaque) c_int { |
| 63 | return sqlite3_api.*.busy_handler.?(db, xBusy, pArg); | 61 | return sqlite3_api.*.busy_handler.?(db, xBusy, pArg); |
| 64 | } | 62 | } |
| 65 | pub export fn sqlite3_busy_timeout(db: ?*c.sqlite3, ms: c_int) c_int { | 63 | pub export fn sqlite3_busy_timeout(db: ?*c.sqlite3, ms: c_int) c_int { |
| @@ -71,10 +69,10 @@ pub export fn sqlite3_changes(db: ?*c.sqlite3) c_int { | |||
| 71 | pub export fn sqlite3_close(db: ?*c.sqlite3) c_int { | 69 | pub export fn sqlite3_close(db: ?*c.sqlite3) c_int { |
| 72 | return sqlite3_api.*.close.?(db); | 70 | return sqlite3_api.*.close.?(db); |
| 73 | } | 71 | } |
| 74 | pub export fn sqlite3_collation_needed(db: ?*c.sqlite3, pCollNeededArg: ?*anyopaque, xCollNeeded: ?*const fn (?*anyopaque, ?*c.sqlite3, c_int, [*c]const u8) callconv(.C) void) c_int { | 72 | pub export fn sqlite3_collation_needed(db: ?*c.sqlite3, pCollNeededArg: ?*anyopaque, xCollNeeded: ?*const fn (?*anyopaque, ?*c.sqlite3, c_int, [*c]const u8) callconv(.c) void) c_int { |
| 75 | return sqlite3_api.*.collation_needed.?(db, pCollNeededArg, xCollNeeded); | 73 | return sqlite3_api.*.collation_needed.?(db, pCollNeededArg, xCollNeeded); |
| 76 | } | 74 | } |
| 77 | pub export fn sqlite3_collation_needed16(db: ?*c.sqlite3, pCollNeededArg: ?*anyopaque, xCollNeeded16: ?*const fn (?*anyopaque, ?*c.sqlite3, c_int, ?*const anyopaque) callconv(.C) void) c_int { | 75 | pub export fn sqlite3_collation_needed16(db: ?*c.sqlite3, pCollNeededArg: ?*anyopaque, xCollNeeded16: ?*const fn (?*anyopaque, ?*c.sqlite3, c_int, ?*const anyopaque) callconv(.c) void) c_int { |
| 78 | return sqlite3_api.*.collation_needed16.?(db, pCollNeededArg, xCollNeeded16); | 76 | return sqlite3_api.*.collation_needed16.?(db, pCollNeededArg, xCollNeeded16); |
| 79 | } | 77 | } |
| 80 | pub export fn sqlite3_column_blob(pStmt: ?*c.sqlite3_stmt, iCol: c_int) ?*const anyopaque { | 78 | pub export fn sqlite3_column_blob(pStmt: ?*c.sqlite3_stmt, iCol: c_int) ?*const anyopaque { |
| @@ -140,7 +138,7 @@ pub export fn sqlite3_column_type(pStmt: ?*c.sqlite3_stmt, iCol: c_int) c_int { | |||
| 140 | pub export fn sqlite3_column_value(pStmt: ?*c.sqlite3_stmt, iCol: c_int) ?*c.sqlite3_value { | 138 | pub export fn sqlite3_column_value(pStmt: ?*c.sqlite3_stmt, iCol: c_int) ?*c.sqlite3_value { |
| 141 | return sqlite3_api.*.column_value.?(pStmt, iCol); | 139 | return sqlite3_api.*.column_value.?(pStmt, iCol); |
| 142 | } | 140 | } |
| 143 | pub export fn sqlite3_commit_hook(db: ?*c.sqlite3, xCallback: ?*const fn (?*anyopaque) callconv(.C) c_int, pArg: ?*anyopaque) ?*anyopaque { | 141 | pub export fn sqlite3_commit_hook(db: ?*c.sqlite3, xCallback: ?*const fn (?*anyopaque) callconv(.c) c_int, pArg: ?*anyopaque) ?*anyopaque { |
| 144 | return sqlite3_api.*.commit_hook.?(db, xCallback, pArg); | 142 | return sqlite3_api.*.commit_hook.?(db, xCallback, pArg); |
| 145 | } | 143 | } |
| 146 | pub export fn sqlite3_complete(sql: [*c]const u8) c_int { | 144 | pub export fn sqlite3_complete(sql: [*c]const u8) c_int { |
| @@ -149,22 +147,22 @@ pub export fn sqlite3_complete(sql: [*c]const u8) c_int { | |||
| 149 | pub export fn sqlite3_complete16(sql: ?*const anyopaque) c_int { | 147 | pub export fn sqlite3_complete16(sql: ?*const anyopaque) c_int { |
| 150 | return sqlite3_api.*.complete16.?(sql); | 148 | return sqlite3_api.*.complete16.?(sql); |
| 151 | } | 149 | } |
| 152 | pub export fn sqlite3_create_collation(db: ?*c.sqlite3, zName: [*c]const u8, eTextRep: c_int, pArg: ?*anyopaque, xCompare: ?*const fn (?*anyopaque, c_int, ?*const anyopaque, c_int, ?*const anyopaque) callconv(.C) c_int) c_int { | 150 | pub export fn sqlite3_create_collation(db: ?*c.sqlite3, zName: [*c]const u8, eTextRep: c_int, pArg: ?*anyopaque, xCompare: ?*const fn (?*anyopaque, c_int, ?*const anyopaque, c_int, ?*const anyopaque) callconv(.c) c_int) c_int { |
| 153 | return sqlite3_api.*.create_collation.?(db, zName, eTextRep, pArg, xCompare); | 151 | return sqlite3_api.*.create_collation.?(db, zName, eTextRep, pArg, xCompare); |
| 154 | } | 152 | } |
| 155 | pub export fn sqlite3_create_collation16(db: ?*c.sqlite3, zName: ?*const anyopaque, eTextRep: c_int, pArg: ?*anyopaque, xCompare: ?*const fn (?*anyopaque, c_int, ?*const anyopaque, c_int, ?*const anyopaque) callconv(.C) c_int) c_int { | 153 | pub export fn sqlite3_create_collation16(db: ?*c.sqlite3, zName: ?*const anyopaque, eTextRep: c_int, pArg: ?*anyopaque, xCompare: ?*const fn (?*anyopaque, c_int, ?*const anyopaque, c_int, ?*const anyopaque) callconv(.c) c_int) c_int { |
| 156 | return sqlite3_api.*.create_collation16.?(db, zName, eTextRep, pArg, xCompare); | 154 | return sqlite3_api.*.create_collation16.?(db, zName, eTextRep, pArg, xCompare); |
| 157 | } | 155 | } |
| 158 | pub export fn sqlite3_create_function(db: ?*c.sqlite3, zFunctionName: [*c]const u8, nArg: c_int, eTextRep: c_int, pApp: ?*anyopaque, xFunc: ?*const fn (?*c.sqlite3_context, c_int, [*c]?*c.sqlite3_value) callconv(.C) void, xStep: ?*const fn (?*c.sqlite3_context, c_int, [*c]?*c.sqlite3_value) callconv(.C) void, xFinal: ?*const fn (?*c.sqlite3_context) callconv(.C) void) c_int { | 156 | pub export fn sqlite3_create_function(db: ?*c.sqlite3, zFunctionName: [*c]const u8, nArg: c_int, eTextRep: c_int, pApp: ?*anyopaque, xFunc: ?*const fn (?*c.sqlite3_context, c_int, [*c]?*c.sqlite3_value) callconv(.c) void, xStep: ?*const fn (?*c.sqlite3_context, c_int, [*c]?*c.sqlite3_value) callconv(.c) void, xFinal: ?*const fn (?*c.sqlite3_context) callconv(.c) void) c_int { |
| 159 | return sqlite3_api.*.create_function.?(db, zFunctionName, nArg, eTextRep, pApp, xFunc, xStep, xFinal); | 157 | return sqlite3_api.*.create_function.?(db, zFunctionName, nArg, eTextRep, pApp, xFunc, xStep, xFinal); |
| 160 | } | 158 | } |
| 161 | pub export fn sqlite3_create_function16(db: ?*c.sqlite3, zFunctionName: ?*const anyopaque, nArg: c_int, eTextRep: c_int, pApp: ?*anyopaque, xFunc: ?*const fn (?*c.sqlite3_context, c_int, [*c]?*c.sqlite3_value) callconv(.C) void, xStep: ?*const fn (?*c.sqlite3_context, c_int, [*c]?*c.sqlite3_value) callconv(.C) void, xFinal: ?*const fn (?*c.sqlite3_context) callconv(.C) void) c_int { | 159 | pub export fn sqlite3_create_function16(db: ?*c.sqlite3, zFunctionName: ?*const anyopaque, nArg: c_int, eTextRep: c_int, pApp: ?*anyopaque, xFunc: ?*const fn (?*c.sqlite3_context, c_int, [*c]?*c.sqlite3_value) callconv(.c) void, xStep: ?*const fn (?*c.sqlite3_context, c_int, [*c]?*c.sqlite3_value) callconv(.c) void, xFinal: ?*const fn (?*c.sqlite3_context) callconv(.c) void) c_int { |
| 162 | return sqlite3_api.*.create_function16.?(db, zFunctionName, nArg, eTextRep, pApp, xFunc, xStep, xFinal); | 160 | return sqlite3_api.*.create_function16.?(db, zFunctionName, nArg, eTextRep, pApp, xFunc, xStep, xFinal); |
| 163 | } | 161 | } |
| 164 | pub export fn sqlite3_create_module(db: ?*c.sqlite3, zName: [*c]const u8, pModule: [*c]const c.sqlite3_module, pAux: ?*anyopaque) c_int { | 162 | pub export fn sqlite3_create_module(db: ?*c.sqlite3, zName: [*c]const u8, pModule: [*c]const c.sqlite3_module, pAux: ?*anyopaque) c_int { |
| 165 | return sqlite3_api.*.create_module.?(db, zName, pModule, pAux); | 163 | return sqlite3_api.*.create_module.?(db, zName, pModule, pAux); |
| 166 | } | 164 | } |
| 167 | pub export fn sqlite3_create_module_v2(db: ?*c.sqlite3, zName: [*c]const u8, pModule: [*c]const c.sqlite3_module, pAux: ?*anyopaque, xDestroy: ?*const fn (?*anyopaque) callconv(.C) void) c_int { | 165 | pub export fn sqlite3_create_module_v2(db: ?*c.sqlite3, zName: [*c]const u8, pModule: [*c]const c.sqlite3_module, pAux: ?*anyopaque, xDestroy: ?*const fn (?*anyopaque) callconv(.c) void) c_int { |
| 168 | return sqlite3_api.*.create_module_v2.?(db, zName, pModule, pAux, xDestroy); | 166 | return sqlite3_api.*.create_module_v2.?(db, zName, pModule, pAux, xDestroy); |
| 169 | } | 167 | } |
| 170 | pub export fn sqlite3_data_count(pStmt: ?*c.sqlite3_stmt) c_int { | 168 | pub export fn sqlite3_data_count(pStmt: ?*c.sqlite3_stmt) c_int { |
| @@ -189,7 +187,7 @@ pub export fn sqlite3_errmsg(db: ?*c.sqlite3) [*c]const u8 { | |||
| 189 | pub export fn sqlite3_errmsg16(db: ?*c.sqlite3) ?*const anyopaque { | 187 | pub export fn sqlite3_errmsg16(db: ?*c.sqlite3) ?*const anyopaque { |
| 190 | return sqlite3_api.*.errmsg16.?(db); | 188 | return sqlite3_api.*.errmsg16.?(db); |
| 191 | } | 189 | } |
| 192 | pub export fn sqlite3_exec(db: ?*c.sqlite3, zSql: [*c]const u8, xCallback: ?*const fn (?*anyopaque, c_int, [*c][*c]u8, [*c][*c]u8) callconv(.C) c_int, pArg: ?*anyopaque, pzErrMsg: [*c][*c]u8) c_int { | 190 | pub export fn sqlite3_exec(db: ?*c.sqlite3, zSql: [*c]const u8, xCallback: ?*const fn (?*anyopaque, c_int, [*c][*c]u8, [*c][*c]u8) callconv(.c) c_int, pArg: ?*anyopaque, pzErrMsg: [*c][*c]u8) c_int { |
| 193 | return sqlite3_api.*.exec.?(db, zSql, xCallback, pArg, pzErrMsg); | 191 | return sqlite3_api.*.exec.?(db, zSql, xCallback, pArg, pzErrMsg); |
| 194 | } | 192 | } |
| 195 | pub export fn sqlite3_finalize(pStmt: ?*c.sqlite3_stmt) c_int { | 193 | pub export fn sqlite3_finalize(pStmt: ?*c.sqlite3_stmt) c_int { |
| @@ -216,7 +214,7 @@ pub export fn sqlite3_interrupt(db: ?*c.sqlite3) void { | |||
| 216 | pub export fn sqlite3_last_insert_rowid(db: ?*c.sqlite3) c.sqlite3_int64 { | 214 | pub export fn sqlite3_last_insert_rowid(db: ?*c.sqlite3) c.sqlite3_int64 { |
| 217 | return sqlite3_api.*.last_insert_rowid.?(db); | 215 | return sqlite3_api.*.last_insert_rowid.?(db); |
| 218 | } | 216 | } |
| 219 | pub export fn sqlite3_libversion() callconv(.C) [*c]const u8 { | 217 | pub export fn sqlite3_libversion() callconv(.c) [*c]const u8 { |
| 220 | return sqlite3_api.*.libversion.?(); | 218 | return sqlite3_api.*.libversion.?(); |
| 221 | } | 219 | } |
| 222 | pub export fn sqlite3_libversion_number() c_int { | 220 | pub export fn sqlite3_libversion_number() c_int { |
| @@ -243,10 +241,10 @@ pub export fn sqlite3_prepare_v2(db: ?*c.sqlite3, zSql: [*c]const u8, nByte: c_i | |||
| 243 | pub export fn sqlite3_prepare16_v2(db: ?*c.sqlite3, zSql: ?*const anyopaque, nByte: c_int, ppStmt: [*c]?*c.sqlite3_stmt, pzTail: [*c]?*const anyopaque) c_int { | 241 | pub export fn sqlite3_prepare16_v2(db: ?*c.sqlite3, zSql: ?*const anyopaque, nByte: c_int, ppStmt: [*c]?*c.sqlite3_stmt, pzTail: [*c]?*const anyopaque) c_int { |
| 244 | return sqlite3_api.*.prepare16_v2.?(db, zSql, nByte, ppStmt, pzTail); | 242 | return sqlite3_api.*.prepare16_v2.?(db, zSql, nByte, ppStmt, pzTail); |
| 245 | } | 243 | } |
| 246 | pub export fn sqlite3_profile(db: ?*c.sqlite3, xProfile: ?*const fn (?*anyopaque, [*c]const u8, c.sqlite3_uint64) callconv(.C) void, pArg: ?*anyopaque) ?*anyopaque { | 244 | pub export fn sqlite3_profile(db: ?*c.sqlite3, xProfile: ?*const fn (?*anyopaque, [*c]const u8, c.sqlite3_uint64) callconv(.c) void, pArg: ?*anyopaque) ?*anyopaque { |
| 247 | return sqlite3_api.*.profile.?(db, xProfile, pArg); | 245 | return sqlite3_api.*.profile.?(db, xProfile, pArg); |
| 248 | } | 246 | } |
| 249 | pub export fn sqlite3_progress_handler(db: ?*c.sqlite3, nOps: c_int, xProgress: ?*const fn (?*anyopaque) callconv(.C) c_int, pArg: ?*anyopaque) void { | 247 | pub export fn sqlite3_progress_handler(db: ?*c.sqlite3, nOps: c_int, xProgress: ?*const fn (?*anyopaque) callconv(.c) c_int, pArg: ?*anyopaque) void { |
| 250 | return sqlite3_api.*.progress_handler.?(db, nOps, xProgress, pArg); | 248 | return sqlite3_api.*.progress_handler.?(db, nOps, xProgress, pArg); |
| 251 | } | 249 | } |
| 252 | pub export fn sqlite3_realloc(pOld: ?*anyopaque, n: c_int) ?*anyopaque { | 250 | pub export fn sqlite3_realloc(pOld: ?*anyopaque, n: c_int) ?*anyopaque { |
| @@ -255,7 +253,7 @@ pub export fn sqlite3_realloc(pOld: ?*anyopaque, n: c_int) ?*anyopaque { | |||
| 255 | pub export fn sqlite3_reset(pStmt: ?*c.sqlite3_stmt) c_int { | 253 | pub export fn sqlite3_reset(pStmt: ?*c.sqlite3_stmt) c_int { |
| 256 | return sqlite3_api.*.reset.?(pStmt); | 254 | return sqlite3_api.*.reset.?(pStmt); |
| 257 | } | 255 | } |
| 258 | pub export fn sqlite3_result_blob(pCtx: ?*c.sqlite3_context, z: ?*const anyopaque, n: c_int, xDel: ?*const fn (?*anyopaque) callconv(.C) void) void { | 256 | pub export fn sqlite3_result_blob(pCtx: ?*c.sqlite3_context, z: ?*const anyopaque, n: c_int, xDel: ?*const fn (?*anyopaque) callconv(.c) void) void { |
| 259 | return sqlite3_api.*.result_blob.?(pCtx, z, n, xDel); | 257 | return sqlite3_api.*.result_blob.?(pCtx, z, n, xDel); |
| 260 | } | 258 | } |
| 261 | 259 | ||
| @@ -278,28 +276,28 @@ pub export fn sqlite3_result_int64(pCtx: ?*c.sqlite3_context, iVal: c.sqlite3_in | |||
| 278 | pub export fn sqlite3_result_null(pCtx: ?*c.sqlite3_context) void { | 276 | pub export fn sqlite3_result_null(pCtx: ?*c.sqlite3_context) void { |
| 279 | return sqlite3_api.*.result_null.?(pCtx); | 277 | return sqlite3_api.*.result_null.?(pCtx); |
| 280 | } | 278 | } |
| 281 | pub export fn sqlite3_result_text(pCtx: ?*c.sqlite3_context, z: [*c]const u8, n: c_int, xDel: ?*const fn (?*anyopaque) callconv(.C) void) void { | 279 | pub export fn sqlite3_result_text(pCtx: ?*c.sqlite3_context, z: [*c]const u8, n: c_int, xDel: ?*const fn (?*anyopaque) callconv(.c) void) void { |
| 282 | return sqlite3_api.*.result_text.?(pCtx, z, n, xDel); | 280 | return sqlite3_api.*.result_text.?(pCtx, z, n, xDel); |
| 283 | } | 281 | } |
| 284 | pub export fn sqlite3_result_text16(pCtx: ?*c.sqlite3_context, z: ?*const anyopaque, n: c_int, xDel: ?*const fn (?*anyopaque) callconv(.C) void) void { | 282 | pub export fn sqlite3_result_text16(pCtx: ?*c.sqlite3_context, z: ?*const anyopaque, n: c_int, xDel: ?*const fn (?*anyopaque) callconv(.c) void) void { |
| 285 | return sqlite3_api.*.result_text16.?(pCtx, z, n, xDel); | 283 | return sqlite3_api.*.result_text16.?(pCtx, z, n, xDel); |
| 286 | } | 284 | } |
| 287 | pub export fn sqlite3_result_text16be(pCtx: ?*c.sqlite3_context, z: ?*const anyopaque, n: c_int, xDel: ?*const fn (?*anyopaque) callconv(.C) void) void { | 285 | pub export fn sqlite3_result_text16be(pCtx: ?*c.sqlite3_context, z: ?*const anyopaque, n: c_int, xDel: ?*const fn (?*anyopaque) callconv(.c) void) void { |
| 288 | return sqlite3_api.*.result_text16be.?(pCtx, z, n, xDel); | 286 | return sqlite3_api.*.result_text16be.?(pCtx, z, n, xDel); |
| 289 | } | 287 | } |
| 290 | pub export fn sqlite3_result_text16le(pCtx: ?*c.sqlite3_context, z: ?*const anyopaque, n: c_int, xDel: ?*const fn (?*anyopaque) callconv(.C) void) void { | 288 | pub export fn sqlite3_result_text16le(pCtx: ?*c.sqlite3_context, z: ?*const anyopaque, n: c_int, xDel: ?*const fn (?*anyopaque) callconv(.c) void) void { |
| 291 | return sqlite3_api.*.result_text16le.?(pCtx, z, n, xDel); | 289 | return sqlite3_api.*.result_text16le.?(pCtx, z, n, xDel); |
| 292 | } | 290 | } |
| 293 | pub export fn sqlite3_result_value(pCtx: ?*c.sqlite3_context, pValue: ?*c.sqlite3_value) void { | 291 | pub export fn sqlite3_result_value(pCtx: ?*c.sqlite3_context, pValue: ?*c.sqlite3_value) void { |
| 294 | return sqlite3_api.*.result_value.?(pCtx, pValue); | 292 | return sqlite3_api.*.result_value.?(pCtx, pValue); |
| 295 | } | 293 | } |
| 296 | pub export fn sqlite3_rollback_hook(db: ?*c.sqlite3, xCallback: ?*const fn (?*anyopaque) callconv(.C) void, pArg: ?*anyopaque) ?*anyopaque { | 294 | pub export fn sqlite3_rollback_hook(db: ?*c.sqlite3, xCallback: ?*const fn (?*anyopaque) callconv(.c) void, pArg: ?*anyopaque) ?*anyopaque { |
| 297 | return sqlite3_api.*.rollback_hook.?(db, xCallback, pArg); | 295 | return sqlite3_api.*.rollback_hook.?(db, xCallback, pArg); |
| 298 | } | 296 | } |
| 299 | pub export fn sqlite3_set_authorizer(db: ?*c.sqlite3, xAuth: ?*const fn (?*anyopaque, c_int, [*c]const u8, [*c]const u8, [*c]const u8, [*c]const u8) callconv(.C) c_int, pArg: ?*anyopaque) c_int { | 297 | pub export fn sqlite3_set_authorizer(db: ?*c.sqlite3, xAuth: ?*const fn (?*anyopaque, c_int, [*c]const u8, [*c]const u8, [*c]const u8, [*c]const u8) callconv(.c) c_int, pArg: ?*anyopaque) c_int { |
| 300 | return sqlite3_api.*.set_authorizer.?(db, xAuth, pArg); | 298 | return sqlite3_api.*.set_authorizer.?(db, xAuth, pArg); |
| 301 | } | 299 | } |
| 302 | pub export fn sqlite3_set_auxdata(pCtx: ?*c.sqlite3_context, iArg: c_int, pAux: ?*anyopaque, xDelete: ?*const fn (?*anyopaque) callconv(.C) void) void { | 300 | pub export fn sqlite3_set_auxdata(pCtx: ?*c.sqlite3_context, iArg: c_int, pAux: ?*anyopaque, xDelete: ?*const fn (?*anyopaque) callconv(.c) void) void { |
| 303 | return sqlite3_api.*.set_auxdata.?(pCtx, iArg, pAux, xDelete); | 301 | return sqlite3_api.*.set_auxdata.?(pCtx, iArg, pAux, xDelete); |
| 304 | } | 302 | } |
| 305 | pub export fn sqlite3_step(pStmt: ?*c.sqlite3_stmt) c_int { | 303 | pub export fn sqlite3_step(pStmt: ?*c.sqlite3_stmt) c_int { |
| @@ -314,10 +312,10 @@ pub export fn sqlite3_thread_cleanup() void { | |||
| 314 | pub export fn sqlite3_total_changes(db: ?*c.sqlite3) c_int { | 312 | pub export fn sqlite3_total_changes(db: ?*c.sqlite3) c_int { |
| 315 | return sqlite3_api.*.total_changes.?(db); | 313 | return sqlite3_api.*.total_changes.?(db); |
| 316 | } | 314 | } |
| 317 | pub export fn sqlite3_trace(db: ?*c.sqlite3, xTrace: ?*const fn (?*anyopaque, [*c]const u8) callconv(.C) void, pArg: ?*anyopaque) ?*anyopaque { | 315 | pub export fn sqlite3_trace(db: ?*c.sqlite3, xTrace: ?*const fn (?*anyopaque, [*c]const u8) callconv(.c) void, pArg: ?*anyopaque) ?*anyopaque { |
| 318 | return sqlite3_api.*.trace.?(db, xTrace, pArg); | 316 | return sqlite3_api.*.trace.?(db, xTrace, pArg); |
| 319 | } | 317 | } |
| 320 | pub export fn sqlite3_update_hook(db: ?*c.sqlite3, xCallback: ?*const fn (?*anyopaque, c_int, [*c]const u8, [*c]const u8, c.sqlite3_int64) callconv(.C) void, pArg: ?*anyopaque) ?*anyopaque { | 318 | pub export fn sqlite3_update_hook(db: ?*c.sqlite3, xCallback: ?*const fn (?*anyopaque, c_int, [*c]const u8, [*c]const u8, c.sqlite3_int64) callconv(.c) void, pArg: ?*anyopaque) ?*anyopaque { |
| 321 | return sqlite3_api.*.update_hook.?(db, xCallback, pArg); | 319 | return sqlite3_api.*.update_hook.?(db, xCallback, pArg); |
| 322 | } | 320 | } |
| 323 | pub export fn sqlite3_user_data(pCtx: ?*c.sqlite3_context) ?*anyopaque { | 321 | pub export fn sqlite3_user_data(pCtx: ?*c.sqlite3_context) ?*anyopaque { |
| @@ -383,7 +381,7 @@ pub export fn sqlite3_blob_read(pBlob: ?*c.sqlite3_blob, z: ?*anyopaque, n: c_in | |||
| 383 | pub export fn sqlite3_blob_write(pBlob: ?*c.sqlite3_blob, z: ?*const anyopaque, n: c_int, iOffset: c_int) c_int { | 381 | pub export fn sqlite3_blob_write(pBlob: ?*c.sqlite3_blob, z: ?*const anyopaque, n: c_int, iOffset: c_int) c_int { |
| 384 | return sqlite3_api.*.blob_write.?(pBlob, z, n, iOffset); | 382 | return sqlite3_api.*.blob_write.?(pBlob, z, n, iOffset); |
| 385 | } | 383 | } |
| 386 | pub export fn sqlite3_create_collation_v2(db: ?*c.sqlite3, zName: [*c]const u8, eTextRep: c_int, pCtx: ?*anyopaque, xCompare: ?*const fn (?*anyopaque, c_int, ?*const anyopaque, c_int, ?*const anyopaque) callconv(.C) c_int, xDel: ?*const fn (?*anyopaque) callconv(.C) void) c_int { | 384 | pub export fn sqlite3_create_collation_v2(db: ?*c.sqlite3, zName: [*c]const u8, eTextRep: c_int, pCtx: ?*anyopaque, xCompare: ?*const fn (?*anyopaque, c_int, ?*const anyopaque, c_int, ?*const anyopaque) callconv(.c) c_int, xDel: ?*const fn (?*anyopaque) callconv(.c) void) c_int { |
| 387 | return sqlite3_api.*.create_collation_v2.?(db, zName, eTextRep, pCtx, xCompare, xDel); | 385 | return sqlite3_api.*.create_collation_v2.?(db, zName, eTextRep, pCtx, xCompare, xDel); |
| 388 | } | 386 | } |
| 389 | pub export fn sqlite3_file_control(db: ?*c.sqlite3, zDbName: [*c]const u8, op: c_int, pArg: ?*anyopaque) c_int { | 387 | pub export fn sqlite3_file_control(db: ?*c.sqlite3, zDbName: [*c]const u8, op: c_int, pArg: ?*anyopaque) c_int { |
| @@ -494,10 +492,10 @@ pub export fn sqlite3_create_function_v2( | |||
| 494 | nArg: c_int, | 492 | nArg: c_int, |
| 495 | eTextRep: c_int, | 493 | eTextRep: c_int, |
| 496 | pApp: ?*anyopaque, | 494 | pApp: ?*anyopaque, |
| 497 | xFunc: ?*const fn (?*c.sqlite3_context, c_int, [*c]?*c.sqlite3_value) callconv(.C) void, | 495 | xFunc: ?*const fn (?*c.sqlite3_context, c_int, [*c]?*c.sqlite3_value) callconv(.c) void, |
| 498 | xStep: ?*const fn (?*c.sqlite3_context, c_int, [*c]?*c.sqlite3_value) callconv(.C) void, | 496 | xStep: ?*const fn (?*c.sqlite3_context, c_int, [*c]?*c.sqlite3_value) callconv(.c) void, |
| 499 | xFinal: ?*const fn (?*c.sqlite3_context) callconv(.C) void, | 497 | xFinal: ?*const fn (?*c.sqlite3_context) callconv(.c) void, |
| 500 | xDestroy: ?*const fn (?*anyopaque) callconv(.C) void, | 498 | xDestroy: ?*const fn (?*anyopaque) callconv(.c) void, |
| 501 | ) c_int { | 499 | ) c_int { |
| 502 | return sqlite3_api.*.create_function_v2.?(db, zFunctionName, nArg, eTextRep, pApp, xFunc, xStep, xFinal, xDestroy); | 500 | return sqlite3_api.*.create_function_v2.?(db, zFunctionName, nArg, eTextRep, pApp, xFunc, xStep, xFinal, xDestroy); |
| 503 | } | 501 | } |
| @@ -522,7 +520,7 @@ pub export fn sqlite3_stmt_status(pStmt: ?*c.sqlite3_stmt, op: c_int, resetFlag: | |||
| 522 | pub export fn sqlite3_strnicmp(zLeft: [*c]const u8, zRight: [*c]const u8, N: c_int) c_int { | 520 | pub export fn sqlite3_strnicmp(zLeft: [*c]const u8, zRight: [*c]const u8, N: c_int) c_int { |
| 523 | return sqlite3_api.*.strnicmp.?(zLeft, zRight, N); | 521 | return sqlite3_api.*.strnicmp.?(zLeft, zRight, N); |
| 524 | } | 522 | } |
| 525 | pub export fn sqlite3_unlock_notify(pBlocked: ?*c.sqlite3, xNotify: ?*const fn ([*c]?*anyopaque, c_int) callconv(.C) void, pNotifyArg: ?*anyopaque) c_int { | 523 | pub export fn sqlite3_unlock_notify(pBlocked: ?*c.sqlite3, xNotify: ?*const fn ([*c]?*anyopaque, c_int) callconv(.c) void, pNotifyArg: ?*anyopaque) c_int { |
| 526 | return sqlite3_api.*.unlock_notify.?(pBlocked, xNotify, pNotifyArg); | 524 | return sqlite3_api.*.unlock_notify.?(pBlocked, xNotify, pNotifyArg); |
| 527 | } | 525 | } |
| 528 | pub export fn sqlite3_wal_autocheckpoint(db: ?*c.sqlite3, N: c_int) c_int { | 526 | pub export fn sqlite3_wal_autocheckpoint(db: ?*c.sqlite3, N: c_int) c_int { |
| @@ -531,7 +529,7 @@ pub export fn sqlite3_wal_autocheckpoint(db: ?*c.sqlite3, N: c_int) c_int { | |||
| 531 | pub export fn sqlite3_wal_checkpoint(db: ?*c.sqlite3, zDb: [*c]const u8) c_int { | 529 | pub export fn sqlite3_wal_checkpoint(db: ?*c.sqlite3, zDb: [*c]const u8) c_int { |
| 532 | return sqlite3_api.*.wal_checkpoint.?(db, zDb); | 530 | return sqlite3_api.*.wal_checkpoint.?(db, zDb); |
| 533 | } | 531 | } |
| 534 | pub export fn sqlite3_wal_hook(db: ?*c.sqlite3, xCallback: ?*const fn (?*anyopaque, ?*c.sqlite3, [*c]const u8, c_int) callconv(.C) c_int, pArg: ?*anyopaque) ?*anyopaque { | 532 | pub export fn sqlite3_wal_hook(db: ?*c.sqlite3, xCallback: ?*const fn (?*anyopaque, ?*c.sqlite3, [*c]const u8, c_int) callconv(.c) c_int, pArg: ?*anyopaque) ?*anyopaque { |
| 535 | return sqlite3_api.*.wal_hook.?(db, xCallback, pArg); | 533 | return sqlite3_api.*.wal_hook.?(db, xCallback, pArg); |
| 536 | } | 534 | } |
| 537 | pub export fn sqlite3_blob_reopen(pBlob: ?*c.sqlite3_blob, iRow: c.sqlite3_int64) c_int { | 535 | pub export fn sqlite3_blob_reopen(pBlob: ?*c.sqlite3_blob, iRow: c.sqlite3_int64) c_int { |
| @@ -576,16 +574,16 @@ pub export fn sqlite3_uri_parameter(zFilename: [*c]const u8, zParam: [*c]const u | |||
| 576 | pub export fn sqlite3_wal_checkpoint_v2(db: ?*c.sqlite3, zDb: [*c]const u8, eMode: c_int, pnLog: [*c]c_int, pnCkpt: [*c]c_int) c_int { | 574 | pub export fn sqlite3_wal_checkpoint_v2(db: ?*c.sqlite3, zDb: [*c]const u8, eMode: c_int, pnLog: [*c]c_int, pnCkpt: [*c]c_int) c_int { |
| 577 | return sqlite3_api.*.wal_checkpoint_v2.?(db, zDb, eMode, pnLog, pnCkpt); | 575 | return sqlite3_api.*.wal_checkpoint_v2.?(db, zDb, eMode, pnLog, pnCkpt); |
| 578 | } | 576 | } |
| 579 | pub export fn sqlite3_auto_extension(xEntryPoint: ?*const fn () callconv(.C) void) c_int { | 577 | pub export fn sqlite3_auto_extension(xEntryPoint: ?*const fn () callconv(.c) void) c_int { |
| 580 | return sqlite3_api.*.auto_extension.?(xEntryPoint); | 578 | return sqlite3_api.*.auto_extension.?(xEntryPoint); |
| 581 | } | 579 | } |
| 582 | pub export fn sqlite3_bind_blob64(pStmt: ?*c.sqlite3_stmt, i: c_int, zData: ?*const anyopaque, nData: c.sqlite3_uint64, xDel: ?*const fn (?*anyopaque) callconv(.C) void) c_int { | 580 | pub export fn sqlite3_bind_blob64(pStmt: ?*c.sqlite3_stmt, i: c_int, zData: ?*const anyopaque, nData: c.sqlite3_uint64, xDel: ?*const fn (?*anyopaque) callconv(.c) void) c_int { |
| 583 | return sqlite3_api.*.bind_blob64.?(pStmt, i, zData, nData, xDel); | 581 | return sqlite3_api.*.bind_blob64.?(pStmt, i, zData, nData, xDel); |
| 584 | } | 582 | } |
| 585 | pub export fn sqlite3_bind_text64(pStmt: ?*c.sqlite3_stmt, i: c_int, zData: [*c]const u8, nData: c.sqlite3_uint64, xDel: ?*const fn (?*anyopaque) callconv(.C) void, encoding: u8) c_int { | 583 | pub export fn sqlite3_bind_text64(pStmt: ?*c.sqlite3_stmt, i: c_int, zData: [*c]const u8, nData: c.sqlite3_uint64, xDel: ?*const fn (?*anyopaque) callconv(.c) void, encoding: u8) c_int { |
| 586 | return sqlite3_api.*.bind_text64.?(pStmt, i, zData, nData, xDel, encoding); | 584 | return sqlite3_api.*.bind_text64.?(pStmt, i, zData, nData, xDel, encoding); |
| 587 | } | 585 | } |
| 588 | pub export fn sqlite3_cancel_auto_extension(xEntryPoint: ?*const fn () callconv(.C) void) c_int { | 586 | pub export fn sqlite3_cancel_auto_extension(xEntryPoint: ?*const fn () callconv(.c) void) c_int { |
| 589 | return sqlite3_api.*.cancel_auto_extension.?(xEntryPoint); | 587 | return sqlite3_api.*.cancel_auto_extension.?(xEntryPoint); |
| 590 | } | 588 | } |
| 591 | pub export fn sqlite3_load_extension(db: ?*c.sqlite3, zFile: [*c]const u8, zProc: [*c]const u8, pzErrMsg: [*c][*c]u8) c_int { | 589 | pub export fn sqlite3_load_extension(db: ?*c.sqlite3, zFile: [*c]const u8, zProc: [*c]const u8, pzErrMsg: [*c][*c]u8) c_int { |
| @@ -603,10 +601,10 @@ pub export fn sqlite3_realloc64(pOld: ?*anyopaque, n: c.sqlite3_uint64) ?*anyopa | |||
| 603 | pub export fn sqlite3_reset_auto_extension() void { | 601 | pub export fn sqlite3_reset_auto_extension() void { |
| 604 | return sqlite3_api.*.reset_auto_extension.?(); | 602 | return sqlite3_api.*.reset_auto_extension.?(); |
| 605 | } | 603 | } |
| 606 | pub export fn sqlite3_result_blob64(pCtx: ?*c.sqlite3_context, z: ?*const anyopaque, n: c.sqlite3_uint64, xDel: ?*const fn (?*anyopaque) callconv(.C) void) void { | 604 | pub export fn sqlite3_result_blob64(pCtx: ?*c.sqlite3_context, z: ?*const anyopaque, n: c.sqlite3_uint64, xDel: ?*const fn (?*anyopaque) callconv(.c) void) void { |
| 607 | return sqlite3_api.*.result_blob64.?(pCtx, z, n, xDel); | 605 | return sqlite3_api.*.result_blob64.?(pCtx, z, n, xDel); |
| 608 | } | 606 | } |
| 609 | pub export fn sqlite3_result_text64(pCtx: ?*c.sqlite3_context, z: [*c]const u8, n: c.sqlite3_uint64, xDel: ?*const fn (?*anyopaque) callconv(.C) void, encoding: u8) void { | 607 | pub export fn sqlite3_result_text64(pCtx: ?*c.sqlite3_context, z: [*c]const u8, n: c.sqlite3_uint64, xDel: ?*const fn (?*anyopaque) callconv(.c) void, encoding: u8) void { |
| 610 | return sqlite3_api.*.result_text64.?(pCtx, z, n, xDel, encoding); | 608 | return sqlite3_api.*.result_text64.?(pCtx, z, n, xDel, encoding); |
| 611 | } | 609 | } |
| 612 | pub export fn sqlite3_strglob(zGlob: [*c]const u8, zStr: [*c]const u8) c_int { | 610 | pub export fn sqlite3_strglob(zGlob: [*c]const u8, zStr: [*c]const u8) c_int { |
| @@ -642,7 +640,7 @@ pub export fn sqlite3_db_cacheflush(db: ?*c.sqlite3) c_int { | |||
| 642 | pub export fn sqlite3_system_errno(db: ?*c.sqlite3) c_int { | 640 | pub export fn sqlite3_system_errno(db: ?*c.sqlite3) c_int { |
| 643 | return sqlite3_api.*.system_errno.?(db); | 641 | return sqlite3_api.*.system_errno.?(db); |
| 644 | } | 642 | } |
| 645 | pub export fn sqlite3_trace_v2(db: ?*c.sqlite3, uMask: c_uint, xCallback: ?*const fn (c_uint, ?*anyopaque, ?*anyopaque, ?*anyopaque) callconv(.C) c_int, pCtx: ?*anyopaque) c_int { | 643 | pub export fn sqlite3_trace_v2(db: ?*c.sqlite3, uMask: c_uint, xCallback: ?*const fn (c_uint, ?*anyopaque, ?*anyopaque, ?*anyopaque) callconv(.c) c_int, pCtx: ?*anyopaque) c_int { |
| 646 | return sqlite3_api.*.trace_v2.?(db, uMask, xCallback, pCtx); | 644 | return sqlite3_api.*.trace_v2.?(db, uMask, xCallback, pCtx); |
| 647 | } | 645 | } |
| 648 | pub export fn sqlite3_expanded_sql(pStmt: ?*c.sqlite3_stmt) [*c]u8 { | 646 | pub export fn sqlite3_expanded_sql(pStmt: ?*c.sqlite3_stmt) [*c]u8 { |
| @@ -657,10 +655,10 @@ pub export fn sqlite3_prepare_v3(db: ?*c.sqlite3, zSql: [*c]const u8, nByte: c_i | |||
| 657 | pub export fn sqlite3_prepare16_v3(db: ?*c.sqlite3, zSql: ?*const anyopaque, nByte: c_int, prepFlags: c_uint, ppStmt: [*c]?*c.sqlite3_stmt, pzTail: [*c]?*const anyopaque) c_int { | 655 | pub export fn sqlite3_prepare16_v3(db: ?*c.sqlite3, zSql: ?*const anyopaque, nByte: c_int, prepFlags: c_uint, ppStmt: [*c]?*c.sqlite3_stmt, pzTail: [*c]?*const anyopaque) c_int { |
| 658 | return sqlite3_api.*.prepare16_v3.?(db, zSql, nByte, prepFlags, ppStmt, pzTail); | 656 | return sqlite3_api.*.prepare16_v3.?(db, zSql, nByte, prepFlags, ppStmt, pzTail); |
| 659 | } | 657 | } |
| 660 | pub export fn sqlite3_bind_pointer(pStmt: ?*c.sqlite3_stmt, i: c_int, pPtr: ?*anyopaque, zPTtype: [*c]const u8, xDestructor: ?*const fn (?*anyopaque) callconv(.C) void) c_int { | 658 | pub export fn sqlite3_bind_pointer(pStmt: ?*c.sqlite3_stmt, i: c_int, pPtr: ?*anyopaque, zPTtype: [*c]const u8, xDestructor: ?*const fn (?*anyopaque) callconv(.c) void) c_int { |
| 661 | return sqlite3_api.*.bind_pointer.?(pStmt, i, pPtr, zPTtype, xDestructor); | 659 | return sqlite3_api.*.bind_pointer.?(pStmt, i, pPtr, zPTtype, xDestructor); |
| 662 | } | 660 | } |
| 663 | pub export fn sqlite3_result_pointer(pCtx: ?*c.sqlite3_context, pPtr: ?*anyopaque, zPType: [*c]const u8, xDestructor: ?*const fn (?*anyopaque) callconv(.C) void) void { | 661 | pub export fn sqlite3_result_pointer(pCtx: ?*c.sqlite3_context, pPtr: ?*anyopaque, zPType: [*c]const u8, xDestructor: ?*const fn (?*anyopaque) callconv(.c) void) void { |
| 664 | return sqlite3_api.*.result_pointer.?(pCtx, pPtr, zPType, xDestructor); | 662 | return sqlite3_api.*.result_pointer.?(pCtx, pPtr, zPType, xDestructor); |
| 665 | } | 663 | } |
| 666 | pub export fn sqlite3_value_pointer(pVal: ?*c.sqlite3_value, zPType: [*c]const u8) ?*anyopaque { | 664 | pub export fn sqlite3_value_pointer(pVal: ?*c.sqlite3_value, zPType: [*c]const u8) ?*anyopaque { |
| @@ -717,11 +715,11 @@ pub export fn sqlite3_create_window_function( | |||
| 717 | nArg: c_int, | 715 | nArg: c_int, |
| 718 | eTextRep: c_int, | 716 | eTextRep: c_int, |
| 719 | pArg: ?*anyopaque, | 717 | pArg: ?*anyopaque, |
| 720 | xStep: ?*const fn (?*c.sqlite3_context, c_int, [*c]?*c.sqlite3_value) callconv(.C) void, | 718 | xStep: ?*const fn (?*c.sqlite3_context, c_int, [*c]?*c.sqlite3_value) callconv(.c) void, |
| 721 | xFinal: ?*const fn (?*c.sqlite3_context) callconv(.C) void, | 719 | xFinal: ?*const fn (?*c.sqlite3_context) callconv(.c) void, |
| 722 | xValue: ?*const fn (?*c.sqlite3_context) callconv(.C) void, | 720 | xValue: ?*const fn (?*c.sqlite3_context) callconv(.c) void, |
| 723 | xInverse: ?*const fn (?*c.sqlite3_context, c_int, [*c]?*c.sqlite3_value) callconv(.C) void, | 721 | xInverse: ?*const fn (?*c.sqlite3_context, c_int, [*c]?*c.sqlite3_value) callconv(.c) void, |
| 724 | xDestroy: ?*const fn (?*anyopaque) callconv(.C) void, | 722 | xDestroy: ?*const fn (?*anyopaque) callconv(.c) void, |
| 725 | ) c_int { | 723 | ) c_int { |
| 726 | return sqlite3_api.*.create_window_function.?( | 724 | return sqlite3_api.*.create_window_function.?( |
| 727 | db, | 725 | db, |
| @@ -778,7 +776,7 @@ pub export fn sqlite3_changes64(db: ?*c.sqlite3) c.sqlite3_int64 { | |||
| 778 | pub export fn sqlite3_total_changes64(db: ?*c.sqlite3) c.sqlite3_int64 { | 776 | pub export fn sqlite3_total_changes64(db: ?*c.sqlite3) c.sqlite3_int64 { |
| 779 | return sqlite3_api.*.total_changes64.?(db); | 777 | return sqlite3_api.*.total_changes64.?(db); |
| 780 | } | 778 | } |
| 781 | pub export fn sqlite3_autovacuum_pages(db: ?*c.sqlite3, xCallback: ?*const fn (?*anyopaque, [*c]const u8, c_uint, c_uint, c_uint) callconv(.C) c_uint, pArg: ?*anyopaque, xDestructor: ?*const fn (?*anyopaque) callconv(.C) void) c_int { | 779 | pub export fn sqlite3_autovacuum_pages(db: ?*c.sqlite3, xCallback: ?*const fn (?*anyopaque, [*c]const u8, c_uint, c_uint, c_uint) callconv(.c) c_uint, pArg: ?*anyopaque, xDestructor: ?*const fn (?*anyopaque) callconv(.c) void) c_int { |
| 782 | return sqlite3_api.*.autovacuum_pages.?(db, xCallback, pArg, xDestructor); | 780 | return sqlite3_api.*.autovacuum_pages.?(db, xCallback, pArg, xDestructor); |
| 783 | } | 781 | } |
| 784 | pub export fn sqlite3_error_offset(db: ?*c.sqlite3) c_int { | 782 | pub export fn sqlite3_error_offset(db: ?*c.sqlite3) c_int { |
| @@ -276,10 +276,7 @@ pub const DetailedError = struct { | |||
| 276 | near: i32, | 276 | near: i32, |
| 277 | message: []const u8, | 277 | message: []const u8, |
| 278 | 278 | ||
| 279 | pub fn format(self: @This(), comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void { | 279 | pub fn format(self: @This(), writer: anytype) !void { |
| 280 | _ = fmt; | ||
| 281 | _ = options; | ||
| 282 | |||
| 283 | _ = try writer.print("{{code: {}, near: {d}, message: {s}}}", .{ self.code, self.near, self.message }); | 280 | _ = try writer.print("{{code: {}, near: {d}, message: {s}}}", .{ self.code, self.near, self.message }); |
| 284 | } | 281 | } |
| 285 | }; | 282 | }; |
diff --git a/examples/zigcrypto.zig b/examples/zigcrypto.zig index 05c44a5..9489df1 100644 --- a/examples/zigcrypto.zig +++ b/examples/zigcrypto.zig | |||
| @@ -39,7 +39,7 @@ fn createAllFunctions(db: *sqlite.Db) !void { | |||
| 39 | ); | 39 | ); |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | pub export fn sqlite3_zigcrypto_init(raw_db: *c.sqlite3, err_msg: [*c][*c]u8, api: *c.sqlite3_api_routines) callconv(.C) c_int { | 42 | pub export fn sqlite3_zigcrypto_init(raw_db: *c.sqlite3, err_msg: [*c][*c]u8, api: *c.sqlite3_api_routines) callconv(.c) c_int { |
| 43 | _ = err_msg; | 43 | _ = err_msg; |
| 44 | 44 | ||
| 45 | c.sqlite3_api = api; | 45 | c.sqlite3_api = api; |
diff --git a/examples/zigcrypto_test.zig b/examples/zigcrypto_test.zig index 9340f99..5922d8d 100644 --- a/examples/zigcrypto_test.zig +++ b/examples/zigcrypto_test.zig | |||
| @@ -41,14 +41,14 @@ pub fn main() anyerror!void { | |||
| 41 | var diags = sqlite.Diagnostics{}; | 41 | var diags = sqlite.Diagnostics{}; |
| 42 | 42 | ||
| 43 | const blake3_digest = db.oneAlloc([]const u8, allocator, "SELECT hex(blake3('foobar'))", .{ .diags = &diags }, .{}) catch |err| { | 43 | const blake3_digest = db.oneAlloc([]const u8, allocator, "SELECT hex(blake3('foobar'))", .{ .diags = &diags }, .{}) catch |err| { |
| 44 | debug.print("unable to get blake3 hash, err: {!}, diags: {s}\n", .{ err, diags }); | 44 | debug.print("unable to get blake3 hash, err: {}, diags: {f}\n", .{ err, diags }); |
| 45 | return err; | 45 | return err; |
| 46 | }; | 46 | }; |
| 47 | debug.assert(blake3_digest != null); | 47 | debug.assert(blake3_digest != null); |
| 48 | debug.assert(mem.eql(u8, "AA51DCD43D5C6C5203EE16906FD6B35DB298B9B2E1DE3FCE81811D4806B76B7D", blake3_digest.?)); | 48 | debug.assert(mem.eql(u8, "AA51DCD43D5C6C5203EE16906FD6B35DB298B9B2E1DE3FCE81811D4806B76B7D", blake3_digest.?)); |
| 49 | 49 | ||
| 50 | const sha3_digest = db.oneAlloc([]const u8, allocator, "SELECT hex(sha3_512('foobar'))", .{ .diags = &diags }, .{}) catch |err| { | 50 | const sha3_digest = db.oneAlloc([]const u8, allocator, "SELECT hex(sha3_512('foobar'))", .{ .diags = &diags }, .{}) catch |err| { |
| 51 | debug.print("unable to get sha3 hash, err: {!}, diags: {s}\n", .{ err, diags }); | 51 | debug.print("unable to get sha3 hash, err: {}, diags: {f}\n", .{ err, diags }); |
| 52 | return err; | 52 | return err; |
| 53 | }; | 53 | }; |
| 54 | debug.assert(sha3_digest != null); | 54 | debug.assert(sha3_digest != null); |
| @@ -132,7 +132,7 @@ pub const Blob = struct { | |||
| 132 | } | 132 | } |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | pub const Reader = io.Reader(*Self, errors.Error, read); | 135 | pub const Reader = io.GenericReader(*Self, errors.Error, read); |
| 136 | 136 | ||
| 137 | /// reader returns a io.Reader. | 137 | /// reader returns a io.Reader. |
| 138 | pub fn reader(self: *Self) Reader { | 138 | pub fn reader(self: *Self) Reader { |
| @@ -164,7 +164,7 @@ pub const Blob = struct { | |||
| 164 | return tmp_buffer.len; | 164 | return tmp_buffer.len; |
| 165 | } | 165 | } |
| 166 | 166 | ||
| 167 | pub const Writer = io.Writer(*Self, Error, write); | 167 | pub const Writer = io.GenericWriter(*Self, Error, write); |
| 168 | 168 | ||
| 169 | /// writer returns a io.Writer. | 169 | /// writer returns a io.Writer. |
| 170 | pub fn writer(self: *Self) Writer { | 170 | pub fn writer(self: *Self) Writer { |
| @@ -261,14 +261,14 @@ pub const Diagnostics = struct { | |||
| 261 | message: []const u8 = "", | 261 | message: []const u8 = "", |
| 262 | err: ?DetailedError = null, | 262 | err: ?DetailedError = null, |
| 263 | 263 | ||
| 264 | pub fn format(self: @This(), comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void { | 264 | pub fn format(self: @This(), writer: anytype) !void { |
| 265 | if (self.err) |err| { | 265 | if (self.err) |err| { |
| 266 | if (self.message.len > 0) { | 266 | if (self.message.len > 0) { |
| 267 | _ = try writer.print("{{message: {s}, detailed error: {s}}}", .{ self.message, err }); | 267 | _ = try writer.print("{{message: {s}, detailed error: {f}}}", .{ self.message, err }); |
| 268 | return; | 268 | return; |
| 269 | } | 269 | } |
| 270 | 270 | ||
| 271 | _ = try err.format(fmt, options, writer); | 271 | _ = try err.format(writer); |
| 272 | return; | 272 | return; |
| 273 | } | 273 | } |
| 274 | 274 | ||
| @@ -704,7 +704,7 @@ pub const Db = struct { | |||
| 704 | user_ctx, | 704 | user_ctx, |
| 705 | null, // xFunc | 705 | null, // xFunc |
| 706 | struct { | 706 | struct { |
| 707 | fn xStep(ctx: ?*c.sqlite3_context, argc: c_int, argv: [*c]?*c.sqlite3_value) callconv(.C) void { | 707 | fn xStep(ctx: ?*c.sqlite3_context, argc: c_int, argv: [*c]?*c.sqlite3_value) callconv(.c) void { |
| 708 | debug.assert(argc == real_args_len); | 708 | debug.assert(argc == real_args_len); |
| 709 | 709 | ||
| 710 | const sqlite_args = argv[0..real_args_len]; | 710 | const sqlite_args = argv[0..real_args_len]; |
| @@ -728,7 +728,7 @@ pub const Db = struct { | |||
| 728 | } | 728 | } |
| 729 | }.xStep, | 729 | }.xStep, |
| 730 | struct { | 730 | struct { |
| 731 | fn xFinal(ctx: ?*c.sqlite3_context) callconv(.C) void { | 731 | fn xFinal(ctx: ?*c.sqlite3_context) callconv(.c) void { |
| 732 | var args: std.meta.ArgsTuple(@TypeOf(finalize_func)) = undefined; | 732 | var args: std.meta.ArgsTuple(@TypeOf(finalize_func)) = undefined; |
| 733 | 733 | ||
| 734 | // Pass the function context | 734 | // Pass the function context |
| @@ -780,7 +780,7 @@ pub const Db = struct { | |||
| 780 | flags, | 780 | flags, |
| 781 | null, | 781 | null, |
| 782 | struct { | 782 | struct { |
| 783 | fn xFunc(ctx: ?*c.sqlite3_context, argc: c_int, argv: [*c]?*c.sqlite3_value) callconv(.C) void { | 783 | fn xFunc(ctx: ?*c.sqlite3_context, argc: c_int, argv: [*c]?*c.sqlite3_value) callconv(.c) void { |
| 784 | debug.assert(argc == fn_info.params.len); | 784 | debug.assert(argc == fn_info.params.len); |
| 785 | 785 | ||
| 786 | const sqlite_args = argv[0..fn_info.params.len]; | 786 | const sqlite_args = argv[0..fn_info.params.len]; |
| @@ -955,7 +955,7 @@ pub const Savepoint = struct { | |||
| 955 | 955 | ||
| 956 | // From DynamiStatement | 956 | // From DynamiStatement |
| 957 | EmptyQuery, | 957 | EmptyQuery, |
| 958 | } || std.fmt.AllocPrintError || Error; | 958 | } || std.mem.Allocator.Error || Error; |
| 959 | 959 | ||
| 960 | fn init(db: *Db, name: []const u8) InitError!Self { | 960 | fn init(db: *Db, name: []const u8) InitError!Self { |
| 961 | if (name.len < 1) return error.SavepointNameTooShort; | 961 | if (name.len < 1) return error.SavepointNameTooShort; |
| @@ -993,7 +993,7 @@ pub const Savepoint = struct { | |||
| 993 | pub fn commit(self: *Self) void { | 993 | pub fn commit(self: *Self) void { |
| 994 | self.commit_stmt.exec(.{}, .{}) catch |err| { | 994 | self.commit_stmt.exec(.{}, .{}) catch |err| { |
| 995 | const detailed_error = self.db.getDetailedError(); | 995 | const detailed_error = self.db.getDetailedError(); |
| 996 | logger.err("unable to release savepoint, error: {}, message: {s}", .{ err, detailed_error }); | 996 | logger.err("unable to release savepoint, error: {}, message: {f}", .{ err, detailed_error }); |
| 997 | }; | 997 | }; |
| 998 | self.committed = true; | 998 | self.committed = true; |
| 999 | } | 999 | } |
| @@ -1008,7 +1008,7 @@ pub const Savepoint = struct { | |||
| 1008 | 1008 | ||
| 1009 | self.rollback_stmt.exec(.{}, .{}) catch |err| { | 1009 | self.rollback_stmt.exec(.{}, .{}) catch |err| { |
| 1010 | const detailed_error = self.db.getDetailedError(); | 1010 | const detailed_error = self.db.getDetailedError(); |
| 1011 | std.debug.panic("unable to rollback transaction, error: {}, message: {s}\n", .{ err, detailed_error }); | 1011 | std.debug.panic("unable to rollback transaction, error: {}, message: {f}\n", .{ err, detailed_error }); |
| 1012 | }; | 1012 | }; |
| 1013 | } | 1013 | } |
| 1014 | }; | 1014 | }; |
| @@ -1589,7 +1589,7 @@ pub const DynamicStatement = struct { | |||
| 1589 | const result = c.sqlite3_finalize(self.stmt); | 1589 | const result = c.sqlite3_finalize(self.stmt); |
| 1590 | if (result != c.SQLITE_OK) { | 1590 | if (result != c.SQLITE_OK) { |
| 1591 | const detailed_error = getLastDetailedErrorFromDb(self.db); | 1591 | const detailed_error = getLastDetailedErrorFromDb(self.db); |
| 1592 | logger.err("unable to finalize prepared statement, result: {}, detailed error: {}", .{ result, detailed_error }); | 1592 | logger.err("unable to finalize prepared statement, result: {}, detailed error: {f}", .{ result, detailed_error }); |
| 1593 | } | 1593 | } |
| 1594 | } | 1594 | } |
| 1595 | 1595 | ||
| @@ -1598,12 +1598,12 @@ pub const DynamicStatement = struct { | |||
| 1598 | const result = c.sqlite3_clear_bindings(self.stmt); | 1598 | const result = c.sqlite3_clear_bindings(self.stmt); |
| 1599 | if (result != c.SQLITE_OK) { | 1599 | if (result != c.SQLITE_OK) { |
| 1600 | const detailed_error = getLastDetailedErrorFromDb(self.db); | 1600 | const detailed_error = getLastDetailedErrorFromDb(self.db); |
| 1601 | logger.err("unable to clear prepared statement bindings, result: {}, detailed error: {}", .{ result, detailed_error }); | 1601 | logger.err("unable to clear prepared statement bindings, result: {}, detailed error: {f}", .{ result, detailed_error }); |
| 1602 | } | 1602 | } |
| 1603 | const result2 = c.sqlite3_reset(self.stmt); | 1603 | const result2 = c.sqlite3_reset(self.stmt); |
| 1604 | if (result2 != c.SQLITE_OK) { | 1604 | if (result2 != c.SQLITE_OK) { |
| 1605 | const detailed_error = getLastDetailedErrorFromDb(self.db); | 1605 | const detailed_error = getLastDetailedErrorFromDb(self.db); |
| 1606 | logger.err("unable to reset prepared statement, result: {}, detailed error: {}", .{ result2, detailed_error }); | 1606 | logger.err("unable to reset prepared statement, result: {}, detailed error: {f}", .{ result2, detailed_error }); |
| 1607 | } | 1607 | } |
| 1608 | } | 1608 | } |
| 1609 | 1609 | ||
| @@ -3223,7 +3223,7 @@ test "sqlite: diagnostics format" { | |||
| 3223 | 3223 | ||
| 3224 | inline for (testCases) |tc| { | 3224 | inline for (testCases) |tc| { |
| 3225 | var buf: [1024]u8 = undefined; | 3225 | var buf: [1024]u8 = undefined; |
| 3226 | const str = try std.fmt.bufPrint(&buf, "my diagnostics: {s}", .{tc.input}); | 3226 | const str = try std.fmt.bufPrint(&buf, "my diagnostics: {f}", .{tc.input}); |
| 3227 | 3227 | ||
| 3228 | try testing.expectEqualStrings(tc.exp, str); | 3228 | try testing.expectEqualStrings(tc.exp, str); |
| 3229 | } | 3229 | } |
| @@ -3390,7 +3390,8 @@ const MyData = struct { | |||
| 3390 | const BaseType = []const u8; | 3390 | const BaseType = []const u8; |
| 3391 | 3391 | ||
| 3392 | pub fn bindField(self: MyData, allocator: mem.Allocator) !BaseType { | 3392 | pub fn bindField(self: MyData, allocator: mem.Allocator) !BaseType { |
| 3393 | return try std.fmt.allocPrint(allocator, "{}", .{std.fmt.fmtSliceHexLower(&self.data)}); | 3393 | const num = std.mem.bytesAsValue(u128, &self.data); |
| 3394 | return try std.fmt.allocPrint(allocator, "{s}", .{std.fmt.hex(num.*)}); | ||
| 3394 | } | 3395 | } |
| 3395 | 3396 | ||
| 3396 | pub fn readField(alloc: mem.Allocator, value: BaseType) !MyData { | 3397 | pub fn readField(alloc: mem.Allocator, value: BaseType) !MyData { |
| @@ -3797,7 +3798,7 @@ test "sqlite: create aggregate function with no aggregate context" { | |||
| 3797 | .{ .diags = &diags }, | 3798 | .{ .diags = &diags }, |
| 3798 | .{}, | 3799 | .{}, |
| 3799 | ) catch |err| { | 3800 | ) catch |err| { |
| 3800 | debug.print("err: {}\n", .{diags}); | 3801 | debug.print("err: {f}\n", .{diags}); |
| 3801 | return err; | 3802 | return err; |
| 3802 | }; | 3803 | }; |
| 3803 | 3804 | ||
| @@ -3858,7 +3859,7 @@ test "sqlite: create aggregate function with an aggregate context" { | |||
| 3858 | .{ .diags = &diags }, | 3859 | .{ .diags = &diags }, |
| 3859 | .{}, | 3860 | .{}, |
| 3860 | ) catch |err| { | 3861 | ) catch |err| { |
| 3861 | debug.print("err: {}\n", .{diags}); | 3862 | debug.print("err: {f}\n", .{diags}); |
| 3862 | return err; | 3863 | return err; |
| 3863 | }; | 3864 | }; |
| 3864 | 3865 | ||
| @@ -50,7 +50,7 @@ pub const VTabDiagnostics = struct { | |||
| 50 | error_message: []const u8 = "unknown error", | 50 | error_message: []const u8 = "unknown error", |
| 51 | 51 | ||
| 52 | pub fn setErrorMessage(self: *Self, comptime format_string: []const u8, values: anytype) void { | 52 | pub fn setErrorMessage(self: *Self, comptime format_string: []const u8, values: anytype) void { |
| 53 | self.error_message = fmt.allocPrint(self.allocator, format_string, values) catch |err| switch (err) { | 53 | self.error_message = fmt.allocPrintSentinel(self.allocator, format_string, values, 0) catch |err| switch (err) { |
| 54 | error.OutOfMemory => "can't set diagnostic message, out of memory", | 54 | error.OutOfMemory => "can't set diagnostic message, out of memory", |
| 55 | }; | 55 | }; |
| 56 | } | 56 | } |
| @@ -717,7 +717,7 @@ pub fn VirtualTable( | |||
| 717 | return try State.init(module_context, table); | 717 | return try State.init(module_context, table); |
| 718 | } | 718 | } |
| 719 | 719 | ||
| 720 | fn xCreate(db: ?*c.sqlite3, module_context_ptr: ?*anyopaque, argc: c_int, argv: [*c]const [*c]const u8, vtab: [*c][*c]c.sqlite3_vtab, err_str: [*c][*c]const u8) callconv(.C) c_int { | 720 | fn xCreate(db: ?*c.sqlite3, module_context_ptr: ?*anyopaque, argc: c_int, argv: [*c]const [*c]const u8, vtab: [*c][*c]c.sqlite3_vtab, err_str: [*c][*c]const u8) callconv(.c) c_int { |
| 721 | _ = db; | 721 | _ = db; |
| 722 | _ = module_context_ptr; | 722 | _ = module_context_ptr; |
| 723 | _ = argc; | 723 | _ = argc; |
| @@ -730,7 +730,7 @@ pub fn VirtualTable( | |||
| 730 | return c.SQLITE_ERROR; | 730 | return c.SQLITE_ERROR; |
| 731 | } | 731 | } |
| 732 | 732 | ||
| 733 | fn xConnect(db: ?*c.sqlite3, module_context_ptr: ?*anyopaque, argc: c_int, argv: [*c]const [*c]const u8, vtab: [*c][*c]c.sqlite3_vtab, err_str: [*c][*c]u8) callconv(.C) c_int { | 733 | fn xConnect(db: ?*c.sqlite3, module_context_ptr: ?*anyopaque, argc: c_int, argv: [*c]const [*c]const u8, vtab: [*c][*c]c.sqlite3_vtab, err_str: [*c][*c]u8) callconv(.c) c_int { |
| 734 | const module_context = getModuleContext(module_context_ptr); | 734 | const module_context = getModuleContext(module_context_ptr); |
| 735 | 735 | ||
| 736 | var arena = heap.ArenaAllocator.init(module_context.allocator); | 736 | var arena = heap.ArenaAllocator.init(module_context.allocator); |
| @@ -761,7 +761,7 @@ pub fn VirtualTable( | |||
| 761 | return c.SQLITE_OK; | 761 | return c.SQLITE_OK; |
| 762 | } | 762 | } |
| 763 | 763 | ||
| 764 | fn xBestIndex(vtab: [*c]c.sqlite3_vtab, index_info_ptr: [*c]c.sqlite3_index_info) callconv(.C) c_int { | 764 | fn xBestIndex(vtab: [*c]c.sqlite3_vtab, index_info_ptr: [*c]c.sqlite3_index_info) callconv(.c) c_int { |
| 765 | const index_info: *c.sqlite3_index_info = index_info_ptr orelse unreachable; | 765 | const index_info: *c.sqlite3_index_info = index_info_ptr orelse unreachable; |
| 766 | 766 | ||
| 767 | // | 767 | // |
| @@ -775,20 +775,20 @@ pub fn VirtualTable( | |||
| 775 | // Create an index builder and let the user build the index. | 775 | // Create an index builder and let the user build the index. |
| 776 | 776 | ||
| 777 | var builder = BestIndexBuilder.init(arena.allocator(), index_info) catch |err| { | 777 | var builder = BestIndexBuilder.init(arena.allocator(), index_info) catch |err| { |
| 778 | logger.err("unable to create best index builder, err: {!}", .{err}); | 778 | logger.err("unable to create best index builder, err: {}", .{err}); |
| 779 | return c.SQLITE_ERROR; | 779 | return c.SQLITE_ERROR; |
| 780 | }; | 780 | }; |
| 781 | 781 | ||
| 782 | var diags = VTabDiagnostics{ .allocator = arena.allocator() }; | 782 | var diags = VTabDiagnostics{ .allocator = arena.allocator() }; |
| 783 | state.table.buildBestIndex(&diags, &builder) catch |err| { | 783 | state.table.buildBestIndex(&diags, &builder) catch |err| { |
| 784 | logger.err("unable to build best index, err: {!}", .{err}); | 784 | logger.err("unable to build best index, err: {}", .{err}); |
| 785 | return c.SQLITE_ERROR; | 785 | return c.SQLITE_ERROR; |
| 786 | }; | 786 | }; |
| 787 | 787 | ||
| 788 | return c.SQLITE_OK; | 788 | return c.SQLITE_OK; |
| 789 | } | 789 | } |
| 790 | 790 | ||
| 791 | fn xDisconnect(vtab: [*c]c.sqlite3_vtab) callconv(.C) c_int { | 791 | fn xDisconnect(vtab: [*c]c.sqlite3_vtab) callconv(.c) c_int { |
| 792 | const nullable_state: ?*State = @fieldParentPtr("vtab", vtab); | 792 | const nullable_state: ?*State = @fieldParentPtr("vtab", vtab); |
| 793 | const state = nullable_state orelse unreachable; | 793 | const state = nullable_state orelse unreachable; |
| 794 | 794 | ||
| @@ -797,7 +797,7 @@ pub fn VirtualTable( | |||
| 797 | return c.SQLITE_OK; | 797 | return c.SQLITE_OK; |
| 798 | } | 798 | } |
| 799 | 799 | ||
| 800 | fn xDestroy(vtab: [*c]c.sqlite3_vtab) callconv(.C) c_int { | 800 | fn xDestroy(vtab: [*c]c.sqlite3_vtab) callconv(.c) c_int { |
| 801 | _ = vtab; | 801 | _ = vtab; |
| 802 | 802 | ||
| 803 | debug.print("xDestroy\n", .{}); | 803 | debug.print("xDestroy\n", .{}); |
| @@ -805,12 +805,12 @@ pub fn VirtualTable( | |||
| 805 | return c.SQLITE_ERROR; | 805 | return c.SQLITE_ERROR; |
| 806 | } | 806 | } |
| 807 | 807 | ||
| 808 | fn xOpen(vtab: [*c]c.sqlite3_vtab, vtab_cursor: [*c][*c]c.sqlite3_vtab_cursor) callconv(.C) c_int { | 808 | fn xOpen(vtab: [*c]c.sqlite3_vtab, vtab_cursor: [*c][*c]c.sqlite3_vtab_cursor) callconv(.c) c_int { |
| 809 | const nullable_state: ?*State = @fieldParentPtr("vtab", vtab); | 809 | const nullable_state: ?*State = @fieldParentPtr("vtab", vtab); |
| 810 | const state = nullable_state orelse unreachable; | 810 | const state = nullable_state orelse unreachable; |
| 811 | 811 | ||
| 812 | const cursor_state = CursorState.init(state.module_context, state.table) catch |err| { | 812 | const cursor_state = CursorState.init(state.module_context, state.table) catch |err| { |
| 813 | logger.err("unable to create cursor state, err: {!}", .{err}); | 813 | logger.err("unable to create cursor state, err: {}", .{err}); |
| 814 | return c.SQLITE_ERROR; | 814 | return c.SQLITE_ERROR; |
| 815 | }; | 815 | }; |
| 816 | vtab_cursor.* = @ptrCast(cursor_state); | 816 | vtab_cursor.* = @ptrCast(cursor_state); |
| @@ -818,7 +818,7 @@ pub fn VirtualTable( | |||
| 818 | return c.SQLITE_OK; | 818 | return c.SQLITE_OK; |
| 819 | } | 819 | } |
| 820 | 820 | ||
| 821 | fn xClose(vtab_cursor: [*c]c.sqlite3_vtab_cursor) callconv(.C) c_int { | 821 | fn xClose(vtab_cursor: [*c]c.sqlite3_vtab_cursor) callconv(.c) c_int { |
| 822 | const nullable_cursor_state: ?*CursorState = @fieldParentPtr("vtab_cursor", vtab_cursor); | 822 | const nullable_cursor_state: ?*CursorState = @fieldParentPtr("vtab_cursor", vtab_cursor); |
| 823 | const cursor_state = nullable_cursor_state orelse unreachable; | 823 | const cursor_state = nullable_cursor_state orelse unreachable; |
| 824 | 824 | ||
| @@ -827,7 +827,7 @@ pub fn VirtualTable( | |||
| 827 | return c.SQLITE_OK; | 827 | return c.SQLITE_OK; |
| 828 | } | 828 | } |
| 829 | 829 | ||
| 830 | fn xEof(vtab_cursor: [*c]c.sqlite3_vtab_cursor) callconv(.C) c_int { | 830 | fn xEof(vtab_cursor: [*c]c.sqlite3_vtab_cursor) callconv(.c) c_int { |
| 831 | const nullable_cursor_state: ?*CursorState = @fieldParentPtr("vtab_cursor", vtab_cursor); | 831 | const nullable_cursor_state: ?*CursorState = @fieldParentPtr("vtab_cursor", vtab_cursor); |
| 832 | const cursor_state = nullable_cursor_state orelse unreachable; | 832 | const cursor_state = nullable_cursor_state orelse unreachable; |
| 833 | const cursor = cursor_state.cursor; | 833 | const cursor = cursor_state.cursor; |
| @@ -865,7 +865,7 @@ pub fn VirtualTable( | |||
| 865 | return res; | 865 | return res; |
| 866 | } | 866 | } |
| 867 | 867 | ||
| 868 | fn xFilter(vtab_cursor: [*c]c.sqlite3_vtab_cursor, idx_num: c_int, idx_str: [*c]const u8, argc: c_int, argv: [*c]?*c.sqlite3_value) callconv(.C) c_int { | 868 | fn xFilter(vtab_cursor: [*c]c.sqlite3_vtab_cursor, idx_num: c_int, idx_str: [*c]const u8, argc: c_int, argv: [*c]?*c.sqlite3_value) callconv(.c) c_int { |
| 869 | const nullable_cursor_state: ?*CursorState = @fieldParentPtr("vtab_cursor", vtab_cursor); | 869 | const nullable_cursor_state: ?*CursorState = @fieldParentPtr("vtab_cursor", vtab_cursor); |
| 870 | const cursor_state = nullable_cursor_state orelse unreachable; | 870 | const cursor_state = nullable_cursor_state orelse unreachable; |
| 871 | const cursor = cursor_state.cursor; | 871 | const cursor = cursor_state.cursor; |
| @@ -878,7 +878,7 @@ pub fn VirtualTable( | |||
| 878 | const id = IndexIdentifier.fromC(idx_num, idx_str); | 878 | const id = IndexIdentifier.fromC(idx_num, idx_str); |
| 879 | 879 | ||
| 880 | const args = filterArgsFromCPointer(arena.allocator(), argc, argv) catch |err| { | 880 | const args = filterArgsFromCPointer(arena.allocator(), argc, argv) catch |err| { |
| 881 | logger.err("unable to create filter args, err: {!}", .{err}); | 881 | logger.err("unable to create filter args, err: {}", .{err}); |
| 882 | return c.SQLITE_ERROR; | 882 | return c.SQLITE_ERROR; |
| 883 | }; | 883 | }; |
| 884 | 884 | ||
| @@ -891,7 +891,7 @@ pub fn VirtualTable( | |||
| 891 | return c.SQLITE_OK; | 891 | return c.SQLITE_OK; |
| 892 | } | 892 | } |
| 893 | 893 | ||
| 894 | fn xNext(vtab_cursor: [*c]c.sqlite3_vtab_cursor) callconv(.C) c_int { | 894 | fn xNext(vtab_cursor: [*c]c.sqlite3_vtab_cursor) callconv(.c) c_int { |
| 895 | const nullable_cursor_state: ?*CursorState = @fieldParentPtr("vtab_cursor", vtab_cursor); | 895 | const nullable_cursor_state: ?*CursorState = @fieldParentPtr("vtab_cursor", vtab_cursor); |
| 896 | const cursor_state = nullable_cursor_state orelse unreachable; | 896 | const cursor_state = nullable_cursor_state orelse unreachable; |
| 897 | const cursor = cursor_state.cursor; | 897 | const cursor = cursor_state.cursor; |
| @@ -910,7 +910,7 @@ pub fn VirtualTable( | |||
| 910 | return c.SQLITE_OK; | 910 | return c.SQLITE_OK; |
| 911 | } | 911 | } |
| 912 | 912 | ||
| 913 | fn xColumn(vtab_cursor: [*c]c.sqlite3_vtab_cursor, ctx: ?*c.sqlite3_context, n: c_int) callconv(.C) c_int { | 913 | fn xColumn(vtab_cursor: [*c]c.sqlite3_vtab_cursor, ctx: ?*c.sqlite3_context, n: c_int) callconv(.c) c_int { |
| 914 | const nullable_cursor_state: ?*CursorState = @fieldParentPtr("vtab_cursor", vtab_cursor); | 914 | const nullable_cursor_state: ?*CursorState = @fieldParentPtr("vtab_cursor", vtab_cursor); |
| 915 | const cursor_state = nullable_cursor_state orelse unreachable; | 915 | const cursor_state = nullable_cursor_state orelse unreachable; |
| 916 | const cursor = cursor_state.cursor; | 916 | const cursor = cursor_state.cursor; |
| @@ -954,7 +954,7 @@ pub fn VirtualTable( | |||
| 954 | return c.SQLITE_OK; | 954 | return c.SQLITE_OK; |
| 955 | } | 955 | } |
| 956 | 956 | ||
| 957 | fn xRowid(vtab_cursor: [*c]c.sqlite3_vtab_cursor, row_id_ptr: [*c]c.sqlite3_int64) callconv(.C) c_int { | 957 | fn xRowid(vtab_cursor: [*c]c.sqlite3_vtab_cursor, row_id_ptr: [*c]c.sqlite3_int64) callconv(.c) c_int { |
| 958 | const nullable_cursor_state: ?*CursorState = @fieldParentPtr("vtab_cursor", vtab_cursor); | 958 | const nullable_cursor_state: ?*CursorState = @fieldParentPtr("vtab_cursor", vtab_cursor); |
| 959 | const cursor_state = nullable_cursor_state orelse unreachable; | 959 | const cursor_state = nullable_cursor_state orelse unreachable; |
| 960 | const cursor = cursor_state.cursor; | 960 | const cursor = cursor_state.cursor; |
| @@ -1011,7 +1011,7 @@ const TestVirtualTable = struct { | |||
| 1011 | n = fmt.parseInt(usize, kv.value, 10) catch |err| { | 1011 | n = fmt.parseInt(usize, kv.value, 10) catch |err| { |
| 1012 | switch (err) { | 1012 | switch (err) { |
| 1013 | error.InvalidCharacter => diags.setErrorMessage("not a number: {s}", .{kv.value}), | 1013 | error.InvalidCharacter => diags.setErrorMessage("not a number: {s}", .{kv.value}), |
| 1014 | else => diags.setErrorMessage("got error while parsing value {s}: {!}", .{ kv.value, err }), | 1014 | else => diags.setErrorMessage("got error while parsing value {s}: {}", .{ kv.value, err }), |
| 1015 | } | 1015 | } |
| 1016 | return err; | 1016 | return err; |
| 1017 | }; | 1017 | }; |
| @@ -1297,7 +1297,7 @@ test "parse module arguments" { | |||
| 1297 | 1297 | ||
| 1298 | const args = try allocator.alloc([*c]const u8, 20); | 1298 | const args = try allocator.alloc([*c]const u8, 20); |
| 1299 | for (args, 0..) |*arg, i| { | 1299 | for (args, 0..) |*arg, i| { |
| 1300 | const tmp = try fmt.allocPrintZ(allocator, "arg={d}", .{i}); | 1300 | const tmp = try fmt.allocPrintSentinel(allocator, "arg={d}", .{i}, 0); |
| 1301 | arg.* = @ptrCast(tmp); | 1301 | arg.* = @ptrCast(tmp); |
| 1302 | } | 1302 | } |
| 1303 | 1303 | ||