Fossil SCM

Update the built-in SQLite to the latest trunk version, for testing.

drh 2024-01-09 13:42 trunk
Commit 5d0d2219e8297a862788bafbf9b7e6047ba74b2b42a6788beec7f98f655d7dd2
+111 -14
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -294,11 +294,11 @@
294294
** When this .h file and its companion .c are directly incorporated into
295295
** a source conglomeration (such as shell.c), the preprocessor symbol
296296
** CIO_WIN_WC_XLATE is defined as 0 or 1, reflecting whether console I/O
297297
** translation for Windows is effected for the build.
298298
*/
299
-
299
+#define HAVE_CONSOLE_IO_H 1
300300
#ifndef SQLITE_INTERNAL_LINKAGE
301301
# define SQLITE_INTERNAL_LINKAGE extern /* external to translation unit */
302302
# include <stdio.h>
303303
#else
304304
# define SHELL_NO_SYSINC /* Better yet, modify mkshellc.tcl for this. */
@@ -573,12 +573,14 @@
573573
# include <stdarg.h>
574574
# include <string.h>
575575
# include <stdlib.h>
576576
# include <limits.h>
577577
# include <assert.h>
578
-# include "console_io.h"
579578
/* # include "sqlite3.h" */
579
+#endif
580
+#ifndef HAVE_CONSOLE_IO_H
581
+# include "console_io.h"
580582
#endif
581583
582584
#ifndef SQLITE_CIO_NO_TRANSLATE
583585
# if (defined(_WIN32) || defined(WIN32)) && !SQLITE_OS_WINRT
584586
# ifndef SHELL_NO_SYSINC
@@ -18143,10 +18145,11 @@
1814318145
u8 doXdgOpen; /* Invoke start/open/xdg-open in output_reset() */
1814418146
u8 nEqpLevel; /* Depth of the EQP output graph */
1814518147
u8 eTraceType; /* SHELL_TRACE_* value for type of trace */
1814618148
u8 bSafeMode; /* True to prohibit unsafe operations */
1814718149
u8 bSafeModePersist; /* The long-term value of bSafeMode */
18150
+ u8 eRestoreState; /* See comments above doAutoDetectRestore() */
1814818151
ColModeOpts cmOpts; /* Option values affecting columnar mode output */
1814918152
unsigned statsOn; /* True to display memory stats before each finalize */
1815018153
unsigned mEqpLines; /* Mask of vertical lines in the EQP output graph */
1815118154
int inputNesting; /* Track nesting level of .read and other redirects */
1815218155
int outCount; /* Revert to stdout when reaching zero */
@@ -23582,11 +23585,10 @@
2358223585
eputz("Where sub-commands are:\n");
2358323586
eputz(" fkey-indexes\n");
2358423587
return SQLITE_ERROR;
2358523588
}
2358623589
23587
-#if !defined SQLITE_OMIT_VIRTUALTABLE
2358823590
static void shellPrepare(
2358923591
sqlite3 *db,
2359023592
int *pRc,
2359123593
const char *zSql,
2359223594
sqlite3_stmt **ppStmt
@@ -23601,16 +23603,12 @@
2360123603
}
2360223604
}
2360323605
2360423606
/*
2360523607
** Create a prepared statement using printf-style arguments for the SQL.
23606
-**
23607
-** This routine is could be marked "static". But it is not always used,
23608
-** depending on compile-time options. By omitting the "static", we avoid
23609
-** nuisance compiler warnings about "defined but not used".
2361023608
*/
23611
-void shellPreparePrintf(
23609
+static void shellPreparePrintf(
2361223610
sqlite3 *db,
2361323611
int *pRc,
2361423612
sqlite3_stmt **ppStmt,
2361523613
const char *zFmt,
2361623614
...
@@ -23629,17 +23627,14 @@
2362923627
sqlite3_free(z);
2363023628
}
2363123629
}
2363223630
}
2363323631
23634
-/* Finalize the prepared statement created using shellPreparePrintf().
23635
-**
23636
-** This routine is could be marked "static". But it is not always used,
23637
-** depending on compile-time options. By omitting the "static", we avoid
23638
-** nuisance compiler warnings about "defined but not used".
23632
+/*
23633
+** Finalize the prepared statement created using shellPreparePrintf().
2363923634
*/
23640
-void shellFinalize(
23635
+static void shellFinalize(
2364123636
int *pRc,
2364223637
sqlite3_stmt *pStmt
2364323638
){
2364423639
if( pStmt ){
2364523640
sqlite3 *db = sqlite3_db_handle(pStmt);
@@ -23651,10 +23646,11 @@
2365123646
*pRc = rc;
2365223647
}
2365323648
}
2365423649
}
2365523650
23651
+#if !defined SQLITE_OMIT_VIRTUALTABLE
2365623652
/* Reset the prepared statement created using shellPreparePrintf().
2365723653
**
2365823654
** This routine is could be marked "static". But it is not always used,
2365923655
** depending on compile-time options. By omitting the "static", we avoid
2366023656
** nuisance compiler warnings about "defined but not used".
@@ -24716,10 +24712,34 @@
2471624712
sqlite3_close(*pDb);
2471724713
*pDb = 0;
2471824714
return zColsSpec;
2471924715
}
2472024716
}
24717
+
24718
+/*
24719
+** Check if the sqlite_schema table contains one or more virtual tables. If
24720
+** parameter zLike is not NULL, then it is an SQL expression that the
24721
+** sqlite_schema row must also match. If one or more such rows are found,
24722
+** print the following warning to the output:
24723
+**
24724
+** WARNING: Script requires that SQLITE_DBCONFIG_DEFENSIVE be disabled
24725
+*/
24726
+static int outputDumpWarning(ShellState *p, const char *zLike){
24727
+ int rc = SQLITE_OK;
24728
+ sqlite3_stmt *pStmt = 0;
24729
+ shellPreparePrintf(p->db, &rc, &pStmt,
24730
+ "SELECT 1 FROM sqlite_schema o WHERE "
24731
+ "sql LIKE 'CREATE VIRTUAL TABLE%%' AND %s", zLike ? zLike : "true"
24732
+ );
24733
+ if( rc==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){
24734
+ oputz("/* WARNING: "
24735
+ "Script requires that SQLITE_DBCONFIG_DEFENSIVE be disabled */\n"
24736
+ );
24737
+ }
24738
+ shellFinalize(&rc, pStmt);
24739
+ return rc;
24740
+}
2472124741
2472224742
/*
2472324743
** If an input line begins with "." then invoke this routine to
2472424744
** process that line.
2472524745
**
@@ -25179,10 +25199,11 @@
2517925199
}
2518025200
}
2518125201
2518225202
open_db(p, 0);
2518325203
25204
+ outputDumpWarning(p, zLike);
2518425205
if( (p->shellFlgs & SHFLG_DumpDataOnly)==0 ){
2518525206
/* When playing back a "dump", the content might appear in an order
2518625207
** which causes immediate foreign key constraints to be violated.
2518725208
** So disable foreign-key constraint enforcement to prevent problems. */
2518825209
oputz("PRAGMA foreign_keys=OFF;\n");
@@ -28241,10 +28262,84 @@
2824128262
zSql[nSql+1] = 0;
2824228263
rc = sqlite3_complete(zSql);
2824328264
zSql[nSql] = 0;
2824428265
return rc;
2824528266
}
28267
+
28268
+/*
28269
+** This function is called after processing each line of SQL in the
28270
+** runOneSqlLine() function. Its purpose is to detect scenarios where
28271
+** defensive mode should be automatically turned off. Specifically, when
28272
+**
28273
+** 1. The first line of input is "PRAGMA foreign_keys=OFF;",
28274
+** 2. The second line of input is "BEGIN TRANSACTION;",
28275
+** 3. The database is empty, and
28276
+** 4. The shell is not running in --safe mode.
28277
+**
28278
+** The implementation uses the ShellState.eRestoreState to maintain state:
28279
+**
28280
+** 0: Have not seen any SQL.
28281
+** 1: Have seen "PRAGMA foreign_keys=OFF;".
28282
+** 2: Currently assuming we are parsing ".dump" restore, defensive mode
28283
+** should be disabled following the current transaction.
28284
+** 3: Nothing left to do.
28285
+*/
28286
+static int doAutoDetectRestore(ShellState *p, const char *zSql){
28287
+ int rc = SQLITE_OK;
28288
+
28289
+ switch( p->eRestoreState ){
28290
+ case 0: {
28291
+ int bDefense = 0; /* True if in defensive mode */
28292
+ const char *zExpect = "PRAGMA foreign_keys=OFF;";
28293
+ assert( strlen(zExpect)==24 );
28294
+ sqlite3_db_config(p->db, SQLITE_DBCONFIG_DEFENSIVE, -1, &bDefense);
28295
+ if( p->bSafeMode==0 && bDefense && memcmp(zSql, zExpect, 25)==0 ){
28296
+ p->eRestoreState = 1;
28297
+ }else{
28298
+ p->eRestoreState = 3;
28299
+ }
28300
+ break;
28301
+ };
28302
+
28303
+ case 1: {
28304
+ const char *zExpect = "BEGIN TRANSACTION;";
28305
+ assert( strlen(zExpect)==18 );
28306
+ if( memcmp(zSql, zExpect, 19)==0 ){
28307
+ /* Now check if the database is empty. */
28308
+ const char *zQuery = "SELECT 1 FROM sqlite_schema LIMIT 1";
28309
+ sqlite3_stmt *pStmt = 0;
28310
+ int bEmpty = 1;
28311
+
28312
+ shellPrepare(p->db, &rc, zQuery, &pStmt);
28313
+ if( rc==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){
28314
+ bEmpty = 0;
28315
+ }
28316
+ shellFinalize(&rc, pStmt);
28317
+ if( bEmpty && rc==SQLITE_OK ){
28318
+ sqlite3_db_config(p->db, SQLITE_DBCONFIG_DEFENSIVE, 0, 0);
28319
+ }else{
28320
+ p->eRestoreState = 3;
28321
+ }
28322
+ }
28323
+ break;
28324
+ }
28325
+
28326
+ case 2: {
28327
+ if( sqlite3_get_autocommit(p->db) ){
28328
+ sqlite3_db_config(p->db, SQLITE_DBCONFIG_DEFENSIVE, 0, 0);
28329
+ p->eRestoreState = 3;
28330
+ }
28331
+ break;
28332
+ }
28333
+
28334
+ default: /* Nothing to do */
28335
+ assert( p->eRestoreState==3 );
28336
+ break;
28337
+ }
28338
+
28339
+ return rc;
28340
+}
2824628341
2824728342
/*
2824828343
** Run a single line of SQL. Return the number of errors.
2824928344
*/
2825028345
static int runOneSqlLine(ShellState *p, char *zSql, FILE *in, int startline){
@@ -28289,10 +28384,12 @@
2828928384
sqlite3_snprintf(sizeof(zLineBuf), zLineBuf,
2829028385
"changes: %lld total_changes: %lld",
2829128386
sqlite3_changes64(p->db), sqlite3_total_changes64(p->db));
2829228387
oputf("%s\n", zLineBuf);
2829328388
}
28389
+
28390
+ if( doAutoDetectRestore(p, zSql) ) return 1;
2829428391
return 0;
2829528392
}
2829628393
2829728394
static void echo_group_input(ShellState *p, const char *zDo){
2829828395
if( ShellHasFlag(p, SHFLG_Echo) ) oputf("%s\n", zDo);
2829928396
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -294,11 +294,11 @@
294 ** When this .h file and its companion .c are directly incorporated into
295 ** a source conglomeration (such as shell.c), the preprocessor symbol
296 ** CIO_WIN_WC_XLATE is defined as 0 or 1, reflecting whether console I/O
297 ** translation for Windows is effected for the build.
298 */
299
300 #ifndef SQLITE_INTERNAL_LINKAGE
301 # define SQLITE_INTERNAL_LINKAGE extern /* external to translation unit */
302 # include <stdio.h>
303 #else
304 # define SHELL_NO_SYSINC /* Better yet, modify mkshellc.tcl for this. */
@@ -573,12 +573,14 @@
573 # include <stdarg.h>
574 # include <string.h>
575 # include <stdlib.h>
576 # include <limits.h>
577 # include <assert.h>
578 # include "console_io.h"
579 /* # include "sqlite3.h" */
 
 
 
580 #endif
581
582 #ifndef SQLITE_CIO_NO_TRANSLATE
583 # if (defined(_WIN32) || defined(WIN32)) && !SQLITE_OS_WINRT
584 # ifndef SHELL_NO_SYSINC
@@ -18143,10 +18145,11 @@
18143 u8 doXdgOpen; /* Invoke start/open/xdg-open in output_reset() */
18144 u8 nEqpLevel; /* Depth of the EQP output graph */
18145 u8 eTraceType; /* SHELL_TRACE_* value for type of trace */
18146 u8 bSafeMode; /* True to prohibit unsafe operations */
18147 u8 bSafeModePersist; /* The long-term value of bSafeMode */
 
18148 ColModeOpts cmOpts; /* Option values affecting columnar mode output */
18149 unsigned statsOn; /* True to display memory stats before each finalize */
18150 unsigned mEqpLines; /* Mask of vertical lines in the EQP output graph */
18151 int inputNesting; /* Track nesting level of .read and other redirects */
18152 int outCount; /* Revert to stdout when reaching zero */
@@ -23582,11 +23585,10 @@
23582 eputz("Where sub-commands are:\n");
23583 eputz(" fkey-indexes\n");
23584 return SQLITE_ERROR;
23585 }
23586
23587 #if !defined SQLITE_OMIT_VIRTUALTABLE
23588 static void shellPrepare(
23589 sqlite3 *db,
23590 int *pRc,
23591 const char *zSql,
23592 sqlite3_stmt **ppStmt
@@ -23601,16 +23603,12 @@
23601 }
23602 }
23603
23604 /*
23605 ** Create a prepared statement using printf-style arguments for the SQL.
23606 **
23607 ** This routine is could be marked "static". But it is not always used,
23608 ** depending on compile-time options. By omitting the "static", we avoid
23609 ** nuisance compiler warnings about "defined but not used".
23610 */
23611 void shellPreparePrintf(
23612 sqlite3 *db,
23613 int *pRc,
23614 sqlite3_stmt **ppStmt,
23615 const char *zFmt,
23616 ...
@@ -23629,17 +23627,14 @@
23629 sqlite3_free(z);
23630 }
23631 }
23632 }
23633
23634 /* Finalize the prepared statement created using shellPreparePrintf().
23635 **
23636 ** This routine is could be marked "static". But it is not always used,
23637 ** depending on compile-time options. By omitting the "static", we avoid
23638 ** nuisance compiler warnings about "defined but not used".
23639 */
23640 void shellFinalize(
23641 int *pRc,
23642 sqlite3_stmt *pStmt
23643 ){
23644 if( pStmt ){
23645 sqlite3 *db = sqlite3_db_handle(pStmt);
@@ -23651,10 +23646,11 @@
23651 *pRc = rc;
23652 }
23653 }
23654 }
23655
 
