From f49f091dfe81bd5cc953ac0b7bf64a7e7ba0d642 Mon Sep 17 00:00:00 2001 From: Ed Yu Date: Tue, 24 Oct 2023 16:09:35 -0700 Subject: Add paths field in build.zig.zon --- build.zig.zon | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.zig.zon b/build.zig.zon index f7f5c2e..dc42098 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,4 +1,5 @@ .{ .name = "sqlite", - .version = "0.0.0", + .version = "3.43.1", + .paths = .{"."}, } -- cgit v1.2.3 From c7349b7652d0b78fa7e06fc36e48f0f6a520af1d Mon Sep 17 00:00:00 2001 From: Ed Yu Date: Tue, 24 Oct 2023 16:45:22 -0700 Subject: Update to sqlite 3.43.2 --- build.zig.zon | 2 +- c/sqlite3.c | 45 ++++++++++++++++++++++++++------------------- c/sqlite3.h | 6 +++--- 3 files changed, 30 insertions(+), 23 deletions(-) diff --git a/build.zig.zon b/build.zig.zon index dc42098..77ec3d9 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,5 +1,5 @@ .{ .name = "sqlite", - .version = "3.43.1", + .version = "3.43.2", .paths = .{"."}, } diff --git a/c/sqlite3.c b/c/sqlite3.c index 1884b08..a1fbd60 100644 --- a/c/sqlite3.c +++ b/c/sqlite3.c @@ -1,6 +1,6 @@ /****************************************************************************** ** This file is an amalgamation of many separate C source files from SQLite -** version 3.43.1. By combining all the individual C code files into this +** version 3.43.2. By combining all the individual C code files into this ** single large file, the entire code can be compiled as a single translation ** unit. This allows many compilers to do optimizations that would not be ** possible if the files were compiled separately. Performance improvements @@ -18,7 +18,7 @@ ** separate file. This file contains only code for the core SQLite library. ** ** The content in this amalgamation comes from Fossil check-in -** d3a40c05c49e1a49264912b1a05bc2143ac. +** 310099cce5a487035fa535dd3002c59ac7f. */ #define SQLITE_CORE 1 #define SQLITE_AMALGAMATION 1 @@ -459,9 +459,9 @@ extern "C" { ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ -#define SQLITE_VERSION "3.43.1" -#define SQLITE_VERSION_NUMBER 3043001 -#define SQLITE_SOURCE_ID "2023-09-11 12:01:27 2d3a40c05c49e1a49264912b1a05bc2143ac0e7c3df588276ce80a4cbc9bd1b0" +#define SQLITE_VERSION "3.43.2" +#define SQLITE_VERSION_NUMBER 3043002 +#define SQLITE_SOURCE_ID "2023-10-10 12:14:04 4310099cce5a487035fa535dd3002c59ac7f1d1bec68d7cf317fd3e769484790" /* ** CAPI3REF: Run-Time Library Version Numbers @@ -35185,29 +35185,29 @@ SQLITE_PRIVATE void sqlite3FpDecode(FpDecode *p, double r, int iRound, int mxRou double rr[2]; rr[0] = r; rr[1] = 0.0; - if( rr[0]>1.84e+19 ){ - while( rr[0]>1.84e+119 ){ + if( rr[0]>9.223372036854774784e+18 ){ + while( rr[0]>9.223372036854774784e+118 ){ exp += 100; dekkerMul2(rr, 1.0e-100, -1.99918998026028836196e-117); } - while( rr[0]>1.84e+29 ){ + while( rr[0]>9.223372036854774784e+28 ){ exp += 10; dekkerMul2(rr, 1.0e-10, -3.6432197315497741579e-27); } - while( rr[0]>1.84e+19 ){ + while( rr[0]>9.223372036854774784e+18 ){ exp += 1; dekkerMul2(rr, 1.0e-01, -5.5511151231257827021e-18); } }else{ - while( rr[0]<1.84e-82 ){ + while( rr[0]<9.223372036854774784e-83 ){ exp -= 100; dekkerMul2(rr, 1.0e+100, -1.5902891109759918046e+83); } - while( rr[0]<1.84e+08 ){ + while( rr[0]<9.223372036854774784e+07 ){ exp -= 10; dekkerMul2(rr, 1.0e+10, 0.0); } - while( rr[0]<1.84e+18 ){ + while( rr[0]<9.22337203685477478e+17 ){ exp -= 1; dekkerMul2(rr, 1.0e+01, 0.0); } @@ -77024,6 +77024,7 @@ static int rebuildPage( int k; /* Current slot in pCArray->apEnd[] */ u8 *pSrcEnd; /* Current pCArray->apEnd[k] value */ + assert( nCell>0 ); assert( i(u32)usableSize) ){ j = 0; } @@ -77330,6 +77331,7 @@ static int editPage( return SQLITE_OK; editpage_fail: /* Unable to edit this page. Rebuild it from scratch instead. */ + if( nNew<1 ) return SQLITE_CORRUPT_BKPT; populateCellCache(pCArray, iNew, nNew); return rebuildPage(pCArray, iNew, nNew, pPg); } @@ -100833,8 +100835,7 @@ static int blobSeekToRow(Incrblob *p, sqlite3_int64 iRow, char **pzErr){ /* Set the value of register r[1] in the SQL statement to integer iRow. ** This is done directly as a performance optimization */ - v->aMem[1].flags = MEM_Int; - v->aMem[1].u.i = iRow; + sqlite3VdbeMemSetInt64(&v->aMem[1], iRow); /* If the statement has been run before (and is paused at the OP_ResultRow) ** then back it up to the point where it does the OP_NotExists. This could @@ -204136,6 +204137,7 @@ static void jsonReplaceFunc( } pParse = jsonParseCached(ctx, argv[0], ctx, argc>1); if( pParse==0 ) return; + pParse->nJPRef++; for(i=1; i<(u32)argc; i+=2){ zPath = (const char*)sqlite3_value_text(argv[i]); pParse->useMod = 1; @@ -204148,6 +204150,7 @@ static void jsonReplaceFunc( jsonReturnJson(pParse, pParse->aNode, ctx, 1); replace_err: jsonDebugPrintParse(pParse); + jsonParseFree(pParse); } @@ -204182,6 +204185,7 @@ static void jsonSetFunc( } pParse = jsonParseCached(ctx, argv[0], ctx, argc>1); if( pParse==0 ) return; + pParse->nJPRef++; for(i=1; i<(u32)argc; i+=2){ zPath = (const char*)sqlite3_value_text(argv[i]); bApnd = 0; @@ -204198,9 +204202,8 @@ static void jsonSetFunc( } jsonDebugPrintParse(pParse); jsonReturnJson(pParse, pParse->aNode, ctx, 1); - jsonSetDone: - /* no cleanup required */; + jsonParseFree(pParse); } /* @@ -239689,7 +239692,6 @@ static void fts5DoSecureDelete( int iIdx = 0; int iStart = 0; int iKeyOff = 0; - int iPrevKeyOff = 0; int iDelKeyOff = 0; /* Offset of deleted key, if any */ nIdx = nPg-iPgIdx; @@ -244251,6 +244253,9 @@ static int fts5FilterMethod( pCsr->iFirstRowid = fts5GetRowidLimit(pRowidGe, SMALLEST_INT64); } + rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex); + if( rc!=SQLITE_OK ) goto filter_out; + if( pTab->pSortCsr ){ /* If pSortCsr is non-NULL, then this call is being made as part of ** processing for a "... MATCH ORDER BY rank" query (ePlan is @@ -244273,7 +244278,9 @@ static int fts5FilterMethod( pCsr->pExpr = pTab->pSortCsr->pExpr; rc = fts5CursorFirst(pTab, pCsr, bDesc); }else if( pCsr->pExpr ){ - rc = fts5CursorParseRank(pConfig, pCsr, pRank); + if( rc==SQLITE_OK ){ + rc = fts5CursorParseRank(pConfig, pCsr, pRank); + } if( rc==SQLITE_OK ){ if( bOrderByRank ){ pCsr->ePlan = FTS5_PLAN_SORTED_MATCH; @@ -245754,7 +245761,7 @@ static void fts5SourceIdFunc( ){ assert( nArg==0 ); UNUSED_PARAM2(nArg, apUnused); - sqlite3_result_text(pCtx, "fts5: 2023-09-11 12:01:27 2d3a40c05c49e1a49264912b1a05bc2143ac0e7c3df588276ce80a4cbc9bd1b0", -1, SQLITE_TRANSIENT); + sqlite3_result_text(pCtx, "fts5: 2023-10-10 12:14:04 4310099cce5a487035fa535dd3002c59ac7f1d1bec68d7cf317fd3e769484790", -1, SQLITE_TRANSIENT); } /* diff --git a/c/sqlite3.h b/c/sqlite3.h index b9d0692..0376113 100644 --- a/c/sqlite3.h +++ b/c/sqlite3.h @@ -146,9 +146,9 @@ extern "C" { ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ -#define SQLITE_VERSION "3.43.1" -#define SQLITE_VERSION_NUMBER 3043001 -#define SQLITE_SOURCE_ID "2023-09-11 12:01:27 2d3a40c05c49e1a49264912b1a05bc2143ac0e7c3df588276ce80a4cbc9bd1b0" +#define SQLITE_VERSION "3.43.2" +#define SQLITE_VERSION_NUMBER 3043002 +#define SQLITE_SOURCE_ID "2023-10-10 12:14:04 4310099cce5a487035fa535dd3002c59ac7f1d1bec68d7cf317fd3e769484790" /* ** CAPI3REF: Run-Time Library Version Numbers -- cgit v1.2.3 From 467c1e9c099a1b12bb84111a7b7544e50b313f77 Mon Sep 17 00:00:00 2001 From: Ed Yu Date: Tue, 21 Nov 2023 15:37:59 -0800 Subject: Update to zig 0.12.0-dev.1664+8ca4a5240 --- query.zig | 4 ++-- sqlite.zig | 72 +++++++++++++++++++++++++++++++------------------------------- test.zig | 2 +- vtab.zig | 18 ++++++++-------- 4 files changed, 48 insertions(+), 48 deletions(-) diff --git a/query.zig b/query.zig index d47600f..9cb624b 100644 --- a/query.zig +++ b/query.zig @@ -276,7 +276,7 @@ test "parsed query: bind markers types" { inline for (testCases) |tc| { @setEvalBranchQuota(100000); - comptime var parsed_query = ParsedQuery(tc.query); + const parsed_query = comptime ParsedQuery(tc.query); try testing.expectEqual(1, parsed_query.nb_bind_markers); @@ -324,7 +324,7 @@ test "parsed query: bind markers identifier" { }; inline for (testCases) |tc| { - comptime var parsed_query = ParsedQuery(tc.query); + const parsed_query = comptime ParsedQuery(tc.query); try testing.expectEqual(@as(usize, 1), parsed_query.nb_bind_markers); diff --git a/sqlite.zig b/sqlite.zig index b251e1f..d521175 100644 --- a/sqlite.zig +++ b/sqlite.zig @@ -106,7 +106,7 @@ pub const Blob = struct { return 0; } - var tmp_buffer = blk: { + const tmp_buffer = blk: { const remaining: usize = @as(usize, @intCast(self.size)) - @as(usize, @intCast(self.offset)); break :blk if (buffer.len > remaining) buffer[0..remaining] else buffer; }; @@ -401,7 +401,7 @@ pub const Db = struct { /// const journal_mode = try db.pragma([]const u8, allocator, .{}, "journal_mode", null); /// pub fn pragmaAlloc(self: *Self, comptime Type: type, allocator: mem.Allocator, options: QueryOptions, comptime name: []const u8, comptime arg: ?[]const u8) !?Type { - comptime var query = getPragmaQuery(name, arg); + const query = comptime getPragmaQuery(name, arg); var stmt = try self.prepare(query); defer stmt.deinit(); @@ -423,7 +423,7 @@ pub const Db = struct { /// /// This cannot allocate memory. If your pragma command returns text you must use an array or call `pragmaAlloc`. pub fn pragma(self: *Self, comptime Type: type, options: QueryOptions, comptime name: []const u8, comptime arg: ?[]const u8) !?Type { - comptime var query = getPragmaQuery(name, arg); + const query = comptime getPragmaQuery(name, arg); var stmt = try self.prepareWithDiags(query, options); defer stmt.deinit(); @@ -936,7 +936,7 @@ pub const Savepoint = struct { var buffer: [256]u8 = undefined; var fba = std.heap.FixedBufferAllocator.init(&buffer); - var allocator = fba.allocator(); + const allocator = fba.allocator(); const commit_query = try std.fmt.allocPrint(allocator, "RELEASE SAVEPOINT {s}", .{name}); const rollback_query = try std.fmt.allocPrint(allocator, "ROLLBACK TRANSACTION TO SAVEPOINT {s}", .{name}); @@ -1028,7 +1028,7 @@ pub fn Iterator(comptime Type: type) type { var dummy_diags = Diagnostics{}; var diags = options.diags orelse &dummy_diags; - var result = c.sqlite3_step(self.stmt); + const result = c.sqlite3_step(self.stmt); if (result == c.SQLITE_DONE) { return null; } @@ -1086,7 +1086,7 @@ pub fn Iterator(comptime Type: type) type { var dummy_diags = Diagnostics{}; var diags = options.diags orelse &dummy_diags; - var result = c.sqlite3_step(self.stmt); + const result = c.sqlite3_step(self.stmt); if (result == c.SQLITE_DONE) { return null; } @@ -1516,7 +1516,7 @@ pub const DynamicStatement = struct { fn prepare(db: *Db, query: []const u8, options: QueryOptions, flags: c_uint) PrepareError!Self { var dummy_diags = Diagnostics{}; var diags = options.diags orelse &dummy_diags; - var stmt = blk: { + const stmt = blk: { var tmp: ?*c.sqlite3_stmt = undefined; const result = c.sqlite3_prepare_v3( db.db, @@ -2312,7 +2312,7 @@ test "sqlite: exec multi with single statement" { test "sqlite: db pragma" { var arena = std.heap.ArenaAllocator.init(testing.allocator); defer arena.deinit(); - var allocator = arena.allocator(); + const allocator = arena.allocator(); var db = try getTestDb(); defer db.deinit(); @@ -2425,7 +2425,7 @@ test "sqlite: db execAlloc" { test "sqlite: read a single user into a struct" { var arena = std.heap.ArenaAllocator.init(testing.allocator); defer arena.deinit(); - var allocator = arena.allocator(); + const allocator = arena.allocator(); var db = try getTestDb(); defer db.deinit(); @@ -2434,7 +2434,7 @@ test "sqlite: read a single user into a struct" { var stmt = try db.prepare("SELECT * FROM user WHERE id = ?{usize}"); defer stmt.deinit(); - var rows = try stmt.all(TestUser, allocator, .{}, .{ + const rows = try stmt.all(TestUser, allocator, .{}, .{ .id = @as(usize, 20), }); for (rows) |row| { @@ -2465,7 +2465,7 @@ test "sqlite: read a single user into a struct" { // Read a row with db.oneAlloc() { - var row = try db.oneAlloc( + const row = try db.oneAlloc( struct { name: Text, id: usize, @@ -2488,7 +2488,7 @@ test "sqlite: read a single user into a struct" { test "sqlite: read all users into a struct" { var arena = std.heap.ArenaAllocator.init(testing.allocator); defer arena.deinit(); - var allocator = arena.allocator(); + const allocator = arena.allocator(); var db = try getTestDb(); defer db.deinit(); @@ -2497,7 +2497,7 @@ test "sqlite: read all users into a struct" { var stmt = try db.prepare("SELECT * FROM user"); defer stmt.deinit(); - var rows = try stmt.all(TestUser, allocator, .{}, .{}); + const rows = try stmt.all(TestUser, allocator, .{}, .{}); try testing.expectEqual(@as(usize, 3), rows.len); for (rows, 0..) |row, i| { const exp = test_users[i]; @@ -2511,7 +2511,7 @@ test "sqlite: read all users into a struct" { test "sqlite: read in an anonymous struct" { var arena = std.heap.ArenaAllocator.init(testing.allocator); defer arena.deinit(); - var allocator = arena.allocator(); + const allocator = arena.allocator(); var db = try getTestDb(); defer db.deinit(); @@ -2547,7 +2547,7 @@ test "sqlite: read in an anonymous struct" { test "sqlite: read in a Text struct" { var arena = std.heap.ArenaAllocator.init(testing.allocator); defer arena.deinit(); - var allocator = arena.allocator(); + const allocator = arena.allocator(); var db = try getTestDb(); defer db.deinit(); @@ -2556,7 +2556,7 @@ test "sqlite: read in a Text struct" { var stmt = try db.prepare("SELECT name, id, age FROM user WHERE id = ?{usize}"); defer stmt.deinit(); - var row = try stmt.oneAlloc( + const row = try stmt.oneAlloc( struct { name: Text, id: usize, @@ -2577,7 +2577,7 @@ test "sqlite: read in a Text struct" { test "sqlite: read a single text value" { var arena = std.heap.ArenaAllocator.init(testing.allocator); defer arena.deinit(); - var allocator = arena.allocator(); + const allocator = arena.allocator(); var db = try getTestDb(); defer db.deinit(); @@ -2659,7 +2659,7 @@ test "sqlite: read a single integer value" { var stmt: StatementType(.{}, query) = try db.prepare(query); defer stmt.deinit(); - var age = try stmt.one(typ, .{}, .{ + const age = try stmt.one(typ, .{}, .{ .id = @as(usize, 20), }); try testing.expect(age != null); @@ -2671,7 +2671,7 @@ test "sqlite: read a single integer value" { test "sqlite: read a single value into an enum backed by an integer" { var arena = std.heap.ArenaAllocator.init(testing.allocator); defer arena.deinit(); - var allocator = arena.allocator(); + const allocator = arena.allocator(); var db = try getTestDb(); defer db.deinit(); @@ -2718,7 +2718,7 @@ test "sqlite: read a single value into an enum backed by an integer" { test "sqlite: read a single value into an enum backed by a string" { var arena = std.heap.ArenaAllocator.init(testing.allocator); defer arena.deinit(); - var allocator = arena.allocator(); + const allocator = arena.allocator(); var db = try getTestDb(); defer db.deinit(); @@ -2819,7 +2819,7 @@ test "sqlite: bind string literal" { test "sqlite: bind pointer" { var arena = std.heap.ArenaAllocator.init(testing.allocator); defer arena.deinit(); - var allocator = arena.allocator(); + const allocator = arena.allocator(); var db = try getTestDb(); defer db.deinit(); @@ -2842,7 +2842,7 @@ test "sqlite: bind pointer" { test "sqlite: read pointers" { var arena = std.heap.ArenaAllocator.init(testing.allocator); defer arena.deinit(); - var allocator = arena.allocator(); + const allocator = arena.allocator(); var db = try getTestDb(); defer db.deinit(); @@ -2952,7 +2952,7 @@ test "sqlite: statement reset" { test "sqlite: statement iterator" { var arena = std.heap.ArenaAllocator.init(testing.allocator); defer arena.deinit(); - var allocator = arena.allocator(); + const allocator = arena.allocator(); var db = try getTestDb(); defer db.deinit(); @@ -3038,7 +3038,7 @@ test "sqlite: statement iterator" { test "sqlite: blob open, reopen" { var arena = std.heap.ArenaAllocator.init(testing.allocator); defer arena.deinit(); - var allocator = arena.allocator(); + const allocator = arena.allocator(); var db = try getTestDb(); defer db.deinit(); @@ -3197,7 +3197,7 @@ test "sqlite: exec with diags, failing statement" { test "sqlite: savepoint with no failures" { var arena = std.heap.ArenaAllocator.init(testing.allocator); defer arena.deinit(); - var allocator = arena.allocator(); + const allocator = arena.allocator(); var db = try getTestDb(); defer db.deinit(); @@ -3226,7 +3226,7 @@ test "sqlite: savepoint with no failures" { var stmt = try db.prepare("SELECT data, author_id FROM article ORDER BY id ASC"); defer stmt.deinit(); - var rows = try stmt.all( + const rows = try stmt.all( struct { data: []const u8, author_id: usize, @@ -3246,7 +3246,7 @@ test "sqlite: savepoint with no failures" { test "sqlite: two nested savepoints with inner failure" { var arena = std.heap.ArenaAllocator.init(testing.allocator); defer arena.deinit(); - var allocator = arena.allocator(); + const allocator = arena.allocator(); var db = try getTestDb(); defer db.deinit(); @@ -3280,7 +3280,7 @@ test "sqlite: two nested savepoints with inner failure" { var stmt = try db.prepare("SELECT data, author_id FROM article"); defer stmt.deinit(); - var rows = try stmt.all( + const rows = try stmt.all( struct { data: []const u8, author_id: usize, @@ -3297,7 +3297,7 @@ test "sqlite: two nested savepoints with inner failure" { test "sqlite: two nested savepoints with outer failure" { var arena = std.heap.ArenaAllocator.init(testing.allocator); defer arena.deinit(); - var allocator = arena.allocator(); + const allocator = arena.allocator(); var db = try getTestDb(); defer db.deinit(); @@ -3325,7 +3325,7 @@ test "sqlite: two nested savepoints with outer failure" { var stmt = try db.prepare("SELECT 1 FROM article"); defer stmt.deinit(); - var rows = try stmt.all(usize, allocator, .{}, .{}); + const rows = try stmt.all(usize, allocator, .{}, .{}); try testing.expectEqual(@as(usize, 0), rows.len); } @@ -3400,7 +3400,7 @@ test "sqlite: bind custom type" { test "sqlite: bind runtime slice" { var arena = std.heap.ArenaAllocator.init(testing.allocator); defer arena.deinit(); - var allocator = arena.allocator(); + const allocator = arena.allocator(); // creating array list on heap so that it's deemed runtime size var list = std.ArrayList([]const u8).init(allocator); @@ -3423,7 +3423,7 @@ test "sqlite: bind runtime slice" { test "sqlite: prepareDynamic" { var arena = std.heap.ArenaAllocator.init(testing.allocator); defer arena.deinit(); - var allocator = arena.allocator(); + const allocator = arena.allocator(); var db = try getTestDb(); defer db.deinit(); @@ -3465,7 +3465,7 @@ test "sqlite: prepareDynamic" { test "sqlite: oneDynamic" { var arena = std.heap.ArenaAllocator.init(testing.allocator); defer arena.deinit(); - var allocator = arena.allocator(); + const allocator = arena.allocator(); var db = try getTestDb(); defer db.deinit(); @@ -3713,7 +3713,7 @@ test "sqlite: create aggregate function with no aggregate context" { }.step, struct { fn finalize(fctx: FunctionContext) u32 { - var ctx = fctx.userContext(*MyContext) orelse return 0; + const ctx = fctx.userContext(*MyContext) orelse return 0; return ctx.sum; } }.finalize, @@ -3761,13 +3761,13 @@ test "sqlite: create aggregate function with an aggregate context" { null, struct { fn step(fctx: FunctionContext, input: u32) void { - var ctx = fctx.aggregateContext(*u32) orelse return; + const ctx = fctx.aggregateContext(*u32) orelse return; ctx.* += input; } }.step, struct { fn finalize(fctx: FunctionContext) u32 { - var ctx = fctx.aggregateContext(*u32) orelse return 0; + const ctx = fctx.aggregateContext(*u32) orelse return 0; return ctx.*; } }.finalize, diff --git a/test.zig b/test.zig index f6d9c9c..fcc8aa7 100644 --- a/test.zig +++ b/test.zig @@ -9,7 +9,7 @@ pub fn getTestDb() !Db { var buf: [1024]u8 = undefined; var fba = std.heap.FixedBufferAllocator.init(&buf); - var mode = dbMode(fba.allocator()); + const mode = dbMode(fba.allocator()); return try Db.init(.{ .open_flags = .{ diff --git a/vtab.zig b/vtab.zig index f5a5fd5..6fbd865 100644 --- a/vtab.zig +++ b/vtab.zig @@ -198,7 +198,7 @@ pub const BestIndexBuilder = struct { const InitError = error{} || mem.Allocator.Error || ConstraintOpFromCodeError; fn init(allocator: mem.Allocator, index_info: *c.sqlite3_index_info) InitError!Self { - var res = Self{ + const res = Self{ .allocator = allocator, .index_info = index_info, .id_str_buffer = std.ArrayList(u8).init(allocator), @@ -538,7 +538,7 @@ pub const ModuleArgument = union(enum) { const ParseModuleArgumentsError = error{} || mem.Allocator.Error; fn parseModuleArguments(allocator: mem.Allocator, argc: c_int, argv: [*c]const [*c]const u8) ParseModuleArgumentsError![]ModuleArgument { - var res = try allocator.alloc(ModuleArgument, @intCast(argc)); + const res = try allocator.alloc(ModuleArgument, @intCast(argc)); errdefer allocator.free(res); for (res, 0..) |*marg, i| { @@ -585,7 +585,7 @@ pub fn VirtualTable( const InitError = error{} || mem.Allocator.Error || Table.InitError; fn init(module_context: *ModuleContext, table: *Table) InitError!*Self { - var res = try module_context.allocator.create(Self); + const res = try module_context.allocator.create(Self); res.* = .{ .vtab = mem.zeroes(c.sqlite3_vtab), .module_context = module_context, @@ -615,7 +615,7 @@ pub fn VirtualTable( const InitError = error{} || mem.Allocator.Error || Table.Cursor.InitError; fn init(module_context: *ModuleContext, table: *Table) InitError!*Self { - var res = try module_context.allocator.create(Self); + const res = try module_context.allocator.create(Self); errdefer module_context.allocator.destroy(res); res.* = .{ @@ -839,7 +839,7 @@ pub fn VirtualTable( fn filterArgsFromCPointer(allocator: mem.Allocator, argc: c_int, argv: [*c]?*c.sqlite3_value) FilterArgsFromCPointerError![]FilterArg { const size: usize = @intCast(argc); - var res = try allocator.alloc(FilterArg, size); + const res = try allocator.alloc(FilterArg, size); for (res, 0..) |*item, i| { item.* = .{ .value = argv[i], @@ -860,7 +860,7 @@ pub fn VirtualTable( const id = IndexIdentifier.fromC(idx_num, idx_str); - var args = filterArgsFromCPointer(arena.allocator(), argc, argv) catch |err| { + const args = filterArgsFromCPointer(arena.allocator(), argc, argv) catch |err| { logger.err("unable to create filter args, err: {!}", .{err}); return c.SQLITE_ERROR; }; @@ -1008,7 +1008,7 @@ const TestVirtualTable = struct { var rand = std.rand.DefaultPrng.init(204882485); - var tmp = try allocator.alloc(Row, n); + const tmp = try allocator.alloc(Row, n); for (tmp) |*s| { const foo_value = data[rand.random().intRangeLessThan(usize, 0, data.len)]; const bar_value = data[rand.random().intRangeLessThan(usize, 0, data.len)]; @@ -1122,7 +1122,7 @@ const TestVirtualTableCursor = struct { pub const InitError = error{} || mem.Allocator.Error; pub fn init(allocator: mem.Allocator, parent: *TestVirtualTable) InitError!*TestVirtualTableCursor { - var res = try allocator.create(TestVirtualTableCursor); + const res = try allocator.create(TestVirtualTableCursor); res.* = .{ .allocator = allocator, .parent = parent, @@ -1275,7 +1275,7 @@ test "parse module arguments" { defer arena.deinit(); const allocator = arena.allocator(); - var args = try allocator.alloc([*c]const u8, 20); + const args = try allocator.alloc([*c]const u8, 20); for (args, 0..) |*arg, i| { const tmp = try fmt.allocPrintZ(allocator, "arg={d}", .{i}); arg.* = @ptrCast(tmp); -- cgit v1.2.3 From 82266f557a692e7a0125fa7c8edc20994bf94718 Mon Sep 17 00:00:00 2001 From: Ed Yu Date: Tue, 21 Nov 2023 15:40:00 -0800 Subject: Update to sqlite 3.44.0 --- build.zig.zon | 2 +- c/sqlite3.c | 6460 ++++++++++++++++++++++++++++++++++++-------------------- c/sqlite3.h | 199 +- c/sqlite3ext.h | 6 + 4 files changed, 4303 insertions(+), 2364 deletions(-) diff --git a/build.zig.zon b/build.zig.zon index 77ec3d9..fcd6730 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,5 +1,5 @@ .{ .name = "sqlite", - .version = "3.43.2", + .version = "3.44.0", .paths = .{"."}, } diff --git a/c/sqlite3.c b/c/sqlite3.c index a1fbd60..8f9309a 100644 --- a/c/sqlite3.c +++ b/c/sqlite3.c @@ -1,6 +1,6 @@ /****************************************************************************** ** This file is an amalgamation of many separate C source files from SQLite -** version 3.43.2. By combining all the individual C code files into this +** version 3.44.0. By combining all the individual C code files into this ** single large file, the entire code can be compiled as a single translation ** unit. This allows many compilers to do optimizations that would not be ** possible if the files were compiled separately. Performance improvements @@ -18,7 +18,7 @@ ** separate file. This file contains only code for the core SQLite library. ** ** The content in this amalgamation comes from Fossil check-in -** 310099cce5a487035fa535dd3002c59ac7f. +** 17129ba1ff7f0daf37100ee82d507aef7827. */ #define SQLITE_CORE 1 #define SQLITE_AMALGAMATION 1 @@ -459,9 +459,9 @@ extern "C" { ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ -#define SQLITE_VERSION "3.43.2" -#define SQLITE_VERSION_NUMBER 3043002 -#define SQLITE_SOURCE_ID "2023-10-10 12:14:04 4310099cce5a487035fa535dd3002c59ac7f1d1bec68d7cf317fd3e769484790" +#define SQLITE_VERSION "3.44.0" +#define SQLITE_VERSION_NUMBER 3044000 +#define SQLITE_SOURCE_ID "2023-11-01 11:23:50 17129ba1ff7f0daf37100ee82d507aef7827cf38de1866e2633096ae6ad81301" /* ** CAPI3REF: Run-Time Library Version Numbers @@ -2440,7 +2440,7 @@ struct sqlite3_mem_methods { ** is stored in each sorted record and the required column values loaded ** from the database as records are returned in sorted order. The default ** value for this option is to never use this optimization. Specifying a -** negative value for this option restores the default behaviour. +** negative value for this option restores the default behavior. ** This option is only available if SQLite is compiled with the ** [SQLITE_ENABLE_SORTER_REFERENCES] compile-time option. ** @@ -2615,7 +2615,7 @@ struct sqlite3_mem_methods { ** database handle, SQLite checks if this will mean that there are now no ** connections at all to the database. If so, it performs a checkpoint ** operation before closing the connection. This option may be used to -** override this behaviour. The first parameter passed to this operation +** override this behavior. The first parameter passed to this operation ** is an integer - positive to disable checkpoints-on-close, or zero (the ** default) to enable them, and negative to leave the setting unchanged. ** The second parameter is a pointer to an integer @@ -4268,6 +4268,7 @@ SQLITE_API void sqlite3_free_filename(sqlite3_filename); ** ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language ** text that describes the error, as either UTF-8 or UTF-16 respectively. +** (See how SQLite handles [invalid UTF] for exceptions to this rule.) ** ^(Memory to hold the error message string is managed internally. ** The application does not need to worry about freeing the result. ** However, the error string might be overwritten or deallocated by @@ -5638,6 +5639,7 @@ SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt); */ SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); + /* ** CAPI3REF: Create Or Redefine SQL Functions ** KEYWORDS: {function creation routines} @@ -6192,32 +6194,32 @@ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*); ** METHOD: sqlite3_context ** ** These functions may be used by (non-aggregate) SQL functions to -** associate metadata with argument values. If the same value is passed to -** multiple invocations of the same SQL function during query execution, under -** some circumstances the associated metadata may be preserved. An example -** of where this might be useful is in a regular-expression matching -** function. The compiled version of the regular expression can be stored as -** metadata associated with the pattern string. +** associate auxiliary data with argument values. If the same argument +** value is passed to multiple invocations of the same SQL function during +** query execution, under some circumstances the associated auxiliary data +** might be preserved. An example of where this might be useful is in a +** regular-expression matching function. The compiled version of the regular +** expression can be stored as auxiliary data associated with the pattern string. ** Then as long as the pattern string remains the same, ** the compiled regular expression can be reused on multiple ** invocations of the same function. ** -** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the metadata +** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the auxiliary data ** associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument ** value to the application-defined function. ^N is zero for the left-most -** function argument. ^If there is no metadata +** function argument. ^If there is no auxiliary data ** associated with the function argument, the sqlite3_get_auxdata(C,N) interface ** returns a NULL pointer. ** -** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th -** argument of the application-defined function. ^Subsequent +** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as auxiliary data for the +** N-th argument of the application-defined function. ^Subsequent ** calls to sqlite3_get_auxdata(C,N) return P from the most recent -** sqlite3_set_auxdata(C,N,P,X) call if the metadata is still valid or -** NULL if the metadata has been discarded. +** sqlite3_set_auxdata(C,N,P,X) call if the auxiliary data is still valid or +** NULL if the auxiliary data has been discarded. ** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL, ** SQLite will invoke the destructor function X with parameter P exactly -** once, when the metadata is discarded. -** SQLite is free to discard the metadata at any time, including: