Merge pull request #695 from thomcc/update-bundled-sqlite

Upgrade bundled sqlite to 3.31.1
This commit is contained in:
Thom Chiovoloni 2020-04-10 18:51:41 -07:00 committed by GitHub
commit 8ce09df917
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 104 additions and 76 deletions

View File

@ -113,7 +113,7 @@ bencher = "0.1"
[dependencies.libsqlite3-sys] [dependencies.libsqlite3-sys]
path = "libsqlite3-sys" path = "libsqlite3-sys"
version = "0.17.3" version = "0.18.0"
[[test]] [[test]]
name = "config_log" name = "config_log"

View File

@ -1,6 +1,6 @@
[package] [package]
name = "libsqlite3-sys" name = "libsqlite3-sys"
version = "0.17.3" version = "0.18.0"
authors = ["John Gallagher <jgallagher@bignerdranch.com>"] authors = ["John Gallagher <jgallagher@bignerdranch.com>"]
edition = "2018" edition = "2018"
repository = "https://github.com/jgallagher/rusqlite" repository = "https://github.com/jgallagher/rusqlite"

View File

@ -1,9 +1,9 @@
/* automatically generated by rust-bindgen */ /* automatically generated by rust-bindgen */
pub const SQLITE_VERSION: &'static [u8; 7usize] = b"3.31.0\0"; pub const SQLITE_VERSION: &'static [u8; 7usize] = b"3.31.1\0";
pub const SQLITE_VERSION_NUMBER: i32 = 3031000; pub const SQLITE_VERSION_NUMBER: i32 = 3031001;
pub const SQLITE_SOURCE_ID: &'static [u8; 85usize] = pub const SQLITE_SOURCE_ID: &'static [u8; 85usize] =
b"2020-01-22 18:38:59 f6affdd41608946fcfcea914ece149038a8b25a62bbe719ed2561c649b86d824\0"; b"2020-01-27 19:55:54 3bfa9cc97da10598521b342961df8f5f68c7388fa117345eeb516eaa837bb4d6\0";
pub const SQLITE_OK: i32 = 0; pub const SQLITE_OK: i32 = 0;
pub const SQLITE_ERROR: i32 = 1; pub const SQLITE_ERROR: i32 = 1;
pub const SQLITE_INTERNAL: i32 = 2; pub const SQLITE_INTERNAL: i32 = 2;

View File