23656 /* Reset the prepared statement created using shellPreparePrintf().
23657 **
23658 ** This routine is could be marked "static". But it is not always used,
23659 ** depending on compile-time options. By omitting the "static", we avoid
23660 ** nuisance compiler warnings about "defined but not used".
@@ -24716,10 +24712,34 @@
24716 sqlite3_close(*pDb);
24717 *pDb = 0;
24718 return zColsSpec;
24719 }
24720 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24721
24722 /*
24723 ** If an input line begins with "." then invoke this routine to
24724 ** process that line.
24725 **
@@ -25179,10 +25199,11 @@
25179 }
25180 }
25181
25182 open_db(p, 0);
25183
 
25184 if( (p->shellFlgs & SHFLG_DumpDataOnly)==0 ){
25185 /* When playing back a "dump", the content might appear in an order
25186 ** which causes immediate foreign key constraints to be violated.
25187 ** So disable foreign-key constraint enforcement to prevent problems. */
25188 oputz("PRAGMA foreign_keys=OFF;\n");
@@ -28241,10 +28262,84 @@
28241 zSql[nSql+1] = 0;
28242 rc = sqlite3_complete(zSql);
28243 zSql[nSql] = 0;
28244 return rc;
28245 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28246
28247 /*
28248 ** Run a single line of SQL. Return the number of errors.
28249 */
28250 static int runOneSqlLine(ShellState *p, char *zSql, FILE *in, int startline){
@@ -28289,10 +28384,12 @@
28289 sqlite3_snprintf(sizeof(zLineBuf), zLineBuf,
28290 "changes: %lld total_changes: %lld",
28291 sqlite3_changes64(p->db), sqlite3_total_changes64(p->db));
28292 oputf("%s\n", zLineBuf);
28293 }
 
 
28294 return 0;
28295 }
28296
28297 static void echo_group_input(ShellState *p, const char *zDo){
28298 if( ShellHasFlag(p, SHFLG_Echo) ) oputf("%s\n", zDo);
28299
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -294,11 +294,11 @@
294 ** When this .h file and its companion .c are directly incorporated into
295 ** a source conglomeration (such as shell.c), the preprocessor symbol
296 ** CIO_WIN_WC_XLATE is defined as 0 or 1, reflecting whether console I/O
297 ** translation for Windows is effected for the build.
298 */
299 #define HAVE_CONSOLE_IO_H 1
300 #ifndef SQLITE_INTERNAL_LINKAGE
301 # define SQLITE_INTERNAL_LINKAGE extern /* external to translation unit */
302 # include <stdio.h>
303 #else
304 # define SHELL_NO_SYSINC /* Better yet, modify mkshellc.tcl for this. */
@@ -573,12 +573,14 @@
573 # include <stdarg.h>
574 # include <string.h>
575 # include <stdlib.h>
576 # include <limits.h>
577 # include <assert.h>
 
578 /* # include "sqlite3.h" */
579 #endif
580 #ifndef HAVE_CONSOLE_IO_H
581 # include "console_io.h"
582 #endif
583
584 #ifndef SQLITE_CIO_NO_TRANSLATE
585 # if (defined(_WIN32) || defined(WIN32)) && !SQLITE_OS_WINRT
586 # ifndef SHELL_NO_SYSINC
@@ -18143,10 +18145,11 @@
18145 u8 doXdgOpen; /* Invoke start/open/xdg-open in output_reset() */
18146 u8 nEqpLevel; /* Depth of the EQP output graph */
18147 u8 eTraceType; /* SHELL_TRACE_* value for type of trace */
18148 u8 bSafeMode; /* True to prohibit unsafe operations */
18149 u8 bSafeModePersist; /* The long-term value of bSafeMode */
18150 u8 eRestoreState; /* See comments above doAutoDetectRestore() */
18151 ColModeOpts cmOpts; /* Option values affecting columnar mode output */
18152 unsigned statsOn; /* True to display memory stats before each finalize */
18153 unsigned mEqpLines; /* Mask of vertical lines in the EQP output graph */
18154 int inputNesting; /* Track nesting level of .read and other redirects */
18155 int outCount; /* Revert to stdout when reaching zero */
@@ -23582,11 +23585,10 @@
23585 eputz("Where sub-commands are:\n");
23586 eputz(" fkey-indexes\n");
23587 return SQLITE_ERROR;
23588 }
23589
 
23590 static void shellPrepare(
23591 sqlite3 *db,
23592 int *pRc,
23593 const char *zSql,
23594 sqlite3_stmt **ppStmt
@@ -23601,16 +23603,12 @@
23603 }
23604 }
23605
23606 /*
23607 ** Create a prepared statement using printf-style arguments for the SQL.
 
 
 
 
23608 */
23609 static void shellPreparePrintf(
23610 sqlite3 *db,
23611 int *pRc,
23612 sqlite3_stmt **ppStmt,
23613 const char *zFmt,
23614 ...
@@ -23629,17 +23627,14 @@
23627 sqlite3_free(z);
23628 }
23629 }
23630 }
23631
23632 /*
23633 ** Finalize the prepared statement created using shellPreparePrintf().
 
 
 
23634 */
23635 static void shellFinalize(
23636 int *pRc,
23637 sqlite3_stmt *pStmt
23638 ){
23639 if( pStmt ){
23640 sqlite3 *db = sqlite3_db_handle(pStmt);
@@ -23651,10 +23646,11 @@
23646 *pRc = rc;
23647 }
23648 }
23649 }
23650
23651 #if !defined SQLITE_OMIT_VIRTUALTABLE
23652 /* Reset the prepared statement created using shellPreparePrintf().
23653 **
23654 ** This routine is could be marked "static". But it is not always used,
23655 ** depending on compile-time options. By omitting the "static", we avoid
23656 ** nuisance compiler warnings about "defined but not used".
@@ -24716,10 +24712,34 @@
24712 sqlite3_close(*pDb);
24713 *pDb = 0;
24714 return zColsSpec;
24715 }
24716 }
24717
24718 /*
24719 ** Check if the sqlite_schema table contains one or more virtual tables. If
24720 ** parameter zLike is not NULL, then it is an SQL expression that the
24721 ** sqlite_schema row must also match. If one or more such rows are found,
24722 ** print the following warning to the output:
24723 **
24724 ** WARNING: Script requires that SQLITE_DBCONFIG_DEFENSIVE be disabled
24725 */
24726 static int outputDumpWarning(ShellState *p, const char *zLike){
24727 int rc = SQLITE_OK;
24728 sqlite3_stmt *pStmt = 0;
24729 shellPreparePrintf(p->db, &rc, &pStmt,
24730 "SELECT 1 FROM sqlite_schema o WHERE "
24731 "sql LIKE 'CREATE VIRTUAL TABLE%%' AND %s", zLike ? zLike : "true"
24732 );
24733 if( rc==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){
24734 oputz("/* WARNING: "
24735 "Script requires that SQLITE_DBCONFIG_DEFENSIVE be disabled */\n"
24736 );
24737 }
24738 shellFinalize(&rc, pStmt);
24739 return rc;
24740 }
24741
24742 /*
24743 ** If an input line begins with "." then invoke this routine to
24744 ** process that line.
24745 **
@@ -25179,10 +25199,11 @@
25199 }
25200 }
25201
25202 open_db(p, 0);
25203
25204 outputDumpWarning(p, zLike);
25205 if( (p->shellFlgs & SHFLG_DumpDataOnly)==0 ){
25206 /* When playing back a "dump", the content might appear in an order
25207 ** which causes immediate foreign key constraints to be violated.
25208 ** So disable foreign-key constraint enforcement to prevent problems. */
25209 oputz("PRAGMA foreign_keys=OFF;\n");
@@ -28241,10 +28262,84 @@
28262 zSql[nSql+1] = 0;
28263 rc = sqlite3_complete(zSql);
28264 zSql[nSql] = 0;
28265 return rc;
28266 }
28267
28268 /*
28269 ** This function is called after processing each line of SQL in the
28270 ** runOneSqlLine() function. Its purpose is to detect scenarios where
28271 ** defensive mode should be automatically turned off. Specifically, when
28272 **
28273 ** 1. The first line of input is "PRAGMA foreign_keys=OFF;",
28274 ** 2. The second line of input is "BEGIN TRANSACTION;",
28275 ** 3. The database is empty, and
28276 ** 4. The shell is not running in --safe mode.
28277 **
28278 ** The implementation uses the ShellState.eRestoreState to maintain state:
28279 **
28280 ** 0: Have not seen any SQL.
28281 ** 1: Have seen "PRAGMA foreign_keys=OFF;".
28282 ** 2: Currently assuming we are parsing ".dump" restore, defensive mode
28283 ** should be disabled following the current transaction.
28284 ** 3: Nothing left to do.
28285 */
28286 static int doAutoDetectRestore(ShellState *p, const char *zSql){
28287 int rc = SQLITE_OK;
28288
28289 switch( p->eRestoreState ){
28290 case 0: {
28291 int bDefense = 0; /* True if in defensive mode */
28292 const char *zExpect = "PRAGMA foreign_keys=OFF;";
28293 assert( strlen(zExpect)==24 );
28294 sqlite3_db_config(p->db, SQLITE_DBCONFIG_DEFENSIVE, -1, &bDefense);
28295 if( p->bSafeMode==0 && bDefense && memcmp(zSql, zExpect, 25)==0 ){
28296 p->eRestoreState = 1;
28297 }else{
28298 p->eRestoreState = 3;
28299 }
28300 break;
28301 };
28302
28303 case 1: {
28304 const char *zExpect = "BEGIN TRANSACTION;";
28305 assert( strlen(zExpect)==18 );
28306 if( memcmp(zSql, zExpect, 19)==0 ){
28307 /* Now check if the database is empty. */
28308 const char *zQuery = "SELECT 1 FROM sqlite_schema LIMIT 1";
28309 sqlite3_stmt *pStmt = 0;
28310 int bEmpty = 1;
28311
28312 shellPrepare(p->db, &rc, zQuery, &pStmt);
28313 if( rc==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){
28314 bEmpty = 0;
28315 }
28316 shellFinalize(&rc, pStmt);
28317 if( bEmpty && rc==SQLITE_OK ){
28318 sqlite3_db_config(p->db, SQLITE_DBCONFIG_DEFENSIVE, 0, 0);
28319 }else{
28320 p->eRestoreState = 3;
28321 }
28322 }
28323 break;
28324 }
28325
28326 case 2: {
28327 if( sqlite3_get_autocommit(p->db) ){
28328 sqlite3_db_config(p->db, SQLITE_DBCONFIG_DEFENSIVE, 0, 0);
28329 p->eRestoreState = 3;
28330 }
28331 break;
28332 }
28333
28334 default: /* Nothing to do */
28335 assert( p->eRestoreState==3 );
28336 break;
28337 }
28338
28339 return rc;
28340 }
28341
28342 /*
28343 ** Run a single line of SQL. Return the number of errors.
28344 */
28345 static int runOneSqlLine(ShellState *p, char *zSql, FILE *in, int startline){
@@ -28289,10 +28384,12 @@
28384 sqlite3_snprintf(sizeof(zLineBuf), zLineBuf,
28385 "changes: %lld total_changes: %lld",
28386 sqlite3_changes64(p->db), sqlite3_total_changes64(p->db));
28387 oputf("%s\n", zLineBuf);
28388 }
28389
28390 if( doAutoDetectRestore(p, zSql) ) return 1;
28391 return 0;
28392 }
28393
28394 static void echo_group_input(ShellState *p, const char *zDo){
28395 if( ShellHasFlag(p, SHFLG_Echo) ) oputf("%s\n", zDo);
28396
+108 -53
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -16,11 +16,11 @@
1616
** if you want a wrapper to interface SQLite with your choice of programming
1717
** language. The code for the "sqlite3" command-line shell is also in a
1818
** separate file. This file contains only code for the core SQLite library.
1919
**
2020
** The content in this amalgamation comes from Fossil check-in
21
-** bcac937526d9a6ef914a74b4d6757fa91cd7.
21
+** 97709ce2a1f5ae05495e412ca27108048e5b.
2222
*/
2323
#define SQLITE_CORE 1
2424
#define SQLITE_AMALGAMATION 1
2525
#ifndef SQLITE_PRIVATE
2626
# define SQLITE_PRIVATE static
@@ -459,11 +459,11 @@
459459
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
460460
** [sqlite_version()] and [sqlite_source_id()].
461461
*/
462462
#define SQLITE_VERSION "3.45.0"
463463
#define SQLITE_VERSION_NUMBER 3045000
464
-#define SQLITE_SOURCE_ID "2024-01-01 19:20:00 bcac937526d9a6ef914a74b4d6757fa91cd74edab871bcd934fde4a2f9b6debd"
464
+#define SQLITE_SOURCE_ID "2024-01-09 12:28:51 97709ce2a1f5ae05495e412ca27108048e5b8a63a1e3bca4be13933f7527da7b"
465465
466466
/*
467467
** CAPI3REF: Run-Time Library Version Numbers
468468
** KEYWORDS: sqlite3_version sqlite3_sourceid
469469
**
@@ -13873,11 +13873,11 @@
1387313873
** This is really just the default value for the max_page_count pragma.
1387413874
** This value can be lowered (or raised) at run-time using that the
1387513875
** max_page_count macro.
1387613876
*/
1387713877
#ifndef SQLITE_MAX_PAGE_COUNT
13878
-# define SQLITE_MAX_PAGE_COUNT 1073741823
13878
+# define SQLITE_MAX_PAGE_COUNT 0xfffffffe /* 4294967294 */
1387913879
#endif
1388013880
1388113881
/*
1388213882
** Maximum length (in bytes) of the pattern in a LIKE or GLOB
1388313883
** operator.
@@ -43060,20 +43060,20 @@
4306043060
#ifdef SQLITE_ENABLE_SETLK_TIMEOUT
4306143061
int iMutex;
4306243062
for(iMutex=ofst; iMutex<ofst+n; iMutex++){
4306343063
if( flags==(SQLITE_SHM_LOCK|SQLITE_SHM_EXCLUSIVE) ){
4306443064
rc = sqlite3_mutex_try(pShmNode->aMutex[iMutex]);
43065
- if( rc!=SQLITE_OK ) break;
43065
+ if( rc!=SQLITE_OK ) goto leave_shmnode_mutexes;
4306643066
}else{
4306743067
sqlite3_mutex_enter(pShmNode->aMutex[iMutex]);
4306843068
}
4306943069
}
4307043070
#else
4307143071
sqlite3_mutex_enter(pShmNode->pShmMutex);
4307243072
#endif
4307343073
43074
- if( rc==SQLITE_OK ){
43074
+ if( ALWAYS(rc==SQLITE_OK) ){
4307543075
if( flags & SQLITE_SHM_UNLOCK ){
4307643076
/* Case (a) - unlock. */
4307743077
int bUnlock = 1;
4307843078
assert( (p->exclMask & p->sharedMask)==0 );
4307943079
assert( !(flags & SQLITE_SHM_EXCLUSIVE) || (p->exclMask & mask)==mask );
@@ -43148,10 +43148,11 @@
4314843148
assert( assertLockingArrayOk(pShmNode) );
4314943149
}
4315043150
4315143151
/* Drop the mutexes acquired above. */
4315243152
#ifdef SQLITE_ENABLE_SETLK_TIMEOUT
43153
+ leave_shmnode_mutexes:
4315343154
for(iMutex--; iMutex>=ofst; iMutex--){
4315443155
sqlite3_mutex_leave(pShmNode->aMutex[iMutex]);
4315543156
}
4315643157
#else
4315743158
sqlite3_mutex_leave(pShmNode->pShmMutex);
@@ -57503,13 +57504,12 @@
5750357504
if( pPager->fd->pMethods==0 ) return 0;
5750457505
if( sqlite3PCacheIsDirty(pPager->pPCache) ) return 0;
5750557506
#ifndef SQLITE_OMIT_WAL
5750657507
if( pPager->pWal ){
5750757508
u32 iRead = 0;
57508
- int rc;
57509
- rc = sqlite3WalFindFrame(pPager->pWal, pgno, &iRead);
57510
- return (rc==SQLITE_OK && iRead==0);
57509
+ (void)sqlite3WalFindFrame(pPager->pWal, pgno, &iRead);
57510
+ return iRead==0;
5751157511
}
5751257512
#endif
5751357513
return 1;
5751457514
}
5751557515
#endif
@@ -67391,10 +67391,41 @@
6739167391
*pChanged = 1;
6739267392
}
6739367393
return rc;
6739467394
}
6739567395
67396
+/*
67397
+** The final argument passed to walTryBeginRead() is of type (int*). The
67398
+** caller should invoke walTryBeginRead as follows:
67399
+**
67400
+** int cnt = 0;
67401
+** do {
67402
+** rc = walTryBeginRead(..., &cnt);
67403
+** }while( rc==WAL_RETRY );
67404
+**
67405
+** The final value of "cnt" is of no use to the caller. It is used by
67406
+** the implementation of walTryBeginRead() as follows:
67407
+**
67408
+** + Each time walTryBeginRead() is called, it is incremented. Once
67409
+** it reaches WAL_RETRY_PROTOCOL_LIMIT - indicating that walTryBeginRead()
67410
+** has many times been invoked and failed with WAL_RETRY - walTryBeginRead()
67411
+** returns SQLITE_PROTOCOL.
67412
+**
67413
+** + If SQLITE_ENABLE_SETLK_TIMEOUT is defined and walTryBeginRead() failed
67414
+** because a blocking lock timed out (SQLITE_BUSY_TIMEOUT from the OS
67415
+** layer), the WAL_RETRY_BLOCKED_MASK bit is set in "cnt". In this case
67416
+** the next invocation of walTryBeginRead() may omit an expected call to
67417
+** sqlite3OsSleep(). There has already been a delay when the previous call
67418
+** waited on a lock.
67419
+*/
67420
+#define WAL_RETRY_PROTOCOL_LIMIT 100
67421
+#ifdef SQLITE_ENABLE_SETLK_TIMEOUT
67422
+# define WAL_RETRY_BLOCKED_MASK 0x10000000
67423
+#else
67424
+# define WAL_RETRY_BLOCKED_MASK 0
67425
+#endif
67426
+
6739667427
/*
6739767428
** Attempt to start a read transaction. This might fail due to a race or
6739867429
** other transient condition. When that happens, it returns WAL_RETRY to
6739967430
** indicate to the caller that it is safe to retry immediately.
6740067431
**
@@ -67441,11 +67472,11 @@
6744167472
** checkpoint process do as much work as possible. This routine might
6744267473
** update values of the aReadMark[] array in the header, but if it does
6744367474
** so it takes care to hold an exclusive lock on the corresponding
6744467475
** WAL_READ_LOCK() while changing values.
6744567476
*/
67446
-static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int cnt){
67477
+static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int *pCnt){
6744767478
volatile WalCkptInfo *pInfo; /* Checkpoint information in wal-index */
6744867479
u32 mxReadMark; /* Largest aReadMark[] value */
6744967480
int mxI; /* Index of largest aReadMark[] value */
6745067481
int i; /* Loop counter */
6745167482
int rc = SQLITE_OK; /* Return code */
@@ -67474,41 +67505,51 @@
6747467505
** is more of a scheduler yield than an actual delay. But on the 10th
6747567506
** an subsequent retries, the delays start becoming longer and longer,
6747667507
** so that on the 100th (and last) RETRY we delay for 323 milliseconds.
6747767508
** The total delay time before giving up is less than 10 seconds.
6747867509
*/
67479
- if( cnt>5 ){
67510
+ (*pCnt)++;
67511
+ if( *pCnt>5 ){
6748067512
int nDelay = 1; /* Pause time in microseconds */
67481
- if( cnt>100 ){
67513
+ int cnt = (*pCnt & ~WAL_RETRY_BLOCKED_MASK);
67514
+ if( cnt>WAL_RETRY_PROTOCOL_LIMIT ){
6748267515
VVA_ONLY( pWal->lockError = 1; )
6748367516
return SQLITE_PROTOCOL;
6748467517
}
67485
- if( cnt>=10 ) nDelay = (cnt-9)*(cnt-9)*39;
67518
+ if( *pCnt>=10 ) nDelay = (cnt-9)*(cnt-9)*39;
6748667519
#ifdef SQLITE_ENABLE_SETLK_TIMEOUT
6748767520
/* In SQLITE_ENABLE_SETLK_TIMEOUT builds, configure the file-descriptor
6748867521
** to block for locks for approximately nDelay us. This affects three
6748967522
** locks: (a) the shared lock taken on the DMS slot in os_unix.c (if
6749067523
** using os_unix.c), (b) the WRITER lock taken in walIndexReadHdr() if the
67491
- ** first attempted read fails, and (c) the shared lock taken on the DMS
67492
- ** slot in os_unix.c. All three of these locks are attempted from within
67493
- ** the call to walIndexReadHdr() below. */
67524
+ ** first attempted read fails, and (c) the shared lock taken on the
67525
+ ** read-mark.
67526
+ **
67527
+ ** If the previous call failed due to an SQLITE_BUSY_TIMEOUT error,
67528
+ ** then sleep for the minimum of 1us. The previous call already provided
67529
+ ** an extra delay while it was blocking on the lock.
67530
+ */
6749467531
nBlockTmout = (nDelay+998) / 1000;
6749567532
if( !useWal && walEnableBlockingMs(pWal, nBlockTmout) ){
67496
- nDelay = 1;
67533
+ if( *pCnt & WAL_RETRY_BLOCKED_MASK ) nDelay = 1;
6749767534
}
6749867535
#endif
6749967536
sqlite3OsSleep(pWal->pVfs, nDelay);
67537
+ *pCnt &= ~WAL_RETRY_BLOCKED_MASK;
6750067538
}
6750167539
6750267540
if( !useWal ){
6750367541
assert( rc==SQLITE_OK );
6750467542
if( pWal->bShmUnreliable==0 ){
6750567543
rc = walIndexReadHdr(pWal, pChanged);
6750667544
}
6750767545
#ifdef SQLITE_ENABLE_SETLK_TIMEOUT
6750867546
walDisableBlocking(pWal);
67509
- if( rc==SQLITE_BUSY_TIMEOUT ) rc = SQLITE_BUSY;
67547
+ if( rc==SQLITE_BUSY_TIMEOUT ){
67548
+ rc = SQLITE_BUSY;
67549
+ *pCnt |= WAL_RETRY_BLOCKED_MASK;
67550
+ }
6751067551
#endif
6751167552
if( rc==SQLITE_BUSY ){
6751267553
/* If there is not a recovery running in another thread or process
6751367554
** then convert BUSY errors to WAL_RETRY. If recovery is known to
6751467555
** be running, convert BUSY to BUSY_RECOVERY. There is a race here
@@ -67624,10 +67665,13 @@
6762467665
6762567666
(void)walEnableBlockingMs(pWal, nBlockTmout);
6762667667
rc = walLockShared(pWal, WAL_READ_LOCK(mxI));
6762767668
walDisableBlocking(pWal);
6762867669
if( rc ){
67670
+ if( rc==SQLITE_BUSY_TIMEOUT ){
67671
+ *pCnt |= WAL_RETRY_BLOCKED_MASK;
67672
+ }
6762967673
assert( (rc&0xFF)!=SQLITE_BUSY||rc==SQLITE_BUSY||rc==SQLITE_BUSY_TIMEOUT );
6763067674
return (rc&0xFF)==SQLITE_BUSY ? WAL_RETRY : rc;
6763167675
}
6763267676
/* Now that the read-lock has been obtained, check that neither the
6763367677
** value in the aReadMark[] array or the contents of the wal-index
@@ -67813,11 +67857,11 @@
6781367857
ckptLock = 1;
6781467858
}
6781567859
#endif
6781667860
6781767861
do{
67818
- rc = walTryBeginRead(pWal, pChanged, 0, ++cnt);
67862
+ rc = walTryBeginRead(pWal, pChanged, 0, &cnt);
6781967863
}while( rc==WAL_RETRY );
6782067864
testcase( (rc&0xff)==SQLITE_BUSY );
6782167865
testcase( (rc&0xff)==SQLITE_IOERR );
6782267866
testcase( rc==SQLITE_PROTOCOL );
6782367867
testcase( rc==SQLITE_OK );
@@ -67994,10 +68038,11 @@
6799468038
if( iFrame<=iLast && iFrame>=pWal->minFrame && sLoc.aPgno[iH-1]==pgno ){
6799568039
assert( iFrame>iRead || CORRUPT_DB );
6799668040
iRead = iFrame;
6799768041
}
6799868042
if( (nCollide--)==0 ){
68043
+ *piRead = 0;
6799968044
return SQLITE_CORRUPT_BKPT;
6800068045
}
6800168046
iKey = walNextHash(iKey);
6800268047
}
6800368048
if( iRead ) break;
@@ -68297,11 +68342,11 @@
6829768342
walUnlockShared(pWal, WAL_READ_LOCK(0));
6829868343
pWal->readLock = -1;
6829968344
cnt = 0;
6830068345
do{
6830168346
int notUsed;
68302
- rc = walTryBeginRead(pWal, &notUsed, 1, ++cnt);
68347
+ rc = walTryBeginRead(pWal, &notUsed, 1, &cnt);
6830368348
}while( rc==WAL_RETRY );
6830468349
assert( (rc&0xff)!=SQLITE_BUSY ); /* BUSY not possible when useWal==1 */
6830568350
testcase( (rc&0xff)==SQLITE_IOERR );
6830668351
testcase( rc==SQLITE_PROTOCOL );
6830768352
testcase( rc==SQLITE_OK );
@@ -75232,11 +75277,10 @@
7523275277
u8 aSave[4];
7523375278
u8 *aWrite = &pBuf[-4];
7523475279
assert( aWrite>=pBufStart ); /* due to (6) */
7523575280
memcpy(aSave, aWrite, 4);
7523675281
rc = sqlite3OsRead(fd, aWrite, a+4, (i64)pBt->pageSize*(nextPage-1));
75237
- if( rc && nextPage>pBt->nPage ) rc = SQLITE_CORRUPT_BKPT;
7523875282
nextPage = get4byte(aWrite);
7523975283
memcpy(aWrite, aSave, 4);
7524075284
}else
7524175285
#endif
7524275286
@@ -122158,11 +122202,12 @@
122158122202
char aff = SQLITE_AFF_NUMERIC;
122159122203
const char *zChar = 0;
122160122204
122161122205
assert( zIn!=0 );
122162122206
while( zIn[0] ){
122163
- h = (h<<8) + sqlite3UpperToLower[(*zIn)&0xff];
122207
+ u8 x = *(u8*)zIn;
122208
+ h = (h<<8) + sqlite3UpperToLower[x];
122164122209
zIn++;
122165122210
if( h==(('c'<<24)+('h'<<16)+('a'<<8)+'r') ){ /* CHAR */
122166122211
aff = SQLITE_AFF_TEXT;
122167122212
zChar = zIn;
122168122213
}else if( h==(('c'<<24)+('l'<<16)+('o'<<8)+'b') ){ /* CLOB */
@@ -126023,20 +126068,21 @@
126023126068
}
126024126069
iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pObjName);
126025126070
if( iDb<0 ) return;
126026126071
z = sqlite3NameFromToken(db, pObjName);
126027126072
if( z==0 ) return;
126028
- zDb = db->aDb[iDb].zDbSName;
126073
+ zDb = pName2->n ? db->aDb[iDb].zDbSName : 0;
126029126074
pTab = sqlite3FindTable(db, z, zDb);
126030126075
if( pTab ){
126031126076
reindexTable(pParse, pTab, 0);
126032126077
sqlite3DbFree(db, z);
126033126078
return;
126034126079
}
126035126080
pIndex = sqlite3FindIndex(db, z, zDb);
126036126081
sqlite3DbFree(db, z);
126037126082
if( pIndex ){
126083
+ iDb = sqlite3SchemaToIndex(db, pIndex->pTable->pSchema);
126038126084
sqlite3BeginWriteOperation(pParse, 0, iDb);
126039126085
sqlite3RefillIndex(pParse, pIndex, -1);
126040126086
return;
126041126087
}
126042126088
sqlite3ErrorMsg(pParse, "unable to identify the object to be reindexed");
@@ -182703,11 +182749,11 @@
182703182749
** If onOff is initially 1, then turn it on. If onOff is initially
182704182750
** off, turn it off. If onOff is initially -1, then change onOff
182705182751
** to be the current setting.
182706182752
*/
182707182753
case SQLITE_TESTCTRL_JSON_SELFCHECK: {
182708
-#if defined(SQLITE_DEBUG)
182754
+#if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_WSD)
182709182755
int *pOnOff = va_arg(ap, int*);
182710182756
if( *pOnOff<0 ){
182711182757
*pOnOff = sqlite3Config.bJsonSelfcheck;
182712182758
}else{
182713182759
sqlite3Config.bJsonSelfcheck = (u8)((*pOnOff)&0xff);
@@ -203415,10 +203461,11 @@
203415203461
struct JsonParse {
203416203462
u8 *aBlob; /* JSONB representation of JSON value */
203417203463
u32 nBlob; /* Bytes of aBlob[] actually used */
203418203464
u32 nBlobAlloc; /* Bytes allocated to aBlob[]. 0 if aBlob is external */
203419203465
char *zJson; /* Json text used for parsing */
203466
+ sqlite3 *db; /* The database connection to which this object belongs */
203420203467
int nJson; /* Length of the zJson string in bytes */
203421203468
u32 nJPRef; /* Number of references to this object */
203422203469
u32 iErr; /* Error location in zJson[] */
203423203470
u16 iDepth; /* Nesting depth */
203424203471
u8 nErr; /* Number of errors seen */
@@ -203940,11 +203987,11 @@
203940203987
pParse->zJson = 0;
203941203988
pParse->nJson = 0;
203942203989
pParse->bJsonIsRCStr = 0;
203943203990
}
203944203991
if( pParse->nBlobAlloc ){
203945
- sqlite3_free(pParse->aBlob);
203992
+ sqlite3DbFree(pParse->db, pParse->aBlob);
203946203993
pParse->aBlob = 0;
203947203994
pParse->nBlob = 0;
203948203995
pParse->nBlobAlloc = 0;
203949203996
}
203950203997
}
@@ -203957,11 +204004,11 @@
203957204004
if( pParse ){
203958204005
if( pParse->nJPRef>1 ){
203959204006
pParse->nJPRef--;
203960204007
}else{
203961204008
jsonParseReset(pParse);
203962
- sqlite3_free(pParse);
204009
+ sqlite3DbFree(pParse->db, pParse);
203963204010
}
203964204011
}
203965204012
}
203966204013
203967204014
/**************************************************************************
@@ -204188,11 +204235,11 @@
204188204235
t = 100;
204189204236
}else{
204190204237
t = pParse->nBlobAlloc*2;
204191204238
}
204192204239
if( t<N ) t = N+100;
204193
- aNew = sqlite3_realloc64( pParse->aBlob, t );
204240
+ aNew = sqlite3DbRealloc(pParse->db, pParse->aBlob, t);
204194204241
if( aNew==0 ){ pParse->oom = 1; return 1; }
204195204242
pParse->aBlob = aNew;
204196204243
pParse->nBlobAlloc = t;
204197204244
return 0;
204198204245
}
@@ -205113,18 +205160,19 @@
205113205160
JsonParse px;
205114205161
memset(&px, 0, sizeof(px));
205115205162
jsonStringTerminate(pStr);
205116205163
px.zJson = pStr->zBuf;
205117205164
px.nJson = pStr->nUsed;
205165
+ px.db = sqlite3_context_db_handle(pStr->pCtx);
205118205166
(void)jsonTranslateTextToBlob(&px, 0);
205119205167
if( px.oom ){
205120
- sqlite3_free(px.aBlob);
205168
+ sqlite3DbFree(px.db, px.aBlob);
205121205169
sqlite3_result_error_nomem(pStr->pCtx);
205122205170
}else{
205123205171
assert( px.nBlobAlloc>0 );
205124205172
assert( !px.bReadOnly );
205125
- sqlite3_result_blob(pStr->pCtx, px.aBlob, px.nBlob, sqlite3_free);
205173
+ sqlite3_result_blob(pStr->pCtx, px.aBlob, px.nBlob, SQLITE_DYNAMIC);
205126205174
}
205127205175
}
205128205176
205129205177
/* The byte at index i is a node type-code. This routine
205130205178
** determines the payload size for that node and writes that
@@ -205736,10 +205784,11 @@
205736205784
const char *zTail /* Tail of the path that determins substructure */
205737205785
){
205738205786
static const u8 emptyObject[] = { JSONB_ARRAY, JSONB_OBJECT };
205739205787
int rc;
205740205788
memset(pIns, 0, sizeof(*pIns));
205789
+ pIns->db = pParse->db;
205741205790
if( zTail[0]==0 ){
205742205791
/* No substructure. Just insert what is given in pParse. */
205743205792
pIns->aBlob = pParse->aIns;
205744205793
pIns->nBlob = pParse->nIns;
205745205794
rc = 0;
@@ -205863,10 +205912,11 @@
205863205912
JsonParse v; /* BLOB encoding of the value to be inserted */
205864205913
JsonParse ix; /* Header of the label to be inserted */
205865205914
testcase( pParse->eEdit==JEDIT_INS );
205866205915
testcase( pParse->eEdit==JEDIT_SET );
205867205916
memset(&ix, 0, sizeof(ix));
205917
+ ix.db = pParse->db;
205868205918
jsonBlobAppendNode(&ix, rawKey?JSONB_TEXTRAW:JSONB_TEXT5, nKey, 0);
205869205919
pParse->oom |= ix.oom;
205870205920
rc = jsonCreateEditSubstructure(pParse, &v, &zPath[i]);
205871205921
if( !JSON_LOOKUP_ISERROR(rc)
205872205922
&& jsonBlobMakeEditable(pParse, ix.nBlob+nKey+v.nBlob)
@@ -206073,11 +206123,11 @@
206073206123
u32 iIn, iOut;
206074206124
const char *z;
206075206125
char *zOut;
206076206126
u32 nOut = sz;
206077206127
z = (const char*)&pParse->aBlob[i+n];
206078
- zOut = sqlite3_malloc( nOut+1 );
206128
+ zOut = sqlite3DbMallocRaw(db, nOut+1);
206079206129
if( zOut==0 ) goto returnfromblob_oom;
206080206130
for(iIn=iOut=0; iIn<sz; iIn++){
206081206131
char c = z[iIn];
206082206132
if( c=='\\' ){
206083206133
u32 v;
@@ -206107,11 +206157,11 @@
206107206157
zOut[iOut++] = c;
206108206158
}
206109206159
} /* end for() */
206110206160
assert( iOut<=nOut );
206111206161
zOut[iOut] = 0;
206112
- sqlite3_result_text(pCtx, zOut, iOut, sqlite3_free);
206162
+ sqlite3_result_text(pCtx, zOut, iOut, SQLITE_DYNAMIC);
206113206163
break;
206114206164
}
206115206165
case JSONB_ARRAY:
206116206166
case JSONB_OBJECT: {
206117206167
int flags = textOnly ? 0 : SQLITE_PTR_TO_INT(sqlite3_user_data(pCtx));
@@ -206160,10 +206210,11 @@
206160206210
JsonParse *pParse
206161206211
){
206162206212
int eType = sqlite3_value_type(pArg);
206163206213
static u8 aNull[] = { 0x00 };
206164206214
memset(pParse, 0, sizeof(pParse[0]));
206215
+ pParse->db = sqlite3_context_db_handle(ctx);
206165206216
switch( eType ){
206166206217
default: {
206167206218
pParse->aBlob = aNull;
206168206219
pParse->nBlob = 1;
206169206220
return 0;
@@ -206185,11 +206236,11 @@
206185206236
if( sqlite3_value_subtype(pArg)==JSON_SUBTYPE ){
206186206237
pParse->zJson = (char*)zJson;
206187206238
pParse->nJson = nJson;
206188206239
if( jsonConvertTextToBlob(pParse, ctx) ){
206189206240
sqlite3_result_error(ctx, "malformed JSON", -1);
206190
- sqlite3_free(pParse->aBlob);
206241
+ sqlite3DbFree(pParse->db, pParse->aBlob);
206191206242
memset(pParse, 0, sizeof(pParse[0]));
206192206243
return 1;
206193206244
}
206194206245
}else{
206195206246
jsonBlobAppendNode(pParse, JSONB_TEXTRAW, nJson, zJson);
@@ -206342,10 +206393,11 @@
206342206393
u32 flgs
206343206394
){
206344206395
int eType; /* Datatype of pArg */
206345206396
JsonParse *p = 0; /* Value to be returned */
206346206397
JsonParse *pFromCache = 0; /* Value taken from cache */
206398
+ sqlite3 *db; /* The database connection */
206347206399
206348206400
assert( ctx!=0 );
206349206401
eType = sqlite3_value_type(pArg);
206350206402
if( eType==SQLITE_NULL ){
206351206403
return 0;
@@ -206355,18 +206407,20 @@
206355206407
pFromCache->nJPRef++;
206356206408
if( (flgs & JSON_EDITABLE)==0 ){
206357206409
return pFromCache;
206358206410
}
206359206411
}
206412
+ db = sqlite3_context_db_handle(ctx);
206360206413
rebuild_from_cache:
206361
- p = sqlite3_malloc64( sizeof(*p) );
206414
+ p = sqlite3DbMallocZero(db, sizeof(*p));
206362206415
if( p==0 ) goto json_pfa_oom;
206363206416
memset(p, 0, sizeof(*p));
206417
+ p->db = db;
206364206418
p->nJPRef = 1;
206365206419
if( pFromCache!=0 ){
206366206420
u32 nBlob = pFromCache->nBlob;
206367
- p->aBlob = sqlite3_malloc64( nBlob );
206421
+ p->aBlob = sqlite3DbMallocRaw(db, nBlob);
206368206422
if( p->aBlob==0 ) goto json_pfa_oom;
206369206423
memcpy(p->aBlob, pFromCache->aBlob, nBlob);
206370206424
p->nBlobAlloc = p->nBlob = nBlob;
206371206425
p->hasNonstd = pFromCache->hasNonstd;
206372206426
jsonParseFree(pFromCache);
@@ -206618,11 +206672,11 @@
206618206672
sqlite3StrAccumInit(&out, 0, 0, 0, 1000000);
206619206673
p = jsonParseFuncArg(ctx, argv[0], 0);
206620206674
if( p==0 ) return;
206621206675
if( argc==1 ){
206622206676
jsonDebugPrintBlob(p, 0, p->nBlob, 0, &out);
206623
- sqlite3_result_text64(ctx, out.zText, out.nChar, sqlite3_free, SQLITE_UTF8);
206677
+ sqlite3_result_text64(ctx, out.zText, out.nChar, SQLITE_DYNAMIC, SQLITE_UTF8);
206624206678
}else{
206625206679
jsonShowParse(p);
206626206680
}
206627206681
jsonParseFree(p);
206628206682
}
@@ -207437,10 +207491,11 @@
207437207491
JsonParse s;
207438207492
207439207493
assert( argc==1 );
207440207494
UNUSED_PARAMETER(argc);
207441207495
memset(&s, 0, sizeof(s));
207496
+ s.db = sqlite3_context_db_handle(ctx);
207442207497
if( jsonFuncArgMightBeBinary(argv[0]) ){
207443207498
s.aBlob = (u8*)sqlite3_value_blob(argv[0]);
207444207499
s.nBlob = sqlite3_value_bytes(argv[0]);
207445207500
iErrPos = (i64)jsonbValidityCheck(&s, 0, s.nBlob, 1);
207446207501
}else{
@@ -207726,34 +207781,34 @@
207726207781
UNUSED_PARAMETER(pAux);
207727207782
rc = sqlite3_declare_vtab(db,
207728207783
"CREATE TABLE x(key,value,type,atom,id,parent,fullkey,path,"
207729207784
"json HIDDEN,root HIDDEN)");
207730207785
if( rc==SQLITE_OK ){
207731
- pNew = (JsonEachConnection*)(*ppVtab = sqlite3_malloc( sizeof(*pNew) ));
207786
+ pNew = (JsonEachConnection*)sqlite3DbMallocZero(db, sizeof(*pNew));
207787
+ *ppVtab = (sqlite3_vtab*)pNew;
207732207788
if( pNew==0 ) return SQLITE_NOMEM;
207733
- memset(pNew, 0, sizeof(*pNew));
207734207789
sqlite3_vtab_config(db, SQLITE_VTAB_INNOCUOUS);
207735207790
pNew->db = db;
207736207791
}
207737207792
return rc;
207738207793
}
207739207794
207740207795
/* destructor for json_each virtual table */
207741207796
static int jsonEachDisconnect(sqlite3_vtab *pVtab){
207742
- sqlite3_free(pVtab);
207797
+ JsonEachConnection *p = (JsonEachConnection*)pVtab;
207798
+ sqlite3DbFree(p->db, pVtab);
207743207799
return SQLITE_OK;
207744207800
}
207745207801
207746207802
/* constructor for a JsonEachCursor object for json_each(). */
207747207803
static int jsonEachOpenEach(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){
207748207804
JsonEachConnection *pVtab = (JsonEachConnection*)p;
207749207805
JsonEachCursor *pCur;
207750207806
207751207807
UNUSED_PARAMETER(p);
207752
- pCur = sqlite3_malloc( sizeof(*pCur) );
207808
+ pCur = sqlite3DbMallocZero(pVtab->db, sizeof(*pCur));
207753207809
if( pCur==0 ) return SQLITE_NOMEM;
207754
- memset(pCur, 0, sizeof(*pCur));
207755207810
pCur->db = pVtab->db;
207756207811
jsonStringZero(&pCur->path);
207757207812
*ppCursor = &pCur->base;
207758207813
return SQLITE_OK;
207759207814
}
@@ -207786,11 +207841,11 @@
207786207841
/* Destructor for a jsonEachCursor object */
207787207842
static int jsonEachClose(sqlite3_vtab_cursor *cur){
207788207843
JsonEachCursor *p = (JsonEachCursor*)cur;
207789207844
jsonEachCursorReset(p);
207790207845
207791
- sqlite3_free(cur);
207846
+ sqlite3DbFree(p->db, cur);
207792207847
return SQLITE_OK;
207793207848
}
207794207849
207795207850
/* Return TRUE if the jsonEachCursor object has been advanced off the end
207796207851
** of the JSON object */
@@ -208120,10 +208175,11 @@
208120208175
UNUSED_PARAMETER(argc);
208121208176
jsonEachCursorReset(p);
208122208177
if( idxNum==0 ) return SQLITE_OK;
208123208178
memset(&p->sParse, 0, sizeof(p->sParse));
208124208179
p->sParse.nJPRef = 1;
208180
+ p->sParse.db = p->db;
208125208181
if( sqlite3_value_type(argv[0])==SQLITE_BLOB ){
208126208182
if( jsonFuncArgMightBeBinary(argv[0]) ){
208127208183
p->sParse.nBlob = sqlite3_value_bytes(argv[0]);
208128208184
p->sParse.aBlob = (u8*)sqlite3_value_blob(argv[0]);
208129208185
}else{
@@ -209071,11 +209127,11 @@
209071209127
209072209128
/* Check if the requested node is already in the hash table. If so,
209073209129
** increase its reference count and return it.
209074209130
*/
209075209131
if( (pNode = nodeHashLookup(pRtree, iNode))!=0 ){
209076
- if( pParent && pParent!=pNode->pParent ){
209132
+ if( pParent && ALWAYS(pParent!=pNode->pParent) ){
209077209133
RTREE_IS_CORRUPT(pRtree);
209078209134
return SQLITE_CORRUPT_VTAB;
209079209135
}
209080209136
pNode->nRef++;
209081209137
*ppNode = pNode;
@@ -211806,11 +211862,11 @@
211806211862
}else{
211807211863
rc = SQLITE_NOMEM;
211808211864
}
211809211865
sqlite3_free(zSql);
211810211866
}
211811
- if( pRtree->nAux ){
211867
+ if( pRtree->nAux && rc!=SQLITE_NOMEM ){
211812211868
pRtree->zReadAuxSql = sqlite3_mprintf(
211813211869
"SELECT * FROM \"%w\".\"%w_rowid\" WHERE rowid=?1",
211814211870
zDb, zPrefix);
211815211871
if( pRtree->zReadAuxSql==0 ){
211816211872
rc = SQLITE_NOMEM;
@@ -212495,19 +212551,17 @@
212495212551
check.db = db;
212496212552
check.zDb = zDb;
212497212553
check.zTab = zTab;
212498212554
212499212555
/* Find the number of auxiliary columns */
212500
- if( check.rc==SQLITE_OK ){
212501
- pStmt = rtreeCheckPrepare(&check, "SELECT * FROM %Q.'%q_rowid'", zDb, zTab);
212502
- if( pStmt ){
212503
- nAux = sqlite3_column_count(pStmt) - 2;
212504
- sqlite3_finalize(pStmt);
212505
- }else
212506
- if( check.rc!=SQLITE_NOMEM ){
212507
- check.rc = SQLITE_OK;
212508
- }
212556
+ pStmt = rtreeCheckPrepare(&check, "SELECT * FROM %Q.'%q_rowid'", zDb, zTab);
212557
+ if( pStmt ){
212558
+ nAux = sqlite3_column_count(pStmt) - 2;
212559
+ sqlite3_finalize(pStmt);
212560
+ }else
212561
+ if( check.rc!=SQLITE_NOMEM ){
212562
+ check.rc = SQLITE_OK;
212509212563
}
212510212564
212511212565
/* Find number of dimensions in the rtree table. */
212512212566
pStmt = rtreeCheckPrepare(&check, "SELECT * FROM %Q.%Q", zDb, zTab);
212513212567
if( pStmt ){
@@ -212558,10 +212612,11 @@
212558212612
UNUSED_PARAMETER(isQuick);
212559212613
rc = rtreeCheckTable(pRtree->db, pRtree->zDb, pRtree->zName, pzErr);
212560212614
if( rc==SQLITE_OK && *pzErr ){
212561212615
*pzErr = sqlite3_mprintf("In RTree %s.%s:\n%z",
212562212616
pRtree->zDb, pRtree->zName, *pzErr);
212617
+ if( (*pzErr)==0 ) rc = SQLITE_NOMEM;
212563212618
}
212564212619
return rc;
212565212620
}
212566212621
212567212622
/*
@@ -250229,12 +250284,12 @@
250229250284
static int fts5RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){
250230250285
Fts5FullTable *pTab = (Fts5FullTable*)pVtab;
250231250286
int rc = SQLITE_OK;
250232250287
fts5CheckTransactionState(pTab, FTS5_ROLLBACKTO, iSavepoint);
250233250288
fts5TripCursors(pTab);
250234
- pTab->p.pConfig->pgsz = 0;
250235250289
if( (iSavepoint+1)<=pTab->iSavepoint ){
250290
+ pTab->p.pConfig->pgsz = 0;
250236250291
rc = sqlite3Fts5StorageRollback(pTab->pStorage);
250237250292
}
250238250293
return rc;
250239250294
}
250240250295
@@ -250435,11 +250490,11 @@
250435250490
int nArg, /* Number of args */
250436250491
sqlite3_value **apUnused /* Function arguments */
250437250492
){
250438250493
assert( nArg==0 );
250439250494
UNUSED_PARAM2(nArg, apUnused);
250440
- sqlite3_result_text(pCtx, "fts5: 2023-12-29 19:03:01 4b70b94616ef37bac969051eee3ea6913a28f30520cdd4fc3a19e848f2cf12b7", -1, SQLITE_TRANSIENT);
250495
+ sqlite3_result_text(pCtx, "fts5: 2024-01-08 19:55:40 cd016f26bb61549a304f2148035e050f76a8f4a35cdb7131bba2f5fc5d09f49e", -1, SQLITE_TRANSIENT);
250441250496
}
250442250497
250443250498
/*
250444250499
** Return true if zName is the extension on one of the shadow tables used
250445250500
** by this module.
250446250501
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -16,11 +16,11 @@
16 ** if you want a wrapper to interface SQLite with your choice of programming
17 ** language. The code for the "sqlite3" command-line shell is also in a
18 ** separate file. This file contains only code for the core SQLite library.
19 **
20 ** The content in this amalgamation comes from Fossil check-in
21 ** bcac937526d9a6ef914a74b4d6757fa91cd7.
22 */
23 #define SQLITE_CORE 1
24 #define SQLITE_AMALGAMATION 1
25 #ifndef SQLITE_PRIVATE
26 # define SQLITE_PRIVATE static
@@ -459,11 +459,11 @@
459 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
460 ** [sqlite_version()] and [sqlite_source_id()].
461 */
462 #define SQLITE_VERSION "3.45.0"
463 #define SQLITE_VERSION_NUMBER 3045000
464 #define SQLITE_SOURCE_ID "2024-01-01 19:20:00 bcac937526d9a6ef914a74b4d6757fa91cd74edab871bcd934fde4a2f9b6debd"
465
466 /*
467 ** CAPI3REF: Run-Time Library Version Numbers
468 ** KEYWORDS: sqlite3_version sqlite3_sourceid
469 **
@@ -13873,11 +13873,11 @@
13873 ** This is really just the default value for the max_page_count pragma.
13874 ** This value can be lowered (or raised) at run-time using that the
13875 ** max_page_count macro.
13876 */
13877 #ifndef SQLITE_MAX_PAGE_COUNT
13878 # define SQLITE_MAX_PAGE_COUNT 1073741823
13879 #endif
13880
13881 /*
13882 ** Maximum length (in bytes) of the pattern in a LIKE or GLOB
13883 ** operator.
@@ -43060,20 +43060,20 @@
43060 #ifdef SQLITE_ENABLE_SETLK_TIMEOUT
43061 int iMutex;
43062 for(iMutex=ofst; iMutex<ofst+n; iMutex++){
43063 if( flags==(SQLITE_SHM_LOCK|SQLITE_SHM_EXCLUSIVE) ){
43064 rc = sqlite3_mutex_try(pShmNode->aMutex[iMutex]);
43065 if( rc!=SQLITE_OK ) break;
43066 }else{
43067 sqlite3_mutex_enter(pShmNode->aMutex[iMutex]);
43068 }
43069 }
43070 #else
43071 sqlite3_mutex_enter(pShmNode->pShmMutex);
43072 #endif
43073
43074 if( rc==SQLITE_OK ){
43075 if( flags & SQLITE_SHM_UNLOCK ){
43076 /* Case (a) - unlock. */
43077 int bUnlock = 1;
43078 assert( (p->exclMask & p->sharedMask)==0 );
43079 assert( !(flags & SQLITE_SHM_EXCLUSIVE) || (p->exclMask & mask)==mask );
@@ -43148,10 +43148,11 @@
43148 assert( assertLockingArrayOk(pShmNode) );
43149 }
43150
43151 /* Drop the mutexes acquired above. */
43152 #ifdef SQLITE_ENABLE_SETLK_TIMEOUT
 
43153 for(iMutex--; iMutex>=ofst; iMutex--){
43154 sqlite3_mutex_leave(pShmNode->aMutex[iMutex]);
43155 }
43156 #else
43157 sqlite3_mutex_leave(pShmNode->pShmMutex);
@@ -57503,13 +57504,12 @@
57503 if( pPager->fd->pMethods==0 ) return 0;
57504 if( sqlite3PCacheIsDirty(pPager->pPCache) ) return 0;
57505 #ifndef SQLITE_OMIT_WAL
57506 if( pPager->pWal ){
57507 u32 iRead = 0;
57508 int rc;
57509 rc = sqlite3WalFindFrame(pPager->pWal, pgno, &iRead);
57510 return (rc==SQLITE_OK && iRead==0);
57511 }
57512 #endif
57513 return 1;
57514 }
57515 #endif
@@ -67391,10 +67391,41 @@
67391 *pChanged = 1;
67392 }
67393 return rc;
67394 }
67395
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67396 /*
67397 ** Attempt to start a read transaction. This might fail due to a race or
67398 ** other transient condition. When that happens, it returns WAL_RETRY to
67399 ** indicate to the caller that it is safe to retry immediately.
67400 **
@@ -67441,11 +67472,11 @@
67441 ** checkpoint process do as much work as possible. This routine might
67442 ** update values of the aReadMark[] array in the header, but if it does
67443 ** so it takes care to hold an exclusive lock on the corresponding
67444 ** WAL_READ_LOCK() while changing values.
67445 */
67446 static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int cnt){
67447 volatile WalCkptInfo *pInfo; /* Checkpoint information in wal-index */
67448 u32 mxReadMark; /* Largest aReadMark[] value */
67449 int mxI; /* Index of largest aReadMark[] value */
67450 int i; /* Loop counter */
67451 int rc = SQLITE_OK; /* Return code */
@@ -67474,41 +67505,51 @@
67474 ** is more of a scheduler yield than an actual delay. But on the 10th
67475 ** an subsequent retries, the delays start becoming longer and longer,
67476 ** so that on the 100th (and last) RETRY we delay for 323 milliseconds.
67477 ** The total delay time before giving up is less than 10 seconds.
67478 */
67479 if( cnt>5 ){
 
67480 int nDelay = 1; /* Pause time in microseconds */
67481 if( cnt>100 ){
 
67482 VVA_ONLY( pWal->lockError = 1; )
67483 return SQLITE_PROTOCOL;
67484 }
67485 if( cnt>=10 ) nDelay = (cnt-9)*(cnt-9)*39;
67486 #ifdef SQLITE_ENABLE_SETLK_TIMEOUT
67487 /* In SQLITE_ENABLE_SETLK_TIMEOUT builds, configure the file-descriptor
67488 ** to block for locks for approximately nDelay us. This affects three
67489 ** locks: (a) the shared lock taken on the DMS slot in os_unix.c (if
67490 ** using os_unix.c), (b) the WRITER lock taken in walIndexReadHdr() if the
67491 ** first attempted read fails, and (c) the shared lock taken on the DMS
67492 ** slot in os_unix.c. All three of these locks are attempted from within
67493 ** the call to walIndexReadHdr() below. */
 
 
 
 
67494 nBlockTmout = (nDelay+998) / 1000;
67495 if( !useWal && walEnableBlockingMs(pWal, nBlockTmout) ){
67496 nDelay = 1;
67497 }
67498 #endif
67499 sqlite3OsSleep(pWal->pVfs, nDelay);
 
67500 }
67501
67502 if( !useWal ){
67503 assert( rc==SQLITE_OK );
67504 if( pWal->bShmUnreliable==0 ){
67505 rc = walIndexReadHdr(pWal, pChanged);
67506 }
67507 #ifdef SQLITE_ENABLE_SETLK_TIMEOUT
67508 walDisableBlocking(pWal);
67509 if( rc==SQLITE_BUSY_TIMEOUT ) rc = SQLITE_BUSY;
 
 
 
67510 #endif
67511 if( rc==SQLITE_BUSY ){
67512 /* If there is not a recovery running in another thread or process
67513 ** then convert BUSY errors to WAL_RETRY. If recovery is known to
67514 ** be running, convert BUSY to BUSY_RECOVERY. There is a race here
@@ -67624,10 +67665,13 @@
67624
67625 (void)walEnableBlockingMs(pWal, nBlockTmout);
67626 rc = walLockShared(pWal, WAL_READ_LOCK(mxI));
67627 walDisableBlocking(pWal);
67628 if( rc ){
 
 
 
67629 assert( (rc&0xFF)!=SQLITE_BUSY||rc==SQLITE_BUSY||rc==SQLITE_BUSY_TIMEOUT );
67630 return (rc&0xFF)==SQLITE_BUSY ? WAL_RETRY : rc;
67631 }
67632 /* Now that the read-lock has been obtained, check that neither the
67633 ** value in the aReadMark[] array or the contents of the wal-index
@@ -67813,11 +67857,11 @@
67813 ckptLock = 1;
67814 }
67815 #endif
67816
67817 do{
67818 rc = walTryBeginRead(pWal, pChanged, 0, ++cnt);
67819 }while( rc==WAL_RETRY );
67820 testcase( (rc&0xff)==SQLITE_BUSY );
67821 testcase( (rc&0xff)==SQLITE_IOERR );
67822 testcase( rc==SQLITE_PROTOCOL );
67823 testcase( rc==SQLITE_OK );
@@ -67994,10 +68038,11 @@
67994 if( iFrame<=iLast && iFrame>=pWal->minFrame && sLoc.aPgno[iH-1]==pgno ){
67995 assert( iFrame>iRead || CORRUPT_DB );
67996 iRead = iFrame;
67997 }
67998 if( (nCollide--)==0 ){
 
67999 return SQLITE_CORRUPT_BKPT;
68000 }
68001 iKey = walNextHash(iKey);
68002 }
68003 if( iRead ) break;
@@ -68297,11 +68342,11 @@
68297 walUnlockShared(pWal, WAL_READ_LOCK(0));
68298 pWal->readLock = -1;
68299 cnt = 0;
68300 do{
68301 int notUsed;
68302 rc = walTryBeginRead(pWal, &notUsed, 1, ++cnt);
68303 }while( rc==WAL_RETRY );
68304 assert( (rc&0xff)!=SQLITE_BUSY ); /* BUSY not possible when useWal==1 */
68305 testcase( (rc&0xff)==SQLITE_IOERR );
68306 testcase( rc==SQLITE_PROTOCOL );
68307 testcase( rc==SQLITE_OK );
@@ -75232,11 +75277,10 @@
75232 u8 aSave[4];
75233 u8 *aWrite = &pBuf[-4];
75234 assert( aWrite>=pBufStart ); /* due to (6) */
75235 memcpy(aSave, aWrite, 4);
75236 rc = sqlite3OsRead(fd, aWrite, a+4, (i64)pBt->pageSize*(nextPage-1));
75237 if( rc && nextPage>pBt->nPage ) rc = SQLITE_CORRUPT_BKPT;
75238 nextPage = get4byte(aWrite);
75239 memcpy(aWrite, aSave, 4);
75240 }else
75241 #endif
75242
@@ -122158,11 +122202,12 @@
122158 char aff = SQLITE_AFF_NUMERIC;
122159 const char *zChar = 0;
122160
122161 assert( zIn!=0 );
122162 while( zIn[0] ){
122163 h = (h<<8) + sqlite3UpperToLower[(*zIn)&0xff];
 
122164 zIn++;
122165 if( h==(('c'<<24)+('h'<<16)+('a'<<8)+'r') ){ /* CHAR */
122166 aff = SQLITE_AFF_TEXT;
122167 zChar = zIn;
122168 }else if( h==(('c'<<24)+('l'<<16)+('o'<<8)+'b') ){ /* CLOB */
@@ -126023,20 +126068,21 @@
126023 }
126024 iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pObjName);
126025 if( iDb<0 ) return;
126026 z = sqlite3NameFromToken(db, pObjName);
126027 if( z==0 ) return;
126028 zDb = db->aDb[iDb].zDbSName;
126029 pTab = sqlite3FindTable(db, z, zDb);
126030 if( pTab ){
126031 reindexTable(pParse, pTab, 0);
126032 sqlite3DbFree(db, z);
126033 return;
126034 }
126035 pIndex = sqlite3FindIndex(db, z, zDb);
126036 sqlite3DbFree(db, z);
126037 if( pIndex ){
 
126038 sqlite3BeginWriteOperation(pParse, 0, iDb);
126039 sqlite3RefillIndex(pParse, pIndex, -1);
126040 return;
126041 }
126042 sqlite3ErrorMsg(pParse, "unable to identify the object to be reindexed");
@@ -182703,11 +182749,11 @@
182703 ** If onOff is initially 1, then turn it on. If onOff is initially
182704 ** off, turn it off. If onOff is initially -1, then change onOff
182705 ** to be the current setting.
182706 */
182707 case SQLITE_TESTCTRL_JSON_SELFCHECK: {
182708 #if defined(SQLITE_DEBUG)
182709 int *pOnOff = va_arg(ap, int*);
182710 if( *pOnOff<0 ){
182711 *pOnOff = sqlite3Config.bJsonSelfcheck;
182712 }else{
182713 sqlite3Config.bJsonSelfcheck = (u8)((*pOnOff)&0xff);
@@ -203415,10 +203461,11 @@
203415 struct JsonParse {
203416 u8 *aBlob; /* JSONB representation of JSON value */
203417 u32 nBlob; /* Bytes of aBlob[] actually used */
203418 u32 nBlobAlloc; /* Bytes allocated to aBlob[]. 0 if aBlob is external */
203419 char *zJson; /* Json text used for parsing */
 
203420 int nJson; /* Length of the zJson string in bytes */
203421 u32 nJPRef; /* Number of references to this object */
203422 u32 iErr; /* Error location in zJson[] */
203423 u16 iDepth; /* Nesting depth */
203424 u8 nErr; /* Number of errors seen */
@@ -203940,11 +203987,11 @@
203940 pParse->zJson = 0;
203941 pParse->nJson = 0;
203942 pParse->bJsonIsRCStr = 0;
203943 }
203944 if( pParse->nBlobAlloc ){
203945 sqlite3_free(pParse->aBlob);
203946 pParse->aBlob = 0;
203947 pParse->nBlob = 0;
203948 pParse->nBlobAlloc = 0;
203949 }
203950 }
@@ -203957,11 +204004,11 @@
203957 if( pParse ){
203958 if( pParse->nJPRef>1 ){
203959 pParse->nJPRef--;
203960 }else{
203961 jsonParseReset(pParse);
203962 sqlite3_free(pParse);
203963 }
203964 }
203965 }
203966
203967 /**************************************************************************
@@ -204188,11 +204235,11 @@
204188 t = 100;
204189 }else{
204190 t = pParse->nBlobAlloc*2;
204191 }
204192 if( t<N ) t = N+100;
204193 aNew = sqlite3_realloc64( pParse->aBlob, t );
204194 if( aNew==0 ){ pParse->oom = 1; return 1; }
204195 pParse->aBlob = aNew;
204196 pParse->nBlobAlloc = t;
204197 return 0;
204198 }
@@ -205113,18 +205160,19 @@
205113 JsonParse px;
205114 memset(&px, 0, sizeof(px));
205115 jsonStringTerminate(pStr);
205116 px.zJson = pStr->zBuf;
205117 px.nJson = pStr->nUsed;
 
205118 (void)jsonTranslateTextToBlob(&px, 0);
205119 if( px.oom ){
205120 sqlite3_free(px.aBlob);
205121 sqlite3_result_error_nomem(pStr->pCtx);
205122 }else{
205123 assert( px.nBlobAlloc>0 );
205124 assert( !px.bReadOnly );
205125 sqlite3_result_blob(pStr->pCtx, px.aBlob, px.nBlob, sqlite3_free);
205126 }
205127 }
205128
205129 /* The byte at index i is a node type-code. This routine
205130 ** determines the payload size for that node and writes that
@@ -205736,10 +205784,11 @@
205736 const char *zTail /* Tail of the path that determins substructure */
205737 ){
205738 static const u8 emptyObject[] = { JSONB_ARRAY, JSONB_OBJECT };
205739 int rc;
205740 memset(pIns, 0, sizeof(*pIns));
 
205741 if( zTail[0]==0 ){
205742 /* No substructure. Just insert what is given in pParse. */
205743 pIns->aBlob = pParse->aIns;
205744 pIns->nBlob = pParse->nIns;
205745 rc = 0;
@@ -205863,10 +205912,11 @@
205863 JsonParse v; /* BLOB encoding of the value to be inserted */
205864 JsonParse ix; /* Header of the label to be inserted */
205865 testcase( pParse->eEdit==JEDIT_INS );
205866 testcase( pParse->eEdit==JEDIT_SET );
205867 memset(&ix, 0, sizeof(ix));
 
205868 jsonBlobAppendNode(&ix, rawKey?JSONB_TEXTRAW:JSONB_TEXT5, nKey, 0);
205869 pParse->oom |= ix.oom;
205870 rc = jsonCreateEditSubstructure(pParse, &v, &zPath[i]);
205871 if( !JSON_LOOKUP_ISERROR(rc)
205872 && jsonBlobMakeEditable(pParse, ix.nBlob+nKey+v.nBlob)
@@ -206073,11 +206123,11 @@
206073 u32 iIn, iOut;
206074 const char *z;
206075 char *zOut;
206076 u32 nOut = sz;
206077 z = (const char*)&pParse->aBlob[i+n];
206078 zOut = sqlite3_malloc( nOut+1 );
206079 if( zOut==0 ) goto returnfromblob_oom;
206080 for(iIn=iOut=0; iIn<sz; iIn++){
206081 char c = z[iIn];
206082 if( c=='\\' ){
206083 u32 v;
@@ -206107,11 +206157,11 @@
206107 zOut[iOut++] = c;
206108 }
206109 } /* end for() */
206110 assert( iOut<=nOut );
206111 zOut[iOut] = 0;
206112 sqlite3_result_text(pCtx, zOut, iOut, sqlite3_free);
206113 break;
206114 }
206115 case JSONB_ARRAY:
206116 case JSONB_OBJECT: {
206117 int flags = textOnly ? 0 : SQLITE_PTR_TO_INT(sqlite3_user_data(pCtx));
@@ -206160,10 +206210,11 @@
206160 JsonParse *pParse
206161 ){
206162 int eType = sqlite3_value_type(pArg);
206163 static u8 aNull[] = { 0x00 };
206164 memset(pParse, 0, sizeof(pParse[0]));
 
206165 switch( eType ){
206166 default: {
206167 pParse->aBlob = aNull;
206168 pParse->nBlob = 1;
206169 return 0;
@@ -206185,11 +206236,11 @@
206185 if( sqlite3_value_subtype(pArg)==JSON_SUBTYPE ){
206186 pParse->zJson = (char*)zJson;
206187 pParse->nJson = nJson;
206188 if( jsonConvertTextToBlob(pParse, ctx) ){
206189 sqlite3_result_error(ctx, "malformed JSON", -1);
206190 sqlite3_free(pParse->aBlob);
206191 memset(pParse, 0, sizeof(pParse[0]));
206192 return 1;
206193 }
206194 }else{
206195 jsonBlobAppendNode(pParse, JSONB_TEXTRAW, nJson, zJson);
@@ -206342,10 +206393,11 @@
206342 u32 flgs
206343 ){
206344 int eType; /* Datatype of pArg */
206345 JsonParse *p = 0; /* Value to be returned */
206346 JsonParse *pFromCache = 0; /* Value taken from cache */
 
206347
206348 assert( ctx!=0 );
206349 eType = sqlite3_value_type(pArg);
206350 if( eType==SQLITE_NULL ){
206351 return 0;
@@ -206355,18 +206407,20 @@
206355 pFromCache->nJPRef++;
206356 if( (flgs & JSON_EDITABLE)==0 ){
206357 return pFromCache;
206358 }
206359 }
 
206360 rebuild_from_cache:
206361 p = sqlite3_malloc64( sizeof(*p) );
206362 if( p==0 ) goto json_pfa_oom;
206363 memset(p, 0, sizeof(*p));
 
206364 p->nJPRef = 1;
206365 if( pFromCache!=0 ){
206366 u32 nBlob = pFromCache->nBlob;
206367 p->aBlob = sqlite3_malloc64( nBlob );
206368 if( p->aBlob==0 ) goto json_pfa_oom;
206369 memcpy(p->aBlob, pFromCache->aBlob, nBlob);
206370 p->nBlobAlloc = p->nBlob = nBlob;
206371 p->hasNonstd = pFromCache->hasNonstd;
206372 jsonParseFree(pFromCache);
@@ -206618,11 +206672,11 @@
206618 sqlite3StrAccumInit(&out, 0, 0, 0, 1000000);
206619 p = jsonParseFuncArg(ctx, argv[0], 0);
206620 if( p==0 ) return;
206621 if( argc==1 ){
206622 jsonDebugPrintBlob(p, 0, p->nBlob, 0, &out);
206623 sqlite3_result_text64(ctx, out.zText, out.nChar, sqlite3_free, SQLITE_UTF8);
206624 }else{
206625 jsonShowParse(p);
206626 }
206627 jsonParseFree(p);
206628 }
@@ -207437,10 +207491,11 @@
207437 JsonParse s;
207438
207439 assert( argc==1 );
207440 UNUSED_PARAMETER(argc);
207441 memset(&s, 0, sizeof(s));
 
207442 if( jsonFuncArgMightBeBinary(argv[0]) ){
207443 s.aBlob = (u8*)sqlite3_value_blob(argv[0]);
207444 s.nBlob = sqlite3_value_bytes(argv[0]);
207445 iErrPos = (i64)jsonbValidityCheck(&s, 0, s.nBlob, 1);
207446 }else{
@@ -207726,34 +207781,34 @@
207726 UNUSED_PARAMETER(pAux);
207727 rc = sqlite3_declare_vtab(db,
207728 "CREATE TABLE x(key,value,type,atom,id,parent,fullkey,path,"
207729 "json HIDDEN,root HIDDEN)");
207730 if( rc==SQLITE_OK ){
207731 pNew = (JsonEachConnection*)(*ppVtab = sqlite3_malloc( sizeof(*pNew) ));
 
207732 if( pNew==0 ) return SQLITE_NOMEM;
207733 memset(pNew, 0, sizeof(*pNew));
207734 sqlite3_vtab_config(db, SQLITE_VTAB_INNOCUOUS);
207735 pNew->db = db;
207736 }
207737 return rc;
207738 }
207739
207740 /* destructor for json_each virtual table */
207741 static int jsonEachDisconnect(sqlite3_vtab *pVtab){
207742 sqlite3_free(pVtab);
 
207743 return SQLITE_OK;
207744 }
207745
207746 /* constructor for a JsonEachCursor object for json_each(). */
207747 static int jsonEachOpenEach(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){
207748 JsonEachConnection *pVtab = (JsonEachConnection*)p;
207749 JsonEachCursor *pCur;
207750
207751 UNUSED_PARAMETER(p);
207752 pCur = sqlite3_malloc( sizeof(*pCur) );
207753 if( pCur==0 ) return SQLITE_NOMEM;
207754 memset(pCur, 0, sizeof(*pCur));
207755 pCur->db = pVtab->db;
207756 jsonStringZero(&pCur->path);
207757 *ppCursor = &pCur->base;
207758 return SQLITE_OK;
207759 }
@@ -207786,11 +207841,11 @@
207786 /* Destructor for a jsonEachCursor object */
207787 static int jsonEachClose(sqlite3_vtab_cursor *cur){
207788 JsonEachCursor *p = (JsonEachCursor*)cur;
207789 jsonEachCursorReset(p);
207790
207791 sqlite3_free(cur);
207792 return SQLITE_OK;
207793 }
207794
207795 /* Return TRUE if the jsonEachCursor object has been advanced off the end
207796 ** of the JSON object */
@@ -208120,10 +208175,11 @@
208120 UNUSED_PARAMETER(argc);
208121 jsonEachCursorReset(p);
208122 if( idxNum==0 ) return SQLITE_OK;
208123 memset(&p->sParse, 0, sizeof(p->sParse));
208124 p->sParse.nJPRef = 1;
 
208125 if( sqlite3_value_type(argv[0])==SQLITE_BLOB ){
208126 if( jsonFuncArgMightBeBinary(argv[0]) ){
208127 p->sParse.nBlob = sqlite3_value_bytes(argv[0]);
208128 p->sParse.aBlob = (u8*)sqlite3_value_blob(argv[0]);
208129 }else{
@@ -209071,11 +209127,11 @@
209071
209072 /* Check if the requested node is already in the hash table. If so,
209073 ** increase its reference count and return it.
209074 */
209075 if( (pNode = nodeHashLookup(pRtree, iNode))!=0 ){
209076 if( pParent && pParent!=pNode->pParent ){
209077 RTREE_IS_CORRUPT(pRtree);
209078 return SQLITE_CORRUPT_VTAB;
209079 }
209080 pNode->nRef++;
209081 *ppNode = pNode;
@@ -211806,11 +211862,11 @@
211806 }else{
211807 rc = SQLITE_NOMEM;
211808 }
211809 sqlite3_free(zSql);
211810 }
211811 if( pRtree->nAux ){
211812 pRtree->zReadAuxSql = sqlite3_mprintf(
211813 "SELECT * FROM \"%w\".\"%w_rowid\" WHERE rowid=?1",
211814 zDb, zPrefix);
211815 if( pRtree->zReadAuxSql==0 ){
211816 rc = SQLITE_NOMEM;
@@ -212495,19 +212551,17 @@
212495 check.db = db;
212496 check.zDb = zDb;
212497 check.zTab = zTab;
212498
212499 /* Find the number of auxiliary columns */
212500 if( check.rc==SQLITE_OK ){
212501 pStmt = rtreeCheckPrepare(&check, "SELECT * FROM %Q.'%q_rowid'", zDb, zTab);
212502 if( pStmt ){
212503 nAux = sqlite3_column_count(pStmt) - 2;
212504 sqlite3_finalize(pStmt);
212505 }else
212506 if( check.rc!=SQLITE_NOMEM ){
212507 check.rc = SQLITE_OK;
212508 }
212509 }
212510
212511 /* Find number of dimensions in the rtree table. */
212512 pStmt = rtreeCheckPrepare(&check, "SELECT * FROM %Q.%Q", zDb, zTab);
212513 if( pStmt ){
@@ -212558,10 +212612,11 @@
212558 UNUSED_PARAMETER(isQuick);
212559 rc = rtreeCheckTable(pRtree->db, pRtree->zDb, pRtree->zName, pzErr);
212560 if( rc==SQLITE_OK && *pzErr ){
212561 *pzErr = sqlite3_mprintf("In RTree %s.%s:\n%z",
212562 pRtree->zDb, pRtree->zName, *pzErr);
 
212563 }
212564 return rc;
212565 }
212566
212567 /*
@@ -250229,12 +250284,12 @@
250229 static int fts5RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){
250230 Fts5FullTable *pTab = (Fts5FullTable*)pVtab;
250231 int rc = SQLITE_OK;
250232 fts5CheckTransactionState(pTab, FTS5_ROLLBACKTO, iSavepoint);
250233 fts5TripCursors(pTab);
250234 pTab->p.pConfig->pgsz = 0;
250235 if( (iSavepoint+1)<=pTab->iSavepoint ){
 
250236 rc = sqlite3Fts5StorageRollback(pTab->pStorage);
250237 }
250238 return rc;
250239 }
250240
@@ -250435,11 +250490,11 @@
250435 int nArg, /* Number of args */
250436 sqlite3_value **apUnused /* Function arguments */
250437 ){
250438 assert( nArg==0 );
250439 UNUSED_PARAM2(nArg, apUnused);
250440 sqlite3_result_text(pCtx, "fts5: 2023-12-29 19:03:01 4b70b94616ef37bac969051eee3ea6913a28f30520cdd4fc3a19e848f2cf12b7", -1, SQLITE_TRANSIENT);
250441 }
250442
250443 /*
250444 ** Return true if zName is the extension on one of the shadow tables used
250445 ** by this module.
250446
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -16,11 +16,11 @@
16 ** if you want a wrapper to interface SQLite with your choice of programming
17 ** language. The code for the "sqlite3" command-line shell is also in a
18 ** separate file. This file contains only code for the core SQLite library.
19 **
20 ** The content in this amalgamation comes from Fossil check-in
21 ** 97709ce2a1f5ae05495e412ca27108048e5b.
22 */
23 #define SQLITE_CORE 1
24 #define SQLITE_AMALGAMATION 1
25 #ifndef SQLITE_PRIVATE
26 # define SQLITE_PRIVATE static
@@ -459,11 +459,11 @@
459 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
460 ** [sqlite_version()] and [sqlite_source_id()].
461 */
462 #define SQLITE_VERSION "3.45.0"
463 #define SQLITE_VERSION_NUMBER 3045000
464 #define SQLITE_SOURCE_ID "2024-01-09 12:28:51 97709ce2a1f5ae05495e412ca27108048e5b8a63a1e3bca4be13933f7527da7b"
465
466 /*
467 ** CAPI3REF: Run-Time Library Version Numbers
468 ** KEYWORDS: sqlite3_version sqlite3_sourceid
469 **
@@ -13873,11 +13873,11 @@
13873 ** This is really just the default value for the max_page_count pragma.
13874 ** This value can be lowered (or raised) at run-time using that the
13875 ** max_page_count macro.
13876 */
13877 #ifndef SQLITE_MAX_PAGE_COUNT
13878 # define SQLITE_MAX_PAGE_COUNT 0xfffffffe /* 4294967294 */
13879 #endif
13880
13881 /*
13882 ** Maximum length (in bytes) of the pattern in a LIKE or GLOB
13883 ** operator.
@@ -43060,20 +43060,20 @@
43060 #ifdef SQLITE_ENABLE_SETLK_TIMEOUT
43061 int iMutex;
43062 for(iMutex=ofst; iMutex<ofst+n; iMutex++){
43063 if( flags==(SQLITE_SHM_LOCK|SQLITE_SHM_EXCLUSIVE) ){
43064 rc = sqlite3_mutex_try(pShmNode->aMutex[iMutex]);
43065 if( rc!=SQLITE_OK ) goto leave_shmnode_mutexes;
43066 }else{
43067 sqlite3_mutex_enter(pShmNode->aMutex[iMutex]);
43068 }
43069 }
43070 #else
43071 sqlite3_mutex_enter(pShmNode->pShmMutex);
43072 #endif
43073
43074 if( ALWAYS(rc==SQLITE_OK) ){
43075 if( flags & SQLITE_SHM_UNLOCK ){
43076 /* Case (a) - unlock. */
43077 int bUnlock = 1;
43078 assert( (p->exclMask & p->sharedMask)==0 );
43079 assert( !(flags & SQLITE_SHM_EXCLUSIVE) || (p->exclMask & mask)==mask );
@@ -43148,10 +43148,11 @@
43148 assert( assertLockingArrayOk(pShmNode) );
43149 }
43150
43151 /* Drop the mutexes acquired above. */
43152 #ifdef SQLITE_ENABLE_SETLK_TIMEOUT
43153 leave_shmnode_mutexes:
43154 for(iMutex--; iMutex>=ofst; iMutex--){
43155 sqlite3_mutex_leave(pShmNode->aMutex[iMutex]);
43156 }
43157 #else
43158 sqlite3_mutex_leave(pShmNode->pShmMutex);
@@ -57503,13 +57504,12 @@
57504 if( pPager->fd->pMethods==0 ) return 0;
57505 if( sqlite3PCacheIsDirty(pPager->pPCache) ) return 0;
57506 #ifndef SQLITE_OMIT_WAL
57507 if( pPager->pWal ){
57508 u32 iRead = 0;
57509 (void)sqlite3WalFindFrame(pPager->pWal, pgno, &iRead);
57510 return iRead==0;
 
57511 }
57512 #endif
57513 return 1;
57514 }
57515 #endif
@@ -67391,10 +67391,41 @@
67391 *pChanged = 1;
67392 }
67393 return rc;
67394 }
67395
67396 /*
67397 ** The final argument passed to walTryBeginRead() is of type (int*). The
67398 ** caller should invoke walTryBeginRead as follows:
67399 **
67400 ** int cnt = 0;
67401 ** do {
67402 ** rc = walTryBeginRead(..., &cnt);
67403 ** }while( rc==WAL_RETRY );
67404 **
67405 ** The final value of "cnt" is of no use to the caller. It is used by
67406 ** the implementation of walTryBeginRead() as follows:
67407 **
67408 ** + Each time walTryBeginRead() is called, it is incremented. Once
67409 ** it reaches WAL_RETRY_PROTOCOL_LIMIT - indicating that walTryBeginRead()
67410 ** has many times been invoked and failed with WAL_RETRY - walTryBeginRead()
67411 ** returns SQLITE_PROTOCOL.
67412 **
67413 ** + If SQLITE_ENABLE_SETLK_TIMEOUT is defined and walTryBeginRead() failed
67414 ** because a blocking lock timed out (SQLITE_BUSY_TIMEOUT from the OS
67415 ** layer), the WAL_RETRY_BLOCKED_MASK bit is set in "cnt". In this case
67416 ** the next invocation of walTryBeginRead() may omit an expected call to
67417 ** sqlite3OsSleep(). There has already been a delay when the previous call
67418 ** waited on a lock.
67419 */
67420 #define WAL_RETRY_PROTOCOL_LIMIT 100
67421 #ifdef SQLITE_ENABLE_SETLK_TIMEOUT
67422 # define WAL_RETRY_BLOCKED_MASK 0x10000000
67423 #else
67424 # define WAL_RETRY_BLOCKED_MASK 0
67425 #endif
67426
67427 /*
67428 ** Attempt to start a read transaction. This might fail due to a race or
67429 ** other transient condition. When that happens, it returns WAL_RETRY to
67430 ** indicate to the caller that it is safe to retry immediately.
67431 **
@@ -67441,11 +67472,11 @@
67472 ** checkpoint process do as much work as possible. This routine might
67473 ** update values of the aReadMark[] array in the header, but if it does
67474 ** so it takes care to hold an exclusive lock on the corresponding
67475 ** WAL_READ_LOCK() while changing values.
67476 */
67477 static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int *pCnt){
67478 volatile WalCkptInfo *pInfo; /* Checkpoint information in wal-index */
67479 u32 mxReadMark; /* Largest aReadMark[] value */
67480 int mxI; /* Index of largest aReadMark[] value */
67481 int i; /* Loop counter */
67482 int rc = SQLITE_OK; /* Return code */
@@ -67474,41 +67505,51 @@
67505 ** is more of a scheduler yield than an actual delay. But on the 10th
67506 ** an subsequent retries, the delays start becoming longer and longer,
67507 ** so that on the 100th (and last) RETRY we delay for 323 milliseconds.
67508 ** The total delay time before giving up is less than 10 seconds.
67509 */
67510 (*pCnt)++;
67511 if( *pCnt>5 ){
67512 int nDelay = 1; /* Pause time in microseconds */
67513 int cnt = (*pCnt & ~WAL_RETRY_BLOCKED_MASK);
67514 if( cnt>WAL_RETRY_PROTOCOL_LIMIT ){
67515 VVA_ONLY( pWal->lockError = 1; )
67516 return SQLITE_PROTOCOL;
67517 }
67518 if( *pCnt>=10 ) nDelay = (cnt-9)*(cnt-9)*39;
67519 #ifdef SQLITE_ENABLE_SETLK_TIMEOUT
67520 /* In SQLITE_ENABLE_SETLK_TIMEOUT builds, configure the file-descriptor
67521 ** to block for locks for approximately nDelay us. This affects three
67522 ** locks: (a) the shared lock taken on the DMS slot in os_unix.c (if
67523 ** using os_unix.c), (b) the WRITER lock taken in walIndexReadHdr() if the
67524 ** first attempted read fails, and (c) the shared lock taken on the
67525 ** read-mark.
67526 **
67527 ** If the previous call failed due to an SQLITE_BUSY_TIMEOUT error,
67528 ** then sleep for the minimum of 1us. The previous call already provided
67529 ** an extra delay while it was blocking on the lock.
67530 */
67531 nBlockTmout = (nDelay+998) / 1000;
67532 if( !useWal && walEnableBlockingMs(pWal, nBlockTmout) ){
67533 if( *pCnt & WAL_RETRY_BLOCKED_MASK ) nDelay = 1;
67534 }
67535 #endif
67536 sqlite3OsSleep(pWal->pVfs, nDelay);
67537 *pCnt &= ~WAL_RETRY_BLOCKED_MASK;
67538 }
67539
67540 if( !useWal ){
67541 assert( rc==SQLITE_OK );
67542 if( pWal->bShmUnreliable==0 ){
67543 rc = walIndexReadHdr(pWal, pChanged);
67544 }
67545 #ifdef SQLITE_ENABLE_SETLK_TIMEOUT
67546 walDisableBlocking(pWal);
67547 if( rc==SQLITE_BUSY_TIMEOUT ){
67548 rc = SQLITE_BUSY;
67549 *pCnt |= WAL_RETRY_BLOCKED_MASK;
67550 }
67551 #endif
67552 if( rc==SQLITE_BUSY ){
67553 /* If there is not a recovery running in another thread or process
67554 ** then convert BUSY errors to WAL_RETRY. If recovery is known to
67555 ** be running, convert BUSY to BUSY_RECOVERY. There is a race here
@@ -67624,10 +67665,13 @@
67665
67666 (void)walEnableBlockingMs(pWal, nBlockTmout);
67667 rc = walLockShared(pWal, WAL_READ_LOCK(mxI));
67668 walDisableBlocking(pWal);
67669 if( rc ){
67670 if( rc==SQLITE_BUSY_TIMEOUT ){
67671 *pCnt |= WAL_RETRY_BLOCKED_MASK;
67672 }
67673 assert( (rc&0xFF)!=SQLITE_BUSY||rc==SQLITE_BUSY||rc==SQLITE_BUSY_TIMEOUT );
67674 return (rc&0xFF)==SQLITE_BUSY ? WAL_RETRY : rc;
67675 }
67676 /* Now that the read-lock has been obtained, check that neither the
67677 ** value in the aReadMark[] array or the contents of the wal-index
@@ -67813,11 +67857,11 @@
67857 ckptLock = 1;
67858 }
67859 #endif
67860
67861 do{
67862 rc = walTryBeginRead(pWal, pChanged, 0, &cnt);
67863 }while( rc==WAL_RETRY );
67864 testcase( (rc&0xff)==SQLITE_BUSY );
67865 testcase( (rc&0xff)==SQLITE_IOERR );
67866 testcase( rc==SQLITE_PROTOCOL );
67867 testcase( rc==SQLITE_OK );
@@ -67994,10 +68038,11 @@
68038 if( iFrame<=iLast && iFrame>=pWal->minFrame && sLoc.aPgno[iH-1]==pgno ){
68039 assert( iFrame>iRead || CORRUPT_DB );
68040 iRead = iFrame;
68041 }
68042 if( (nCollide--)==0 ){
68043 *piRead = 0;
68044 return SQLITE_CORRUPT_BKPT;
68045 }
68046 iKey = walNextHash(iKey);
68047 }
68048 if( iRead ) break;
@@ -68297,11 +68342,11 @@
68342 walUnlockShared(pWal, WAL_READ_LOCK(0));
68343 pWal->readLock = -1;
68344 cnt = 0;
68345 do{
68346 int notUsed;
68347 rc = walTryBeginRead(pWal, &notUsed, 1, &cnt);
68348 }while( rc==WAL_RETRY );
68349 assert( (rc&0xff)!=SQLITE_BUSY ); /* BUSY not possible when useWal==1 */
68350 testcase( (rc&0xff)==SQLITE_IOERR );
68351 testcase( rc==SQLITE_PROTOCOL );
68352 testcase( rc==SQLITE_OK );
@@ -75232,11 +75277,10 @@
75277 u8 aSave[4];
75278 u8 *aWrite = &pBuf[-4];
75279 assert( aWrite>=pBufStart ); /* due to (6) */
75280 memcpy(aSave, aWrite, 4);
75281 rc = sqlite3OsRead(fd, aWrite, a+4, (i64)pBt->pageSize*(nextPage-1));
 
75282 nextPage = get4byte(aWrite);
75283 memcpy(aWrite, aSave, 4);
75284 }else
75285 #endif
75286
@@ -122158,11 +122202,12 @@
122202 char aff = SQLITE_AFF_NUMERIC;
122203 const char *zChar = 0;
122204
122205 assert( zIn!=0 );
122206 while( zIn[0] ){
122207 u8 x = *(u8*)zIn;
122208 h = (h<<8) + sqlite3UpperToLower[x];
122209 zIn++;
122210 if( h==(('c'<<24)+('h'<<16)+('a'<<8)+'r') ){ /* CHAR */
122211 aff = SQLITE_AFF_TEXT;
122212 zChar = zIn;
122213 }else if( h==(('c'<<24)+('l'<<16)+('o'<<8)+'b') ){ /* CLOB */
@@ -126023,20 +126068,21 @@
126068 }
126069 iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pObjName);
126070 if( iDb<0 ) return;
126071 z = sqlite3NameFromToken(db, pObjName);
126072 if( z==0 ) return;
126073 zDb = pName2->n ? db->aDb[iDb].zDbSName : 0;
126074 pTab = sqlite3FindTable(db, z, zDb);
126075 if( pTab ){
126076 reindexTable(pParse, pTab, 0);
126077 sqlite3DbFree(db, z);
126078 return;
126079 }
126080 pIndex = sqlite3FindIndex(db, z, zDb);
126081 sqlite3DbFree(db, z);
126082 if( pIndex ){
126083 iDb = sqlite3SchemaToIndex(db, pIndex->pTable->pSchema);
126084 sqlite3BeginWriteOperation(pParse, 0, iDb);
126085 sqlite3RefillIndex(pParse, pIndex, -1);
126086 return;
126087 }
126088 sqlite3ErrorMsg(pParse, "unable to identify the object to be reindexed");
@@ -182703,11 +182749,11 @@
182749 ** If onOff is initially 1, then turn it on. If onOff is initially
182750 ** off, turn it off. If onOff is initially -1, then change onOff
182751 ** to be the current setting.
182752 */
182753 case SQLITE_TESTCTRL_JSON_SELFCHECK: {
182754 #if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_WSD)
182755 int *pOnOff = va_arg(ap, int*);
182756 if( *pOnOff<0 ){
182757 *pOnOff = sqlite3Config.bJsonSelfcheck;
182758 }else{
182759 sqlite3Config.bJsonSelfcheck = (u8)((*pOnOff)&0xff);
@@ -203415,10 +203461,11 @@
203461 struct JsonParse {
203462 u8 *aBlob; /* JSONB representation of JSON value */
203463 u32 nBlob; /* Bytes of aBlob[] actually used */
203464 u32 nBlobAlloc; /* Bytes allocated to aBlob[]. 0 if aBlob is external */
203465 char *zJson; /* Json text used for parsing */
203466 sqlite3 *db; /* The database connection to which this object belongs */
203467 int nJson; /* Length of the zJson string in bytes */
203468 u32 nJPRef; /* Number of references to this object */
203469 u32 iErr; /* Error location in zJson[] */
203470 u16 iDepth; /* Nesting depth */
203471 u8 nErr; /* Number of errors seen */
@@ -203940,11 +203987,11 @@
203987 pParse->zJson = 0;
203988 pParse->nJson = 0;
203989 pParse->bJsonIsRCStr = 0;
203990 }
203991 if( pParse->nBlobAlloc ){
203992 sqlite3DbFree(pParse->db, pParse->aBlob);
203993 pParse->aBlob = 0;
203994 pParse->nBlob = 0;
203995 pParse->nBlobAlloc = 0;
203996 }
203997 }
@@ -203957,11 +204004,11 @@
204004 if( pParse ){
204005 if( pParse->nJPRef>1 ){
204006 pParse->nJPRef--;
204007 }else{
204008 jsonParseReset(pParse);
204009 sqlite3DbFree(pParse->db, pParse);
204010 }
204011 }
204012 }
204013
204014 /**************************************************************************
@@ -204188,11 +204235,11 @@
204235 t = 100;
204236 }else{
204237 t = pParse->nBlobAlloc*2;
204238 }
204239 if( t<N ) t = N+100;
204240 aNew = sqlite3DbRealloc(pParse->db, pParse->aBlob, t);
204241 if( aNew==0 ){ pParse->oom = 1; return 1; }
204242 pParse->aBlob = aNew;
204243 pParse->nBlobAlloc = t;
204244 return 0;
204245 }
@@ -205113,18 +205160,19 @@
205160 JsonParse px;
205161 memset(&px, 0, sizeof(px));
205162 jsonStringTerminate(pStr);
205163 px.zJson = pStr->zBuf;
205164 px.nJson = pStr->nUsed;
205165 px.db = sqlite3_context_db_handle(pStr->pCtx);
205166 (void)jsonTranslateTextToBlob(&px, 0);
205167 if( px.oom ){
205168 sqlite3DbFree(px.db, px.aBlob);
205169 sqlite3_result_error_nomem(pStr->pCtx);
205170 }else{
205171 assert( px.nBlobAlloc>0 );
205172 assert( !px.bReadOnly );
205173 sqlite3_result_blob(pStr->pCtx, px.aBlob, px.nBlob, SQLITE_DYNAMIC);
205174 }
205175 }
205176
205177 /* The byte at index i is a node type-code. This routine
205178 ** determines the payload size for that node and writes that
@@ -205736,10 +205784,11 @@
205784 const char *zTail /* Tail of the path that determins substructure */
205785 ){
205786 static const u8 emptyObject[] = { JSONB_ARRAY, JSONB_OBJECT };
205787 int rc;
205788 memset(pIns, 0, sizeof(*pIns));
205789 pIns->db = pParse->db;
205790 if( zTail[0]==0 ){
205791 /* No substructure. Just insert what is given in pParse. */
205792 pIns->aBlob = pParse->aIns;
205793 pIns->nBlob = pParse->nIns;
205794 rc = 0;
@@ -205863,10 +205912,11 @@
205912 JsonParse v; /* BLOB encoding of the value to be inserted */
205913 JsonParse ix; /* Header of the label to be inserted */
205914 testcase( pParse->eEdit==JEDIT_INS );
205915 testcase( pParse->eEdit==JEDIT_SET );
205916 memset(&ix, 0, sizeof(ix));
205917 ix.db = pParse->db;
205918 jsonBlobAppendNode(&ix, rawKey?JSONB_TEXTRAW:JSONB_TEXT5, nKey, 0);
205919 pParse->oom |= ix.oom;
205920 rc = jsonCreateEditSubstructure(pParse, &v, &zPath[i]);
205921 if( !JSON_LOOKUP_ISERROR(rc)
205922 && jsonBlobMakeEditable(pParse, ix.nBlob+nKey+v.nBlob)
@@ -206073,11 +206123,11 @@
206123 u32 iIn, iOut;
206124 const char *z;
206125 char *zOut;
206126 u32 nOut = sz;
206127 z = (const char*)&pParse->aBlob[i+n];
206128 zOut = sqlite3DbMallocRaw(db, nOut+1);
206129 if( zOut==0 ) goto returnfromblob_oom;
206130 for(iIn=iOut=0; iIn<sz; iIn++){
206131 char c = z[iIn];
206132 if( c=='\\' ){
206133 u32 v;
@@ -206107,11 +206157,11 @@
206157 zOut[iOut++] = c;
206158 }
206159 } /* end for() */
206160 assert( iOut<=nOut );
206161 zOut[iOut] = 0;
206162 sqlite3_result_text(pCtx, zOut, iOut, SQLITE_DYNAMIC);
206163 break;
206164 }
206165 case JSONB_ARRAY:
206166 case JSONB_OBJECT: {
206167 int flags = textOnly ? 0 : SQLITE_PTR_TO_INT(sqlite3_user_data(pCtx));
@@ -206160,10 +206210,11 @@
206210 JsonParse *pParse
206211 ){
206212 int eType = sqlite3_value_type(pArg);
206213 static u8 aNull[] = { 0x00 };
206214 memset(pParse, 0, sizeof(pParse[0]));
206215 pParse->db = sqlite3_context_db_handle(ctx);
206216 switch( eType ){
206217 default: {
206218 pParse->aBlob = aNull;
206219 pParse->nBlob = 1;
206220 return 0;
@@ -206185,11 +206236,11 @@
206236 if( sqlite3_value_subtype(pArg)==JSON_SUBTYPE ){
206237 pParse->zJson = (char*)zJson;
206238 pParse->nJson = nJson;
206239 if( jsonConvertTextToBlob(pParse, ctx) ){
206240 sqlite3_result_error(ctx, "malformed JSON", -1);
206241 sqlite3DbFree(pParse->db, pParse->aBlob);
206242 memset(pParse, 0, sizeof(pParse[0]));
206243 return 1;
206244 }
206245 }else{
206246 jsonBlobAppendNode(pParse, JSONB_TEXTRAW, nJson, zJson);
@@ -206342,10 +206393,11 @@
206393 u32 flgs
206394 ){
206395 int eType; /* Datatype of pArg */
206396 JsonParse *p = 0; /* Value to be returned */
206397 JsonParse *pFromCache = 0; /* Value taken from cache */
206398 sqlite3 *db; /* The database connection */
206399
206400 assert( ctx!=0 );
206401 eType = sqlite3_value_type(pArg);
206402 if( eType==SQLITE_NULL ){
206403 return 0;
@@ -206355,18 +206407,20 @@
206407 pFromCache->nJPRef++;
206408 if( (flgs & JSON_EDITABLE)==0 ){
206409 return pFromCache;
206410 }
206411 }
206412 db = sqlite3_context_db_handle(ctx);
206413 rebuild_from_cache:
206414 p = sqlite3DbMallocZero(db, sizeof(*p));
206415 if( p==0 ) goto json_pfa_oom;
206416 memset(p, 0, sizeof(*p));
206417 p->db = db;
206418 p->nJPRef = 1;
206419 if( pFromCache!=0 ){
206420 u32 nBlob = pFromCache->nBlob;
206421 p->aBlob = sqlite3DbMallocRaw(db, nBlob);
206422 if( p->aBlob==0 ) goto json_pfa_oom;
206423 memcpy(p->aBlob, pFromCache->aBlob, nBlob);
206424 p->nBlobAlloc = p->nBlob = nBlob;
206425 p->hasNonstd = pFromCache->hasNonstd;
206426 jsonParseFree(pFromCache);
@@ -206618,11 +206672,11 @@
206672 sqlite3StrAccumInit(&out, 0, 0, 0, 1000000);
206673 p = jsonParseFuncArg(ctx, argv[0], 0);
206674 if( p==0 ) return;
206675 if( argc==1 ){
206676 jsonDebugPrintBlob(p, 0, p->nBlob, 0, &out);
206677 sqlite3_result_text64(ctx, out.zText, out.nChar, SQLITE_DYNAMIC, SQLITE_UTF8);
206678 }else{
206679 jsonShowParse(p);
206680 }
206681 jsonParseFree(p);
206682 }
@@ -207437,10 +207491,11 @@
207491 JsonParse s;
207492
207493 assert( argc==1 );
207494 UNUSED_PARAMETER(argc);
207495 memset(&s, 0, sizeof(s));
207496 s.db = sqlite3_context_db_handle(ctx);
207497 if( jsonFuncArgMightBeBinary(argv[0]) ){
207498 s.aBlob = (u8*)sqlite3_value_blob(argv[0]);
207499 s.nBlob = sqlite3_value_bytes(argv[0]);
207500 iErrPos = (i64)jsonbValidityCheck(&s, 0, s.nBlob, 1);
207501 }else{
@@ -207726,34 +207781,34 @@
207781 UNUSED_PARAMETER(pAux);
207782 rc = sqlite3_declare_vtab(db,
207783 "CREATE TABLE x(key,value,type,atom,id,parent,fullkey,path,"
207784 "json HIDDEN,root HIDDEN)");
207785 if( rc==SQLITE_OK ){
207786 pNew = (JsonEachConnection*)sqlite3DbMallocZero(db, sizeof(*pNew));
207787 *ppVtab = (sqlite3_vtab*)pNew;
207788 if( pNew==0 ) return SQLITE_NOMEM;
 
207789 sqlite3_vtab_config(db, SQLITE_VTAB_INNOCUOUS);
207790 pNew->db = db;
207791 }
207792 return rc;
207793 }
207794
207795 /* destructor for json_each virtual table */
207796 static int jsonEachDisconnect(sqlite3_vtab *pVtab){
207797 JsonEachConnection *p = (JsonEachConnection*)pVtab;
207798 sqlite3DbFree(p->db, pVtab);
207799 return SQLITE_OK;
207800 }
207801
207802 /* constructor for a JsonEachCursor object for json_each(). */
207803 static int jsonEachOpenEach(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){
207804 JsonEachConnection *pVtab = (JsonEachConnection*)p;
207805 JsonEachCursor *pCur;
207806
207807 UNUSED_PARAMETER(p);
207808 pCur = sqlite3DbMallocZero(pVtab->db, sizeof(*pCur));
207809 if( pCur==0 ) return SQLITE_NOMEM;
 
207810 pCur->db = pVtab->db;
207811 jsonStringZero(&pCur->path);
207812 *ppCursor = &pCur->base;
207813 return SQLITE_OK;
207814 }
@@ -207786,11 +207841,11 @@
207841 /* Destructor for a jsonEachCursor object */
207842 static int jsonEachClose(sqlite3_vtab_cursor *cur){
207843 JsonEachCursor *p = (JsonEachCursor*)cur;
207844 jsonEachCursorReset(p);
207845
207846 sqlite3DbFree(p->db, cur);
207847 return SQLITE_OK;
207848 }
207849
207850 /* Return TRUE if the jsonEachCursor object has been advanced off the end
207851 ** of the JSON object */
@@ -208120,10 +208175,11 @@
208175 UNUSED_PARAMETER(argc);
208176 jsonEachCursorReset(p);
208177 if( idxNum==0 ) return SQLITE_OK;
208178 memset(&p->sParse, 0, sizeof(p->sParse));
208179 p->sParse.nJPRef = 1;
208180 p->sParse.db = p->db;
208181 if( sqlite3_value_type(argv[0])==SQLITE_BLOB ){
208182 if( jsonFuncArgMightBeBinary(argv[0]) ){
208183 p->sParse.nBlob = sqlite3_value_bytes(argv[0]);
208184 p->sParse.aBlob = (u8*)sqlite3_value_blob(argv[0]);
208185 }else{
@@ -209071,11 +209127,11 @@
209127
209128 /* Check if the requested node is already in the hash table. If so,
209129 ** increase its reference count and return it.
209130 */
209131 if( (pNode = nodeHashLookup(pRtree, iNode))!=0 ){
209132 if( pParent && ALWAYS(pParent!=pNode->pParent) ){
209133 RTREE_IS_CORRUPT(pRtree);
209134 return SQLITE_CORRUPT_VTAB;
209135 }
209136 pNode->nRef++;
209137 *ppNode = pNode;
@@ -211806,11 +211862,11 @@
211862 }else{
211863 rc = SQLITE_NOMEM;
211864 }
211865 sqlite3_free(zSql);
211866 }
211867 if( pRtree->nAux && rc!=SQLITE_NOMEM ){
211868 pRtree->zReadAuxSql = sqlite3_mprintf(
211869 "SELECT * FROM \"%w\".\"%w_rowid\" WHERE rowid=?1",
211870 zDb, zPrefix);
211871 if( pRtree->zReadAuxSql==0 ){
211872 rc = SQLITE_NOMEM;
@@ -212495,19 +212551,17 @@
212551 check.db = db;
212552 check.zDb = zDb;
212553 check.zTab = zTab;
212554
212555 /* Find the number of auxiliary columns */
212556 pStmt = rtreeCheckPrepare(&check, "SELECT * FROM %Q.'%q_rowid'", zDb, zTab);
212557 if( pStmt ){
212558 nAux = sqlite3_column_count(pStmt) - 2;
212559 sqlite3_finalize(pStmt);
212560 }else
212561 if( check.rc!=SQLITE_NOMEM ){
212562 check.rc = SQLITE_OK;
 
 
212563 }
212564
212565 /* Find number of dimensions in the rtree table. */
212566 pStmt = rtreeCheckPrepare(&check, "SELECT * FROM %Q.%Q", zDb, zTab);
212567 if( pStmt ){
@@ -212558,10 +212612,11 @@
212612 UNUSED_PARAMETER(isQuick);
212613 rc = rtreeCheckTable(pRtree->db, pRtree->zDb, pRtree->zName, pzErr);
212614 if( rc==SQLITE_OK && *pzErr ){
212615 *pzErr = sqlite3_mprintf("In RTree %s.%s:\n%z",
212616 pRtree->zDb, pRtree->zName, *pzErr);
212617 if( (*pzErr)==0 ) rc = SQLITE_NOMEM;
212618 }
212619 return rc;
212620 }
212621
212622 /*
@@ -250229,12 +250284,12 @@
250284 static int fts5RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){
250285 Fts5FullTable *pTab = (Fts5FullTable*)pVtab;
250286 int rc = SQLITE_OK;
250287 fts5CheckTransactionState(pTab, FTS5_ROLLBACKTO, iSavepoint);
250288 fts5TripCursors(pTab);
 
250289 if( (iSavepoint+1)<=pTab->iSavepoint ){
250290 pTab->p.pConfig->pgsz = 0;
250291 rc = sqlite3Fts5StorageRollback(pTab->pStorage);
250292 }
250293 return rc;
250294 }
250295
@@ -250435,11 +250490,11 @@
250490 int nArg, /* Number of args */
250491 sqlite3_value **apUnused /* Function arguments */
250492 ){
250493 assert( nArg==0 );
250494 UNUSED_PARAM2(nArg, apUnused);
250495 sqlite3_result_text(pCtx, "fts5: 2024-01-08 19:55:40 cd016f26bb61549a304f2148035e050f76a8f4a35cdb7131bba2f5fc5d09f49e", -1, SQLITE_TRANSIENT);
250496 }
250497
250498 /*
250499 ** Return true if zName is the extension on one of the shadow tables used
250500 ** by this module.
250501
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,11 +146,11 @@
146146
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147147
** [sqlite_version()] and [sqlite_source_id()].
148148
*/
149149
#define SQLITE_VERSION "3.45.0"
150150
#define SQLITE_VERSION_NUMBER 3045000
151
-#define SQLITE_SOURCE_ID "2024-01-01 19:20:00 bcac937526d9a6ef914a74b4d6757fa91cd74edab871bcd934fde4a2f9b6debd"
151
+#define SQLITE_SOURCE_ID "2024-01-09 12:28:51 97709ce2a1f5ae05495e412ca27108048e5b8a63a1e3bca4be13933f7527da7b"
152152
153153
/*
154154
** CAPI3REF: Run-Time Library Version Numbers
155155
** KEYWORDS: sqlite3_version sqlite3_sourceid
156156
**
157157
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,11 +146,11 @@
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.45.0"
150 #define SQLITE_VERSION_NUMBER 3045000
151 #define SQLITE_SOURCE_ID "2024-01-01 19:20:00 bcac937526d9a6ef914a74b4d6757fa91cd74edab871bcd934fde4a2f9b6debd"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
157
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,11 +146,11 @@
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.45.0"
150 #define SQLITE_VERSION_NUMBER 3045000
151 #define SQLITE_SOURCE_ID "2024-01-09 12:28:51 97709ce2a1f5ae05495e412ca27108048e5b8a63a1e3bca4be13933f7527da7b"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
157

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button