sqlite-amalgamation-3370100.zip

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3728 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2022-01-02 16:08:19 +00:00
parent 4268963e70
commit d550092bd3
3 changed files with 75 additions and 52 deletions

80
deps/sqlite/shell.c vendored
View File

@ -19999,16 +19999,8 @@ static int do_meta_command(char *zLine, ShellState *p){
char *zNewFilename = 0; /* Name of the database file to open */ char *zNewFilename = 0; /* Name of the database file to open */
int iName = 1; /* Index in azArg[] of the filename */ int iName = 1; /* Index in azArg[] of the filename */
int newFlag = 0; /* True to delete file before opening */ int newFlag = 0; /* True to delete file before opening */
/* Close the existing database */ int openMode = SHELL_OPEN_UNSPEC;
session_close_all(p, -1);
close_db(p->db);
p->db = 0;
p->pAuxDb->zDbFilename = 0;
sqlite3_free(p->pAuxDb->zFreeOnClose);
p->pAuxDb->zFreeOnClose = 0;
p->openMode = SHELL_OPEN_UNSPEC;
p->openFlags = 0;
p->szMax = 0;
/* Check for command-line arguments */ /* Check for command-line arguments */
for(iName=1; iName<nArg; iName++){ for(iName=1; iName<nArg; iName++){
const char *z = azArg[iName]; const char *z = azArg[iName];
@ -20016,19 +20008,19 @@ static int do_meta_command(char *zLine, ShellState *p){
newFlag = 1; newFlag = 1;
#ifdef SQLITE_HAVE_ZLIB #ifdef SQLITE_HAVE_ZLIB
}else if( optionMatch(z, "zip") ){ }else if( optionMatch(z, "zip") ){
p->openMode = SHELL_OPEN_ZIPFILE; openMode = SHELL_OPEN_ZIPFILE;
#endif #endif
}else if( optionMatch(z, "append") ){ }else if( optionMatch(z, "append") ){
p->openMode = SHELL_OPEN_APPENDVFS; openMode = SHELL_OPEN_APPENDVFS;
}else if( optionMatch(z, "readonly") ){ }else if( optionMatch(z, "readonly") ){
p->openMode = SHELL_OPEN_READONLY; openMode = SHELL_OPEN_READONLY;
}else if( optionMatch(z, "nofollow") ){ }else if( optionMatch(z, "nofollow") ){
p->openFlags |= SQLITE_OPEN_NOFOLLOW; p->openFlags |= SQLITE_OPEN_NOFOLLOW;
#ifndef SQLITE_OMIT_DESERIALIZE #ifndef SQLITE_OMIT_DESERIALIZE
}else if( optionMatch(z, "deserialize") ){ }else if( optionMatch(z, "deserialize") ){
p->openMode = SHELL_OPEN_DESERIALIZE; openMode = SHELL_OPEN_DESERIALIZE;
}else if( optionMatch(z, "hexdb") ){ }else if( optionMatch(z, "hexdb") ){
p->openMode = SHELL_OPEN_HEXDB; openMode = SHELL_OPEN_HEXDB;
}else if( optionMatch(z, "maxsize") && iName+1<nArg ){ }else if( optionMatch(z, "maxsize") && iName+1<nArg ){
p->szMax = integerValue(azArg[++iName]); p->szMax = integerValue(azArg[++iName]);
#endif /* SQLITE_OMIT_DESERIALIZE */ #endif /* SQLITE_OMIT_DESERIALIZE */
@ -20044,6 +20036,18 @@ static int do_meta_command(char *zLine, ShellState *p){
zNewFilename = sqlite3_mprintf("%s", z); zNewFilename = sqlite3_mprintf("%s", z);
} }
} }
/* Close the existing database */
session_close_all(p, -1);
close_db(p->db);
p->db = 0;
p->pAuxDb->zDbFilename = 0;
sqlite3_free(p->pAuxDb->zFreeOnClose);
p->pAuxDb->zFreeOnClose = 0;
p->openMode = openMode;
p->openFlags = 0;
p->szMax = 0;
/* If a filename is specified, try to open it first */ /* If a filename is specified, try to open it first */
if( zNewFilename || p->openMode==SHELL_OPEN_HEXDB ){ if( zNewFilename || p->openMode==SHELL_OPEN_HEXDB ){
if( newFlag && !p->bSafeMode ) shellDeleteFile(zNewFilename); if( newFlag && !p->bSafeMode ) shellDeleteFile(zNewFilename);
@ -21262,30 +21266,31 @@ static int do_meta_command(char *zLine, ShellState *p){
static const struct { static const struct {
const char *zCtrlName; /* Name of a test-control option */ const char *zCtrlName; /* Name of a test-control option */
int ctrlCode; /* Integer code for that option */ int ctrlCode; /* Integer code for that option */
int unSafe; /* Not valid for --safe mode */
const char *zUsage; /* Usage notes */ const char *zUsage; /* Usage notes */
} aCtrl[] = { } aCtrl[] = {
{ "always", SQLITE_TESTCTRL_ALWAYS, "BOOLEAN" }, { "always", SQLITE_TESTCTRL_ALWAYS, 1, "BOOLEAN" },
{ "assert", SQLITE_TESTCTRL_ASSERT, "BOOLEAN" }, { "assert", SQLITE_TESTCTRL_ASSERT, 1, "BOOLEAN" },
/*{ "benign_malloc_hooks",SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS, "" },*/ /*{ "benign_malloc_hooks",SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS,1, "" },*/
/*{ "bitvec_test", SQLITE_TESTCTRL_BITVEC_TEST, "" },*/ /*{ "bitvec_test", SQLITE_TESTCTRL_BITVEC_TEST, 1, "" },*/
{ "byteorder", SQLITE_TESTCTRL_BYTEORDER, "" }, { "byteorder", SQLITE_TESTCTRL_BYTEORDER, 0, "" },
{ "extra_schema_checks",SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS,"BOOLEAN" }, { "extra_schema_checks",SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS,0,"BOOLEAN" },
/*{ "fault_install", SQLITE_TESTCTRL_FAULT_INSTALL, "" },*/ /*{ "fault_install", SQLITE_TESTCTRL_FAULT_INSTALL, 1,"" },*/
{ "imposter", SQLITE_TESTCTRL_IMPOSTER, "SCHEMA ON/OFF ROOTPAGE"}, { "imposter", SQLITE_TESTCTRL_IMPOSTER,1,"SCHEMA ON/OFF ROOTPAGE"},
{ "internal_functions", SQLITE_TESTCTRL_INTERNAL_FUNCTIONS, "" }, { "internal_functions", SQLITE_TESTCTRL_INTERNAL_FUNCTIONS,0,"" },
{ "localtime_fault", SQLITE_TESTCTRL_LOCALTIME_FAULT,"BOOLEAN" }, { "localtime_fault", SQLITE_TESTCTRL_LOCALTIME_FAULT,0,"BOOLEAN" },
{ "never_corrupt", SQLITE_TESTCTRL_NEVER_CORRUPT, "BOOLEAN" }, { "never_corrupt", SQLITE_TESTCTRL_NEVER_CORRUPT,1, "BOOLEAN" },
{ "optimizations", SQLITE_TESTCTRL_OPTIMIZATIONS, "DISABLE-MASK" }, { "optimizations", SQLITE_TESTCTRL_OPTIMIZATIONS,0,"DISABLE-MASK" },
#ifdef YYCOVERAGE #ifdef YYCOVERAGE
{ "parser_coverage", SQLITE_TESTCTRL_PARSER_COVERAGE, "" }, { "parser_coverage", SQLITE_TESTCTRL_PARSER_COVERAGE,0,"" },
#endif #endif
{ "pending_byte", SQLITE_TESTCTRL_PENDING_BYTE, "OFFSET " }, { "pending_byte", SQLITE_TESTCTRL_PENDING_BYTE,0, "OFFSET " },
{ "prng_restore", SQLITE_TESTCTRL_PRNG_RESTORE, "" }, { "prng_restore", SQLITE_TESTCTRL_PRNG_RESTORE,0, "" },
{ "prng_save", SQLITE_TESTCTRL_PRNG_SAVE, "" }, { "prng_save", SQLITE_TESTCTRL_PRNG_SAVE, 0, "" },
{ "prng_seed", SQLITE_TESTCTRL_PRNG_SEED, "SEED ?db?" }, { "prng_seed", SQLITE_TESTCTRL_PRNG_SEED, 0, "SEED ?db?" },
{ "seek_count", SQLITE_TESTCTRL_SEEK_COUNT, "" }, { "seek_count", SQLITE_TESTCTRL_SEEK_COUNT, 0, "" },
{ "sorter_mmap", SQLITE_TESTCTRL_SORTER_MMAP, "NMAX" }, { "sorter_mmap", SQLITE_TESTCTRL_SORTER_MMAP, 0, "NMAX" },
{ "tune", SQLITE_TESTCTRL_TUNE, "ID VALUE" }, { "tune", SQLITE_TESTCTRL_TUNE, 1, "ID VALUE" },
}; };
int testctrl = -1; int testctrl = -1;
int iCtrl = -1; int iCtrl = -1;
@ -21333,6 +21338,11 @@ static int do_meta_command(char *zLine, ShellState *p){
if( testctrl<0 ){ if( testctrl<0 ){
utf8_printf(stderr,"Error: unknown test-control: %s\n" utf8_printf(stderr,"Error: unknown test-control: %s\n"
"Use \".testctrl --help\" for help\n", zCmd); "Use \".testctrl --help\" for help\n", zCmd);
}else if( aCtrl[iCtrl].unSafe && p->bSafeMode ){
utf8_printf(stderr,
"line %d: \".testctrl %s\" may not be used in safe mode\n",
p->lineno, aCtrl[iCtrl].zCtrlName);
exit(1);
}else{ }else{
switch(testctrl){ switch(testctrl){

29
deps/sqlite/sqlite3.c vendored
View File

@ -1,6 +1,6 @@
/****************************************************************************** /******************************************************************************
** This file is an amalgamation of many separate C source files from SQLite ** This file is an amalgamation of many separate C source files from SQLite
** version 3.37.0. By combining all the individual C code files into this ** version 3.37.1. By combining all the individual C code files into this
** single large file, the entire code can be compiled as a single translation ** single large file, the entire code can be compiled as a single translation
** unit. This allows many compilers to do optimizations that would not be ** unit. This allows many compilers to do optimizations that would not be
** possible if the files were compiled separately. Performance improvements ** possible if the files were compiled separately. Performance improvements
@ -452,9 +452,9 @@ extern "C" {
** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()]. ** [sqlite_version()] and [sqlite_source_id()].
*/ */
#define SQLITE_VERSION "3.37.0" #define SQLITE_VERSION "3.37.1"
#define SQLITE_VERSION_NUMBER 3037000 #define SQLITE_VERSION_NUMBER 3037001
#define SQLITE_SOURCE_ID "2021-11-27 14:13:22 bd41822c7424d393a30e92ff6cb254d25c26769889c1499a18a0b9339f5d6c8a" #define SQLITE_SOURCE_ID "2021-12-30 15:30:28 378629bf2ea546f73eee84063c5358439a12f7300e433f18c9e1bddd948dea62"
/* /*
** CAPI3REF: Run-Time Library Version Numbers ** CAPI3REF: Run-Time Library Version Numbers
@ -104085,7 +104085,7 @@ SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr *p){
return ExprHasProperty(p, EP_CanBeNull) || return ExprHasProperty(p, EP_CanBeNull) ||
p->y.pTab==0 || /* Reference to column of index on expression */ p->y.pTab==0 || /* Reference to column of index on expression */
(p->iColumn>=0 (p->iColumn>=0
&& ALWAYS(p->y.pTab->aCol!=0) /* Defense against OOM problems */ && p->y.pTab->aCol!=0 /* Possible due to prior error */
&& p->y.pTab->aCol[p->iColumn].notNull==0); && p->y.pTab->aCol[p->iColumn].notNull==0);
default: default:
return 1; return 1;
@ -126000,6 +126000,7 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(
if( onError==OE_Replace /* IPK rule is REPLACE */ if( onError==OE_Replace /* IPK rule is REPLACE */
&& onError!=overrideError /* Rules for other constraints are different */ && onError!=overrideError /* Rules for other constraints are different */
&& pTab->pIndex /* There exist other constraints */ && pTab->pIndex /* There exist other constraints */
&& !upsertIpkDelay /* IPK check already deferred by UPSERT */
){ ){
ipkTop = sqlite3VdbeAddOp0(v, OP_Goto)+1; ipkTop = sqlite3VdbeAddOp0(v, OP_Goto)+1;
VdbeComment((v, "defer IPK REPLACE until last")); VdbeComment((v, "defer IPK REPLACE until last"));
@ -126408,6 +126409,7 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(
if( ipkTop ){ if( ipkTop ){
sqlite3VdbeGoto(v, ipkTop); sqlite3VdbeGoto(v, ipkTop);
VdbeComment((v, "Do IPK REPLACE")); VdbeComment((v, "Do IPK REPLACE"));
assert( ipkBottom>0 );
sqlite3VdbeJumpHere(v, ipkBottom); sqlite3VdbeJumpHere(v, ipkBottom);
} }
@ -133005,6 +133007,7 @@ static int sqlite3LockAndPrepare(
** reset is considered a permanent error. */ ** reset is considered a permanent error. */
rc = sqlite3Prepare(db, zSql, nBytes, prepFlags, pOld, ppStmt, pzTail); rc = sqlite3Prepare(db, zSql, nBytes, prepFlags, pOld, ppStmt, pzTail);
assert( rc==SQLITE_OK || *ppStmt==0 ); assert( rc==SQLITE_OK || *ppStmt==0 );
if( rc==SQLITE_OK || db->mallocFailed ) break;
}while( rc==SQLITE_ERROR_RETRY }while( rc==SQLITE_ERROR_RETRY
|| (rc==SQLITE_SCHEMA && (sqlite3ResetOneSchema(db,-1), cnt++)==0) ); || (rc==SQLITE_SCHEMA && (sqlite3ResetOneSchema(db,-1), cnt++)==0) );
sqlite3BtreeLeaveAll(db); sqlite3BtreeLeaveAll(db);
@ -169411,6 +169414,8 @@ SQLITE_API int sqlite3_limit(sqlite3 *db, int limitId, int newLimit){
if( newLimit>=0 ){ /* IMP: R-52476-28732 */ if( newLimit>=0 ){ /* IMP: R-52476-28732 */
if( newLimit>aHardLimit[limitId] ){ if( newLimit>aHardLimit[limitId] ){
newLimit = aHardLimit[limitId]; /* IMP: R-51463-25634 */ newLimit = aHardLimit[limitId]; /* IMP: R-51463-25634 */
}else if( newLimit<1 && limitId==SQLITE_LIMIT_LENGTH ){
newLimit = 1;
} }
db->aLimit[limitId] = newLimit; db->aLimit[limitId] = newLimit;
} }
@ -170814,13 +170819,17 @@ SQLITE_API int sqlite3_test_control(int op, ...){
*/ */
case SQLITE_TESTCTRL_IMPOSTER: { case SQLITE_TESTCTRL_IMPOSTER: {
sqlite3 *db = va_arg(ap, sqlite3*); sqlite3 *db = va_arg(ap, sqlite3*);
int iDb;
sqlite3_mutex_enter(db->mutex); sqlite3_mutex_enter(db->mutex);
db->init.iDb = sqlite3FindDbName(db, va_arg(ap,const char*)); iDb = sqlite3FindDbName(db, va_arg(ap,const char*));
if( iDb>=0 ){
db->init.iDb = iDb;
db->init.busy = db->init.imposterTable = va_arg(ap,int); db->init.busy = db->init.imposterTable = va_arg(ap,int);
db->init.newTnum = va_arg(ap,int); db->init.newTnum = va_arg(ap,int);
if( db->init.busy==0 && db->init.newTnum>0 ){ if( db->init.busy==0 && db->init.newTnum>0 ){
sqlite3ResetAllSchemasOfConnection(db); sqlite3ResetAllSchemasOfConnection(db);
} }
}
sqlite3_mutex_leave(db->mutex); sqlite3_mutex_leave(db->mutex);
break; break;
} }
@ -177073,7 +177082,7 @@ SQLITE_PRIVATE void sqlite3Fts3DoclistPrev(
assert( nDoclist>0 ); assert( nDoclist>0 );
assert( *pbEof==0 ); assert( *pbEof==0 );
assert( p || *piDocid==0 ); assert_fts3_nc( p || *piDocid==0 );
assert( !p || (p>aDoclist && p<&aDoclist[nDoclist]) ); assert( !p || (p>aDoclist && p<&aDoclist[nDoclist]) );
if( p==0 ){ if( p==0 ){
@ -224759,10 +224768,14 @@ static void fts5SegIterReverseNewPage(Fts5Index *p, Fts5SegIter *pIter){
int iRowidOff; int iRowidOff;
iRowidOff = fts5LeafFirstRowidOff(pNew); iRowidOff = fts5LeafFirstRowidOff(pNew);
if( iRowidOff ){ if( iRowidOff ){
if( iRowidOff>=pNew->szLeaf ){
p->rc = FTS5_CORRUPT;
}else{
pIter->pLeaf = pNew; pIter->pLeaf = pNew;
pIter->iLeafOffset = iRowidOff; pIter->iLeafOffset = iRowidOff;
} }
} }
}
if( pIter->pLeaf ){ if( pIter->pLeaf ){
u8 *a = &pIter->pLeaf->p[pIter->iLeafOffset]; u8 *a = &pIter->pLeaf->p[pIter->iLeafOffset];
@ -232489,7 +232502,7 @@ static void fts5SourceIdFunc(
){ ){
assert( nArg==0 ); assert( nArg==0 );
UNUSED_PARAM2(nArg, apUnused); UNUSED_PARAM2(nArg, apUnused);
sqlite3_result_text(pCtx, "fts5: 2021-11-27 14:13:22 bd41822c7424d393a30e92ff6cb254d25c26769889c1499a18a0b9339f5d6c8a", -1, SQLITE_TRANSIENT); sqlite3_result_text(pCtx, "fts5: 2021-12-30 15:30:28 378629bf2ea546f73eee84063c5358439a12f7300e433f18c9e1bddd948dea62", -1, SQLITE_TRANSIENT);
} }
/* /*

View File

@ -146,9 +146,9 @@ extern "C" {
** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()]. ** [sqlite_version()] and [sqlite_source_id()].
*/ */
#define SQLITE_VERSION "3.37.0" #define SQLITE_VERSION "3.37.1"
#define SQLITE_VERSION_NUMBER 3037000 #define SQLITE_VERSION_NUMBER 3037001
#define SQLITE_SOURCE_ID "2021-11-27 14:13:22 bd41822c7424d393a30e92ff6cb254d25c26769889c1499a18a0b9339f5d6c8a" #define SQLITE_SOURCE_ID "2021-12-30 15:30:28 378629bf2ea546f73eee84063c5358439a12f7300e433f18c9e1bddd948dea62"
/* /*
** CAPI3REF: Run-Time Library Version Numbers ** CAPI3REF: Run-Time Library Version Numbers