From d557e6b81c13956e9cb420b5574be47450989c77 Mon Sep 17 00:00:00 2001 From: utelle Date: Tue, 26 Nov 2024 22:18:10 +0100 Subject: [PATCH] Prepare release of version 1.9.1 - Based on SQLite version 3.47.1 - Remove need to specify AES hw compile time options --- CHANGELOG.md | 10 +- Makefile.am | 10 +- configure.ac | 2 +- premake5.lua | 12 +- readme.md | 7 +- src/rekeyvacuum.c | 2 +- src/series.c | 16 +- src/shell.c | 841 ++++++++++++++++++++-------------------- src/sqlite3.c | 118 ++++-- src/sqlite3.h | 15 +- src/sqlite3mc_version.h | 4 +- src/sqlite3patched.c | 120 ++++-- src/tclsqlite.c | 25 +- 13 files changed, 655 insertions(+), 527 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a304d0b..2ec4286 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.9.1] - 2024-11-26 + +### Changed + +- Based on SQLite version 3.47.1 +- Remove need to specify AES hw compile time options + ## [1.9.0] - 2024-10-22 ### Changed @@ -533,7 +540,8 @@ The following ciphers are supported: - AES 256 Bit CBC - SHA1/SHA256/SHA512 HMAC ([SQLCipher](https://www.zetetic.net/sqlcipher/), database versions 1, 2, 3, and 4) - RC4 - No HMAC ([System.Data.SQLite](http://system.data.sqlite.org)) -[Unreleased]: ../../compare/v1.9.0...HEAD +[Unreleased]: ../../compare/v1.9.1...HEAD +[1.9.1]: ../../compare/v1.8.7...v1.9.1 [1.9.0]: ../../compare/v1.8.7...v1.9.0 [1.8.7]: ../../compare/v1.8.6...v1.8.7 [1.8.6]: ../../compare/v1.8.5...v1.8.6 diff --git a/Makefile.am b/Makefile.am index ff4fd82..b558b1c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,14 +1,14 @@ # Process this file with automake to create Makefile.in for sqlite3mc library # -# Copyright (C) 2019-2023 Ulrich Telle +# Copyright (C) 2019-2024 Ulrich Telle # # This file is covered by the same licence as the entire SQLite3 Multiple Ciphers package. -if HOST_X86 -X86_FLAGS = -msse4.2 -maes -else +#if HOST_X86 +#X86_FLAGS = -msse4.2 -maes +#else X86_FLAGS = -endif +#endif if HOST_ARM #ARM_FLAGS = -march=native diff --git a/configure.ac b/configure.ac index 5739796..7afcc30 100644 --- a/configure.ac +++ b/configure.ac @@ -4,7 +4,7 @@ dnl Copyright (C) 2019-2024 Ulrich Telle dnl dnl This file is covered by the same licence as the entire SQLite3 Multiple Ciphers package. -AC_INIT([sqlite3mc], [1.9.0], [ulrich@telle-online.de]) +AC_INIT([sqlite3mc], [1.9.1], [ulrich@telle-online.de]) dnl This is the version tested with, might work with earlier ones. AC_PREREQ([2.69]) diff --git a/premake5.lua b/premake5.lua index 2c27a68..a82e7c8 100644 --- a/premake5.lua +++ b/premake5.lua @@ -39,7 +39,7 @@ project "sqlite3mc_lib" end else toolset("gcc") - buildoptions { "-msse4.2", "-maes" } +-- buildoptions { "-msse4.2", "-maes" } -- buildoptions { "-march=native" } end makesettings { "include config.gcc" } @@ -135,7 +135,7 @@ project "sqlite3mc_dll" end else toolset("gcc") - buildoptions { "-msse4.2", "-maes" } +-- buildoptions { "-msse4.2", "-maes" } -- buildoptions { "-march=native" } end makesettings { "include config.gcc" } @@ -227,7 +227,7 @@ project "sqlite3mc_shell" end else toolset("gcc") - buildoptions { "-msse4.2", "-maes" } +-- buildoptions { "-msse4.2", "-maes" } -- buildoptions { "-march=native" } end makesettings { "include config.gcc" } @@ -286,7 +286,7 @@ project "sqlite3mc_libicu" end else toolset("gcc") - buildoptions { "-msse4.2", "-maes" } +-- buildoptions { "-msse4.2", "-maes" } -- buildoptions { "-march=native" } end makesettings { "include config.gcc" } @@ -383,7 +383,7 @@ project "sqlite3mc_dllicu" end else toolset("gcc") - buildoptions { "-msse4.2", "-maes" } +-- buildoptions { "-msse4.2", "-maes" } -- buildoptions { "-march=native" } end makesettings { "include config.gcc" } @@ -488,7 +488,7 @@ project "sqlite3mc_shellicu" end else toolset("gcc") - buildoptions { "-msse4.2", "-maes" } +-- buildoptions { "-msse4.2", "-maes" } -- buildoptions { "-march=native" } end makesettings { "include config.gcc" } diff --git a/readme.md b/readme.md index e525ad0..f74fd60 100644 --- a/readme.md +++ b/readme.md @@ -10,10 +10,9 @@ The code was mainly developed under Windows, but was tested under Linux as well. ## Version information -* 1.9.0 - *October 2024* - - Based on SQLite version 3.47.0 - - Changed signature of cipher scheme method `GenerateKey` (affects only developers of dynamic cipher schemes) - - Using differing KDF and HMAC algorithms resulted in databases incompatible with the original SQLCipher library. Setting the parameter `hmac_algorithm_compat` to 0 restores the (incompatible) behaviour. +* 1.9.1 - *November 2024* + - Based on SQLite version 3.47.1 + - Remove need to specify AES hw compile time options For further version information please consult the [CHANGELOG](CHANGELOG.md). diff --git a/src/rekeyvacuum.c b/src/rekeyvacuum.c index 557f146..698f64c 100644 --- a/src/rekeyvacuum.c +++ b/src/rekeyvacuum.c @@ -27,7 +27,7 @@ ** Change 4: Call sqlite3mcBtreeSetPageSize instead of sqlite3BtreeSetPageSize for main database ** (sqlite3mcBtreeSetPageSize allows to reduce the number of reserved bytes) ** -** This code is generated by the script rekeyvacuum.sh from SQLite version 3.47.0 amalgamation. +** This code is generated by the script rekeyvacuum.sh from SQLite version 3.47.1 amalgamation. */ SQLITE_PRIVATE SQLITE_NOINLINE int sqlite3mcRunVacuumForRekey( char **pzErrMsg, /* Write error message here */ diff --git a/src/series.c b/src/series.c index e0810fa..aff9796 100644 --- a/src/series.c +++ b/src/series.c @@ -659,7 +659,7 @@ static int seriesBestIndex( continue; } if( pConstraint->iColumniColumn==SERIES_COLUMN_VALUE ){ + if( pConstraint->iColumn==SERIES_COLUMN_VALUE && pConstraint->usable ){ switch( op ){ case SQLITE_INDEX_CONSTRAINT_EQ: case SQLITE_INDEX_CONSTRAINT_IS: { @@ -667,7 +667,9 @@ static int seriesBestIndex( idxNum &= ~0x3300; aIdx[5] = i; aIdx[6] = -1; +#ifndef ZERO_ARGUMENT_GENERATE_SERIES bStartSeen = 1; +#endif break; } case SQLITE_INDEX_CONSTRAINT_GE: { @@ -675,7 +677,9 @@ static int seriesBestIndex( idxNum |= 0x0100; idxNum &= ~0x0200; aIdx[5] = i; +#ifndef ZERO_ARGUMENT_GENERATE_SERIES bStartSeen = 1; +#endif break; } case SQLITE_INDEX_CONSTRAINT_GT: { @@ -683,7 +687,9 @@ static int seriesBestIndex( idxNum |= 0x0200; idxNum &= ~0x0100; aIdx[5] = i; +#ifndef ZERO_ARGUMENT_GENERATE_SERIES bStartSeen = 1; +#endif break; } case SQLITE_INDEX_CONSTRAINT_LE: { @@ -751,7 +757,7 @@ static int seriesBestIndex( return SQLITE_CONSTRAINT; } if( (idxNum & 0x03)==0x03 ){ - /* Both start= and stop= boundaries are available. This is the + /* Both start= and stop= boundaries are available. This is the ** the preferred case */ pIdxInfo->estimatedCost = (double)(2 - ((idxNum&4)!=0)); pIdxInfo->estimatedRows = 1000; @@ -780,7 +786,7 @@ static int seriesBestIndex( } /* -** This following structure defines all the methods for the +** This following structure defines all the methods for the ** generate_series virtual table. */ static sqlite3_module seriesModule = { @@ -817,8 +823,8 @@ static sqlite3_module seriesModule = { __declspec(dllexport) #endif int sqlite3_series_init( - sqlite3 *db, - char **pzErrMsg, + sqlite3 *db, + char **pzErrMsg, const sqlite3_api_routines *pApi ){ int rc = SQLITE_OK; diff --git a/src/shell.c b/src/shell.c index 3a2c444..dc6536f 100644 --- a/src/shell.c +++ b/src/shell.c @@ -274,7 +274,7 @@ extern LPWSTR sqlite3_win32_utf8_to_unicode(const char *zText); ** ************************************************************************* ** -** This header file contains definitions of interfaces that provide +** This header file contains definitions of interfaces that provide ** cross-platform I/O for UTF-8 content. ** ** On most platforms, the interfaces definitions in this file are @@ -418,8 +418,8 @@ FILE *sqlite3_fopen(const char *zFilename, const char *zMode){ sz1 = (int)strlen(zFilename); sz2 = (int)strlen(zMode); - b1 = sqlite3_malloc( (sz1+1)*sizeof(b1[0]) ); - b2 = sqlite3_malloc( (sz2+1)*sizeof(b1[0]) ); + b1 = malloc( (sz1+1)*sizeof(b1[0]) ); + b2 = malloc( (sz2+1)*sizeof(b1[0]) ); if( b1 && b2 ){ sz1 = MultiByteToWideChar(CP_UTF8, 0, zFilename, sz1, b1, sz1); b1[sz1] = 0; @@ -427,8 +427,8 @@ FILE *sqlite3_fopen(const char *zFilename, const char *zMode){ b2[sz2] = 0; fp = _wfopen(b1, b2); } - sqlite3_free(b1); - sqlite3_free(b2); + free(b1); + free(b2); simBinaryOther = 0; return fp; } @@ -444,8 +444,8 @@ FILE *sqlite3_popen(const char *zCommand, const char *zMode){ sz1 = (int)strlen(zCommand); sz2 = (int)strlen(zMode); - b1 = sqlite3_malloc( (sz1+1)*sizeof(b1[0]) ); - b2 = sqlite3_malloc( (sz2+1)*sizeof(b1[0]) ); + b1 = malloc( (sz1+1)*sizeof(b1[0]) ); + b2 = malloc( (sz2+1)*sizeof(b1[0]) ); if( b1 && b2 ){ sz1 = MultiByteToWideChar(CP_UTF8, 0, zCommand, sz1, b1, sz1); b1[sz1] = 0; @@ -453,8 +453,8 @@ FILE *sqlite3_popen(const char *zCommand, const char *zMode){ b2[sz2] = 0; fp = _wpopen(b1, b2); } - sqlite3_free(b1); - sqlite3_free(b2); + free(b1); + free(b2); return fp; } @@ -2084,7 +2084,7 @@ static FILE *memtraceOut; /* Methods that trace memory allocations */ static void *memtraceMalloc(int n){ if( memtraceOut ){ - fprintf(memtraceOut, "MEMTRACE: allocate %d bytes\n", + fprintf(memtraceOut, "MEMTRACE: allocate %d bytes\n", memtraceBase.xRoundup(n)); } return memtraceBase.xMalloc(n); @@ -2914,7 +2914,7 @@ static unsigned char *SHA3Final(SHA3Context *p){ ** Implementation of the sha3(X,SIZE) function. ** ** Return a BLOB which is the SIZE-bit SHA3 hash of X. The default -** size is 256. If X is a BLOB, it is hashed as is. +** size is 256. If X is a BLOB, it is hashed as is. ** For all other non-NULL types of input, X is converted into a UTF-8 string ** and the string is hashed without the trailing 0x00 terminator. The hash ** of a NULL value is NULL. @@ -3594,16 +3594,16 @@ int sqlite3_sha_init( static int one = 1; SQLITE_EXTENSION_INIT2(pApi); (void)pzErrMsg; /* Unused parameter */ - rc = sqlite3_create_function(db, "sha1", 1, + rc = sqlite3_create_function(db, "sha1", 1, SQLITE_UTF8 | SQLITE_INNOCUOUS | SQLITE_DETERMINISTIC, 0, sha1Func, 0, 0); if( rc==SQLITE_OK ){ - rc = sqlite3_create_function(db, "sha1b", 1, + rc = sqlite3_create_function(db, "sha1b", 1, SQLITE_UTF8 | SQLITE_INNOCUOUS | SQLITE_DETERMINISTIC, (void*)&one, sha1Func, 0, 0); } if( rc==SQLITE_OK ){ - rc = sqlite3_create_function(db, "sha1_query", 1, + rc = sqlite3_create_function(db, "sha1_query", 1, SQLITE_UTF8|SQLITE_DIRECTONLY, 0, sha1QueryFunc, 0, 0); } @@ -3696,8 +3696,8 @@ static int uintCollFunc( #endif int sqlite3_uint_init( - sqlite3 *db, - char **pzErrMsg, + sqlite3 *db, + char **pzErrMsg, const sqlite3_api_routines *pApi ){ SQLITE_EXTENSION_INIT2(pApi); @@ -3833,7 +3833,7 @@ static Decimal *decimalNewFromText(const char *zIn, int n){ p->nFrac = 0; } } - if( iExp>0 ){ + if( iExp>0 ){ p->a = sqlite3_realloc64(p->a, p->nDigit + iExp + 1 ); if( p->a==0 ) goto new_from_text_failed; memset(p->a+p->nDigit, 0, iExp); @@ -4227,7 +4227,7 @@ static void decimalMul(Decimal *pA, Decimal *pB){ int minFrac; if( pA==0 || pA->oom || pA->isNull - || pB==0 || pB->oom || pB->isNull + || pB==0 || pB->oom || pB->isNull ){ goto mul_end; } @@ -4513,7 +4513,7 @@ static void decimalMulFunc( Decimal *pB = decimal_new(context, argv[1], 1); UNUSED_PARAMETER(argc); if( pA==0 || pA->oom || pA->isNull - || pB==0 || pB->oom || pB->isNull + || pB==0 || pB->oom || pB->isNull ){ goto mul_end; } @@ -4550,8 +4550,8 @@ static void decimalPow2Func( #endif int sqlite3_decimal_init( - sqlite3 *db, - char **pzErrMsg, + sqlite3 *db, + char **pzErrMsg, const sqlite3_api_routines *pApi ){ int rc = SQLITE_OK; @@ -4936,7 +4936,7 @@ static void percentSort(double *a, unsigned int n){ int iGt; /* Entries at or after a[iGt] are greater than rPivot */ int i; /* Loop counter */ double rPivot; /* The pivot value */ - + assert( n>=2 ); if( a[0]>a[n-1] ){ SWAP_DOUBLE(a[0],a[n-1]) @@ -4968,7 +4968,7 @@ static void percentSort(double *a, unsigned int n){ }while( i=2 ) percentSort(a, iLt); if( n-iGt>=2 ) percentSort(a+iGt, n-iGt); - + /* Uncomment for testing */ #if 0 for(i=0; iiColumniColumn==SERIES_COLUMN_VALUE ){ + if( pConstraint->iColumn==SERIES_COLUMN_VALUE && pConstraint->usable ){ switch( op ){ case SQLITE_INDEX_CONSTRAINT_EQ: case SQLITE_INDEX_CONSTRAINT_IS: { @@ -6849,7 +6849,9 @@ static int seriesBestIndex( idxNum &= ~0x3300; aIdx[5] = i; aIdx[6] = -1; +#ifndef ZERO_ARGUMENT_GENERATE_SERIES bStartSeen = 1; +#endif break; } case SQLITE_INDEX_CONSTRAINT_GE: { @@ -6857,7 +6859,9 @@ static int seriesBestIndex( idxNum |= 0x0100; idxNum &= ~0x0200; aIdx[5] = i; +#ifndef ZERO_ARGUMENT_GENERATE_SERIES bStartSeen = 1; +#endif break; } case SQLITE_INDEX_CONSTRAINT_GT: { @@ -6865,7 +6869,9 @@ static int seriesBestIndex( idxNum |= 0x0200; idxNum &= ~0x0100; aIdx[5] = i; +#ifndef ZERO_ARGUMENT_GENERATE_SERIES bStartSeen = 1; +#endif break; } case SQLITE_INDEX_CONSTRAINT_LE: { @@ -6933,7 +6939,7 @@ static int seriesBestIndex( return SQLITE_CONSTRAINT; } if( (idxNum & 0x03)==0x03 ){ - /* Both start= and stop= boundaries are available. This is the + /* Both start= and stop= boundaries are available. This is the ** the preferred case */ pIdxInfo->estimatedCost = (double)(2 - ((idxNum&4)!=0)); pIdxInfo->estimatedRows = 1000; @@ -6962,7 +6968,7 @@ static int seriesBestIndex( } /* -** This following structure defines all the methods for the +** This following structure defines all the methods for the ** generate_series virtual table. */ static sqlite3_module seriesModule = { @@ -6999,8 +7005,8 @@ static sqlite3_module seriesModule = { #endif int sqlite3_series_init( - sqlite3 *db, - char **pzErrMsg, + sqlite3 *db, + char **pzErrMsg, const sqlite3_api_routines *pApi ){ int rc = SQLITE_OK; @@ -7189,7 +7195,7 @@ static void re_add_state(ReStateSet *pSet, int newState){ /* Extract the next unicode character from *pzIn and return it. Advance ** *pzIn to the first byte past the end of the character returned. To -** be clear: this routine converts utf8 to unicode. This routine is +** be clear: this routine converts utf8 to unicode. This routine is ** optimized for the common case where the next character is a single byte. */ static unsigned re_next_char(ReInput *p){ @@ -7260,7 +7266,7 @@ static int re_match(ReCompiled *pRe, const unsigned char *zIn, int nIn){ /* Look for the initial prefix match, if there is one. */ if( pRe->nInit ){ unsigned char x = pRe->zInit[0]; - while( in.i+pRe->nInit<=in.mx + while( in.i+pRe->nInit<=in.mx && (zIn[in.i]!=x || strncmp((const char*)zIn+in.i, (const char*)pRe->zInit, pRe->nInit)!=0) ){ @@ -7730,7 +7736,7 @@ static const char *re_compile(ReCompiled **ppRe, const char *zIn, int noCase){ /* The following is a performance optimization. If the regex begins with ** ".*" (if the input regex lacks an initial "^") and afterwards there are ** one or more matching characters, enter those matching characters into - ** zInit[]. The re_match() routine can then search ahead in the input + ** zInit[]. The re_match() routine can then search ahead in the input ** string looking for the initial match without having to run the whole ** regex engine over the string. Do not worry about trying to match ** unicode characters beyond plane 0 - those are very rare and this is @@ -7873,14 +7879,14 @@ static void re_bytecode_func( #endif int sqlite3_regexp_init( - sqlite3 *db, - char **pzErrMsg, + sqlite3 *db, + char **pzErrMsg, const sqlite3_api_routines *pApi ){ int rc = SQLITE_OK; SQLITE_EXTENSION_INIT2(pApi); (void)pzErrMsg; /* Unused */ - rc = sqlite3_create_function(db, "regexp", 2, + rc = sqlite3_create_function(db, "regexp", 2, SQLITE_UTF8|SQLITE_INNOCUOUS|SQLITE_DETERMINISTIC, 0, re_sql_func, 0, 0); if( rc==SQLITE_OK ){ @@ -7974,8 +7980,8 @@ int sqlite3_regexp_init( ** directory, NULL. ** ** If a non-NULL value is specified for the optional $dir parameter and -** $path is a relative path, then $path is interpreted relative to $dir. -** And the paths returned in the "name" column of the table are also +** $path is a relative path, then $path is interpreted relative to $dir. +** And the paths returned in the "name" column of the table are also ** relative to directory $dir. ** ** Notes on building this extension for Windows: @@ -8037,7 +8043,7 @@ SQLITE_EXTENSION_INIT1 /* -** Set the result stored by context ctx to a blob containing the +** Set the result stored by context ctx to a blob containing the ** contents of file zName. Or, leave the result unchanged (NULL) ** if the file does not exist or is unreadable. ** @@ -8270,7 +8276,7 @@ static int makeDirectory( } /* -** This function does the work for the writefile() UDF. Refer to +** This function does the work for the writefile() UDF. Refer to ** header comments at the top of this file for details. */ static int writeFile( @@ -8372,10 +8378,10 @@ static int writeFile( return 1; } #else - /* Legacy unix. + /* Legacy unix. ** ** Do not use utimes() on a symbolic link - it sees through the link and - ** modifies the timestamps on the target. Or fails if the target does + ** modifies the timestamps on the target. Or fails if the target does ** not exist. */ if( 0==S_ISLNK(mode) ){ struct timeval times[2]; @@ -8393,7 +8399,7 @@ static int writeFile( } /* -** Implementation of the "writefile(W,X[,Y[,Z]]])" SQL function. +** Implementation of the "writefile(W,X[,Y[,Z]]])" SQL function. ** Refer to header comments at the top of this file for details. */ static void writefileFunc( @@ -8407,7 +8413,7 @@ static void writefileFunc( sqlite3_int64 mtime = -1; if( argc<2 || argc>4 ){ - sqlite3_result_error(context, + sqlite3_result_error(context, "wrong number of arguments to function writefile()", -1 ); return; @@ -8477,7 +8483,7 @@ static void lsModeFunc( #ifndef SQLITE_OMIT_VIRTUALTABLE -/* +/* ** Cursor type for recursively iterating through a directory structure. */ typedef struct fsdir_cursor fsdir_cursor; @@ -8625,7 +8631,7 @@ static int fsdirNext(sqlite3_vtab_cursor *cur){ } pCur->iLvl = iNew; pLvl = &pCur->aLvl[iNew]; - + pLvl->zDir = pCur->zPath; pCur->zPath = 0; pLvl->pDir = opendir(pLvl->zDir); @@ -8756,7 +8762,7 @@ static int fsdirEof(sqlite3_vtab_cursor *cur){ ** idxNum==2 Both PATH and DIR supplied */ static int fsdirFilter( - sqlite3_vtab_cursor *cur, + sqlite3_vtab_cursor *cur, int idxNum, const char *idxStr, int argc, sqlite3_value **argv ){ @@ -8845,7 +8851,7 @@ static int fsdirBestIndex( } break; } - } + } } if( seenPath || seenDir ){ /* If input parameters are unusable, disallow this plan */ @@ -8917,14 +8923,14 @@ static int fsdirRegister(sqlite3 *db){ #endif int sqlite3_fileio_init( - sqlite3 *db, - char **pzErrMsg, + sqlite3 *db, + char **pzErrMsg, const sqlite3_api_routines *pApi ){ int rc = SQLITE_OK; SQLITE_EXTENSION_INIT2(pApi); (void)pzErrMsg; /* Unused parameter */ - rc = sqlite3_create_function(db, "readfile", 1, + rc = sqlite3_create_function(db, "readfile", 1, SQLITE_UTF8|SQLITE_DIRECTONLY, 0, readfileFunc, 0, 0); if( rc==SQLITE_OK ){ @@ -9301,11 +9307,11 @@ static int completionEof(sqlite3_vtab_cursor *cur){ /* ** This method is called to "rewind" the completion_cursor object back ** to the first row of output. This method is always called at least -** once prior to any call to completionColumn() or completionRowid() or +** once prior to any call to completionColumn() or completionRowid() or ** completionEof(). */ static int completionFilter( - sqlite3_vtab_cursor *pVtabCursor, + sqlite3_vtab_cursor *pVtabCursor, int idxNum, const char *idxStr, int argc, sqlite3_value **argv ){ @@ -9397,7 +9403,7 @@ static int completionBestIndex( } /* -** This following structure defines all the methods for the +** This following structure defines all the methods for the ** completion virtual table. */ static sqlite3_module completionModule = { @@ -9442,8 +9448,8 @@ int sqlite3CompletionVtabInit(sqlite3 *db){ #endif int sqlite3_completion_init( - sqlite3 *db, - char **pzErrMsg, + sqlite3 *db, + char **pzErrMsg, const sqlite3_api_routines *pApi ){ int rc = SQLITE_OK; @@ -9639,7 +9645,7 @@ static sqlite3_vfs apnd_vfs = { 1024, /* mxPathname */ 0, /* pNext */ "apndvfs", /* zName */ - 0, /* pAppData (set when registered) */ + 0, /* pAppData (set when registered) */ apndOpen, /* xOpen */ apndDelete, /* xDelete */ apndAccess, /* xAccess */ @@ -9692,9 +9698,9 @@ static int apndClose(sqlite3_file *pFile){ ** Read data from an apnd-file. */ static int apndRead( - sqlite3_file *pFile, - void *zBuf, - int iAmt, + sqlite3_file *pFile, + void *zBuf, + int iAmt, sqlite_int64 iOfst ){ ApndFile *paf = (ApndFile *)pFile; @@ -9999,7 +10005,7 @@ static int apndOpen( } if( apndIsOrdinaryDatabaseFile(sz, pBaseFile) ){ /* The file being opened appears to be just an ordinary DB. Copy - ** the base dispatch-table so this instance mimics the base VFS. + ** the base dispatch-table so this instance mimics the base VFS. */ memmove(pApndFile, pBaseFile, pBaseVfs->szOsFile); return SQLITE_OK; @@ -10014,7 +10020,7 @@ static int apndOpen( rc = SQLITE_CANTOPEN; pFile->pMethods = 0; }else{ - /* Round newly added appendvfs location to #define'd page boundary. + /* Round newly added appendvfs location to #define'd page boundary. ** Note that nothing has yet been written to the underlying file. ** The append mark will be written along with first content write. ** Until then, paf->iMark value indicates it is not yet written. @@ -10038,17 +10044,17 @@ static int apndDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){ ** All other VFS methods are pass-thrus. */ static int apndAccess( - sqlite3_vfs *pVfs, - const char *zPath, - int flags, + sqlite3_vfs *pVfs, + const char *zPath, + int flags, int *pResOut ){ return ORIGVFS(pVfs)->xAccess(ORIGVFS(pVfs), zPath, flags, pResOut); } static int apndFullPathname( - sqlite3_vfs *pVfs, - const char *zPath, - int nOut, + sqlite3_vfs *pVfs, + const char *zPath, + int nOut, char *zOut ){ return ORIGVFS(pVfs)->xFullPathname(ORIGVFS(pVfs),zPath,nOut,zOut); @@ -10097,17 +10103,17 @@ static const char *apndNextSystemCall(sqlite3_vfs *pVfs, const char *zName){ return ORIGVFS(pVfs)->xNextSystemCall(ORIGVFS(pVfs), zName); } - + #ifdef _WIN32 #endif -/* +/* ** This routine is called when the extension is loaded. ** Register the new VFS. */ int sqlite3_appendvfs_init( - sqlite3 *db, - char **pzErrMsg, + sqlite3 *db, + char **pzErrMsg, const sqlite3_api_routines *pApi ){ int rc = SQLITE_OK; @@ -10222,10 +10228,10 @@ SQLITE_EXTENSION_INIT1 /* ** Definitions for mode bitmasks S_IFDIR, S_IFREG and S_IFLNK. ** -** In some ways it would be better to obtain these values from system +** In some ways it would be better to obtain these values from system ** header files. But, the dependency is undesirable and (a) these ** have been stable for decades, (b) the values are part of POSIX and -** are also made explicit in [man stat], and (c) are part of the +** are also made explicit in [man stat], and (c) are part of the ** file format for zip archives. */ #ifndef S_IFDIR @@ -10238,7 +10244,7 @@ SQLITE_EXTENSION_INIT1 # define S_IFLNK 0120000 #endif -static const char ZIPFILE_SCHEMA[] = +static const char ZIPFILE_SCHEMA[] = "CREATE TABLE y(" "name PRIMARY KEY," /* 0: Name of file in zip archive */ "mode," /* 1: POSIX mode for file */ @@ -10259,8 +10265,8 @@ static const char ZIPFILE_SCHEMA[] = ** ** ZIPFILE_NEWENTRY_MADEBY: ** Use this value for the "version-made-by" field in new zip file -** entries. The upper byte indicates "unix", and the lower byte -** indicates that the zip file matches pkzip specification 3.0. +** entries. The upper byte indicates "unix", and the lower byte +** indicates that the zip file matches pkzip specification 3.0. ** This is what info-zip seems to do. ** ** ZIPFILE_NEWENTRY_REQUIRED: @@ -10289,7 +10295,7 @@ static const char ZIPFILE_SCHEMA[] = #define ZIPFILE_SIGNATURE_EOCD 0x06054b50 /* -** The sizes of the fixed-size part of each of the three main data +** The sizes of the fixed-size part of each of the three main data ** structures in a zip archive. */ #define ZIPFILE_LFH_FIXED_SZ 30 @@ -10382,7 +10388,7 @@ struct ZipfileCDS { *** uncompressed size 4 bytes *** file name length 2 bytes *** extra field length 2 bytes -*** +*** */ typedef struct ZipfileLFH ZipfileLFH; struct ZipfileLFH { @@ -10408,7 +10414,7 @@ struct ZipfileEntry { ZipfileEntry *pNext; /* Next element in in-memory CDS */ }; -/* +/* ** Cursor type for zipfile tables. */ typedef struct ZipfileCsr ZipfileCsr; @@ -10481,7 +10487,7 @@ static void zipfileDequote(char *zIn){ /* ** Construct a new ZipfileTab virtual table object. -** +** ** argv[0] -> module name ("zipfile") ** argv[1] -> database name ** argv[2] -> table name @@ -10550,7 +10556,7 @@ static void zipfileEntryFree(ZipfileEntry *p){ } /* -** Release resources that should be freed at the end of a write +** Release resources that should be freed at the end of a write ** transaction. */ static void zipfileCleanupTransaction(ZipfileTab *pTab){ @@ -10659,7 +10665,7 @@ static void zipfileCursorErr(ZipfileCsr *pCsr, const char *zFmt, ...){ /* ** Read nRead bytes of data from offset iOff of file pFile into buffer ** aRead[]. Return SQLITE_OK if successful, or an SQLite error code -** otherwise. +** otherwise. ** ** If an error does occur, output variable (*pzErrmsg) may be set to point ** to an English language error message. It is the responsibility of the @@ -10867,7 +10873,7 @@ static int zipfileScanExtra(u8 *aExtra, int nExtra, u32 *pmTime){ ** File modification date: ** Bits 00-04: day ** Bits 05-08: month (1-12) -** Bits 09-15: years from 1980 +** Bits 09-15: years from 1980 ** ** https://msdn.microsoft.com/en-us/library/9kkf9tah.aspx */ @@ -10927,9 +10933,9 @@ static void zipfileMtimeToDos(ZipfileCDS *pCds, u32 mUnixTime){ pCds->mDate = pCds->mTime = 0; } - assert( mUnixTime<315507600 - || mUnixTime==zipfileMtime(pCds) - || ((mUnixTime % 2) && mUnixTime-1==zipfileMtime(pCds)) + assert( mUnixTime<315507600 + || mUnixTime==zipfileMtime(pCds) + || ((mUnixTime % 2) && mUnixTime-1==zipfileMtime(pCds)) /* || (mUnixTime % 2) */ ); } @@ -10997,7 +11003,7 @@ static int zipfileGetEntry( if( rc==SQLITE_OK ){ u32 *pt = &pNew->mUnixTime; - pNew->cds.zFile = sqlite3_mprintf("%.*s", nFile, aRead); + pNew->cds.zFile = sqlite3_mprintf("%.*s", nFile, aRead); pNew->aExtra = (u8*)&pNew[1]; memcpy(pNew->aExtra, &aRead[nFile], nExtra); if( pNew->cds.zFile==0 ){ @@ -11025,7 +11031,7 @@ static int zipfileGetEntry( memcpy(pNew->aData, &aBlob[pNew->iDataOff], pNew->cds.szCompressed); } }else{ - *pzErr = sqlite3_mprintf("failed to read LFH at offset %d", + *pzErr = sqlite3_mprintf("failed to read LFH at offset %d", (int)pNew->cds.iOffset ); } @@ -11077,8 +11083,8 @@ static int zipfileNext(sqlite3_vtab_cursor *cur){ return rc; } -static void zipfileFree(void *p) { - sqlite3_free(p); +static void zipfileFree(void *p) { + sqlite3_free(p); } /* @@ -11128,7 +11134,7 @@ static void zipfileInflate( ** Buffer aIn (size nIn bytes) contains uncompressed data. This function ** compresses it and sets (*ppOut) to point to a buffer containing the ** compressed data. The caller is responsible for eventually calling -** sqlite3_free() to release buffer (*ppOut). Before returning, (*pnOut) +** sqlite3_free() to release buffer (*ppOut). Before returning, (*pnOut) ** is set to the size of buffer (*ppOut) in bytes. ** ** If no error occurs, SQLITE_OK is returned. Otherwise, an SQLite error @@ -11317,8 +11323,8 @@ static int zipfileReadEOCD( /* Scan backwards looking for the signature bytes */ for(i=nRead-20; i>=0; i--){ - if( aRead[i]==0x50 && aRead[i+1]==0x4b - && aRead[i+2]==0x05 && aRead[i+3]==0x06 + if( aRead[i]==0x50 && aRead[i+1]==0x4b + && aRead[i+2]==0x05 && aRead[i+3]==0x06 ){ break; } @@ -11343,14 +11349,14 @@ static int zipfileReadEOCD( } /* -** Add object pNew to the linked list that begins at ZipfileTab.pFirstEntry +** Add object pNew to the linked list that begins at ZipfileTab.pFirstEntry ** and ends with pLastEntry. If argument pBefore is NULL, then pNew is added ** to the end of the list. Otherwise, it is added to the list immediately ** before pBefore (which is guaranteed to be a part of said list). */ static void zipfileAddEntry( - ZipfileTab *pTab, - ZipfileEntry *pBefore, + ZipfileTab *pTab, + ZipfileEntry *pBefore, ZipfileEntry *pNew ){ assert( (pTab->pFirstEntry==0)==(pTab->pLastEntry==0) ); @@ -11396,7 +11402,7 @@ static int zipfileLoadDirectory(ZipfileTab *pTab, const u8 *aBlob, int nBlob){ ** xFilter callback. */ static int zipfileFilter( - sqlite3_vtab_cursor *cur, + sqlite3_vtab_cursor *cur, int idxNum, const char *idxStr, int argc, sqlite3_value **argv ){ @@ -11559,7 +11565,7 @@ static int zipfileAppendEntry( } static int zipfileGetMode( - sqlite3_value *pVal, + sqlite3_value *pVal, int bIsDir, /* If true, default to directory */ u32 *pMode, /* OUT: Mode value */ char **pzErr /* OUT: Error message */ @@ -11622,7 +11628,7 @@ static int zipfileBegin(sqlite3_vtab *pVtab){ } /* Open a write fd on the file. Also load the entire central directory - ** structure into memory. During the transaction any new file data is + ** structure into memory. During the transaction any new file data is ** appended to the archive file, but the central directory is accumulated ** in main-memory until the transaction is committed. */ pTab->pWriteFd = sqlite3_fopen(pTab->zFile, "ab+"); @@ -11705,9 +11711,9 @@ static void zipfileRemoveEntryFromList(ZipfileTab *pTab, ZipfileEntry *pOld){ ** xUpdate method. */ static int zipfileUpdate( - sqlite3_vtab *pVtab, - int nVal, - sqlite3_value **apVal, + sqlite3_vtab *pVtab, + int nVal, + sqlite3_value **apVal, sqlite_int64 *pRowid ){ ZipfileTab *pTab = (ZipfileTab*)pVtab; @@ -11762,7 +11768,7 @@ static int zipfileUpdate( rc = SQLITE_CONSTRAINT; } if( sqlite3_value_type(apVal[6])!=SQLITE_NULL ){ - zipfileTableErr(pTab, "rawdata must be NULL"); + zipfileTableErr(pTab, "rawdata must be NULL"); rc = SQLITE_CONSTRAINT; } @@ -12354,7 +12360,7 @@ static int zipfileRegister(sqlite3 *db){ int rc = sqlite3_create_module(db, "zipfile" , &zipfileModule, 0); if( rc==SQLITE_OK ) rc = sqlite3_overload_function(db, "zipfile_cds", -1); if( rc==SQLITE_OK ){ - rc = sqlite3_create_function(db, "zipfile", -1, SQLITE_UTF8, 0, 0, + rc = sqlite3_create_function(db, "zipfile", -1, SQLITE_UTF8, 0, 0, zipfileStep, zipfileFinal ); } @@ -12372,8 +12378,8 @@ static int zipfileRegister(sqlite3 *db){ #endif int sqlite3_zipfile_init( - sqlite3 *db, - char **pzErrMsg, + sqlite3 *db, + char **pzErrMsg, const sqlite3_api_routines *pApi ){ SQLITE_EXTENSION_INIT2(pApi); @@ -12492,14 +12498,14 @@ static void sqlarUncompressFunc( #endif int sqlite3_sqlar_init( - sqlite3 *db, - char **pzErrMsg, + sqlite3 *db, + char **pzErrMsg, const sqlite3_api_routines *pApi ){ int rc = SQLITE_OK; SQLITE_EXTENSION_INIT2(pApi); (void)pzErrMsg; /* Unused parameter */ - rc = sqlite3_create_function(db, "sqlar_compress", 1, + rc = sqlite3_create_function(db, "sqlar_compress", 1, SQLITE_UTF8|SQLITE_INNOCUOUS, 0, sqlarCompressFunc, 0, 0); if( rc==SQLITE_OK ){ @@ -12549,7 +12555,7 @@ sqlite3expert *sqlite3_expert_new(sqlite3 *db, char **pzErr); ** By default, sqlite3_expert_analyze() generates sqlite_stat1 data for ** each candidate index. This involves scanning and sorting the entire ** contents of each user database table once for each candidate index -** associated with the table. For large databases, this can be +** associated with the table. For large databases, this can be ** prohibitively slow. This option allows the sqlite3expert object to ** be configured so that sqlite_stat1 data is instead generated based on a ** subset of each table, or so that no sqlite_stat1 data is used at all. @@ -12609,7 +12615,7 @@ int sqlite3_expert_sql( ** add further SQL statements to the analysis. ** ** If successful, SQLITE_OK is returned and (*pzErr) is set to NULL. Or, if -** an error occurs, an SQLite error code is returned and (*pzErr) set to +** an error occurs, an SQLite error code is returned and (*pzErr) set to ** point to a buffer containing an English language error message. In this ** case it is the responsibility of the caller to eventually free the buffer ** using sqlite3_free(). @@ -12638,7 +12644,7 @@ int sqlite3_expert_count(sqlite3expert*); ** The value passed as the third argument must be one of the EXPERT_REPORT_* ** #define constants defined below. ** -** For some EXPERT_REPORT_* parameters, the buffer returned contains +** For some EXPERT_REPORT_* parameters, the buffer returned contains ** information relating to a specific SQL statement. In these cases that ** SQL statement is identified by the value passed as the second argument. ** SQL statements are numbered from 0 in the order in which they are parsed. @@ -12651,7 +12657,7 @@ int sqlite3_expert_count(sqlite3expert*); ** ** EXPERT_REPORT_INDEXES: ** Return a buffer containing the CREATE INDEX statements for all recommended -** indexes for statement iStmt. If there are no new recommeded indexes, NULL +** indexes for statement iStmt. If there are no new recommeded indexes, NULL ** is returned. ** ** EXPERT_REPORT_PLAN: @@ -12659,7 +12665,7 @@ int sqlite3_expert_count(sqlite3expert*); ** iStmt after the proposed indexes have been added to the database schema. ** ** EXPERT_REPORT_CANDIDATES: -** Return a pointer to a buffer containing the CREATE INDEX statements +** Return a pointer to a buffer containing the CREATE INDEX statements ** for all indexes that were tested (for all SQL statements). The iStmt ** parameter is ignored for EXPERT_REPORT_CANDIDATES calls. */ @@ -12674,8 +12680,8 @@ const char *sqlite3_expert_report(sqlite3expert*, int iStmt, int eReport); #define EXPERT_REPORT_CANDIDATES 4 /* -** Free an (sqlite3expert*) handle and all associated resources. There -** should be one call to this function for each successful call to +** Free an (sqlite3expert*) handle and all associated resources. There +** should be one call to this function for each successful call to ** sqlite3-expert_new(). */ void sqlite3_expert_destroy(sqlite3expert*); @@ -12771,7 +12777,7 @@ struct IdxScan { }; /* -** Information regarding a single database table. Extracted from +** Information regarding a single database table. Extracted from ** "PRAGMA table_info" by function idxGetTableInfo(). */ struct IdxColumn { @@ -12855,7 +12861,7 @@ struct sqlite3expert { /* -** Allocate and return nByte bytes of zeroed memory using sqlite3_malloc(). +** Allocate and return nByte bytes of zeroed memory using sqlite3_malloc(). ** If the allocation fails, set *pRc to SQLITE_NOMEM and return NULL. */ static void *idxMalloc(int *pRc, int nByte){ @@ -12911,11 +12917,11 @@ static int idxHashString(const char *z, int n){ /* ** If zKey is already present in the hash table, return non-zero and do ** nothing. Otherwise, add an entry with key zKey and payload string zVal to -** the hash table passed as the second argument. +** the hash table passed as the second argument. */ static int idxHashAdd( - int *pRc, - IdxHash *pHash, + int *pRc, + IdxHash *pHash, const char *zKey, const char *zVal ){ @@ -12947,7 +12953,7 @@ static int idxHashAdd( } /* -** If zKey/nKey is present in the hash table, return a pointer to the +** If zKey/nKey is present in the hash table, return a pointer to the ** hash-entry object. */ static IdxHashEntry *idxHashFind(IdxHash *pHash, const char *zKey, int nKey){ @@ -13086,7 +13092,7 @@ static char *expertDequote(const char *zIn){ return zRet; } -/* +/* ** This function is the implementation of both the xConnect and xCreate ** methods of the r-tree virtual table. ** @@ -13142,7 +13148,7 @@ static int expertBestIndex(sqlite3_vtab *pVtab, sqlite3_index_info *pIdxInfo){ int rc = SQLITE_OK; int n = 0; IdxScan *pScan; - const int opmask = + const int opmask = SQLITE_INDEX_CONSTRAINT_EQ | SQLITE_INDEX_CONSTRAINT_GT | SQLITE_INDEX_CONSTRAINT_LT | SQLITE_INDEX_CONSTRAINT_GE | SQLITE_INDEX_CONSTRAINT_LE; @@ -13159,10 +13165,10 @@ static int expertBestIndex(sqlite3_vtab *pVtab, sqlite3_index_info *pIdxInfo){ /* Add the constraints to the IdxScan object */ for(i=0; inConstraint; i++){ struct sqlite3_index_constraint *pCons = &pIdxInfo->aConstraint[i]; - if( pCons->usable - && pCons->iColumn>=0 + if( pCons->usable + && pCons->iColumn>=0 && p->pTab->aCol[pCons->iColumn].iPk==0 - && (pCons->op & opmask) + && (pCons->op & opmask) ){ IdxConstraint *pNew; const char *zColl = sqlite3_vtab_collation(pIdxInfo, i); @@ -13205,9 +13211,9 @@ static int expertBestIndex(sqlite3_vtab *pVtab, sqlite3_index_info *pIdxInfo){ } static int expertUpdate( - sqlite3_vtab *pVtab, - int nData, - sqlite3_value **azData, + sqlite3_vtab *pVtab, + int nData, + sqlite3_value **azData, sqlite_int64 *pRowid ){ (void)pVtab; @@ -13217,7 +13223,7 @@ static int expertUpdate( return SQLITE_OK; } -/* +/* ** Virtual table module xOpen method. */ static int expertOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){ @@ -13229,7 +13235,7 @@ static int expertOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){ return rc; } -/* +/* ** Virtual table module xClose method. */ static int expertClose(sqlite3_vtab_cursor *cur){ @@ -13242,7 +13248,7 @@ static int expertClose(sqlite3_vtab_cursor *cur){ /* ** Virtual table module xEof method. ** -** Return non-zero if the cursor does not currently point to a valid +** Return non-zero if the cursor does not currently point to a valid ** record (i.e if the scan has finished), or zero otherwise. */ static int expertEof(sqlite3_vtab_cursor *cur){ @@ -13250,7 +13256,7 @@ static int expertEof(sqlite3_vtab_cursor *cur){ return pCsr->pData==0; } -/* +/* ** Virtual table module xNext method. */ static int expertNext(sqlite3_vtab_cursor *cur){ @@ -13269,7 +13275,7 @@ static int expertNext(sqlite3_vtab_cursor *cur){ return rc; } -/* +/* ** Virtual table module xRowid method. */ static int expertRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){ @@ -13278,7 +13284,7 @@ static int expertRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){ return SQLITE_OK; } -/* +/* ** Virtual table module xColumn method. */ static int expertColumn(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){ @@ -13291,11 +13297,11 @@ static int expertColumn(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){ return SQLITE_OK; } -/* +/* ** Virtual table module xFilter method. */ static int expertFilter( - sqlite3_vtab_cursor *cur, + sqlite3_vtab_cursor *cur, int idxNum, const char *idxStr, int argc, sqlite3_value **argv ){ @@ -13465,7 +13471,7 @@ static int idxGetTableInfo( } /* -** This function is a no-op if *pRc is set to anything other than +** This function is a no-op if *pRc is set to anything other than ** SQLITE_OK when it is called. ** ** If *pRc is initially set to SQLITE_OK, then the text specified by @@ -13508,7 +13514,7 @@ static char *idxAppendText(int *pRc, char *zIn, const char *zFmt, ...){ static int idxIdentifierRequiresQuotes(const char *zId){ int i; int nId = STRLEN(zId); - + if( sqlite3_keyword_check(zId, nId) ) return 1; for(i=0; zId[i]; i++){ @@ -13559,7 +13565,7 @@ static char *idxAppendColDefn( /* ** Search database dbm for an index compatible with the one idxCreateFromCons() -** would create from arguments pScan, pEq and pTail. If no error occurs and +** would create from arguments pScan, pEq and pTail. If no error occurs and ** such an index is found, return non-zero. Or, if no such index is found, ** return zero. ** @@ -13649,7 +13655,7 @@ static int countNonzeros(void* pCount, int nc, static int idxCreateFromCons( sqlite3expert *p, IdxScan *pScan, - IdxConstraint *pEq, + IdxConstraint *pEq, IdxConstraint *pTail ){ sqlite3 *dbm = p->dbm; @@ -13743,7 +13749,7 @@ static int idxFindConstraint(IdxConstraint *pList, IdxConstraint *p){ } static int idxCreateFromWhere( - sqlite3expert *p, + sqlite3expert *p, IdxScan *pScan, /* Create indexes for this scan */ IdxConstraint *pTail /* range/ORDER BY constraints for inclusion */ ){ @@ -13778,7 +13784,7 @@ static int idxCreateFromWhere( } /* -** Create candidate indexes in database [dbm] based on the data in +** Create candidate indexes in database [dbm] based on the data in ** linked-list pScan. */ static int idxCreateCandidates(sqlite3expert *p){ @@ -13825,7 +13831,7 @@ static void idxScanFree(IdxScan *pScan, IdxScan *pLast){ } /* -** Free all elements of the linked list starting from pStatement up +** Free all elements of the linked list starting from pStatement up ** until pLast (pLast is not freed). */ static void idxStatementFree(IdxStatement *pStatement, IdxStatement *pLast){ @@ -13903,8 +13909,8 @@ static int idxFindIndexes( const char *zIdx = 0; if( i+13pTab; const char *zTab = pTab->zName; - const char *zSql = + const char *zSql = "SELECT 'CREATE TEMP' || substr(sql, 7) FROM sqlite_schema " "WHERE tbl_name = %Q AND type IN ('table', 'trigger') " "ORDER BY type;"; @@ -14029,7 +14035,7 @@ static int idxProcessOneTrigger( int i; zWrite = idxAppendText(&rc, zWrite, "UPDATE %Q SET ", zInt); for(i=0; inCol; i++){ - zWrite = idxAppendText(&rc, zWrite, "%s%Q=?", i==0 ? "" : ", ", + zWrite = idxAppendText(&rc, zWrite, "%s%Q=?", i==0 ? "" : ", ", pTab->aCol[i].zName ); } @@ -14087,8 +14093,8 @@ static int idxProcessTriggers(sqlite3expert *p, char **pzErr){ ** of (*pbContains) is undefined in this case. */ static int expertDbContainsObject( - sqlite3 *db, - const char *zTab, + sqlite3 *db, + const char *zTab, int *pbContains /* OUT: True if object exists */ ){ const char *zSql = "SELECT 1 FROM sqlite_schema WHERE name = ?"; @@ -14111,14 +14117,14 @@ static int expertDbContainsObject( /* ** Execute SQL command zSql using database handle db. If no error occurs, -** set (*pzErr) to NULL and return SQLITE_OK. +** set (*pzErr) to NULL and return SQLITE_OK. ** ** If an error does occur, return an SQLite error code and set (*pzErr) to ** point to a buffer containing an English language error message. Except, ** if the error message begins with "no such module:", then ignore the ** error and return as if the SQL statement had succeeded. ** -** This is used to copy as much of the database schema as possible while +** This is used to copy as much of the database schema as possible while ** ignoring any errors related to missing virtual table modules. */ static int expertSchemaSql(sqlite3 *db, const char *zSql, char **pzErr){ @@ -14177,7 +14183,7 @@ static int idxCreateVtabSchema(sqlite3expert *p, char **pzErrmsg){ }else{ IdxTable *pTab; rc = idxGetTableInfo(p->db, zName, &pTab, pzErrmsg); - if( rc==SQLITE_OK ){ + if( rc==SQLITE_OK && ALWAYS(pTab!=0) ){ int i; char *zInner = 0; char *zOuter = 0; @@ -14187,14 +14193,14 @@ static int idxCreateVtabSchema(sqlite3expert *p, char **pzErrmsg){ /* The statement the vtab will pass to sqlite3_declare_vtab() */ zInner = idxAppendText(&rc, 0, "CREATE TABLE x("); for(i=0; inCol; i++){ - zInner = idxAppendText(&rc, zInner, "%s%Q COLLATE %s", + zInner = idxAppendText(&rc, zInner, "%s%Q COLLATE %s", (i==0 ? "" : ", "), pTab->aCol[i].zName, pTab->aCol[i].zColl ); } zInner = idxAppendText(&rc, zInner, ")"); /* The CVT statement to create the vtab */ - zOuter = idxAppendText(&rc, 0, + zOuter = idxAppendText(&rc, 0, "CREATE VIRTUAL TABLE %Q USING expert(%Q)", zName, zInner ); if( rc==SQLITE_OK ){ @@ -14335,7 +14341,7 @@ static void idxRemFunc( static int idxLargestIndex(sqlite3 *db, int *pnMax, char **pzErr){ int rc = SQLITE_OK; - const char *zMax = + const char *zMax = "SELECT max(i.seqno) FROM " " sqlite_schema AS s, " " pragma_index_list(s.name) AS l, " @@ -14384,8 +14390,8 @@ static int idxPopulateOneStat1( sqlite3_free(zOrder); return sqlite3_reset(pIndexXInfo); } - zCols = idxAppendText(&rc, zCols, - "%sx.%Q IS sqlite_expert_rem(%d, x.%Q) COLLATE %s", + zCols = idxAppendText(&rc, zCols, + "%sx.%Q IS sqlite_expert_rem(%d, x.%Q) COLLATE %s", zComma, zName, nCol, zName, zColl ); zOrder = idxAppendText(&rc, zOrder, "%s%d", zComma, ++nCol); @@ -14482,13 +14488,13 @@ static int idxBuildSampleTable(sqlite3expert *p, const char *zTab){ ** indexes have already been created in database sqlite3expert.dbm, this ** function populates sqlite_stat1 table in the same database. ** -** The stat1 data is generated by querying the +** The stat1 data is generated by querying the */ static int idxPopulateStat1(sqlite3expert *p, char **pzErr){ int rc = SQLITE_OK; int nMax =0; struct IdxRemCtx *pCtx = 0; - struct IdxSampleCtx samplectx; + struct IdxSampleCtx samplectx; int i; i64 iPrev = -100000; sqlite3_stmt *pAllIndex = 0; @@ -14500,7 +14506,7 @@ static int idxPopulateStat1(sqlite3expert *p, char **pzErr){ " sqlite_schema AS s, " " pragma_index_list(s.name) AS l " "WHERE s.type = 'table'"; - const char *zIndexXInfo = + const char *zIndexXInfo = "SELECT name, coll FROM pragma_index_xinfo(?) WHERE key"; const char *zWrite = "INSERT INTO sqlite_stat1 VALUES(?, ?, ?)"; @@ -14519,12 +14525,12 @@ static int idxPopulateStat1(sqlite3expert *p, char **pzErr){ if( rc==SQLITE_OK ){ sqlite3 *dbrem = (p->iSample==100 ? p->db : p->dbv); - rc = sqlite3_create_function(dbrem, "sqlite_expert_rem", + rc = sqlite3_create_function(dbrem, "sqlite_expert_rem", 2, SQLITE_UTF8, (void*)pCtx, idxRemFunc, 0, 0 ); } if( rc==SQLITE_OK ){ - rc = sqlite3_create_function(p->db, "sqlite_expert_sample", + rc = sqlite3_create_function(p->db, "sqlite_expert_sample", 0, SQLITE_UTF8, (void*)&samplectx, idxSampleFunc, 0, 0 ); } @@ -14557,7 +14563,7 @@ static int idxPopulateStat1(sqlite3expert *p, char **pzErr){ iPrev = iRowid; } if( rc==SQLITE_OK && p->iSample<100 ){ - rc = sqlite3_exec(p->dbv, + rc = sqlite3_exec(p->dbv, "DROP TABLE IF EXISTS temp." UNIQUE_TABLE_NAME, 0,0,0 ); } @@ -14711,7 +14717,7 @@ sqlite3expert *sqlite3_expert_new(sqlite3 *db, char **pzErrmsg){ /* Copy the entire schema of database [db] into [dbm]. */ if( rc==SQLITE_OK ){ sqlite3_stmt *pSql = 0; - rc = idxPrintfPrepareStmt(pNew->db, &pSql, pzErrmsg, + rc = idxPrintfPrepareStmt(pNew->db, &pSql, pzErrmsg, "SELECT sql, name, substr(sql,1,14)=='create virtual' COLLATE nocase" " FROM sqlite_schema WHERE substr(name,1,7)!='sqlite_' COLLATE nocase" " ORDER BY 3 DESC, rowid" @@ -14846,8 +14852,8 @@ int sqlite3_expert_analyze(sqlite3expert *p, char **pzErr){ /* Formulate the EXPERT_REPORT_CANDIDATES text */ for(pEntry=p->hIdx.pFirst; pEntry; pEntry=pEntry->pNext){ - p->zCandidates = idxAppendText(&rc, p->zCandidates, - "%s;%s%s\n", pEntry->zVal, + p->zCandidates = idxAppendText(&rc, p->zCandidates, + "%s;%s%s\n", pEntry->zVal, pEntry->zVal2 ? " -- stat1: " : "", pEntry->zVal2 ); } @@ -14972,7 +14978,7 @@ void sqlite3_expert_destroy(sqlite3expert *p){ ** sqlite3_intck_close(p); ** ** Usually, the sqlite3_intck object opens a read transaction within the -** first call to sqlite3_intck_step() and holds it open until the +** first call to sqlite3_intck_step() and holds it open until the ** integrity-check is complete. However, if sqlite3_intck_unlock() is ** called, the read transaction is ended and a new read transaction opened ** by the subsequent call to sqlite3_intck_step(). @@ -15001,7 +15007,7 @@ typedef struct sqlite3_intck sqlite3_intck; ** ** The integrity-check will be conducted on database zDb (which must be "main", ** "temp", or the name of an attached database) of database handle db. Once -** this function has been called successfully, the caller should not use +** this function has been called successfully, the caller should not use ** database handle db until the integrity-check object has been destroyed ** using sqlite3_intck_close(). */ @@ -15021,59 +15027,59 @@ void sqlite3_intck_close(sqlite3_intck *pCk); /* ** Do the next step of the integrity-check operation specified by the handle -** passed as the only argument. This function returns SQLITE_DONE if the +** passed as the only argument. This function returns SQLITE_DONE if the ** integrity-check operation is finished, or an SQLite error code if ** an error occurs, or SQLITE_OK if no error occurs but the integrity-check ** is not finished. It is not considered an error if database corruption ** is encountered. ** ** Following a successful call to sqlite3_intck_step() (one that returns -** SQLITE_OK), sqlite3_intck_message() returns a non-NULL value if +** SQLITE_OK), sqlite3_intck_message() returns a non-NULL value if ** corruption was detected in the db. ** ** If an error occurs and a value other than SQLITE_OK or SQLITE_DONE is ** returned, then the integrity-check handle is placed in an error state. -** In this state all subsequent calls to sqlite3_intck_step() or -** sqlite3_intck_unlock() will immediately return the same error. The -** sqlite3_intck_error() method may be used to obtain an English language +** In this state all subsequent calls to sqlite3_intck_step() or +** sqlite3_intck_unlock() will immediately return the same error. The +** sqlite3_intck_error() method may be used to obtain an English language ** error message in this case. */ int sqlite3_intck_step(sqlite3_intck *pCk); /* -** If the previous call to sqlite3_intck_step() encountered corruption +** If the previous call to sqlite3_intck_step() encountered corruption ** within the database, then this function returns a pointer to a buffer -** containing a nul-terminated string describing the corruption in +** containing a nul-terminated string describing the corruption in ** English. If the previous call to sqlite3_intck_step() did not encounter -** corruption, or if there was no previous call, this function returns +** corruption, or if there was no previous call, this function returns ** NULL. */ const char *sqlite3_intck_message(sqlite3_intck *pCk); /* -** Close any read-transaction opened by an earlier call to +** Close any read-transaction opened by an earlier call to ** sqlite3_intck_step(). Any subsequent call to sqlite3_intck_step() will ** open a new transaction. Return SQLITE_OK if successful, or an SQLite error ** code otherwise. ** ** If an error occurs, then the integrity-check handle is placed in an error -** state. In this state all subsequent calls to sqlite3_intck_step() or -** sqlite3_intck_unlock() will immediately return the same error. The -** sqlite3_intck_error() method may be used to obtain an English language +** state. In this state all subsequent calls to sqlite3_intck_step() or +** sqlite3_intck_unlock() will immediately return the same error. The +** sqlite3_intck_error() method may be used to obtain an English language ** error message in this case. */ int sqlite3_intck_unlock(sqlite3_intck *pCk); /* ** If an error has occurred in an earlier call to sqlite3_intck_step() -** or sqlite3_intck_unlock(), then this method returns the associated +** or sqlite3_intck_unlock(), then this method returns the associated ** SQLite error code. Additionally, if pzErr is not NULL, then (*pzErr) ** may be set to point to a nul-terminated string containing an English ** language error message. Or, if no error message is available, to ** NULL. ** ** If no error has occurred within sqlite3_intck_step() or -** sqlite_intck_unlock() calls on the handle passed as the first argument, +** sqlite_intck_unlock() calls on the handle passed as the first argument, ** then SQLITE_OK is returned and (*pzErr) set to NULL. */ int sqlite3_intck_error(sqlite3_intck *pCk, const char **pzErr); @@ -15121,7 +15127,7 @@ const char *sqlite3_intck_test_sql(sqlite3_intck *pCk, const char *zObj); ** statement. ** ** rc: -** Error code returned by most recent sqlite3_intck_step() or +** Error code returned by most recent sqlite3_intck_step() or ** sqlite3_intck_unlock() call. This is set to SQLITE_DONE when ** the integrity-check operation is finished. ** @@ -15188,7 +15194,7 @@ static sqlite3_stmt *intckPrepare(sqlite3_intck *p, const char *zSql){ ** error occurs within this function, it leaves an error in said handle. ** ** Otherwise, this function treats argument zFmt as a printf() style format -** string. It formats it according to the trailing arguments and then +** string. It formats it according to the trailing arguments and then ** attempts to prepare the results and return the resulting prepared ** statement. */ @@ -15229,7 +15235,7 @@ static int intckStep(sqlite3_intck *p, sqlite3_stmt *pStmt){ } /* -** Execute SQL statement zSql. There is no way to obtain any results +** Execute SQL statement zSql. There is no way to obtain any results ** returned by the statement. This function uses the sqlite3_intck error ** code convention. */ @@ -15261,8 +15267,8 @@ static char *intckMprintf(sqlite3_intck *p, const char *zFmt, ...){ } /* -** This is used by sqlite3_intck_unlock() to save the vector key value -** required to restart the current pCheck query as a nul-terminated string +** This is used by sqlite3_intck_unlock() to save the vector key value +** required to restart the current pCheck query as a nul-terminated string ** in p->zKey. */ static void intckSaveKey(sqlite3_intck *p){ @@ -15275,7 +15281,7 @@ static void intckSaveKey(sqlite3_intck *p){ assert( p->pCheck ); assert( p->zKey==0 ); - pXinfo = intckPrepareFmt(p, + pXinfo = intckPrepareFmt(p, "SELECT group_concat(desc, '') FROM %Q.sqlite_schema s, " "pragma_index_xinfo(%Q, %Q) " "WHERE s.type='index' AND s.name=%Q", @@ -15286,7 +15292,7 @@ static void intckSaveKey(sqlite3_intck *p){ } if( zDir==0 ){ - /* Object is a table, not an index. This is the easy case,as there are + /* Object is a table, not an index. This is the easy case,as there are ** no DESC columns or NULL values in a primary key. */ const char *zSep = "SELECT '(' || "; for(ii=0; iinKeyVal; ii++){ @@ -15326,7 +15332,7 @@ static void intckSaveKey(sqlite3_intck *p){ zRhsSep = " || ',' || "; } - zWhere = intckMprintf(p, + zWhere = intckMprintf(p, "'(%z) IS (' || %z || ') AND ' || %z", zLhs, zRhs, zWhere); } @@ -15338,7 +15344,7 @@ static void intckSaveKey(sqlite3_intck *p){ zWhere ); } - zSql = intckMprintf(p, + zSql = intckMprintf(p, "WITH wc(q) AS (\n%z\n)" "SELECT 'VALUES' || group_concat('(' || q || ')', ',\n ') FROM wc" , zSql @@ -15373,8 +15379,8 @@ static void intckFindObject(sqlite3_intck *p){ assert( p->rc==SQLITE_OK ); assert( p->pCheck==0 ); - pStmt = intckPrepareFmt(p, - "WITH tables(table_name) AS (" + pStmt = intckPrepareFmt(p, + "WITH tables(table_name) AS (" " SELECT name" " FROM %Q.sqlite_schema WHERE (type='table' OR type='index') AND rootpage" " UNION ALL " @@ -15444,12 +15450,12 @@ static int intckIsSpace(char c){ /* ** Argument z points to the text of a CREATE INDEX statement. This function -** identifies the part of the text that contains either the index WHERE +** identifies the part of the text that contains either the index WHERE ** clause (if iCol<0) or the iCol'th column of the index. ** ** If (iCol<0), the identified fragment does not include the "WHERE" keyword, ** only the expression that follows it. If (iCol>=0) then the identified -** fragment does not include any trailing sort-order keywords - "ASC" or +** fragment does not include any trailing sort-order keywords - "ASC" or ** "DESC". ** ** If the CREATE INDEX statement does not contain the requested field or @@ -15543,8 +15549,8 @@ static const char *intckParseCreateIndex(const char *z, int iCol, int *pnByte){ ** SELECT parse_create_index(, ); */ static void intckParseCreateIndexFunc( - sqlite3_context *pCtx, - int nVal, + sqlite3_context *pCtx, + int nVal, sqlite3_value **apVal ){ const char *zSql = (const char*)sqlite3_value_text(apVal[0]); @@ -15580,7 +15586,7 @@ static int intckGetAutoIndex(sqlite3_intck *p){ static int intckIsIndex(sqlite3_intck *p, const char *zObj){ int bRet = 0; sqlite3_stmt *pStmt = 0; - pStmt = intckPrepareFmt(p, + pStmt = intckPrepareFmt(p, "SELECT 1 FROM %Q.sqlite_schema WHERE name=%Q AND type='index'", p->zDb, zObj ); @@ -15612,7 +15618,7 @@ static char *intckCheckObjectSql( int bAutoIndex = 0; int bIsIndex = 0; - const char *zCommon = + const char *zCommon = /* Relation without_rowid also contains just one row. Column "b" is ** set to true if the table being examined is a WITHOUT ROWID table, ** or false otherwise. */ @@ -15658,7 +15664,7 @@ static char *intckCheckObjectSql( ** i_pk: "i.'a', i.'b'" ** ... ** n_pk: 2 - */ + */ ", tabpk(db, tab, idx, o_pk, i_pk, q_pk, eq_pk, ps_pk, pk_pk, n_pk) AS (" " WITH pkfields(f, a) AS (" " SELECT i.col_name, i.col_alias FROM idx_cols i WHERE i.idx_ispk" @@ -15707,7 +15713,7 @@ static char *intckCheckObjectSql( " )" " || format('\n FROM %Q.%Q ', t.db, t.tab)" /* If the object being checked is a table, append "NOT INDEXED". - ** Otherwise, append "INDEXED BY ", and then, if the index + ** Otherwise, append "INDEXED BY ", and then, if the index ** is a partial index " WHERE ". */ " || CASE WHEN t.idx IS NULL THEN " " 'NOT INDEXED'" @@ -15892,7 +15898,7 @@ int sqlite3_intck_open( pNew->db = db; pNew->zDb = (const char*)&pNew[1]; memcpy(&pNew[1], zDb, nDb+1); - rc = sqlite3_create_function(db, "parse_create_index", + rc = sqlite3_create_function(db, "parse_create_index", 2, SQLITE_UTF8, 0, intckParseCreateIndexFunc, 0, 0 ); if( rc!=SQLITE_OK ){ @@ -15969,7 +15975,7 @@ int sqlite3_intck_step(sqlite3_intck *p){ p->nKeyVal = 0; if( p->rc==SQLITE_CORRUPT ){ p->rc = SQLITE_OK; - p->zMessage = intckMprintf(p, + p->zMessage = intckMprintf(p, "corruption found while scanning database object %s", p->zObj ); } @@ -16018,7 +16024,7 @@ int sqlite3_intck_unlock(sqlite3_intck *p){ } /* -** Return the SQL statement used to check object zObj. Or, if zObj is +** Return the SQL statement used to check object zObj. Or, if zObj is ** NULL, the current SQL statement. */ const char *sqlite3_intck_test_sql(sqlite3_intck *p, const char *zObj){ @@ -16120,8 +16126,8 @@ static void stmtrandFunc( #endif int sqlite3_stmtrand_init( - sqlite3 *db, - char **pzErrMsg, + sqlite3 *db, + char **pzErrMsg, const sqlite3_api_routines *pApi ){ int rc = SQLITE_OK; @@ -16199,7 +16205,7 @@ int sqlite3_stmtrand_init( ** ** The call to vfstrace_register() simply creates the shim VFS that does ** tracing. The application must also arrange to use the new VFS for -** all database connections that are created and for which tracing is +** all database connections that are created and for which tracing is ** desired. This can be done by specifying the trace VFS using URI filename ** notation, or by specifying the trace VFS as the 4th parameter to ** sqlite3_open_v2() or by making the trace VFS be the default (by setting @@ -16245,7 +16251,7 @@ int sqlite3_stmtrand_init( ** invariants are (1) you must have -DSQLITE_ENABLE_VFSTRACE so that ** the shell.c source file will know to include the -vfstrace command-line ** option and (2) you must compile and link the three source files -** shell,c, test_vfstrace.c, and sqlite3.c. +** shell,c, test_vfstrace.c, and sqlite3.c. */ #include #include @@ -16463,9 +16469,9 @@ static int vfstraceClose(sqlite3_file *pFile){ ** Read data from an vfstrace-file. */ static int vfstraceRead( - sqlite3_file *pFile, - void *zBuf, - int iAmt, + sqlite3_file *pFile, + void *zBuf, + int iAmt, sqlite_int64 iOfst ){ vfstrace_file *p = (vfstrace_file *)pFile; @@ -16482,9 +16488,9 @@ static int vfstraceRead( ** Write data to an vfstrace-file. */ static int vfstraceWrite( - sqlite3_file *pFile, - const void *zBuf, - int iAmt, + sqlite3_file *pFile, + const void *zBuf, + int iAmt, sqlite_int64 iOfst ){ vfstrace_file *p = (vfstrace_file *)pFile; @@ -16598,7 +16604,7 @@ static int vfstraceCheckReservedLock(sqlite3_file *pFile, int *pResOut){ vfstrace_file *p = (vfstrace_file *)pFile; vfstrace_info *pInfo = p->pInfo; int rc; - vfstrace_printf(pInfo, "%s.xCheckReservedLock(%s,%d)", + vfstrace_printf(pInfo, "%s.xCheckReservedLock(%s,%d)", pInfo->zVfsName, p->zFName); rc = p->pReal->pMethods->xCheckReservedLock(p->pReal, pResOut); vfstrace_print_errcode(pInfo, " -> %s", rc); @@ -16663,7 +16669,7 @@ static int vfstraceFileControl(sqlite3_file *pFile, int op, void *pArg){ case SQLITE_FCNTL_COMMIT_PHASETWO: zOp = "COMMIT_PHASETWO"; break; case SQLITE_FCNTL_WIN32_SET_HANDLE: zOp = "WIN32_SET_HANDLE"; break; case SQLITE_FCNTL_WAL_BLOCK: zOp = "WAL_BLOCK"; break; - case SQLITE_FCNTL_ZIPVFS: zOp = "ZIPVFS"; break; + case SQLITE_FCNTL_ZIPVFS: zOp = "ZIPVFS"; break; case SQLITE_FCNTL_RBU: zOp = "RBU"; break; case SQLITE_FCNTL_VFS_POINTER: zOp = "VFS_POINTER"; break; case SQLITE_FCNTL_JOURNAL_POINTER: zOp = "JOURNAL_POINTER"; break; @@ -16784,10 +16790,10 @@ static int vfstraceShmLock(sqlite3_file *pFile, int ofst, int n, int flags){ return rc; } static int vfstraceShmMap( - sqlite3_file *pFile, - int iRegion, - int szRegion, - int isWrite, + sqlite3_file *pFile, + int iRegion, + int szRegion, + int isWrite, void volatile **pp ){ vfstrace_file *p = (vfstrace_file *)pFile; @@ -16893,9 +16899,9 @@ static int vfstraceDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){ ** is available, or false otherwise. */ static int vfstraceAccess( - sqlite3_vfs *pVfs, - const char *zPath, - int flags, + sqlite3_vfs *pVfs, + const char *zPath, + int flags, int *pResOut ){ vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData; @@ -16915,9 +16921,9 @@ static int vfstraceAccess( ** of at least (DEVSYM_MAX_PATHNAME+1) bytes. */ static int vfstraceFullPathname( - sqlite3_vfs *pVfs, - const char *zPath, - int nOut, + sqlite3_vfs *pVfs, + const char *zPath, + int nOut, char *zOut ){ vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData; @@ -16943,7 +16949,7 @@ static void *vfstraceDlOpen(sqlite3_vfs *pVfs, const char *zPath){ /* ** Populate the buffer zErrMsg (size nByte bytes) with a human readable -** utf-8 string describing the most recent error encountered associated +** utf-8 string describing the most recent error encountered associated ** with dynamic libraries. */ static void vfstraceDlError(sqlite3_vfs *pVfs, int nByte, char *zErrMsg){ @@ -16975,7 +16981,7 @@ static void vfstraceDlClose(sqlite3_vfs *pVfs, void *pHandle){ } /* -** Populate the buffer pointed to by zBufOut with nByte bytes of +** Populate the buffer pointed to by zBufOut with nByte bytes of ** random data. */ static int vfstraceRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut){ @@ -16986,7 +16992,7 @@ static int vfstraceRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut){ } /* -** Sleep for nMicro microseconds. Return the number of microseconds +** Sleep for nMicro microseconds. Return the number of microseconds ** actually slept. */ static int vfstraceSleep(sqlite3_vfs *pVfs, int nMicro){ @@ -17048,7 +17054,7 @@ static const char *vfstraceNextSystemCall(sqlite3_vfs *pVfs, const char *zName){ /* ** Clients invoke this routine to construct a new trace-vfs shim. ** -** Return SQLITE_OK on success. +** Return SQLITE_OK on success. ** ** SQLITE_NOMEM is returned in the case of a memory allocation error. ** SQLITE_NOTFOUND is returned if zOldVfsName does not exist. @@ -17096,11 +17102,11 @@ int vfstrace_register( pNew->xCurrentTimeInt64 = pRoot->xCurrentTimeInt64==0 ? 0 : vfstraceCurrentTimeInt64; if( pNew->iVersion>=3 ){ - pNew->xSetSystemCall = pRoot->xSetSystemCall==0 ? 0 : + pNew->xSetSystemCall = pRoot->xSetSystemCall==0 ? 0 : vfstraceSetSystemCall; - pNew->xGetSystemCall = pRoot->xGetSystemCall==0 ? 0 : + pNew->xGetSystemCall = pRoot->xGetSystemCall==0 ? 0 : vfstraceGetSystemCall; - pNew->xNextSystemCall = pRoot->xNextSystemCall==0 ? 0 : + pNew->xNextSystemCall = pRoot->xNextSystemCall==0 ? 0 : vfstraceNextSystemCall; } } @@ -17166,8 +17172,8 @@ void vfstrace_unregister(const char *zTraceName){ ** ** 3) Executes the recovery by repeatedly calling sqlite3_recover_step() on ** the handle until it returns something other than SQLITE_OK. If it -** returns SQLITE_DONE, then the recovery operation completed without -** error. If it returns some other non-SQLITE_OK value, then an error +** returns SQLITE_DONE, then the recovery operation completed without +** error. If it returns some other non-SQLITE_OK value, then an error ** has occurred. ** ** 4) Retrieves any error code and English language error message using the @@ -17177,7 +17183,7 @@ void vfstrace_unregister(const char *zTraceName){ ** 5) Destroys the sqlite3_recover handle and frees all resources ** using sqlite3_recover_finish(). ** -** The application may abandon the recovery operation at any point +** The application may abandon the recovery operation at any point ** before it is finished by passing the sqlite3_recover handle to ** sqlite3_recover_finish(). This is not an error, but the final state ** of the output database, or the results of running the partial script @@ -17216,7 +17222,7 @@ extern "C" { */ typedef struct sqlite3_recover sqlite3_recover; -/* +/* ** These two APIs attempt to create and return a new sqlite3_recover object. ** In both cases the first two arguments identify the (possibly ** corrupt) database to recover data from. The first argument is an open @@ -17233,10 +17239,10 @@ typedef struct sqlite3_recover sqlite3_recover; ** be returned to the user as a series of SQL statements. Executing these ** SQL statements results in the same database as would have been created ** had sqlite3_recover_init() been used. For each SQL statement in the -** output, the callback function passed as the third argument (xSql) is +** output, the callback function passed as the third argument (xSql) is ** invoked once. The first parameter is a passed a copy of the fourth argument ** to this function (pCtx) as its first parameter, and a pointer to a -** nul-terminated buffer containing the SQL statement formated as UTF-8 as +** nul-terminated buffer containing the SQL statement formated as UTF-8 as ** the second. If the xSql callback returns any value other than SQLITE_OK, ** then processing is immediately abandoned and the value returned used as ** the recover handle error code (see below). @@ -17247,13 +17253,13 @@ typedef struct sqlite3_recover sqlite3_recover; ** sqlite3_recover_finish() is called on all allocated handles. */ sqlite3_recover *sqlite3_recover_init( - sqlite3* db, - const char *zDb, + sqlite3* db, + const char *zDb, const char *zUri ); sqlite3_recover *sqlite3_recover_init_sql( - sqlite3* db, - const char *zDb, + sqlite3* db, + const char *zDb, int (*xSql)(void*, const char*), void *pCtx ); @@ -17286,11 +17292,11 @@ int sqlite3_recover_config(sqlite3_recover*, int op, void *pArg); ** The pArg value must actually be a pointer to a value of type ** int containing value 0 or 1 cast as a (void*). If this option is set ** (argument is 1) and a lost-and-found table has been configured using -** SQLITE_RECOVER_LOST_AND_FOUND, then is assumed that the freelist is +** SQLITE_RECOVER_LOST_AND_FOUND, then is assumed that the freelist is ** corrupt and an attempt is made to recover records from pages that ** appear to be linked into the freelist. Otherwise, pages on the freelist ** are ignored. Setting this option can recover more data from the -** database, but often ends up "recovering" deleted records. The default +** database, but often ends up "recovering" deleted records. The default ** value is 0 (clear). ** ** SQLITE_RECOVER_ROWIDS: @@ -17304,7 +17310,7 @@ int sqlite3_recover_config(sqlite3_recover*, int op, void *pArg); ** SQLITE_RECOVER_SLOWINDEXES: ** The pArg value must actually be a pointer to a value of type ** int containing value 0 or 1 cast as a (void*). If this option is clear -** (argument is 0), then when creating an output database, the recover +** (argument is 0), then when creating an output database, the recover ** module creates and populates non-UNIQUE indexes right at the end of the ** recovery operation - after all recoverable data has been inserted ** into the new database. This is faster overall, but means that the @@ -17312,7 +17318,7 @@ int sqlite3_recover_config(sqlite3_recover*, int op, void *pArg); ** be need to create a large number of indexes, which may be very slow. ** ** Or, if this option is set (argument is 1), then non-UNIQUE indexes -** are created in the output database before it is populated with +** are created in the output database before it is populated with ** recovered data. This is slower overall, but avoids the slow call ** to sqlite3_recover_step() at the end of the recovery operation. ** @@ -17324,7 +17330,7 @@ int sqlite3_recover_config(sqlite3_recover*, int op, void *pArg); #define SQLITE_RECOVER_SLOWINDEXES 4 /* -** Perform a unit of work towards the recovery operation. This function +** Perform a unit of work towards the recovery operation. This function ** must normally be called multiple times to complete database recovery. ** ** If no error occurs but the recovery operation is not completed, this @@ -17340,7 +17346,7 @@ int sqlite3_recover_config(sqlite3_recover*, int op, void *pArg); */ int sqlite3_recover_step(sqlite3_recover*); -/* +/* ** Run the recovery operation to completion. Return SQLITE_OK if successful, ** or an SQLite error code otherwise. Calling this function is the same ** as executing: @@ -17352,9 +17358,9 @@ int sqlite3_recover_run(sqlite3_recover*); /* ** If an error has been encountered during a prior call to -** sqlite3_recover_step(), then this function attempts to return a -** pointer to a buffer containing an English language explanation of -** the error. If no error message is available, or if an out-of memory +** sqlite3_recover_step(), then this function attempts to return a +** pointer to a buffer containing an English language explanation of +** the error. If no error message is available, or if an out-of memory ** error occurs while attempting to allocate a buffer in which to format ** the error message, NULL is returned. ** @@ -17369,7 +17375,7 @@ const char *sqlite3_recover_errmsg(sqlite3_recover*); */ int sqlite3_recover_errcode(sqlite3_recover*); -/* +/* ** Clean up a recovery object created by a call to sqlite3_recover_init(). ** The results of using a recovery object with any API after it has been ** passed to this function are undefined. @@ -17434,7 +17440,7 @@ int sqlite3_recover_finish(sqlite3_recover*); ** INSERT INTO t1(rowid, a, b) VALUES(5, 'v', 'five'); ** INSERT INTO t1(rowid, a, b) VALUES(10, 'x', 'ten'); ** -** the sqlite_dbdata table contains, as well as from entries related to +** the sqlite_dbdata table contains, as well as from entries related to ** page 1, content equivalent to: ** ** INSERT INTO sqlite_dbdata(pgno, cell, field, value) VALUES @@ -17462,7 +17468,7 @@ int sqlite3_recover_finish(sqlite3_recover*); ** child page in the database. */ -#if !defined(SQLITEINT_H) +#if !defined(SQLITEINT_H) /* #include "sqlite3.h" */ /* typedef unsigned char u8; */ @@ -17474,7 +17480,7 @@ int sqlite3_recover_finish(sqlite3_recover*); #ifndef SQLITE_OMIT_VIRTUALTABLE -#define DBDATA_PADDING_BYTES 100 +#define DBDATA_PADDING_BYTES 100 typedef struct DbdataTable DbdataTable; typedef struct DbdataCursor DbdataCursor; @@ -17510,7 +17516,7 @@ struct DbdataCursor { u8 *pHdrPtr; u8 *pPtr; u32 enc; /* Text encoding */ - + sqlite3_int64 iIntkey; /* Integer key value */ }; @@ -17574,7 +17580,7 @@ static void dbdataBufferFree(DbdataBuffer *pBuf){ } /* -** Connect to an sqlite_dbdata (pAux==0) or sqlite_dbptr (pAux!=0) virtual +** Connect to an sqlite_dbdata (pAux==0) or sqlite_dbptr (pAux!=0) virtual ** table. */ static int dbdataConnect( @@ -17697,7 +17703,7 @@ static int dbdataOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){ } /* -** Restore a cursor object to the state it was in when first allocated +** Restore a cursor object to the state it was in when first allocated ** by dbdataOpen(). */ static void dbdataResetCursor(DbdataCursor *pCsr){ @@ -17728,8 +17734,8 @@ static int dbdataClose(sqlite3_vtab_cursor *pCursor){ return SQLITE_OK; } -/* -** Utility methods to decode 16 and 32-bit big-endian unsigned integers. +/* +** Utility methods to decode 16 and 32-bit big-endian unsigned integers. */ static u32 get_uint16(unsigned char *a){ return (a[0]<<8)|a[1]; @@ -17851,28 +17857,28 @@ static int dbdataValueBytes(int eType){ ** result of context object pCtx. */ static void dbdataValue( - sqlite3_context *pCtx, + sqlite3_context *pCtx, u32 enc, - int eType, + int eType, u8 *pData, sqlite3_int64 nData ){ if( eType>=0 ){ if( dbdataValueBytes(eType)<=nData ){ switch( eType ){ - case 0: - case 10: - case 11: + case 0: + case 10: + case 11: sqlite3_result_null(pCtx); break; - - case 8: + + case 8: sqlite3_result_int(pCtx, 0); break; case 9: sqlite3_result_int(pCtx, 1); break; - + case 1: case 2: case 3: case 4: case 5: case 6: case 7: { sqlite3_uint64 v = (signed char)pData[0]; pData++; @@ -17884,7 +17890,7 @@ static void dbdataValue( case 3: v = (v<<8) + pData[0]; pData++; case 2: v = (v<<8) + pData[0]; pData++; } - + if( eType==7 ){ double r; memcpy(&r, &v, sizeof(r)); @@ -17894,7 +17900,7 @@ static void dbdataValue( } break; } - + default: { int n = ((eType-12) / 2); if( eType % 2 ){ @@ -17996,7 +18002,7 @@ static int dbdataNext(sqlite3_vtab_cursor *pCursor){ int iHdr; int U, X; int nLocal; - + switch( pCsr->aPage[iOff] ){ case 0x02: nPointer = 4; @@ -18016,16 +18022,16 @@ static int dbdataNext(sqlite3_vtab_cursor *pCursor){ bNextPage = 1; }else{ int iCellPtr = iOff + 8 + nPointer + pCsr->iCell*2; - + if( iCellPtr>pCsr->nPage ){ bNextPage = 1; }else{ iOff = get_uint16(&pCsr->aPage[iCellPtr]); } - + /* For an interior node cell, skip past the child-page number */ iOff += nPointer; - + /* Load the "byte of payload including overflow" field */ if( bNextPage || iOff>pCsr->nPage || iOff<=iCellPtr ){ bNextPage = 1; @@ -18034,12 +18040,12 @@ static int dbdataNext(sqlite3_vtab_cursor *pCursor){ if( nPayload>0x7fffff00 ) nPayload &= 0x3fff; if( nPayload==0 ) nPayload = 1; } - + /* If this is a leaf intkey cell, load the rowid */ if( bHasRowid && !bNextPage && iOffnPage ){ iOff += dbdataGetVarint(&pCsr->aPage[iOff], &pCsr->iIntkey); } - + /* Figure out how much data to read from the local page */ U = pCsr->nPage; if( bHasRowid ){ @@ -18065,7 +18071,7 @@ static int dbdataNext(sqlite3_vtab_cursor *pCursor){ }else{ /* Allocate space for payload. And a bit more to catch small buffer - ** overruns caused by attempting to read a varint or similar from + ** overruns caused by attempting to read a varint or similar from ** near the end of a corrupt record. */ rc = dbdataBufferSize(&pCsr->rec, nPayload+DBDATA_PADDING_BYTES); if( rc!=SQLITE_OK ) return rc; @@ -18101,7 +18107,7 @@ static int dbdataNext(sqlite3_vtab_cursor *pCursor){ } memset(&pCsr->rec.aBuf[nPayload], 0, DBDATA_PADDING_BYTES); pCsr->nRec = nPayload; - + iHdr = dbdataGetVarintU32(pCsr->rec.aBuf, &nHdr); if( nHdr>nPayload ) nHdr = 0; pCsr->nHdr = nHdr; @@ -18114,7 +18120,7 @@ static int dbdataNext(sqlite3_vtab_cursor *pCursor){ pCsr->iField++; if( pCsr->iField>0 ){ sqlite3_int64 iType; - if( pCsr->pHdrPtr>=&pCsr->rec.aBuf[pCsr->nRec] + if( pCsr->pHdrPtr>=&pCsr->rec.aBuf[pCsr->nRec] || pCsr->iField>=DBDATA_MX_FIELD ){ bNextPage = 1; @@ -18154,7 +18160,7 @@ static int dbdataNext(sqlite3_vtab_cursor *pCursor){ return SQLITE_OK; } -/* +/* ** Return true if the cursor is at EOF. */ static int dbdataEof(sqlite3_vtab_cursor *pCursor){ @@ -18174,9 +18180,9 @@ static int dbdataIsFunction(const char *zSchema){ return 0; } -/* +/* ** Determine the size in pages of database zSchema (where zSchema is -** "main", "temp" or the name of an attached database) and set +** "main", "temp" or the name of an attached database) and set ** pCsr->szDb accordingly. If successful, return SQLITE_OK. Otherwise, ** an SQLite error code. */ @@ -18222,11 +18228,11 @@ static int dbdataGetEncoding(DbdataCursor *pCsr){ } -/* +/* ** xFilter method for sqlite_dbdata and sqlite_dbptr. */ static int dbdataFilter( - sqlite3_vtab_cursor *pCursor, + sqlite3_vtab_cursor *pCursor, int idxNum, const char *idxStr, int argc, sqlite3_value **argv ){ @@ -18264,7 +18270,7 @@ static int dbdataFilter( sqlite3_free(zSql); } }else{ - rc = sqlite3_prepare_v2(pTab->db, + rc = sqlite3_prepare_v2(pTab->db, "SELECT data FROM sqlite_dbpage(?) WHERE pgno=?", -1, &pCsr->pStmt, 0 ); @@ -18294,8 +18300,8 @@ static int dbdataFilter( ** Return a column for the sqlite_dbdata or sqlite_dbptr table. */ static int dbdataColumn( - sqlite3_vtab_cursor *pCursor, - sqlite3_context *ctx, + sqlite3_vtab_cursor *pCursor, + sqlite3_context *ctx, int i ){ DbdataCursor *pCsr = (DbdataCursor*)pCursor; @@ -18338,7 +18344,7 @@ static int dbdataColumn( sqlite3_int64 iType; dbdataGetVarintU32(pCsr->pHdrPtr, &iType); dbdataValue( - ctx, pCsr->enc, iType, pCsr->pPtr, + ctx, pCsr->enc, iType, pCsr->pPtr, &pCsr->rec.aBuf[pCsr->nRec] - pCsr->pPtr ); } @@ -18349,7 +18355,7 @@ static int dbdataColumn( return SQLITE_OK; } -/* +/* ** Return the rowid for an sqlite_dbdata or sqlite_dptr table. */ static int dbdataRowid(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){ @@ -18399,8 +18405,8 @@ static int sqlite3DbdataRegister(sqlite3 *db){ } int sqlite3_dbdata_init( - sqlite3 *db, - char **pzErrMsg, + sqlite3 *db, + char **pzErrMsg, const sqlite3_api_routines *pApi ){ (void)pzErrMsg; @@ -18462,7 +18468,7 @@ typedef struct RecoverColumn RecoverColumn; ** Name of the table. ** ** nCol/aCol[]: -** aCol[] is an array of nCol columns. In the order in which they appear +** aCol[] is an array of nCol columns. In the order in which they appear ** in the table. ** ** bIntkey: @@ -18474,7 +18480,7 @@ typedef struct RecoverColumn RecoverColumn; ** used to construct the output database. If the table does has a rowid ** but not an INTEGER PRIMARY KEY column, then iRowidBind contains the ** index of the bind paramater to which the rowid value should be bound. -** Otherwise, it contains -1. If the table does contain an INTEGER PRIMARY +** Otherwise, it contains -1. If the table does contain an INTEGER PRIMARY ** KEY column, then the rowid value should be bound to the index associated ** with the column. ** @@ -18545,7 +18551,7 @@ struct RecoverColumn { ** aElem[]: ** Array large enough to contain a bit for each key. For key value ** iKey, the associated bit is the bit (iKey%32) of aElem[iKey/32]. -** In other words, the following is true if bit iKey is set, or +** In other words, the following is true if bit iKey is set, or ** false if it is clear: ** ** (aElem[iKey/32] & (1 << (iKey%32))) ? 1 : 0 @@ -18686,11 +18692,11 @@ static RecoverGlobal recover_g; /* ** Use this static SQLite mutex to protect the globals during the ** first call to sqlite3_recover_step(). -*/ +*/ #define RECOVER_MUTEX_ID SQLITE_MUTEX_STATIC_APP2 -/* +/* ** Default value for SQLITE_RECOVER_ROWIDS (sqlite3_recover.bRecoverRowid). */ #define RECOVER_ROWID_DEFAULT 1 @@ -18731,8 +18737,8 @@ static int recoverStrlen(const char *zStr){ } /* -** This function is a no-op if the recover handle passed as the first -** argument already contains an error (if p->errCode!=SQLITE_OK). +** This function is a no-op if the recover handle passed as the first +** argument already contains an error (if p->errCode!=SQLITE_OK). ** ** Otherwise, an attempt is made to allocate, zero and return a buffer nByte ** bytes in size. If successful, a pointer to the new buffer is returned. Or, @@ -18758,8 +18764,8 @@ static void *recoverMalloc(sqlite3_recover *p, i64 nByte){ ** the first argument. The error code is set to the value of parameter ** errCode. ** -** Parameter zFmt must be a printf() style formatting string. The handle -** error message is set to the result of using any trailing arguments for +** Parameter zFmt must be a printf() style formatting string. The handle +** error message is set to the result of using any trailing arguments for ** parameter substitutions in the formatting string. ** ** For example: @@ -18767,8 +18773,8 @@ static void *recoverMalloc(sqlite3_recover *p, i64 nByte){ ** recoverError(p, SQLITE_ERROR, "no such table: %s", zTablename); */ static int recoverError( - sqlite3_recover *p, - int errCode, + sqlite3_recover *p, + int errCode, const char *zFmt, ... ){ char *z = 0; @@ -18847,7 +18853,7 @@ static int recoverDbError(sqlite3_recover *p, sqlite3 *db){ /* ** This function is a no-op if recover handle p already contains an error -** (if p->errCode!=SQLITE_OK). +** (if p->errCode!=SQLITE_OK). ** ** Otherwise, it attempts to prepare the SQL statement in zSql against ** database handle db. If successful, the statement handle is returned. @@ -18856,7 +18862,7 @@ static int recoverDbError(sqlite3_recover *p, sqlite3 *db){ */ static sqlite3_stmt *recoverPrepare( sqlite3_recover *p, - sqlite3 *db, + sqlite3 *db, const char *zSql ){ sqlite3_stmt *pStmt = 0; @@ -18870,7 +18876,7 @@ static sqlite3_stmt *recoverPrepare( /* ** This function is a no-op if recover handle p already contains an error -** (if p->errCode!=SQLITE_OK). +** (if p->errCode!=SQLITE_OK). ** ** Otherwise, argument zFmt is used as a printf() style format string, ** along with any trailing arguments, to create an SQL statement. This @@ -18881,7 +18887,7 @@ static sqlite3_stmt *recoverPrepare( */ static sqlite3_stmt *recoverPreparePrintf( sqlite3_recover *p, - sqlite3 *db, + sqlite3 *db, const char *zFmt, ... ){ sqlite3_stmt *pStmt = 0; @@ -18902,7 +18908,7 @@ static sqlite3_stmt *recoverPreparePrintf( } /* -** Reset SQLite statement handle pStmt. If the call to sqlite3_reset() +** Reset SQLite statement handle pStmt. If the call to sqlite3_reset() ** indicates that an error occurred, and there is not already an error ** in the recover handle passed as the first argument, set the error ** code and error message appropriately. @@ -18919,7 +18925,7 @@ static sqlite3_stmt *recoverReset(sqlite3_recover *p, sqlite3_stmt *pStmt){ } /* -** Finalize SQLite statement handle pStmt. If the call to sqlite3_reset() +** Finalize SQLite statement handle pStmt. If the call to sqlite3_reset() ** indicates that an error occurred, and there is not already an error ** in the recover handle passed as the first argument, set the error ** code and error message appropriately. @@ -18934,7 +18940,7 @@ static void recoverFinalize(sqlite3_recover *p, sqlite3_stmt *pStmt){ /* ** This function is a no-op if recover handle p already contains an error -** (if p->errCode!=SQLITE_OK). A copy of p->errCode is returned in this +** (if p->errCode!=SQLITE_OK). A copy of p->errCode is returned in this ** case. ** ** Otherwise, execute SQL script zSql. If successful, return SQLITE_OK. @@ -18957,9 +18963,9 @@ static int recoverExec(sqlite3_recover *p, sqlite3 *db, const char *zSql){ ** (e.g. an OOM) occurs. */ static void recoverBindValue( - sqlite3_recover *p, - sqlite3_stmt *pStmt, - int iBind, + sqlite3_recover *p, + sqlite3_stmt *pStmt, + int iBind, sqlite3_value *pVal ){ if( p->errCode==SQLITE_OK ){ @@ -19021,16 +19027,16 @@ static i64 recoverPageCount(sqlite3_recover *p){ } /* -** Implementation of SQL scalar function "read_i32". The first argument to -** this function must be a blob. The second a non-negative integer. This +** Implementation of SQL scalar function "read_i32". The first argument to +** this function must be a blob. The second a non-negative integer. This ** function reads and returns a 32-bit big-endian integer from byte ** offset (4*) of the blob. ** ** SELECT read_i32(, ) */ static void recoverReadI32( - sqlite3_context *context, - int argc, + sqlite3_context *context, + int argc, sqlite3_value **argv ){ const unsigned char *pBlob; @@ -19058,7 +19064,7 @@ static void recoverReadI32( ** lost-and-found table, and it depends on those routines having populated ** the sqlite3_recover.laf.pUsed variable. ** -** The only argument to this function is a page-number. It returns true +** The only argument to this function is a page-number. It returns true ** if the page has already been used somehow during data recovery, or false ** otherwise. ** @@ -19076,18 +19082,18 @@ static void recoverPageIsUsed( } /* -** The implementation of a user-defined SQL function invoked by the +** The implementation of a user-defined SQL function invoked by the ** sqlite_dbdata and sqlite_dbptr virtual table modules to access pages ** of the database being recovered. ** ** This function always takes a single integer argument. If the argument ** is zero, then the value returned is the number of pages in the db being -** recovered. If the argument is greater than zero, it is a page number. -** The value returned in this case is an SQL blob containing the data for +** recovered. If the argument is greater than zero, it is a page number. +** The value returned in this case is an SQL blob containing the data for ** the identified page of the db being recovered. e.g. ** ** SELECT getpage(0); -- return number of pages in db -** SELECT getpage(4); -- return page 4 of db as a blob of data +** SELECT getpage(4); -- return page 4 of db as a blob of data */ static void recoverGetPage( sqlite3_context *pCtx, @@ -19169,8 +19175,8 @@ static const char *recoverUnusedString( ** is returned. */ static void recoverEscapeCrlf( - sqlite3_context *context, - int argc, + sqlite3_context *context, + int argc, sqlite3_value **argv ){ const char *zText = (const char*)sqlite3_value_text(argv[0]); @@ -19249,7 +19255,7 @@ static void recoverEscapeCrlf( /* ** This function is a no-op if recover handle p already contains an error ** (if p->errCode!=SQLITE_OK). A copy of the error code is returned in -** this case. +** this case. ** ** Otherwise, attempt to populate temporary table "recovery.schema" with the ** parts of the database schema that can be extracted from the input database. @@ -19279,10 +19285,10 @@ static int recoverCacheSchema(sqlite3_recover *p){ } /* -** If this recover handle is not in SQL callback mode (i.e. was not created -** using sqlite3_recover_init_sql()) of if an error has already occurred, +** If this recover handle is not in SQL callback mode (i.e. was not created +** using sqlite3_recover_init_sql()) of if an error has already occurred, ** this function is a no-op. Otherwise, issue a callback with SQL statement -** zSql as the parameter. +** zSql as the parameter. ** ** If the callback returns non-zero, set the recover handle error code to ** the value returned (so that the caller will abandon processing). @@ -19316,8 +19322,8 @@ static void recoverTransferSettings(sqlite3_recover *p){ }; int ii; - /* Truncate the output database to 0 pages in size. This is done by - ** opening a new, empty, temp db, then using the backup API to clobber + /* Truncate the output database to 0 pages in size. This is done by + ** opening a new, empty, temp db, then using the backup API to clobber ** any existing output db with a copy of it. */ if( p->errCode==SQLITE_OK ){ sqlite3 *db2 = 0; @@ -19363,7 +19369,7 @@ static void recoverTransferSettings(sqlite3_recover *p){ /* ** This function is a no-op if recover handle p already contains an error ** (if p->errCode!=SQLITE_OK). A copy of the error code is returned in -** this case. +** this case. ** ** Otherwise, an attempt is made to open the output database, attach ** and create the schema of the temporary database used to store @@ -19408,7 +19414,7 @@ static int recoverOpenOutput(sqlite3_recover *p){ for(ii=0; p->errCode==SQLITE_OK && ii<(int)(sizeof(aFunc)/sizeof(aFunc[0])); ii++){ - p->errCode = sqlite3_create_function(db, aFunc[ii].zName, + p->errCode = sqlite3_create_function(db, aFunc[ii].zName, aFunc[ii].nArg, SQLITE_UTF8, (void*)p, aFunc[ii].xFunc, 0, 0 ); } @@ -19419,7 +19425,7 @@ static int recoverOpenOutput(sqlite3_recover *p){ /* ** Attach the auxiliary database 'recovery' to the output database handle. -** This temporary database is used during the recovery process and then +** This temporary database is used during the recovery process and then ** discarded. */ static void recoverOpenRecovery(sqlite3_recover *p){ @@ -19427,7 +19433,7 @@ static void recoverOpenRecovery(sqlite3_recover *p){ recoverExec(p, p->dbOut, zSql); recoverExec(p, p->dbOut, "PRAGMA writable_schema = 1;" - "CREATE TABLE recovery.map(pgno INTEGER PRIMARY KEY, parent INT);" + "CREATE TABLE recovery.map(pgno INTEGER PRIMARY KEY, parent INT);" "CREATE TABLE recovery.schema(type, name, tbl_name, rootpage, sql);" ); sqlite3_free(zSql); @@ -19444,15 +19450,15 @@ static void recoverOpenRecovery(sqlite3_recover *p){ ** store the schema in memory. The new RecoverTable object is linked into ** the list at sqlite3_recover.pTblList. ** -** Parameter iRoot must be the root page of table zName in the INPUT +** Parameter iRoot must be the root page of table zName in the INPUT ** database. */ static void recoverAddTable( - sqlite3_recover *p, + sqlite3_recover *p, const char *zName, /* Name of table created in output db */ i64 iRoot /* Root page of same table in INPUT db */ ){ - sqlite3_stmt *pStmt = recoverPreparePrintf(p, p->dbOut, + sqlite3_stmt *pStmt = recoverPreparePrintf(p, p->dbOut, "PRAGMA table_xinfo(%Q)", zName ); @@ -19553,7 +19559,7 @@ static void recoverAddTable( ** Additionally, records are added to the sqlite_schema table of the ** output database for any VIRTUAL tables. The CREATE VIRTUAL TABLE ** records are written directly to sqlite_schema, not actually executed. -** If the handle is in SQL callback mode, then callbacks are invoked +** If the handle is in SQL callback mode, then callbacks are invoked ** with equivalent SQL statements. */ static int recoverWriteSchema1(sqlite3_recover *p){ @@ -19678,7 +19684,7 @@ static int recoverWriteSchema2(sqlite3_recover *p){ ** INSERT INTO (a, c, d) VALUES (?1, ?2, ?3); ** ** In this case even though 4 values were extracted from the input db, -** only 3 are written to the output, as the generated STORED column +** only 3 are written to the output, as the generated STORED column ** cannot be written. ** ** If the recover handle is in SQL callback mode, then the SQL statement @@ -19686,7 +19692,7 @@ static int recoverWriteSchema2(sqlite3_recover *p){ ** a single text value - itself an SQL statement similar to the above, ** except with SQL literals in place of the variables. For example: ** -** SELECT 'INSERT INTO (a, c, d) VALUES (' +** SELECT 'INSERT INTO (a, c, d) VALUES (' ** || quote(?1) || ', ' ** || quote(?2) || ', ' ** || quote(?3) || ')'; @@ -19695,7 +19701,7 @@ static int recoverWriteSchema2(sqlite3_recover *p){ ** free the statement handle using sqlite3_finalize(). */ static sqlite3_stmt *recoverInsertStmt( - sqlite3_recover *p, + sqlite3_recover *p, RecoverTable *pTab, int nField ){ @@ -19735,7 +19741,7 @@ static sqlite3_stmt *recoverInsertStmt( zSql = recoverMPrintf(p, "%z%s%Q", zSql, zSep, pTab->aCol[ii].zCol); if( bSql ){ - zBind = recoverMPrintf(p, + zBind = recoverMPrintf(p, "%z%sescape_crlf(quote(?%d))", zBind, zSqlSep, pTab->aCol[ii].iBind ); zSqlSep = "||', '||"; @@ -19747,7 +19753,7 @@ static sqlite3_stmt *recoverInsertStmt( } if( bSql ){ - zFinal = recoverMPrintf(p, "SELECT %Q || ') VALUES (' || %s || ')'", + zFinal = recoverMPrintf(p, "SELECT %Q || ') VALUES (' || %s || ')'", zSql, zBind ); }else{ @@ -19758,7 +19764,7 @@ static sqlite3_stmt *recoverInsertStmt( sqlite3_free(zSql); sqlite3_free(zBind); sqlite3_free(zFinal); - + return pRet; } @@ -19775,12 +19781,12 @@ static RecoverTable *recoverFindTable(sqlite3_recover *p, u32 iRoot){ } /* -** This function attempts to create a lost and found table within the +** This function attempts to create a lost and found table within the ** output db. If successful, it returns a pointer to a buffer containing ** the name of the new table. It is the responsibility of the caller to ** eventually free this buffer using sqlite3_free(). ** -** If an error occurs, NULL is returned and an error code and error +** If an error occurs, NULL is returned and an error code and error ** message left in the recover handle. */ static char *recoverLostAndFoundCreate( @@ -19887,11 +19893,11 @@ static sqlite3_stmt *recoverLostAndFoundInsert( ** to identify the root page of the tree that page iPg belonged to. ** If successful, it sets output variable (*piRoot) to the page number ** of the root page and returns SQLITE_OK. Otherwise, if an error occurs, -** an SQLite error code is returned and the final value of *piRoot +** an SQLite error code is returned and the final value of *piRoot ** undefined. */ static int recoverLostAndFoundFindRoot( - sqlite3_recover *p, + sqlite3_recover *p, i64 iPg, i64 *piRoot ){ @@ -19997,12 +20003,12 @@ static void recoverLostAndFoundOnePage(sqlite3_recover *p, i64 iPage){ } /* -** Perform one step (sqlite3_recover_step()) of work for the connection +** Perform one step (sqlite3_recover_step()) of work for the connection ** passed as the only argument, which is guaranteed to be in -** RECOVER_STATE_LOSTANDFOUND3 state - during which the lost-and-found -** table of the output database is populated with recovered data that can +** RECOVER_STATE_LOSTANDFOUND3 state - during which the lost-and-found +** table of the output database is populated with recovered data that can ** not be assigned to any recovered schema object. -*/ +*/ static int recoverLostAndFound3Step(sqlite3_recover *p){ RecoverStateLAF *pLaf = &p->laf; if( p->errCode==SQLITE_OK ){ @@ -20027,11 +20033,11 @@ static int recoverLostAndFound3Step(sqlite3_recover *p){ } /* -** Initialize resources required in RECOVER_STATE_LOSTANDFOUND3 -** state - during which the lost-and-found table of the output database -** is populated with recovered data that can not be assigned to any +** Initialize resources required in RECOVER_STATE_LOSTANDFOUND3 +** state - during which the lost-and-found table of the output database +** is populated with recovered data that can not be assigned to any ** recovered schema object. -*/ +*/ static void recoverLostAndFound3Init(sqlite3_recover *p){ RecoverStateLAF *pLaf = &p->laf; @@ -20055,7 +20061,7 @@ static void recoverLostAndFound3Init(sqlite3_recover *p){ "SELECT -1, -1, -1" ); - pLaf->apVal = (sqlite3_value**)recoverMalloc(p, + pLaf->apVal = (sqlite3_value**)recoverMalloc(p, pLaf->nMaxField*sizeof(sqlite3_value*) ); } @@ -20065,7 +20071,7 @@ static void recoverLostAndFound3Init(sqlite3_recover *p){ ** Initialize resources required in RECOVER_STATE_WRITING state - during which ** tables recovered from the schema of the input database are populated with ** recovered data. -*/ +*/ static int recoverWriteDataInit(sqlite3_recover *p){ RecoverStateW1 *p1 = &p->w1; RecoverTable *pTbl = 0; @@ -20090,7 +20096,7 @@ static int recoverWriteDataInit(sqlite3_recover *p){ " WHERE type='table' AND (sql NOT LIKE 'create virtual%')" " ORDER BY (tbl_name='sqlite_sequence') ASC" ); - p1->pSel = recoverPrepare(p, p->dbOut, + p1->pSel = recoverPrepare(p, p->dbOut, "WITH RECURSIVE pages(page) AS (" " SELECT ?1" " UNION" @@ -20107,7 +20113,7 @@ static int recoverWriteDataInit(sqlite3_recover *p){ } /* -** Clean up resources allocated by recoverWriteDataInit() (stuff in +** Clean up resources allocated by recoverWriteDataInit() (stuff in ** sqlite3_recover.w1). */ static void recoverWriteDataCleanup(sqlite3_recover *p){ @@ -20124,11 +20130,11 @@ static void recoverWriteDataCleanup(sqlite3_recover *p){ } /* -** Perform one step (sqlite3_recover_step()) of work for the connection +** Perform one step (sqlite3_recover_step()) of work for the connection ** passed as the only argument, which is guaranteed to be in ** RECOVER_STATE_WRITING state - during which tables recovered from the ** schema of the input database are populated with recovered data. -*/ +*/ static int recoverWriteDataStep(sqlite3_recover *p){ RecoverStateW1 *p1 = &p->w1; sqlite3_stmt *pSel = p1->pSel; @@ -20156,7 +20162,7 @@ static int recoverWriteDataStep(sqlite3_recover *p){ recoverSqlCallback(p, "DELETE FROM sqlite_sequence"); } - /* Bind the root page of this table within the original database to + /* Bind the root page of this table within the original database to ** SELECT statement p1->pSel. The SELECT statement will then iterate ** through cells that look like they belong to table pTab. */ sqlite3_bind_int64(pSel, 1, iRoot); @@ -20254,7 +20260,7 @@ static int recoverWriteDataStep(sqlite3_recover *p){ ** Initialize resources required by sqlite3_recover_step() in ** RECOVER_STATE_LOSTANDFOUND1 state - during which the set of pages not ** already allocated to a recovered schema element is determined. -*/ +*/ static void recoverLostAndFound1Init(sqlite3_recover *p){ RecoverStateLAF *pLaf = &p->laf; sqlite3_stmt *pStmt = 0; @@ -20302,11 +20308,11 @@ static void recoverLostAndFound1Init(sqlite3_recover *p){ } /* -** Perform one step (sqlite3_recover_step()) of work for the connection +** Perform one step (sqlite3_recover_step()) of work for the connection ** passed as the only argument, which is guaranteed to be in ** RECOVER_STATE_LOSTANDFOUND1 state - during which the set of pages not ** already allocated to a recovered schema element is determined. -*/ +*/ static int recoverLostAndFound1Step(sqlite3_recover *p){ RecoverStateLAF *pLaf = &p->laf; int rc = p->errCode; @@ -20325,10 +20331,10 @@ static int recoverLostAndFound1Step(sqlite3_recover *p){ } /* -** Initialize resources required by RECOVER_STATE_LOSTANDFOUND2 +** Initialize resources required by RECOVER_STATE_LOSTANDFOUND2 ** state - during which the pages identified in RECOVER_STATE_LOSTANDFOUND1 ** are sorted into sets that likely belonged to the same database tree. -*/ +*/ static void recoverLostAndFound2Init(sqlite3_recover *p){ RecoverStateLAF *pLaf = &p->laf; @@ -20354,12 +20360,12 @@ static void recoverLostAndFound2Init(sqlite3_recover *p){ } /* -** Perform one step (sqlite3_recover_step()) of work for the connection +** Perform one step (sqlite3_recover_step()) of work for the connection ** passed as the only argument, which is guaranteed to be in -** RECOVER_STATE_LOSTANDFOUND2 state - during which the pages identified -** in RECOVER_STATE_LOSTANDFOUND1 are sorted into sets that likely belonged +** RECOVER_STATE_LOSTANDFOUND2 state - during which the pages identified +** in RECOVER_STATE_LOSTANDFOUND1 are sorted into sets that likely belonged ** to the same database tree. -*/ +*/ static int recoverLostAndFound2Step(sqlite3_recover *p){ RecoverStateLAF *pLaf = &p->laf; if( p->errCode==SQLITE_OK ){ @@ -20368,7 +20374,7 @@ static int recoverLostAndFound2Step(sqlite3_recover *p){ i64 iChild = sqlite3_column_int(pLaf->pAllAndParent, 1); if( recoverBitmapQuery(pLaf->pUsed, iChild)==0 ){ sqlite3_bind_int64(pLaf->pMapInsert, 1, iChild); - sqlite3_bind_value(pLaf->pMapInsert, 2, + sqlite3_bind_value(pLaf->pMapInsert, 2, sqlite3_column_value(pLaf->pAllAndParent, 0) ); sqlite3_step(pLaf->pMapInsert); @@ -20437,7 +20443,7 @@ static void recoverFinalCleanup(sqlite3_recover *p){ { #ifndef NDEBUG - int res = + int res = #endif sqlite3_close(p->dbOut); assert( res==SQLITE_OK ); @@ -20446,7 +20452,7 @@ static void recoverFinalCleanup(sqlite3_recover *p){ } /* -** Decode and return an unsigned 16-bit big-endian integer value from +** Decode and return an unsigned 16-bit big-endian integer value from ** buffer a[]. */ static u32 recoverGetU16(const u8 *a){ @@ -20454,7 +20460,7 @@ static u32 recoverGetU16(const u8 *a){ } /* -** Decode and return an unsigned 32-bit big-endian integer value from +** Decode and return an unsigned 32-bit big-endian integer value from ** buffer a[]. */ static u32 recoverGetU32(const u8 *a){ @@ -20479,8 +20485,8 @@ static int recoverGetVarint(const u8 *a, i64 *pVal){ /* ** The second argument points to a buffer n bytes in size. If this buffer -** or a prefix thereof appears to contain a well-formed SQLite b-tree page, -** return the page-size in bytes. Otherwise, if the buffer does not +** or a prefix thereof appears to contain a well-formed SQLite b-tree page, +** return the page-size in bytes. Otherwise, if the buffer does not ** appear to contain a well-formed b-tree page, return 0. */ static int recoverIsValidPage(u8 *aTmp, const u8 *a, int n){ @@ -20641,8 +20647,8 @@ static void recoverPutU32(u8 *a, u32 v){ } /* -** Detect the page-size of the database opened by file-handle pFd by -** searching the first part of the file for a well-formed SQLite b-tree +** Detect the page-size of the database opened by file-handle pFd by +** searching the first part of the file for a well-formed SQLite b-tree ** page. If parameter nReserve is non-zero, then as well as searching for ** a b-tree page with zero reserved bytes, this function searches for one ** with nReserve reserved bytes at the end of it. @@ -20735,15 +20741,15 @@ static int recoverVfsRead(sqlite3_file *pFd, void *aBuf, int nByte, i64 iOff){ ** + the wal-mode flags (16-bits at offset 18) ** ** We also try to preserve the auto-vacuum, incr-value, user-version - ** and application-id fields - all 32 bit quantities at offsets + ** and application-id fields - all 32 bit quantities at offsets ** 52, 60, 64 and 68. All other fields are set to known good values. ** - ** Byte offset 105 should also contain the page-size as a 16-bit + ** Byte offset 105 should also contain the page-size as a 16-bit ** integer. */ const int aPreserve[] = {32, 36, 52, 60, 64, 68}; u8 aHdr[108] = { - 0x53, 0x51, 0x4c, 0x69, 0x74, 0x65, 0x20, 0x66, + 0x53, 0x51, 0x4c, 0x69, 0x74, 0x65, 0x20, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x20, 0x33, 0x00, 0xFF, 0xFF, 0x01, 0x01, 0x00, 0x40, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, @@ -20835,7 +20841,7 @@ static int recoverVfsRead(sqlite3_file *pFd, void *aBuf, int nByte, i64 iOff){ }else{ \ rc = code; \ } \ - return rc; + return rc; /* ** Methods of the wrapper VFS. All methods except for xRead() and xClose() @@ -20923,9 +20929,9 @@ static int recoverVfsShmUnmap(sqlite3_file *pFd, int deleteFlag){ } static int recoverVfsFetch( - sqlite3_file *pFd, - sqlite3_int64 iOff, - int iAmt, + sqlite3_file *pFd, + sqlite3_int64 iOff, + int iAmt, void **pp ){ (void)pFd; @@ -20994,7 +21000,7 @@ static void recoverStep(sqlite3_recover *p){ recoverEnterMutex(); recoverInstallWrapper(p); - /* Open the output database. And register required virtual tables and + /* Open the output database. And register required virtual tables and ** user functions with the new handle. */ recoverOpenOutput(p); @@ -21016,7 +21022,7 @@ static void recoverStep(sqlite3_recover *p){ recoverWriteSchema1(p); p->eState = RECOVER_STATE_WRITING; break; - + case RECOVER_STATE_WRITING: { if( p->w1.pTbls==0 ){ recoverWriteDataInit(p); @@ -21101,8 +21107,8 @@ static void recoverStep(sqlite3_recover *p){ ** sqlite3_recover_run(). */ sqlite3_recover *recoverInit( - sqlite3* db, - const char *zDb, + sqlite3* db, + const char *zDb, const char *zUri, /* Output URI for _recover_init() */ int (*xSql)(void*, const char*),/* SQL callback for _recover_init_sql() */ void *pSqlCtx /* Context arg for _recover_init_sql() */ @@ -21139,8 +21145,8 @@ sqlite3_recover *recoverInit( ** the recovered data. */ sqlite3_recover *sqlite3_recover_init( - sqlite3* db, - const char *zDb, + sqlite3* db, + const char *zDb, const char *zUri ){ return recoverInit(db, zDb, zUri, 0, 0); @@ -21151,8 +21157,8 @@ sqlite3_recover *sqlite3_recover_init( ** form of SQL statements via a callback. */ sqlite3_recover *sqlite3_recover_init_sql( - sqlite3* db, - const char *zDb, + sqlite3* db, + const char *zDb, int (*xSql)(void*, const char*), void *pSqlCtx ){ @@ -21763,7 +21769,7 @@ static void setCrlfMode(ShellState *p){ } #else UNUSED_PARAMETER(p); -#endif +#endif } /* @@ -23241,7 +23247,7 @@ static int display_stats( iHiwtr = iCur = -1; sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_USED, &iCur, &iHiwtr, bReset); - sqlite3_fprintf(out, + sqlite3_fprintf(out, "Lookaside Slots Used: %d (max %d)\n", iCur, iHiwtr); sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_HIT, &iCur, &iHiwtr, bReset); @@ -26029,7 +26035,7 @@ static char *SQLITE_CDECL csv_read_one_field(ImportCtx *p){ break; } if( pc==cQuote && c!='\r' ){ - sqlite3_fprintf(stderr,"%s:%d: unescaped %c character\n", + sqlite3_fprintf(stderr,"%s:%d: unescaped %c character\n", p->zFile, p->nLine, cQuote); } if( c==EOF ){ @@ -26997,7 +27003,7 @@ static void shellPreparePrintf( } } -/* +/* ** Finalize the prepared statement created using shellPreparePrintf(). */ static void shellFinalize( @@ -28169,13 +28175,13 @@ static int faultsim_callback(int iArg){ if( faultsim_state.iCnt ){ if( faultsim_state.iCnt>0 ) faultsim_state.iCnt--; if( faultsim_state.eVerbose>=2 ){ - sqlite3_fprintf(stdout, + sqlite3_fprintf(stdout, "FAULT-SIM id=%d no-fault (cnt=%d)\n", iArg, faultsim_state.iCnt); } return SQLITE_OK; } if( faultsim_state.eVerbose>=1 ){ - sqlite3_fprintf(stdout, + sqlite3_fprintf(stdout, "FAULT-SIM id=%d returns %d\n", iArg, faultsim_state.iErr); } faultsim_state.iCnt = faultsim_state.iInterval; @@ -29144,7 +29150,7 @@ static int do_meta_command(char *zLine, ShellState *p){ sqlite3 *dbCols = 0; char *zRenames = 0; char *zColDefs; - zCreate = sqlite3_mprintf("CREATE TABLE \"%w\".\"%w\"", + zCreate = sqlite3_mprintf("CREATE TABLE \"%w\".\"%w\"", zSchema ? zSchema : "main", zTable); while( xRead(&sCtx) ){ zAutoColumn(sCtx.z, &dbCols, 0); @@ -29221,7 +29227,7 @@ static int do_meta_command(char *zLine, ShellState *p){ shell_out_of_memory(); } if( zSchema ){ - sqlite3_snprintf(nByte, zSql, "INSERT INTO \"%w\".\"%w\" VALUES(?", + sqlite3_snprintf(nByte, zSql, "INSERT INTO \"%w\".\"%w\" VALUES(?", zSchema, zTable); }else{ sqlite3_snprintf(nByte, zSql, "INSERT INTO \"%w\" VALUES(?", zTable); @@ -29849,7 +29855,7 @@ static int do_meta_command(char *zLine, ShellState *p){ }else if( c=='o' && cli_strcmp(z,"-w")==0 ){ eMode = 'w'; /* Web browser */ }else{ - sqlite3_fprintf(p->out, + sqlite3_fprintf(p->out, "ERROR: unknown option: \"%s\". Usage:\n", azArg[i]); showHelp(p->out, azArg[0]); rc = 1; @@ -31220,7 +31226,7 @@ static int do_meta_command(char *zLine, ShellState *p){ /* Special processing for .testctrl opt MASK ... ** Each MASK argument can be one of: ** - ** +LABEL Enable the named optimization + ** +LABEL Enable the named optimization ** ** -LABEL Disable the named optimization ** @@ -31850,7 +31856,6 @@ static QuickScanState quickscan(char *zLine, QuickScanState qss, char cWait = (char)qss; /* intentional narrowing loss */ if( cWait==0 ){ PlainScan: - assert( cWait==0 ); while( (cin = *zLine++)!=0 ){ if( IsSpace(cin) ) continue; @@ -31902,7 +31907,6 @@ static QuickScanState quickscan(char *zLine, QuickScanState qss, if( *zLine != '/' ) continue; ++zLine; - cWait = 0; CONTINUE_PROMPT_AWAITC(pst, 0); qss = QSS_SETV(qss, 0); goto PlainScan; @@ -31914,7 +31918,6 @@ static QuickScanState quickscan(char *zLine, QuickScanState qss, } deliberate_fall_through; case ']': - cWait = 0; CONTINUE_PROMPT_AWAITC(pst, 0); qss = QSS_SETV(qss, 0); goto PlainScan; @@ -31973,7 +31976,7 @@ static int line_is_complete(char *zSql, int nSql){ ** 2. The second line of input is "BEGIN TRANSACTION;", ** 3. The database is empty, and ** 4. The shell is not running in --safe mode. -** +** ** The implementation uses the ShellState.eRestoreState to maintain state: ** ** 0: Have not seen any SQL. @@ -32000,7 +32003,7 @@ static int doAutoDetectRestore(ShellState *p, const char *zSql){ } break; }; - + case 1: { int bIsDump = 0; const char *zExpect = "BEGIN TRANSACTION;"; @@ -32009,7 +32012,7 @@ static int doAutoDetectRestore(ShellState *p, const char *zSql){ /* Now check if the database is empty. */ const char *zQuery = "SELECT 1 FROM sqlite_schema LIMIT 1"; sqlite3_stmt *pStmt = 0; - + bIsDump = 1; shellPrepare(p->db, &rc, zQuery, &pStmt); if( rc==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){ @@ -32030,7 +32033,7 @@ static int doAutoDetectRestore(ShellState *p, const char *zSql){ } break; } - + default: { if( sqlite3_get_autocommit(p->db) ){ if( (p->eRestoreState & 2) ){ diff --git a/src/sqlite3.c b/src/sqlite3.c index 2886d04..099c548 100644 --- a/src/sqlite3.c +++ b/src/sqlite3.c @@ -1,6 +1,6 @@ /****************************************************************************** ** This file is an amalgamation of many separate C source files from SQLite -** version 3.47.0. By combining all the individual C code files into this +** version 3.47.1. By combining all the individual C code files into this ** single large file, the entire code can be compiled as a single translation ** unit. This allows many compilers to do optimizations that would not be ** possible if the files were compiled separately. Performance improvements @@ -18,7 +18,7 @@ ** separate file. This file contains only code for the core SQLite library. ** ** The content in this amalgamation comes from Fossil check-in -** 03a9703e27c44437c39363d0baf82db4ebc9. +** b95d11e958643b969c47a8e5857f3793b9e6. */ #define SQLITE_CORE 1 #define SQLITE_AMALGAMATION 1 @@ -462,9 +462,9 @@ extern "C" { ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ -#define SQLITE_VERSION "3.47.0" -#define SQLITE_VERSION_NUMBER 3047000 -#define SQLITE_SOURCE_ID "2024-10-21 16:30:22 03a9703e27c44437c39363d0baf82db4ebc94538a0f28411c85dda156f82636e" +#define SQLITE_VERSION "3.47.1" +#define SQLITE_VERSION_NUMBER 3047001 +#define SQLITE_SOURCE_ID "2024-11-25 12:07:48 b95d11e958643b969c47a8e5857f3793b9e69700b8f1469371386369a26e577e" /* ** CAPI3REF: Run-Time Library Version Numbers @@ -968,6 +968,13 @@ SQLITE_API int sqlite3_exec( ** filesystem supports doing multiple write operations atomically when those ** write operations are bracketed by [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] and ** [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE]. +** +** The SQLITE_IOCAP_SUBPAGE_READ property means that it is ok to read +** from the database file in amounts that are not a multiple of the +** page size and that do not begin at a page boundary. Without this +** property, SQLite is careful to only do full-page reads and write +** on aligned pages, with the one exception that it will do a sub-page +** read of the first page to access the database header. */ #define SQLITE_IOCAP_ATOMIC 0x00000001 #define SQLITE_IOCAP_ATOMIC512 0x00000002 @@ -984,6 +991,7 @@ SQLITE_API int sqlite3_exec( #define SQLITE_IOCAP_POWERSAFE_OVERWRITE 0x00001000 #define SQLITE_IOCAP_IMMUTABLE 0x00002000 #define SQLITE_IOCAP_BATCH_ATOMIC 0x00004000 +#define SQLITE_IOCAP_SUBPAGE_READ 0x00008000 /* ** CAPI3REF: File Locking Levels @@ -1130,6 +1138,7 @@ struct sqlite3_file { **
  • [SQLITE_IOCAP_POWERSAFE_OVERWRITE] **
  • [SQLITE_IOCAP_IMMUTABLE] **
  • [SQLITE_IOCAP_BATCH_ATOMIC] +**
  • [SQLITE_IOCAP_SUBPAGE_READ] ** ** ** The SQLITE_IOCAP_ATOMIC property means that all writes of @@ -32298,6 +32307,7 @@ SQLITE_PRIVATE void sqlite3RecordErrorOffsetOfExpr(sqlite3 *db, const Expr *pExp pExpr = pExpr->pLeft; } if( pExpr==0 ) return; + if( ExprHasProperty(pExpr, EP_FromDDL) ) return; db->errByteOffset = pExpr->w.iOfst; } @@ -42591,6 +42601,7 @@ static void setDeviceCharacteristics(unixFile *pFd){ if( pFd->ctrlFlags & UNIXFILE_PSOW ){ pFd->deviceCharacteristics |= SQLITE_IOCAP_POWERSAFE_OVERWRITE; } + pFd->deviceCharacteristics |= SQLITE_IOCAP_SUBPAGE_READ; pFd->sectorSize = SQLITE_DEFAULT_SECTOR_SIZE; } @@ -50391,7 +50402,7 @@ static int winSectorSize(sqlite3_file *id){ */ static int winDeviceCharacteristics(sqlite3_file *id){ winFile *p = (winFile*)id; - return SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN | + return SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN | SQLITE_IOCAP_SUBPAGE_READ | ((p->ctrlFlags & WINFILE_PSOW)?SQLITE_IOCAP_POWERSAFE_OVERWRITE:0); } @@ -51779,7 +51790,7 @@ static int winOpen( int rc = SQLITE_OK; /* Function Return Code */ #if !defined(NDEBUG) || SQLITE_OS_WINCE - int eType = flags&0xFFFFFF00; /* Type of file to open */ + int eType = flags&0x0FFF00; /* Type of file to open */ #endif int isExclusive = (flags & SQLITE_OPEN_EXCLUSIVE); @@ -57999,18 +58010,26 @@ static const unsigned char aJournalMagic[] = { ** Return true if page pgno can be read directly from the database file ** by the b-tree layer. This is the case if: ** -** * the database file is open, -** * there are no dirty pages in the cache, and -** * the desired page is not currently in the wal file. +** (1) the database file is open +** (2) the VFS for the database is able to do unaligned sub-page reads +** (3) there are no dirty pages in the cache, and +** (4) the desired page is not currently in the wal file. */ SQLITE_PRIVATE int sqlite3PagerDirectReadOk(Pager *pPager, Pgno pgno){ - if( pPager->fd->pMethods==0 ) return 0; - if( sqlite3PCacheIsDirty(pPager->pPCache) ) return 0; + assert( pPager!=0 ); + assert( pPager->fd!=0 ); + if( pPager->fd->pMethods==0 ) return 0; /* Case (1) */ + assert( pPager->fd->pMethods->xDeviceCharacteristics!=0 ); + if( (pPager->fd->pMethods->xDeviceCharacteristics(pPager->fd) + & SQLITE_IOCAP_SUBPAGE_READ)==0 ){ + return 0; /* Case (2) */ + } + if( sqlite3PCacheIsDirty(pPager->pPCache) ) return 0; /* Failed (3) */ #ifndef SQLITE_OMIT_WAL if( pPager->pWal ){ u32 iRead = 0; (void)sqlite3WalFindFrame(pPager->pWal, pgno, &iRead); - return iRead==0; + return iRead==0; /* Condition (4) */ } #endif return 1; @@ -158939,6 +158958,7 @@ static Expr *removeUnindexableInClauseTerms( pNew->pLeft->x.pList = pLhs; } pSelect->pEList = pRhs; + pSelect->selId = ++pParse->nSelect; /* Req'd for SubrtnSig validity */ if( pLhs && pLhs->nExpr==1 ){ /* Take care here not to generate a TK_VECTOR containing only a ** single value. Since the parser never creates such a vector, some @@ -189798,10 +189818,15 @@ static int fts3PoslistPhraseMerge( if( *p1==POS_COLUMN ){ p1++; p1 += fts3GetVarint32(p1, &iCol1); + /* iCol1==0 indicates corruption. Column 0 does not have a POS_COLUMN + ** entry, so this is actually end-of-doclist. */ + if( iCol1==0 ) return 0; } if( *p2==POS_COLUMN ){ p2++; p2 += fts3GetVarint32(p2, &iCol2); + /* As above, iCol2==0 indicates corruption. */ + if( iCol2==0 ) return 0; } while( 1 ){ @@ -192972,7 +192997,7 @@ static int fts3EvalNearTest(Fts3Expr *pExpr, int *pRc){ nTmp += p->pRight->pPhrase->doclist.nList; } nTmp += p->pPhrase->doclist.nList; - aTmp = sqlite3_malloc64(nTmp*2); + aTmp = sqlite3_malloc64(nTmp*2 + FTS3_VARINT_MAX); if( !aTmp ){ *pRc = SQLITE_NOMEM; res = 0; @@ -194525,10 +194550,11 @@ static int getNextString( Fts3PhraseToken *pToken; p = fts3ReallocOrFree(p, nSpace + ii*sizeof(Fts3PhraseToken)); - if( !p ) goto no_mem; - zTemp = fts3ReallocOrFree(zTemp, nTemp + nByte); - if( !zTemp ) goto no_mem; + if( !zTemp || !p ){ + rc = SQLITE_NOMEM; + goto getnextstring_out; + } assert( nToken==ii ); pToken = &((Fts3Phrase *)(&p[1]))->aToken[ii]; @@ -194543,9 +194569,6 @@ static int getNextString( nToken = ii+1; } } - - pModule->xClose(pCursor); - pCursor = 0; } if( rc==SQLITE_DONE ){ @@ -194553,7 +194576,10 @@ static int getNextString( char *zBuf = 0; p = fts3ReallocOrFree(p, nSpace + nToken*sizeof(Fts3PhraseToken) + nTemp); - if( !p ) goto no_mem; + if( !p ){ + rc = SQLITE_NOMEM; + goto getnextstring_out; + } memset(p, 0, (char *)&(((Fts3Phrase *)&p[1])->aToken[0])-(char *)p); p->eType = FTSQUERY_PHRASE; p->pPhrase = (Fts3Phrase *)&p[1]; @@ -194561,11 +194587,9 @@ static int getNextString( p->pPhrase->nToken = nToken; zBuf = (char *)&p->pPhrase->aToken[nToken]; + assert( nTemp==0 || zTemp ); if( zTemp ){ memcpy(zBuf, zTemp, nTemp); - sqlite3_free(zTemp); - }else{ - assert( nTemp==0 ); } for(jj=0; jjpPhrase->nToken; jj++){ @@ -194575,17 +194599,17 @@ static int getNextString( rc = SQLITE_OK; } - *ppExpr = p; - return rc; -no_mem: - + getnextstring_out: if( pCursor ){ pModule->xClose(pCursor); } sqlite3_free(zTemp); - sqlite3_free(p); - *ppExpr = 0; - return SQLITE_NOMEM; + if( rc!=SQLITE_OK ){ + sqlite3_free(p); + p = 0; + } + *ppExpr = p; + return rc; } /* @@ -232806,7 +232830,27 @@ SQLITE_API int sqlite3session_config(int op, void *pArg){ /************** End of sqlite3session.c **************************************/ /************** Begin file fts5.c ********************************************/ - +/* +** This, the "fts5.c" source file, is a composite file that is itself +** assembled from the following files: +** +** fts5.h +** fts5Int.h +** fts5parse.h <--- Generated from fts5parse.y by Lemon +** fts5parse.c <--- Generated from fts5parse.y by Lemon +** fts5_aux.c +** fts5_buffer.c +** fts5_config.c +** fts5_expr.c +** fts5_hash.c +** fts5_index.c +** fts5_main.c +** fts5_storage.c +** fts5_tokenize.c +** fts5_unicode2.c +** fts5_varint.c +** fts5_vocab.c +*/ #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS5) #if !defined(NDEBUG) && !defined(SQLITE_DEBUG) @@ -232816,6 +232860,12 @@ SQLITE_API int sqlite3session_config(int op, void *pArg){ # undef NDEBUG #endif +#ifdef HAVE_STDINT_H +/* #include */ +#endif +#ifdef HAVE_INTTYPES_H +/* #include */ +#endif /* ** 2014 May 31 ** @@ -254888,7 +254938,7 @@ static void fts5SourceIdFunc( ){ assert( nArg==0 ); UNUSED_PARAM2(nArg, apUnused); - sqlite3_result_text(pCtx, "fts5: 2024-10-21 16:30:22 03a9703e27c44437c39363d0baf82db4ebc94538a0f28411c85dda156f82636e", -1, SQLITE_TRANSIENT); + sqlite3_result_text(pCtx, "fts5: 2024-11-25 12:07:48 b95d11e958643b969c47a8e5857f3793b9e69700b8f1469371386369a26e577e", -1, SQLITE_TRANSIENT); } /* @@ -260079,7 +260129,7 @@ static int sqlite3Fts5VocabInit(Fts5Global *pGlobal, sqlite3 *db){ } - +/* Here ends the fts5.c composite file. */ #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS5) */ /************** End of fts5.c ************************************************/ diff --git a/src/sqlite3.h b/src/sqlite3.h index eaffd1e..dbecc3f 100644 --- a/src/sqlite3.h +++ b/src/sqlite3.h @@ -146,9 +146,9 @@ extern "C" { ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ -#define SQLITE_VERSION "3.47.0" -#define SQLITE_VERSION_NUMBER 3047000 -#define SQLITE_SOURCE_ID "2024-10-21 16:30:22 03a9703e27c44437c39363d0baf82db4ebc94538a0f28411c85dda156f82636e" +#define SQLITE_VERSION "3.47.1" +#define SQLITE_VERSION_NUMBER 3047001 +#define SQLITE_SOURCE_ID "2024-11-25 12:07:48 b95d11e958643b969c47a8e5857f3793b9e69700b8f1469371386369a26e577e" /* ** CAPI3REF: Run-Time Library Version Numbers @@ -652,6 +652,13 @@ SQLITE_API int sqlite3_exec( ** filesystem supports doing multiple write operations atomically when those ** write operations are bracketed by [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] and ** [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE]. +** +** The SQLITE_IOCAP_SUBPAGE_READ property means that it is ok to read +** from the database file in amounts that are not a multiple of the +** page size and that do not begin at a page boundary. Without this +** property, SQLite is careful to only do full-page reads and write +** on aligned pages, with the one exception that it will do a sub-page +** read of the first page to access the database header. */ #define SQLITE_IOCAP_ATOMIC 0x00000001 #define SQLITE_IOCAP_ATOMIC512 0x00000002 @@ -668,6 +675,7 @@ SQLITE_API int sqlite3_exec( #define SQLITE_IOCAP_POWERSAFE_OVERWRITE 0x00001000 #define SQLITE_IOCAP_IMMUTABLE 0x00002000 #define SQLITE_IOCAP_BATCH_ATOMIC 0x00004000 +#define SQLITE_IOCAP_SUBPAGE_READ 0x00008000 /* ** CAPI3REF: File Locking Levels @@ -814,6 +822,7 @@ struct sqlite3_file { **
  • [SQLITE_IOCAP_POWERSAFE_OVERWRITE] **
  • [SQLITE_IOCAP_IMMUTABLE] **
  • [SQLITE_IOCAP_BATCH_ATOMIC] +**
  • [SQLITE_IOCAP_SUBPAGE_READ] ** ** ** The SQLITE_IOCAP_ATOMIC property means that all writes of diff --git a/src/sqlite3mc_version.h b/src/sqlite3mc_version.h index aed03fd..d25f356 100644 --- a/src/sqlite3mc_version.h +++ b/src/sqlite3mc_version.h @@ -14,8 +14,8 @@ #define SQLITE3MC_VERSION_MAJOR 1 #define SQLITE3MC_VERSION_MINOR 9 -#define SQLITE3MC_VERSION_RELEASE 0 +#define SQLITE3MC_VERSION_RELEASE 1 #define SQLITE3MC_VERSION_SUBRELEASE 0 -#define SQLITE3MC_VERSION_STRING "SQLite3 Multiple Ciphers 1.9.0" +#define SQLITE3MC_VERSION_STRING "SQLite3 Multiple Ciphers 1.9.1" #endif /* SQLITE3MC_VERSION_H_ */ diff --git a/src/sqlite3patched.c b/src/sqlite3patched.c index 9397b4d..5edab51 100644 --- a/src/sqlite3patched.c +++ b/src/sqlite3patched.c @@ -1,6 +1,6 @@ /****************************************************************************** ** This file is an amalgamation of many separate C source files from SQLite -** version 3.47.0. By combining all the individual C code files into this +** version 3.47.1. By combining all the individual C code files into this ** single large file, the entire code can be compiled as a single translation ** unit. This allows many compilers to do optimizations that would not be ** possible if the files were compiled separately. Performance improvements @@ -18,7 +18,7 @@ ** separate file. This file contains only code for the core SQLite library. ** ** The content in this amalgamation comes from Fossil check-in -** 03a9703e27c44437c39363d0baf82db4ebc9. +** b95d11e958643b969c47a8e5857f3793b9e6. */ #define SQLITE_CORE 1 #define SQLITE_AMALGAMATION 1 @@ -462,9 +462,9 @@ extern "C" { ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ -#define SQLITE_VERSION "3.47.0" -#define SQLITE_VERSION_NUMBER 3047000 -#define SQLITE_SOURCE_ID "2024-10-21 16:30:22 03a9703e27c44437c39363d0baf82db4ebc94538a0f28411c85dda156f82636e" +#define SQLITE_VERSION "3.47.1" +#define SQLITE_VERSION_NUMBER 3047001 +#define SQLITE_SOURCE_ID "2024-11-25 12:07:48 b95d11e958643b969c47a8e5857f3793b9e69700b8f1469371386369a26e577e" /* ** CAPI3REF: Run-Time Library Version Numbers @@ -968,6 +968,13 @@ SQLITE_API int sqlite3_exec( ** filesystem supports doing multiple write operations atomically when those ** write operations are bracketed by [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] and ** [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE]. +** +** The SQLITE_IOCAP_SUBPAGE_READ property means that it is ok to read +** from the database file in amounts that are not a multiple of the +** page size and that do not begin at a page boundary. Without this +** property, SQLite is careful to only do full-page reads and write +** on aligned pages, with the one exception that it will do a sub-page +** read of the first page to access the database header. */ #define SQLITE_IOCAP_ATOMIC 0x00000001 #define SQLITE_IOCAP_ATOMIC512 0x00000002 @@ -984,6 +991,7 @@ SQLITE_API int sqlite3_exec( #define SQLITE_IOCAP_POWERSAFE_OVERWRITE 0x00001000 #define SQLITE_IOCAP_IMMUTABLE 0x00002000 #define SQLITE_IOCAP_BATCH_ATOMIC 0x00004000 +#define SQLITE_IOCAP_SUBPAGE_READ 0x00008000 /* ** CAPI3REF: File Locking Levels @@ -1130,6 +1138,7 @@ struct sqlite3_file { **
  • [SQLITE_IOCAP_POWERSAFE_OVERWRITE] **
  • [SQLITE_IOCAP_IMMUTABLE] **
  • [SQLITE_IOCAP_BATCH_ATOMIC] +**
  • [SQLITE_IOCAP_SUBPAGE_READ] ** ** ** The SQLITE_IOCAP_ATOMIC property means that all writes of @@ -11197,7 +11206,7 @@ SQLITE_API int sqlite3_deserialize( } /* End of the 'extern "C"' block */ #endif #endif /* SQLITE3_H */ - + /* Function prototypes of SQLite3 Multiple Ciphers */ SQLITE_PRIVATE int sqlite3mcCheckVfs(const char*); SQLITE_PRIVATE int sqlite3mcFileControlPragma(sqlite3*, const char*, int, void*); @@ -32316,6 +32325,7 @@ SQLITE_PRIVATE void sqlite3RecordErrorOffsetOfExpr(sqlite3 *db, const Expr *pExp pExpr = pExpr->pLeft; } if( pExpr==0 ) return; + if( ExprHasProperty(pExpr, EP_FromDDL) ) return; db->errByteOffset = pExpr->w.iOfst; } @@ -42613,6 +42623,7 @@ static void setDeviceCharacteristics(unixFile *pFd){ if( pFd->ctrlFlags & UNIXFILE_PSOW ){ pFd->deviceCharacteristics |= SQLITE_IOCAP_POWERSAFE_OVERWRITE; } + pFd->deviceCharacteristics |= SQLITE_IOCAP_SUBPAGE_READ; pFd->sectorSize = SQLITE_DEFAULT_SECTOR_SIZE; } @@ -50413,7 +50424,7 @@ static int winSectorSize(sqlite3_file *id){ */ static int winDeviceCharacteristics(sqlite3_file *id){ winFile *p = (winFile*)id; - return SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN | + return SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN | SQLITE_IOCAP_SUBPAGE_READ | ((p->ctrlFlags & WINFILE_PSOW)?SQLITE_IOCAP_POWERSAFE_OVERWRITE:0); } @@ -51801,7 +51812,7 @@ static int winOpen( int rc = SQLITE_OK; /* Function Return Code */ #if !defined(NDEBUG) || SQLITE_OS_WINCE - int eType = flags&0xFFFFFF00; /* Type of file to open */ + int eType = flags&0x0FFF00; /* Type of file to open */ #endif int isExclusive = (flags & SQLITE_OPEN_EXCLUSIVE); @@ -58021,19 +58032,27 @@ static const unsigned char aJournalMagic[] = { ** Return true if page pgno can be read directly from the database file ** by the b-tree layer. This is the case if: ** -** * the database file is open, -** * there are no dirty pages in the cache, and -** * the desired page is not currently in the wal file. +** (1) the database file is open +** (2) the VFS for the database is able to do unaligned sub-page reads +** (3) there are no dirty pages in the cache, and +** (4) the desired page is not currently in the wal file. */ SQLITE_PRIVATE int sqlite3PagerDirectReadOk(Pager *pPager, Pgno pgno){ - if( pPager->fd->pMethods==0 ) return 0; - if( sqlite3PCacheIsDirty(pPager->pPCache) ) return 0; + assert( pPager!=0 ); + assert( pPager->fd!=0 ); + if( pPager->fd->pMethods==0 ) return 0; /* Case (1) */ + assert( pPager->fd->pMethods->xDeviceCharacteristics!=0 ); + if( (pPager->fd->pMethods->xDeviceCharacteristics(pPager->fd) + & SQLITE_IOCAP_SUBPAGE_READ)==0 ){ + return 0; /* Case (2) */ + } + if( sqlite3PCacheIsDirty(pPager->pPCache) ) return 0; /* Failed (3) */ if( sqlite3mcPagerHasCodec(pPager) != 0 ) return 0; #ifndef SQLITE_OMIT_WAL if( pPager->pWal ){ u32 iRead = 0; (void)sqlite3WalFindFrame(pPager->pWal, pgno, &iRead); - return iRead==0; + return iRead==0; /* Condition (4) */ } #endif return 1; @@ -158973,6 +158992,7 @@ static Expr *removeUnindexableInClauseTerms( pNew->pLeft->x.pList = pLhs; } pSelect->pEList = pRhs; + pSelect->selId = ++pParse->nSelect; /* Req'd for SubrtnSig validity */ if( pLhs && pLhs->nExpr==1 ){ /* Take care here not to generate a TK_VECTOR containing only a ** single value. Since the parser never creates such a vector, some @@ -189840,10 +189860,15 @@ static int fts3PoslistPhraseMerge( if( *p1==POS_COLUMN ){ p1++; p1 += fts3GetVarint32(p1, &iCol1); + /* iCol1==0 indicates corruption. Column 0 does not have a POS_COLUMN + ** entry, so this is actually end-of-doclist. */ + if( iCol1==0 ) return 0; } if( *p2==POS_COLUMN ){ p2++; p2 += fts3GetVarint32(p2, &iCol2); + /* As above, iCol2==0 indicates corruption. */ + if( iCol2==0 ) return 0; } while( 1 ){ @@ -193014,7 +193039,7 @@ static int fts3EvalNearTest(Fts3Expr *pExpr, int *pRc){ nTmp += p->pRight->pPhrase->doclist.nList; } nTmp += p->pPhrase->doclist.nList; - aTmp = sqlite3_malloc64(nTmp*2); + aTmp = sqlite3_malloc64(nTmp*2 + FTS3_VARINT_MAX); if( !aTmp ){ *pRc = SQLITE_NOMEM; res = 0; @@ -194567,10 +194592,11 @@ static int getNextString( Fts3PhraseToken *pToken; p = fts3ReallocOrFree(p, nSpace + ii*sizeof(Fts3PhraseToken)); - if( !p ) goto no_mem; - zTemp = fts3ReallocOrFree(zTemp, nTemp + nByte); - if( !zTemp ) goto no_mem; + if( !zTemp || !p ){ + rc = SQLITE_NOMEM; + goto getnextstring_out; + } assert( nToken==ii ); pToken = &((Fts3Phrase *)(&p[1]))->aToken[ii]; @@ -194585,9 +194611,6 @@ static int getNextString( nToken = ii+1; } } - - pModule->xClose(pCursor); - pCursor = 0; } if( rc==SQLITE_DONE ){ @@ -194595,7 +194618,10 @@ static int getNextString( char *zBuf = 0; p = fts3ReallocOrFree(p, nSpace + nToken*sizeof(Fts3PhraseToken) + nTemp); - if( !p ) goto no_mem; + if( !p ){ + rc = SQLITE_NOMEM; + goto getnextstring_out; + } memset(p, 0, (char *)&(((Fts3Phrase *)&p[1])->aToken[0])-(char *)p); p->eType = FTSQUERY_PHRASE; p->pPhrase = (Fts3Phrase *)&p[1]; @@ -194603,11 +194629,9 @@ static int getNextString( p->pPhrase->nToken = nToken; zBuf = (char *)&p->pPhrase->aToken[nToken]; + assert( nTemp==0 || zTemp ); if( zTemp ){ memcpy(zBuf, zTemp, nTemp); - sqlite3_free(zTemp); - }else{ - assert( nTemp==0 ); } for(jj=0; jjpPhrase->nToken; jj++){ @@ -194617,17 +194641,17 @@ static int getNextString( rc = SQLITE_OK; } - *ppExpr = p; - return rc; -no_mem: - + getnextstring_out: if( pCursor ){ pModule->xClose(pCursor); } sqlite3_free(zTemp); - sqlite3_free(p); - *ppExpr = 0; - return SQLITE_NOMEM; + if( rc!=SQLITE_OK ){ + sqlite3_free(p); + p = 0; + } + *ppExpr = p; + return rc; } /* @@ -232848,7 +232872,27 @@ SQLITE_API int sqlite3session_config(int op, void *pArg){ /************** End of sqlite3session.c **************************************/ /************** Begin file fts5.c ********************************************/ - +/* +** This, the "fts5.c" source file, is a composite file that is itself +** assembled from the following files: +** +** fts5.h +** fts5Int.h +** fts5parse.h <--- Generated from fts5parse.y by Lemon +** fts5parse.c <--- Generated from fts5parse.y by Lemon +** fts5_aux.c +** fts5_buffer.c +** fts5_config.c +** fts5_expr.c +** fts5_hash.c +** fts5_index.c +** fts5_main.c +** fts5_storage.c +** fts5_tokenize.c +** fts5_unicode2.c +** fts5_varint.c +** fts5_vocab.c +*/ #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS5) #if !defined(NDEBUG) && !defined(SQLITE_DEBUG) @@ -232858,6 +232902,12 @@ SQLITE_API int sqlite3session_config(int op, void *pArg){ # undef NDEBUG #endif +#ifdef HAVE_STDINT_H +/* #include */ +#endif +#ifdef HAVE_INTTYPES_H +/* #include */ +#endif /* ** 2014 May 31 ** @@ -254930,7 +254980,7 @@ static void fts5SourceIdFunc( ){ assert( nArg==0 ); UNUSED_PARAM2(nArg, apUnused); - sqlite3_result_text(pCtx, "fts5: 2024-10-21 16:30:22 03a9703e27c44437c39363d0baf82db4ebc94538a0f28411c85dda156f82636e", -1, SQLITE_TRANSIENT); + sqlite3_result_text(pCtx, "fts5: 2024-11-25 12:07:48 b95d11e958643b969c47a8e5857f3793b9e69700b8f1469371386369a26e577e", -1, SQLITE_TRANSIENT); } /* @@ -260121,7 +260171,7 @@ static int sqlite3Fts5VocabInit(Fts5Global *pGlobal, sqlite3 *db){ } - +/* Here ends the fts5.c composite file. */ #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS5) */ /************** End of fts5.c ************************************************/ diff --git a/src/tclsqlite.c b/src/tclsqlite.c index c639b11..8eff356 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -1099,7 +1099,7 @@ static void tclSqlFunc(sqlite3_context *context, int argc, sqlite3_value**argv){ eType = SQLITE_BLOB; }else if( (c=='b' && strcmp(zType,"boolean")==0) || (c=='w' && strcmp(zType,"wideInt")==0) - || (c=='i' && strcmp(zType,"int")==0) + || (c=='i' && strcmp(zType,"int")==0) ){ eType = SQLITE_INTEGER; }else if( c=='d' && strcmp(zType,"double")==0 ){ @@ -1900,9 +1900,9 @@ static int SQLITE_TCLAPI DbEvalNextCmd( if( pArray==0 ){ Tcl_ObjSetVar2(interp, apColName[i], 0, dbEvalColumnValue(p,i), 0); }else if( (p->evalFlags & SQLITE_EVAL_WITHOUTNULLS)!=0 - && sqlite3_column_type(p->pPreStmt->pStmt, i)==SQLITE_NULL + && sqlite3_column_type(p->pPreStmt->pStmt, i)==SQLITE_NULL ){ - Tcl_UnsetVar2(interp, Tcl_GetString(pArray), + Tcl_UnsetVar2(interp, Tcl_GetString(pArray), Tcl_GetString(apColName[i]), 0); }else{ Tcl_ObjSetVar2(interp, pArray, apColName[i], dbEvalColumnValue(p,i), 0); @@ -2014,7 +2014,7 @@ static int SQLITE_TCLAPI DbObjCmd( "timeout", "total_changes", "trace", "trace_v2", "transaction", "unlock_notify", "update_hook", "version", "wal_hook", - 0 + 0 }; enum DB_enum { DB_AUTHORIZER, DB_BACKUP, DB_BIND_FALLBACK, @@ -2160,7 +2160,7 @@ static int SQLITE_TCLAPI DbObjCmd( ** value of the CALLBACK as the binding. If CALLBACK returns something ** other than TCL_OK or TCL_ERROR then bind a NULL. ** - ** If CALLBACK is an empty string, then revert to the default behavior + ** If CALLBACK is an empty string, then revert to the default behavior ** which is to set the binding to NULL. ** ** If CALLBACK returns an error, that causes the statement execution to @@ -2755,7 +2755,7 @@ static int SQLITE_TCLAPI DbObjCmd( } deserialize_error: #endif - break; + break; } /* @@ -2865,7 +2865,7 @@ static int SQLITE_TCLAPI DbObjCmd( objv++; } if( objc<3 || objc>5 ){ - Tcl_WrongNumArgs(interp, 2, objv, + Tcl_WrongNumArgs(interp, 2, objv, "?OPTIONS? SQL ?ARRAY-NAME? ?SCRIPT?"); return TCL_ERROR; } @@ -3268,7 +3268,7 @@ static int SQLITE_TCLAPI DbObjCmd( /* ** $db serialize ?DATABASE? ** - ** Return a serialization of a database. + ** Return a serialization of a database. */ case DB_SERIALIZE: { #ifdef SQLITE_OMIT_DESERIALIZE @@ -3594,7 +3594,7 @@ static int SQLITE_TCLAPI DbObjCmd( */ case DB_PREUPDATE: { #ifndef SQLITE_ENABLE_PREUPDATE_HOOK - Tcl_AppendResult(interp, "preupdate_hook was omitted at compile-time", + Tcl_AppendResult(interp, "preupdate_hook was omitted at compile-time", (char*)0); rc = TCL_ERROR; #else @@ -3733,7 +3733,7 @@ static int SQLITE_TCLAPI DbObjCmd( return TCL_ERROR; } } - if( i==2 ){ + if( i==2 ){ Tcl_SetResult(interp, (char *)sqlite3_libversion(), TCL_STATIC); } break; @@ -4040,12 +4040,15 @@ static const char *tclsh_main_loop(void){ #ifdef WIN32 "set new [list]\n" "foreach arg $argv {\n" - "if {[file exists $arg]} {\n" + "if {[string match -* $arg] || [file exists $arg]} {\n" "lappend new $arg\n" "} else {\n" + "set once 0\n" "foreach match [lsort [glob -nocomplain $arg]] {\n" "lappend new $match\n" + "set once 1\n" "}\n" + "if {!$once} {lappend new $arg}\n" "}\n" "}\n" "set argv $new\n"