@ -1,6 +1,6 @@
/****************************************************************************** /******************************************************************************
** This file is an amalgamation of many separate C source files from SQLite ** This file is an amalgamation of many separate C source files from SQLite
** version 3.31.0. By combining all the individual C code files into this ** version 3.31.1. By combining all the individual C code files into this
** single large file, the entire code can be compiled as a single translation ** single large file, the entire code can be compiled as a single translation
** unit. This allows many compilers to do optimizations that would not be ** unit. This allows many compilers to do optimizations that would not be
** possible if the files were compiled separately. Performance improvements ** possible if the files were compiled separately. Performance improvements
@ -1165,9 +1165,9 @@ extern "C" {
** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()]. ** [sqlite_version()] and [sqlite_source_id()].
*/ */
#define SQLITE_VERSION "3.31.0" #define SQLITE_VERSION "3.31.1"
#define SQLITE_VERSION_NUMBER 3031000 #define SQLITE_VERSION_NUMBER 3031001
#define SQLITE_SOURCE_ID "2020-01-22 18:38:59 f6affdd41608946fcfcea914ece149038a8b25a62bbe719ed2561c649b86d824" #define SQLITE_SOURCE_ID "2020-01-27 19:55:54 3bfa9cc97da10598521b342961df8f5f68c7388fa117345eeb516eaa837bb4d6"
/* /*
** CAPI3REF: Run-Time Library Version Numbers ** CAPI3REF: Run-Time Library Version Numbers
@ -56233,30 +56233,48 @@ SQLITE_PRIVATE int sqlite3PagerOpen(
** Database file handle (pVfs->szOsFile bytes) ** Database file handle (pVfs->szOsFile bytes)
** Sub-journal file handle (journalFileSize bytes) ** Sub-journal file handle (journalFileSize bytes)
** Main journal file handle (journalFileSize bytes) ** Main journal file handle (journalFileSize bytes)
** \0\1\0 journal prefix (3 bytes) ** \0\0\0\0 database prefix (4 bytes)
** Journal filename (nPathname+8+1 bytes)
** \2\0 WAL prefix (2 bytes)
** WAL filename (nPathname+4+1 bytes)
** \3\0 database prefix (2 bytes)
** Database file name (nPathname+1 bytes) ** Database file name (nPathname+1 bytes)
** URI query parameters (nUriByte bytes) ** URI query parameters (nUriByte bytes)
** \0\0 terminator (2 bytes) ** Journal filename (nPathname+8+1 bytes)
** WAL filename (nPathname+4+1 bytes)
** \0\0\0 terminator (3 bytes)
**
** Some 3rd-party software, over which we have no control, depends on
** the specific order of the filenames and the \0 separators between them
** so that it can (for example) find the database filename given the WAL
** filename without using the sqlite3_filename_database() API. This is a
** misuse of SQLite and a bug in the 3rd-party software, but the 3rd-party
** software is in widespread use, so we try to avoid changing the filename
** order and formatting if possible. In particular, the details of the
** filename format expected by 3rd-party software should be as follows:
**
** - Main Database Path
** - \0
** - Multiple URI components consisting of:
** - Key
** - \0
** - Value
** - \0
** - \0
** - Journal Path
** - \0
** - WAL Path (zWALName)
** - \0
*/ */
pPtr = (u8 *)sqlite3MallocZero( pPtr = (u8 *)sqlite3MallocZero(
ROUND8(sizeof(*pPager)) + /* Pager structure */ ROUND8(sizeof(*pPager)) + /* Pager structure */
ROUND8(pcacheSize) + /* PCache object */ ROUND8(pcacheSize) + /* PCache object */
ROUND8(pVfs->szOsFile) + /* The main db file */ ROUND8(pVfs->szOsFile) + /* The main db file */
journalFileSize * 2 + /* The two journal files */ journalFileSize * 2 + /* The two journal files */
3 + /* Journal prefix */ 4 + /* Database prefix */
nPathname + 8 + 1 + /* Journal filename */
#ifndef SQLITE_OMIT_WAL
2 + /* WAL prefix */
nPathname + 4 + 1 + /* WAL filename */
#endif
2 + /* Database prefix */
nPathname + 1 + /* database filename */ nPathname + 1 + /* database filename */
nUriByte + /* query parameters */ nUriByte + /* query parameters */
2 /* Terminator */ nPathname + 8 + 1 + /* Journal filename */
#ifndef SQLITE_OMIT_WAL
nPathname + 4 + 1 + /* WAL filename */
#endif
3 /* Terminator */
); );
assert( EIGHT_BYTE_ALIGNMENT(SQLITE_INT_TO_PTR(journalFileSize)) ); assert( EIGHT_BYTE_ALIGNMENT(SQLITE_INT_TO_PTR(journalFileSize)) );
if( !pPtr ){ if( !pPtr ){
@ -56270,9 +56288,20 @@ SQLITE_PRIVATE int sqlite3PagerOpen(
pPager->jfd = (sqlite3_file*)pPtr; pPtr += journalFileSize; pPager->jfd = (sqlite3_file*)pPtr; pPtr += journalFileSize;
assert( EIGHT_BYTE_ALIGNMENT(pPager->jfd) ); assert( EIGHT_BYTE_ALIGNMENT(pPager->jfd) );
/* Fill in the Pager.zFilename and pPager.zQueryParam fields */
pPtr += 4; /* Skip zero prefix */
pPager->zFilename = (char*)pPtr;
if( nPathname>0 ){
memcpy(pPtr, zPathname, nPathname); pPtr += nPathname + 1;
if( zUri ){
memcpy(pPtr, zUri, nUriByte); pPtr += nUriByte;
}else{
pPtr++;
}
}
/* Fill in Pager.zJournal */ /* Fill in Pager.zJournal */
pPtr[1] = '\001'; pPtr += 3;
if( nPathname>0 ){ if( nPathname>0 ){
pPager->zJournal = (char*)pPtr; pPager->zJournal = (char*)pPtr;
memcpy(pPtr, zPathname, nPathname); pPtr += nPathname; memcpy(pPtr, zPathname, nPathname); pPtr += nPathname;
@ -56283,12 +56312,10 @@ SQLITE_PRIVATE int sqlite3PagerOpen(
#endif #endif
}else{ }else{
pPager->zJournal = 0; pPager->zJournal = 0;
pPtr++;
} }
#ifndef SQLITE_OMIT_WAL #ifndef SQLITE_OMIT_WAL
/* Fill in Pager.zWal */ /* Fill in Pager.zWal */
pPtr[0] = '\002'; pPtr[1] = 0; pPtr += 2;
if( nPathname>0 ){ if( nPathname>0 ){
pPager->zWal = (char*)pPtr; pPager->zWal = (char*)pPtr;
memcpy(pPtr, zPathname, nPathname); pPtr += nPathname; memcpy(pPtr, zPathname, nPathname); pPtr += nPathname;
@ -56299,21 +56326,9 @@ SQLITE_PRIVATE int sqlite3PagerOpen(
#endif #endif
}else{ }else{
pPager->zWal = 0; pPager->zWal = 0;
pPtr++;
} }
#endif #endif
/* Fill in the Pager.zFilename and pPager.zQueryParam fields */
pPtr[0] = '\003'; pPtr[1] = 0; pPtr += 2;
pPager->zFilename = (char*)pPtr;
if( nPathname>0 ){
memcpy(pPtr, zPathname, nPathname); pPtr += nPathname + 1;
if( zUri ){
memcpy(pPtr, zUri, nUriByte); /* pPtr += nUriByte; // not needed */
}
/* Double-zero terminator implied by the sqlite3MallocZero */
}
if( nPathname ) sqlite3DbFree(0, zPathname); if( nPathname ) sqlite3DbFree(0, zPathname);
pPager->pVfs = pVfs; pPager->pVfs = pVfs;
pPager->vfsFlags = vfsFlags; pPager->vfsFlags = vfsFlags;
@ -58433,8 +58448,8 @@ SQLITE_PRIVATE int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint){
** sqlite3_uri_parameter() and sqlite3_filename_database() and friends. ** sqlite3_uri_parameter() and sqlite3_filename_database() and friends.
*/ */
SQLITE_PRIVATE const char *sqlite3PagerFilename(const Pager *pPager, int nullIfMemDb){ SQLITE_PRIVATE const char *sqlite3PagerFilename(const Pager *pPager, int nullIfMemDb){
static const char zFake[] = { 0x00, 0x01, 0x00, 0x00, 0x00 }; static const char zFake[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
return (nullIfMemDb && pPager->memDb) ? &zFake[3] : pPager->zFilename; return (nullIfMemDb && pPager->memDb) ? &zFake[4] : pPager->zFilename;
} }
/* /*
@ -117491,6 +117506,9 @@ SQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3 *db, Expr *pExpr, int *pIsNocas
assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
nExpr = pExpr->x.pList->nExpr; nExpr = pExpr->x.pList->nExpr;
pDef = sqlite3FindFunction(db, pExpr->u.zToken, nExpr, SQLITE_UTF8, 0); pDef = sqlite3FindFunction(db, pExpr->u.zToken, nExpr, SQLITE_UTF8, 0);
#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
if( pDef==0 ) return 0;
#endif
if( NEVER(pDef==0) || (pDef->funcFlags & SQLITE_FUNC_LIKE)==0 ){ if( NEVER(pDef==0) || (pDef->funcFlags & SQLITE_FUNC_LIKE)==0 ){
return 0; return 0;
} }
@ -122767,11 +122785,11 @@ typedef int (*sqlite3_loadext_entry)(
/* Version 3.26.0 and later */ /* Version 3.26.0 and later */
#define sqlite3_normalized_sql sqlite3_api->normalized_sql #define sqlite3_normalized_sql sqlite3_api->normalized_sql
/* Version 3.28.0 and later */ /* Version 3.28.0 and later */
#define sqlite3_stmt_isexplain sqlite3_api->isexplain #define sqlite3_stmt_isexplain sqlite3_api->stmt_isexplain
#define sqlite3_value_frombind sqlite3_api->frombind #define sqlite3_value_frombind sqlite3_api->value_frombind
/* Version 3.30.0 and later */ /* Version 3.30.0 and later */
#define sqlite3_drop_modules sqlite3_api->drop_modules #define sqlite3_drop_modules sqlite3_api->drop_modules
/* Version 3.31.0 andn later */ /* Version 3.31.0 and later */
#define sqlite3_hard_heap_limit64 sqlite3_api->hard_heap_limit64 #define sqlite3_hard_heap_limit64 sqlite3_api->hard_heap_limit64
#define sqlite3_uri_key sqlite3_api->uri_key #define sqlite3_uri_key sqlite3_api->uri_key
#define sqlite3_filename_database sqlite3_api->filename_database #define sqlite3_filename_database sqlite3_api->filename_database
@ -163282,6 +163300,21 @@ SQLITE_API int sqlite3_test_control(int op, ...){
return rc; return rc;
} }
/*
** The Pager stores the Database filename, Journal filename, and WAL filename
** consecutively in memory, in that order. The database filename is prefixed
** by four zero bytes. Locate the start of the database filename by searching
** backwards for the first byte following four consecutive zero bytes.
**
** This only works if the filename passed in was obtained from the Pager.
*/
static const char *databaseName(const char *zName){
while( zName[-1]!=0 || zName[-2]!=0 || zName[-3]!=0 || zName[-4]!=0 ){
zName--;
}
return zName;
}
/* /*
** This is a utility routine, useful to VFS implementations, that checks ** This is a utility routine, useful to VFS implementations, that checks
** to see if a database file was a URI that contained a specific query ** to see if a database file was a URI that contained a specific query
@ -163295,6 +163328,7 @@ SQLITE_API int sqlite3_test_control(int op, ...){
*/ */
SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam){ SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam){
if( zFilename==0 || zParam==0 ) return 0; if( zFilename==0 || zParam==0 ) return 0;
zFilename = databaseName(zFilename);
zFilename += sqlite3Strlen30(zFilename) + 1; zFilename += sqlite3Strlen30(zFilename) + 1;
while( zFilename[0] ){ while( zFilename[0] ){
int x = strcmp(zFilename, zParam); int x = strcmp(zFilename, zParam);
@ -163310,6 +163344,7 @@ SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *
*/ */
SQLITE_API const char *sqlite3_uri_key(const char *zFilename, int N){ SQLITE_API const char *sqlite3_uri_key(const char *zFilename, int N){
if( zFilename==0 || N<0 ) return 0; if( zFilename==0 || N<0 ) return 0;
zFilename = databaseName(zFilename);
zFilename += sqlite3Strlen30(zFilename) + 1; zFilename += sqlite3Strlen30(zFilename) + 1;
while( zFilename[0] && (N--)>0 ){ while( zFilename[0] && (N--)>0 ){
zFilename += sqlite3Strlen30(zFilename) + 1; zFilename += sqlite3Strlen30(zFilename) + 1;
@ -163343,25 +163378,6 @@ SQLITE_API sqlite3_int64 sqlite3_uri_int64(
return bDflt; return bDflt;
} }
/*
** The Pager stores the Journal filename, WAL filename, and Database filename
** consecutively in memory, in that order, with prefixes \000\001\000,
** \002\000, and \003\000, in that order. Thus the three names look like query
** parameters if you start at the first prefix.
**
** This routine backs up a filename to the start of the first prefix.
**
** This only works if the filenamed passed in was obtained from the Pager.
*/
static const char *startOfNameList(const char *zName){
while( zName[0]!='\001' || zName[1]!=0 ){
zName -= 3;
while( zName[0]!='\000' ){ zName--; }
zName++;
}
return zName-1;
}
/* /*
** Translate a filename that was handed to a VFS routine into the corresponding ** Translate a filename that was handed to a VFS routine into the corresponding
** database, journal, or WAL file. ** database, journal, or WAL file.
@ -163373,14 +163389,26 @@ static const char *startOfNameList(const char *zName){
** corruption. ** corruption.
*/ */
SQLITE_API const char *sqlite3_filename_database(const char *zFilename){ SQLITE_API const char *sqlite3_filename_database(const char *zFilename){
return databaseName(zFilename);
return sqlite3_uri_parameter(zFilename - 3, "\003"); return sqlite3_uri_parameter(zFilename - 3, "\003");
} }
SQLITE_API const char *sqlite3_filename_journal(const char *zFilename){ SQLITE_API const char *sqlite3_filename_journal(const char *zFilename){
const char *z = sqlite3_uri_parameter(startOfNameList(zFilename), "\001"); zFilename = databaseName(zFilename);
return ALWAYS(z) && z[0] ? z : 0; zFilename += sqlite3Strlen30(zFilename) + 1;
while( zFilename[0] ){
zFilename += sqlite3Strlen30(zFilename) + 1;
zFilename += sqlite3Strlen30(zFilename) + 1;
}
return zFilename + 1;
} }
SQLITE_API const char *sqlite3_filename_wal(const char *zFilename){ SQLITE_API const char *sqlite3_filename_wal(const char *zFilename){
return sqlite3_uri_parameter(startOfNameList(zFilename), "\002"); #ifdef SQLITE_OMIT_WAL
return 0;
#else
zFilename = sqlite3_filename_journal(zFilename);
zFilename += sqlite3Strlen30(zFilename) + 1;
return zFilename;
#endif
} }
/* /*
@ -219999,8 +220027,8 @@ static int fts5QueryCksum(
** contain valid utf-8, return non-zero. ** contain valid utf-8, return non-zero.
*/ */
static int fts5TestUtf8(const char *z, int n){ static int fts5TestUtf8(const char *z, int n){
assert_nc( n>0 );
int i = 0; int i = 0;
assert_nc( n>0 );
while( i<n ){ while( i<n ){
if( (z[i] & 0x80)==0x00 ){ if( (z[i] & 0x80)==0x00 ){
i++; i++;
@ -223639,7 +223667,7 @@ static void fts5SourceIdFunc(
){ ){
assert( nArg==0 ); assert( nArg==0 );
UNUSED_PARAM2(nArg, apUnused); UNUSED_PARAM2(nArg, apUnused);
sqlite3_result_text(pCtx, "fts5: 2020-01-22 18:38:59 f6affdd41608946fcfcea914ece149038a8b25a62bbe719ed2561c649b86d824", -1, SQLITE_TRANSIENT); sqlite3_result_text(pCtx, "fts5: 2020-01-27 19:55:54 3bfa9cc97da10598521b342961df8f5f68c7388fa117345eeb516eaa837bb4d6", -1, SQLITE_TRANSIENT);
} }
/* /*
@ -228412,9 +228440,9 @@ SQLITE_API int sqlite3_stmt_init(
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */ #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
/************** End of stmt.c ************************************************/ /************** End of stmt.c ************************************************/
#if __LINE__!=228415 #if __LINE__!=228443
#undef SQLITE_SOURCE_ID #undef SQLITE_SOURCE_ID
#define SQLITE_SOURCE_ID "2020-01-22 18:38:59 f6affdd41608946fcfcea914ece149038a8b25a62bbe719ed2561c649b86alt2" #define SQLITE_SOURCE_ID "2020-01-27 19:55:54 3bfa9cc97da10598521b342961df8f5f68c7388fa117345eeb516eaa837balt2"
#endif #endif
/* Return the source-id for this library */ /* Return the source-id for this library */
SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; } SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }

View File

@ -123,9 +123,9 @@ extern "C" {
** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()]. ** [sqlite_version()] and [sqlite_source_id()].
*/ */
#define SQLITE_VERSION "3.31.0" #define SQLITE_VERSION "3.31.1"
#define SQLITE_VERSION_NUMBER 3031000 #define SQLITE_VERSION_NUMBER 3031001
#define SQLITE_SOURCE_ID "2020-01-22 18:38:59 f6affdd41608946fcfcea914ece149038a8b25a62bbe719ed2561c649b86d824" #define SQLITE_SOURCE_ID "2020-01-27 19:55:54 3bfa9cc97da10598521b342961df8f5f68c7388fa117345eeb516eaa837bb4d6"
/* /*
** CAPI3REF: Run-Time Library Version Numbers ** CAPI3REF: Run-Time Library Version Numbers

View File

@ -620,11 +620,11 @@ typedef int (*sqlite3_loadext_entry)(
/* Version 3.26.0 and later */ /* Version 3.26.0 and later */
#define sqlite3_normalized_sql sqlite3_api->normalized_sql #define sqlite3_normalized_sql sqlite3_api->normalized_sql
/* Version 3.28.0 and later */ /* Version 3.28.0 and later */
#define sqlite3_stmt_isexplain sqlite3_api->isexplain #define sqlite3_stmt_isexplain sqlite3_api->stmt_isexplain
#define sqlite3_value_frombind sqlite3_api->frombind #define sqlite3_value_frombind sqlite3_api->value_frombind
/* Version 3.30.0 and later */ /* Version 3.30.0 and later */
#define sqlite3_drop_modules sqlite3_api->drop_modules #define sqlite3_drop_modules sqlite3_api->drop_modules
/* Version 3.31.0 andn later */ /* Version 3.31.0 and later */
#define sqlite3_hard_heap_limit64 sqlite3_api->hard_heap_limit64 #define sqlite3_hard_heap_limit64 sqlite3_api->hard_heap_limit64
#define sqlite3_uri_key sqlite3_api->uri_key #define sqlite3_uri_key sqlite3_api->uri_key
#define sqlite3_filename_database sqlite3_api->filename_database #define sqlite3_filename_database sqlite3_api->filename_database

View File

@ -4,7 +4,7 @@ cd $SCRIPT_DIR
export SQLITE3_LIB_DIR=$SCRIPT_DIR/sqlite3 export SQLITE3_LIB_DIR=$SCRIPT_DIR/sqlite3
# Download and extract amalgamation # Download and extract amalgamation
SQLITE=sqlite-amalgamation-3310000 SQLITE=sqlite-amalgamation-3310100
curl -O https://sqlite.org/2020/$SQLITE.zip curl -O https://sqlite.org/2020/$SQLITE.zip
unzip -p $SQLITE.zip $SQLITE/sqlite3.c > $SQLITE3_LIB_DIR/sqlite3.c unzip -p $SQLITE.zip $SQLITE/sqlite3.c > $SQLITE3_LIB_DIR/sqlite3.c
unzip -p $SQLITE.zip $SQLITE/sqlite3.h > $SQLITE3_LIB_DIR/sqlite3.h unzip -p $SQLITE.zip $SQLITE/sqlite3.h > $SQLITE3_LIB_DIR/sqlite3.h