Fossil SCM

Update to a newer version of 3.40.0 that includes a fix to shell.c that allows it to be compiled with older C compilers.

drh 2022-11-07 18:44 trunk
Commit 25799e8930258c22dad3b620481e01e6ae7aa5fea07da523b4a83b9e159722d7
+14 -8
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -11487,11 +11487,11 @@
1148711487
1148811488
#if !defined(SQLITEINT_H)
1148911489
/* #include "sqlite3ext.h" */
1149011490
1149111491
/* typedef unsigned char u8; */
11492
-typedef unsigned int u32;
11492
+/* typedef unsigned int u32; */
1149311493
1149411494
#endif
1149511495
SQLITE_EXTENSION_INIT1
1149611496
#include <string.h>
1149711497
#include <assert.h>
@@ -12890,36 +12890,43 @@
1289012890
/*
1289112891
** Default value for SQLITE_RECOVER_ROWIDS (sqlite3_recover.bRecoverRowid).
1289212892
*/
1289312893
#define RECOVER_ROWID_DEFAULT 1
1289412894
12895
+/*
12896
+** Mutex handling:
12897
+**
12898
+** recoverEnterMutex() - Enter the recovery mutex
12899
+** recoverLeaveMutex() - Leave the recovery mutex
12900
+** recoverAssertMutexHeld() - Assert that the recovery mutex is held
12901
+*/
1289512902
#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE==0
1289612903
# define recoverEnterMutex()
1289712904
# define recoverLeaveMutex()
12898
-# define recoverAssertMutexHeld()
1289912905
#else
1290012906
static void recoverEnterMutex(void){
1290112907
sqlite3_mutex_enter(sqlite3_mutex_alloc(RECOVER_MUTEX_ID));
1290212908
}
1290312909
static void recoverLeaveMutex(void){
1290412910
sqlite3_mutex_leave(sqlite3_mutex_alloc(RECOVER_MUTEX_ID));
1290512911
}
12912
+#endif
12913
+#if SQLITE_THREADSAFE+0>=1 && defined(SQLITE_DEBUG)
1290612914
static void recoverAssertMutexHeld(void){
1290712915
assert( sqlite3_mutex_held(sqlite3_mutex_alloc(RECOVER_MUTEX_ID)) );
1290812916
}
12917
+#else
12918
+# define recoverAssertMutexHeld()
1290912919
#endif
1291012920
1291112921
1291212922
/*
1291312923
** Like strlen(). But handles NULL pointer arguments.
1291412924
*/
1291512925
static int recoverStrlen(const char *zStr){
12916
- int nRet = 0;
12917
- if( zStr ){
12918
- while( zStr[nRet] ) nRet++;
12919
- }
12920
- return nRet;
12926
+ if( zStr==0 ) return 0;
12927
+ return (int)(strlen(zStr)&0x7fffffff);
1292112928
}
1292212929
1292312930
/*
1292412931
** This function is a no-op if the recover handle passed as the first
1292512932
** argument already contains an error (if p->errCode!=SQLITE_OK).
@@ -15456,11 +15463,10 @@
1545615463
}
1545715464
return rc;
1545815465
}
1545915466
1546015467
#endif /* ifndef SQLITE_OMIT_VIRTUALTABLE */
15461
-
1546215468
1546315469
/************************* End ../ext/recover/sqlite3recover.c ********************/
1546415470
#endif
1546515471
1546615472
#if defined(SQLITE_ENABLE_SESSION)
1546715473
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -11487,11 +11487,11 @@
11487
11488 #if !defined(SQLITEINT_H)
11489 /* #include "sqlite3ext.h" */
11490
11491 /* typedef unsigned char u8; */
11492 typedef unsigned int u32;
11493
11494 #endif
11495 SQLITE_EXTENSION_INIT1
11496 #include <string.h>
11497 #include <assert.h>
@@ -12890,36 +12890,43 @@
12890 /*
12891 ** Default value for SQLITE_RECOVER_ROWIDS (sqlite3_recover.bRecoverRowid).
12892 */
12893 #define RECOVER_ROWID_DEFAULT 1
12894
 
 
 
 
 
 
 
12895 #if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE==0
12896 # define recoverEnterMutex()
12897 # define recoverLeaveMutex()
12898 # define recoverAssertMutexHeld()
12899 #else
12900 static void recoverEnterMutex(void){
12901 sqlite3_mutex_enter(sqlite3_mutex_alloc(RECOVER_MUTEX_ID));
12902 }
12903 static void recoverLeaveMutex(void){
12904 sqlite3_mutex_leave(sqlite3_mutex_alloc(RECOVER_MUTEX_ID));
12905 }
 
 
12906 static void recoverAssertMutexHeld(void){
12907 assert( sqlite3_mutex_held(sqlite3_mutex_alloc(RECOVER_MUTEX_ID)) );
12908 }
 
 
12909 #endif
12910
12911
12912 /*
12913 ** Like strlen(). But handles NULL pointer arguments.
12914 */
12915 static int recoverStrlen(const char *zStr){
12916 int nRet = 0;
12917 if( zStr ){
12918 while( zStr[nRet] ) nRet++;
12919 }
12920 return nRet;
12921 }
12922
12923 /*
12924 ** This function is a no-op if the recover handle passed as the first
12925 ** argument already contains an error (if p->errCode!=SQLITE_OK).
@@ -15456,11 +15463,10 @@
15456 }
15457 return rc;
15458 }
15459
15460 #endif /* ifndef SQLITE_OMIT_VIRTUALTABLE */
15461
15462
15463 /************************* End ../ext/recover/sqlite3recover.c ********************/
15464 #endif
15465
15466 #if defined(SQLITE_ENABLE_SESSION)
15467
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -11487,11 +11487,11 @@
11487
11488 #if !defined(SQLITEINT_H)
11489 /* #include "sqlite3ext.h" */
11490
11491 /* typedef unsigned char u8; */
11492 /* typedef unsigned int u32; */
11493
11494 #endif
11495 SQLITE_EXTENSION_INIT1
11496 #include <string.h>
11497 #include <assert.h>
@@ -12890,36 +12890,43 @@
12890 /*
12891 ** Default value for SQLITE_RECOVER_ROWIDS (sqlite3_recover.bRecoverRowid).
12892 */
12893 #define RECOVER_ROWID_DEFAULT 1
12894
12895 /*
12896 ** Mutex handling:
12897 **
12898 ** recoverEnterMutex() - Enter the recovery mutex
12899 ** recoverLeaveMutex() - Leave the recovery mutex
12900 ** recoverAssertMutexHeld() - Assert that the recovery mutex is held
12901 */
12902 #if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE==0
12903 # define recoverEnterMutex()
12904 # define recoverLeaveMutex()
 
12905 #else
12906 static void recoverEnterMutex(void){
12907 sqlite3_mutex_enter(sqlite3_mutex_alloc(RECOVER_MUTEX_ID));
12908 }
12909 static void recoverLeaveMutex(void){
12910 sqlite3_mutex_leave(sqlite3_mutex_alloc(RECOVER_MUTEX_ID));
12911 }
12912 #endif
12913 #if SQLITE_THREADSAFE+0>=1 && defined(SQLITE_DEBUG)
12914 static void recoverAssertMutexHeld(void){
12915 assert( sqlite3_mutex_held(sqlite3_mutex_alloc(RECOVER_MUTEX_ID)) );
12916 }
12917 #else
12918 # define recoverAssertMutexHeld()
12919 #endif
12920
12921
12922 /*
12923 ** Like strlen(). But handles NULL pointer arguments.
12924 */
12925 static int recoverStrlen(const char *zStr){
12926 if( zStr==0 ) return 0;
12927 return (int)(strlen(zStr)&0x7fffffff);
 
 
 
12928 }
12929
12930 /*
12931 ** This function is a no-op if the recover handle passed as the first
12932 ** argument already contains an error (if p->errCode!=SQLITE_OK).
@@ -15456,11 +15463,10 @@
15463 }
15464 return rc;
15465 }
15466
15467 #endif /* ifndef SQLITE_OMIT_VIRTUALTABLE */
 
15468
15469 /************************* End ../ext/recover/sqlite3recover.c ********************/
15470 #endif
15471
15472 #if defined(SQLITE_ENABLE_SESSION)
15473
+93 -37
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -452,11 +452,11 @@
452452
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
453453
** [sqlite_version()] and [sqlite_source_id()].
454454
*/
455455
#define SQLITE_VERSION "3.40.0"
456456
#define SQLITE_VERSION_NUMBER 3040000
457
-#define SQLITE_SOURCE_ID "2022-11-04 16:39:39 0e5597ce5353dea2cdb092b166b57ba1d60f8115eb468349f2b2869803691a2c"
457
+#define SQLITE_SOURCE_ID "2022-11-07 18:36:02 3645585f37631d60cefab1d55cdb1ee060aae87317b9b158a01329ca8a4d3e1e"
458458
459459
/*
460460
** CAPI3REF: Run-Time Library Version Numbers
461461
** KEYWORDS: sqlite3_version sqlite3_sourceid
462462
**
@@ -6178,13 +6178,14 @@
61786178
** application-defined function to be a text string in an encoding
61796179
** specified by the fifth (and last) parameter, which must be one
61806180
** of [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE].
61816181
** ^SQLite takes the text result from the application from
61826182
** the 2nd parameter of the sqlite3_result_text* interfaces.
6183
-** ^If the 3rd parameter to the sqlite3_result_text* interfaces
6184
-** is negative, then SQLite takes result text from the 2nd parameter
6185
-** through the first zero character.
6183
+** ^If the 3rd parameter to any of the sqlite3_result_text* interfaces
6184
+** other than sqlite3_result_text64() is negative, then SQLite computes
6185
+** the string length itself by searching the 2nd parameter for the first
6186
+** zero character.
61866187
** ^If the 3rd parameter to the sqlite3_result_text* interfaces
61876188
** is non-negative, then as many bytes (not characters) of the text
61886189
** pointed to by the 2nd parameter are taken as the application-defined
61896190
** function result. If the 3rd parameter is non-negative, then it
61906191
** must be the byte offset into the string where the NUL terminator would
@@ -49485,13 +49486,14 @@
4948549486
}
4948649487
return 0;
4948749488
}
4948849489
4948949490
/*
49490
-** If sqlite3_temp_directory is not, take the mutex and return true.
49491
+** If sqlite3_temp_directory is defined, take the mutex and return true.
4949149492
**
49492
-** If sqlite3_temp_directory is NULL, omit the mutex and return false.
49493
+** If sqlite3_temp_directory is NULL (undefined), omit the mutex and
49494
+** return false.
4949349495
*/
4949449496
static int winTempDirDefined(void){
4949549497
sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR));
4949649498
if( sqlite3_temp_directory!=0 ) return 1;
4949749499
sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR));
@@ -74325,12 +74327,12 @@
7432574327
7432674328
assert( sqlite3_mutex_held(pBt->mutex) );
7432774329
assert( eMode==BTALLOC_ANY || (nearby>0 && IfNotOmitAV(pBt->autoVacuum)) );
7432874330
pPage1 = pBt->pPage1;
7432974331
mxPage = btreePagecount(pBt);
74330
- /* EVIDENCE-OF: R-05119-02637 The 4-byte big-endian integer at offset 36
74331
- ** stores stores the total number of pages on the freelist. */
74332
+ /* EVIDENCE-OF: R-21003-45125 The 4-byte big-endian integer at offset 36
74333
+ ** stores the total number of pages on the freelist. */
7433274334
n = get4byte(&pPage1->aData[36]);
7433374335
testcase( n==mxPage-1 );
7433474336
if( n>=mxPage ){
7433574337
return SQLITE_CORRUPT_BKPT;
7433674338
}
@@ -140949,12 +140951,12 @@
140949140951
140950140952
/* Jump to the this point in order to terminate the query.
140951140953
*/
140952140954
sqlite3VdbeResolveLabel(v, labelEnd);
140953140955
140954
- /* Reassemble the compound query so that it will be freed correctly
140955
- ** by the calling function */
140956
+ /* Make arrangements to free the 2nd and subsequent arms of the compound
140957
+ ** after the parse has finished */
140956140958
if( pSplit->pPrior ){
140957140959
sqlite3ParserAddCleanup(pParse,
140958140960
(void(*)(sqlite3*,void*))sqlite3SelectDelete, pSplit->pPrior);
140959140961
}
140960140962
pSplit->pPrior = pPrior;
@@ -207732,10 +207734,38 @@
207732207734
#define SQLITE_RBU_STATE_CHECKPOINT 3
207733207735
#define SQLITE_RBU_STATE_DONE 4
207734207736
#define SQLITE_RBU_STATE_ERROR 5
207735207737
207736207738
SQLITE_API int sqlite3rbu_state(sqlite3rbu *pRbu);
207739
+
207740
+/*
207741
+** As part of applying an RBU update or performing an RBU vacuum operation,
207742
+** the system must at one point move the *-oal file to the equivalent *-wal
207743
+** path. Normally, it does this by invoking POSIX function rename(2) directly.
207744
+** Except on WINCE platforms, where it uses win32 API MoveFileW(). This
207745
+** function may be used to register a callback that the RBU module will invoke
207746
+** instead of one of these APIs.
207747
+**
207748
+** If a callback is registered with an RBU handle, it invokes it instead
207749
+** of rename(2) when it needs to move a file within the file-system. The
207750
+** first argument passed to the xRename() callback is a copy of the second
207751
+** argument (pArg) passed to this function. The second is the full path
207752
+** to the file to move and the third the full path to which it should be
207753
+** moved. The callback function should return SQLITE_OK to indicate
207754
+** success. If an error occurs, it should return an SQLite error code.
207755
+** In this case the RBU operation will be abandoned and the error returned
207756
+** to the RBU user.
207757
+**
207758
+** Passing a NULL pointer in place of the xRename argument to this function
207759
+** restores the default behaviour.
207760
+*/
207761
+SQLITE_API void sqlite3rbu_rename_handler(
207762
+ sqlite3rbu *pRbu,
207763
+ void *pArg,
207764
+ int (*xRename)(void *pArg, const char *zOld, const char *zNew)
207765
+);
207766
+
207737207767
207738207768
/*
207739207769
** Create an RBU VFS named zName that accesses the underlying file-system
207740207770
** via existing VFS zParent. Or, if the zParent parameter is passed NULL,
207741207771
** then the new RBU VFS uses the default system VFS to access the file-system.
@@ -208100,10 +208130,12 @@
208100208130
const char *zVfsName; /* Name of automatically created rbu vfs */
208101208131
rbu_file *pTargetFd; /* File handle open on target db */
208102208132
int nPagePerSector; /* Pages per sector for pTargetFd */
208103208133
i64 iOalSz;
208104208134
i64 nPhaseOneStep;
208135
+ void *pRenameArg;
208136
+ int (*xRename)(void*, const char*, const char*);
208105208137
208106208138
/* The following state variables are used as part of the incremental
208107208139
** checkpoint stage (eStage==RBU_STAGE_CKPT). See comments surrounding
208108208140
** function rbuSetupCheckpoint() for details. */
208109208141
u32 iMaxFrame; /* Largest iWalFrame value in aFrame[] */
@@ -210948,36 +210980,11 @@
210948210980
assert( p->rc==SQLITE_OK );
210949210981
p->rc = rbuLockDatabase(dbMain);
210950210982
}
210951210983
210952210984
if( p->rc==SQLITE_OK ){
210953
-#if defined(_WIN32_WCE)
210954
- {
210955
- LPWSTR zWideOal;
210956
- LPWSTR zWideWal;
210957
-
210958
- zWideOal = rbuWinUtf8ToUnicode(zOal);
210959
- if( zWideOal ){
210960
- zWideWal = rbuWinUtf8ToUnicode(zWal);
210961
- if( zWideWal ){
210962
- if( MoveFileW(zWideOal, zWideWal) ){
210963
- p->rc = SQLITE_OK;
210964
- }else{
210965
- p->rc = SQLITE_IOERR;
210966
- }
210967
- sqlite3_free(zWideWal);
210968
- }else{
210969
- p->rc = SQLITE_IOERR_NOMEM;
210970
- }
210971
- sqlite3_free(zWideOal);
210972
- }else{
210973
- p->rc = SQLITE_IOERR_NOMEM;
210974
- }
210975
- }
210976
-#else
210977
- p->rc = rename(zOal, zWal) ? SQLITE_IOERR : SQLITE_OK;
210978
-#endif
210985
+ p->rc = p->xRename(p->pRenameArg, zOal, zWal);
210979210986
}
210980210987
210981210988
if( p->rc!=SQLITE_OK
210982210989
|| rbuIsVacuum(p)
210983210990
|| rbuExclusiveCheckpoint(dbMain)==0
@@ -211712,10 +211719,11 @@
211712211719
if( p ){
211713211720
RbuState *pState = 0;
211714211721
211715211722
/* Create the custom VFS. */
211716211723
memset(p, 0, sizeof(sqlite3rbu));
211724
+ sqlite3rbu_rename_handler(p, 0, 0);
211717211725
rbuCreateVfs(p);
211718211726
211719211727
/* Open the target, RBU and state databases */
211720211728
if( p->rc==SQLITE_OK ){
211721211729
char *pCsr = (char*)&p[1];
@@ -212102,10 +212110,58 @@
212102212110
}
212103212111
212104212112
p->rc = rc;
212105212113
return rc;
212106212114
}
212115
+
212116
+/*
212117
+** Default xRename callback for RBU.
212118
+*/
212119
+static int xDefaultRename(void *pArg, const char *zOld, const char *zNew){
212120
+ int rc = SQLITE_OK;
212121
+#if defined(_WIN32_WCE)
212122
+ {
212123
+ LPWSTR zWideOld;
212124
+ LPWSTR zWideNew;
212125
+
212126
+ zWideOld = rbuWinUtf8ToUnicode(zOld);
212127
+ if( zWideOld ){
212128
+ zWideNew = rbuWinUtf8ToUnicode(zNew);
212129
+ if( zWideNew ){
212130
+ if( MoveFileW(zWideOld, zWideNew) ){
212131
+ rc = SQLITE_OK;
212132
+ }else{
212133
+ rc = SQLITE_IOERR;
212134
+ }
212135
+ sqlite3_free(zWideNew);
212136
+ }else{
212137
+ rc = SQLITE_IOERR_NOMEM;
212138
+ }
212139
+ sqlite3_free(zWideOld);
212140
+ }else{
212141
+ rc = SQLITE_IOERR_NOMEM;
212142
+ }
212143
+ }
212144
+#else
212145
+ rc = rename(zOld, zNew) ? SQLITE_IOERR : SQLITE_OK;
212146
+#endif
212147
+ return rc;
212148
+}
212149
+
212150
+SQLITE_API void sqlite3rbu_rename_handler(
212151
+ sqlite3rbu *pRbu,
212152
+ void *pArg,
212153
+ int (*xRename)(void *pArg, const char *zOld, const char *zNew)
212154
+){
212155
+ if( xRename ){
212156
+ pRbu->xRename = xRename;
212157
+ pRbu->pRenameArg = pArg;
212158
+ }else{
212159
+ pRbu->xRename = xDefaultRename;
212160
+ pRbu->pRenameArg = 0;
212161
+ }
212162
+}
212107212163
212108212164
/**************************************************************************
212109212165
** Beginning of RBU VFS shim methods. The VFS shim modifies the behaviour
212110212166
** of a standard VFS in the following ways:
212111212167
**
@@ -238472,11 +238528,11 @@
238472238528
int nArg, /* Number of args */
238473238529
sqlite3_value **apUnused /* Function arguments */
238474238530
){
238475238531
assert( nArg==0 );
238476238532
UNUSED_PARAM2(nArg, apUnused);
238477
- sqlite3_result_text(pCtx, "fts5: 2022-11-04 16:39:39 0e5597ce5353dea2cdb092b166b57ba1d60f8115eb468349f2b2869803691a2c", -1, SQLITE_TRANSIENT);
238533
+ sqlite3_result_text(pCtx, "fts5: 2022-11-07 18:36:02 3645585f37631d60cefab1d55cdb1ee060aae87317b9b158a01329ca8a4d3e1e", -1, SQLITE_TRANSIENT);
238478238534
}
238479238535
238480238536
/*
238481238537
** Return true if zName is the extension on one of the shadow tables used
238482238538
** by this module.
238483238539
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -452,11 +452,11 @@
452 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
453 ** [sqlite_version()] and [sqlite_source_id()].
454 */
455 #define SQLITE_VERSION "3.40.0"
456 #define SQLITE_VERSION_NUMBER 3040000
457 #define SQLITE_SOURCE_ID "2022-11-04 16:39:39 0e5597ce5353dea2cdb092b166b57ba1d60f8115eb468349f2b2869803691a2c"
458
459 /*
460 ** CAPI3REF: Run-Time Library Version Numbers
461 ** KEYWORDS: sqlite3_version sqlite3_sourceid
462 **
@@ -6178,13 +6178,14 @@
6178 ** application-defined function to be a text string in an encoding
6179 ** specified by the fifth (and last) parameter, which must be one
6180 ** of [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE].
6181 ** ^SQLite takes the text result from the application from
6182 ** the 2nd parameter of the sqlite3_result_text* interfaces.
6183 ** ^If the 3rd parameter to the sqlite3_result_text* interfaces
6184 ** is negative, then SQLite takes result text from the 2nd parameter
6185 ** through the first zero character.
 
6186 ** ^If the 3rd parameter to the sqlite3_result_text* interfaces
6187 ** is non-negative, then as many bytes (not characters) of the text
6188 ** pointed to by the 2nd parameter are taken as the application-defined
6189 ** function result. If the 3rd parameter is non-negative, then it
6190 ** must be the byte offset into the string where the NUL terminator would
@@ -49485,13 +49486,14 @@
49485 }
49486 return 0;
49487 }
49488
49489 /*
49490 ** If sqlite3_temp_directory is not, take the mutex and return true.
49491 **
49492 ** If sqlite3_temp_directory is NULL, omit the mutex and return false.
 
49493 */
49494 static int winTempDirDefined(void){
49495 sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR));
49496 if( sqlite3_temp_directory!=0 ) return 1;
49497 sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR));
@@ -74325,12 +74327,12 @@
74325
74326 assert( sqlite3_mutex_held(pBt->mutex) );
74327 assert( eMode==BTALLOC_ANY || (nearby>0 && IfNotOmitAV(pBt->autoVacuum)) );
74328 pPage1 = pBt->pPage1;
74329 mxPage = btreePagecount(pBt);
74330 /* EVIDENCE-OF: R-05119-02637 The 4-byte big-endian integer at offset 36
74331 ** stores stores the total number of pages on the freelist. */
74332 n = get4byte(&pPage1->aData[36]);
74333 testcase( n==mxPage-1 );
74334 if( n>=mxPage ){
74335 return SQLITE_CORRUPT_BKPT;
74336 }
@@ -140949,12 +140951,12 @@
140949
140950 /* Jump to the this point in order to terminate the query.
140951 */
140952 sqlite3VdbeResolveLabel(v, labelEnd);
140953
140954 /* Reassemble the compound query so that it will be freed correctly
140955 ** by the calling function */
140956 if( pSplit->pPrior ){
140957 sqlite3ParserAddCleanup(pParse,
140958 (void(*)(sqlite3*,void*))sqlite3SelectDelete, pSplit->pPrior);
140959 }
140960 pSplit->pPrior = pPrior;
@@ -207732,10 +207734,38 @@
207732 #define SQLITE_RBU_STATE_CHECKPOINT 3
207733 #define SQLITE_RBU_STATE_DONE 4
207734 #define SQLITE_RBU_STATE_ERROR 5
207735
207736 SQLITE_API int sqlite3rbu_state(sqlite3rbu *pRbu);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207737
207738 /*
207739 ** Create an RBU VFS named zName that accesses the underlying file-system
207740 ** via existing VFS zParent. Or, if the zParent parameter is passed NULL,
207741 ** then the new RBU VFS uses the default system VFS to access the file-system.
@@ -208100,10 +208130,12 @@
208100 const char *zVfsName; /* Name of automatically created rbu vfs */
208101 rbu_file *pTargetFd; /* File handle open on target db */
208102 int nPagePerSector; /* Pages per sector for pTargetFd */
208103 i64 iOalSz;
208104 i64 nPhaseOneStep;
 
 
208105
208106 /* The following state variables are used as part of the incremental
208107 ** checkpoint stage (eStage==RBU_STAGE_CKPT). See comments surrounding
208108 ** function rbuSetupCheckpoint() for details. */
208109 u32 iMaxFrame; /* Largest iWalFrame value in aFrame[] */
@@ -210948,36 +210980,11 @@
210948 assert( p->rc==SQLITE_OK );
210949 p->rc = rbuLockDatabase(dbMain);
210950 }
210951
210952 if( p->rc==SQLITE_OK ){
210953 #if defined(_WIN32_WCE)
210954 {
210955 LPWSTR zWideOal;
210956 LPWSTR zWideWal;
210957
210958 zWideOal = rbuWinUtf8ToUnicode(zOal);
210959 if( zWideOal ){
210960 zWideWal = rbuWinUtf8ToUnicode(zWal);
210961 if( zWideWal ){
210962 if( MoveFileW(zWideOal, zWideWal) ){
210963 p->rc = SQLITE_OK;
210964 }else{
210965 p->rc = SQLITE_IOERR;
210966 }
210967 sqlite3_free(zWideWal);
210968 }else{
210969 p->rc = SQLITE_IOERR_NOMEM;
210970 }
210971 sqlite3_free(zWideOal);
210972 }else{
210973 p->rc = SQLITE_IOERR_NOMEM;
210974 }
210975 }
210976 #else
210977 p->rc = rename(zOal, zWal) ? SQLITE_IOERR : SQLITE_OK;
210978 #endif
210979 }
210980
210981 if( p->rc!=SQLITE_OK
210982 || rbuIsVacuum(p)
210983 || rbuExclusiveCheckpoint(dbMain)==0
@@ -211712,10 +211719,11 @@
211712 if( p ){
211713 RbuState *pState = 0;
211714
211715 /* Create the custom VFS. */
211716 memset(p, 0, sizeof(sqlite3rbu));
 
211717 rbuCreateVfs(p);
211718
211719 /* Open the target, RBU and state databases */
211720 if( p->rc==SQLITE_OK ){
211721 char *pCsr = (char*)&p[1];
@@ -212102,10 +212110,58 @@
212102 }
212103
212104 p->rc = rc;
212105 return rc;
212106 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
212107
212108 /**************************************************************************
212109 ** Beginning of RBU VFS shim methods. The VFS shim modifies the behaviour
212110 ** of a standard VFS in the following ways:
212111 **
@@ -238472,11 +238528,11 @@
238472 int nArg, /* Number of args */
238473 sqlite3_value **apUnused /* Function arguments */
238474 ){
238475 assert( nArg==0 );
238476 UNUSED_PARAM2(nArg, apUnused);
238477 sqlite3_result_text(pCtx, "fts5: 2022-11-04 16:39:39 0e5597ce5353dea2cdb092b166b57ba1d60f8115eb468349f2b2869803691a2c", -1, SQLITE_TRANSIENT);
238478 }
238479
238480 /*
238481 ** Return true if zName is the extension on one of the shadow tables used
238482 ** by this module.
238483
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -452,11 +452,11 @@
452 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
453 ** [sqlite_version()] and [sqlite_source_id()].
454 */
455 #define SQLITE_VERSION "3.40.0"
456 #define SQLITE_VERSION_NUMBER 3040000
457 #define SQLITE_SOURCE_ID "2022-11-07 18:36:02 3645585f37631d60cefab1d55cdb1ee060aae87317b9b158a01329ca8a4d3e1e"
458
459 /*
460 ** CAPI3REF: Run-Time Library Version Numbers
461 ** KEYWORDS: sqlite3_version sqlite3_sourceid
462 **
@@ -6178,13 +6178,14 @@
6178 ** application-defined function to be a text string in an encoding
6179 ** specified by the fifth (and last) parameter, which must be one
6180 ** of [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE].
6181 ** ^SQLite takes the text result from the application from
6182 ** the 2nd parameter of the sqlite3_result_text* interfaces.
6183 ** ^If the 3rd parameter to any of the sqlite3_result_text* interfaces
6184 ** other than sqlite3_result_text64() is negative, then SQLite computes
6185 ** the string length itself by searching the 2nd parameter for the first
6186 ** zero character.
6187 ** ^If the 3rd parameter to the sqlite3_result_text* interfaces
6188 ** is non-negative, then as many bytes (not characters) of the text
6189 ** pointed to by the 2nd parameter are taken as the application-defined
6190 ** function result. If the 3rd parameter is non-negative, then it
6191 ** must be the byte offset into the string where the NUL terminator would
@@ -49485,13 +49486,14 @@
49486 }
49487 return 0;
49488 }
49489
49490 /*
49491 ** If sqlite3_temp_directory is defined, take the mutex and return true.
49492 **
49493 ** If sqlite3_temp_directory is NULL (undefined), omit the mutex and
49494 ** return false.
49495 */
49496 static int winTempDirDefined(void){
49497 sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR));
49498 if( sqlite3_temp_directory!=0 ) return 1;
49499 sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR));
@@ -74325,12 +74327,12 @@
74327
74328 assert( sqlite3_mutex_held(pBt->mutex) );
74329 assert( eMode==BTALLOC_ANY || (nearby>0 && IfNotOmitAV(pBt->autoVacuum)) );
74330 pPage1 = pBt->pPage1;
74331 mxPage = btreePagecount(pBt);
74332 /* EVIDENCE-OF: R-21003-45125 The 4-byte big-endian integer at offset 36
74333 ** stores the total number of pages on the freelist. */
74334 n = get4byte(&pPage1->aData[36]);
74335 testcase( n==mxPage-1 );
74336 if( n>=mxPage ){
74337 return SQLITE_CORRUPT_BKPT;
74338 }
@@ -140949,12 +140951,12 @@
140951
140952 /* Jump to the this point in order to terminate the query.
140953 */
140954 sqlite3VdbeResolveLabel(v, labelEnd);
140955
140956 /* Make arrangements to free the 2nd and subsequent arms of the compound
140957 ** after the parse has finished */
140958 if( pSplit->pPrior ){
140959 sqlite3ParserAddCleanup(pParse,
140960 (void(*)(sqlite3*,void*))sqlite3SelectDelete, pSplit->pPrior);
140961 }
140962 pSplit->pPrior = pPrior;
@@ -207732,10 +207734,38 @@
207734 #define SQLITE_RBU_STATE_CHECKPOINT 3
207735 #define SQLITE_RBU_STATE_DONE 4
207736 #define SQLITE_RBU_STATE_ERROR 5
207737
207738 SQLITE_API int sqlite3rbu_state(sqlite3rbu *pRbu);
207739
207740 /*
207741 ** As part of applying an RBU update or performing an RBU vacuum operation,
207742 ** the system must at one point move the *-oal file to the equivalent *-wal
207743 ** path. Normally, it does this by invoking POSIX function rename(2) directly.
207744 ** Except on WINCE platforms, where it uses win32 API MoveFileW(). This
207745 ** function may be used to register a callback that the RBU module will invoke
207746 ** instead of one of these APIs.
207747 **
207748 ** If a callback is registered with an RBU handle, it invokes it instead
207749 ** of rename(2) when it needs to move a file within the file-system. The
207750 ** first argument passed to the xRename() callback is a copy of the second
207751 ** argument (pArg) passed to this function. The second is the full path
207752 ** to the file to move and the third the full path to which it should be
207753 ** moved. The callback function should return SQLITE_OK to indicate
207754 ** success. If an error occurs, it should return an SQLite error code.
207755 ** In this case the RBU operation will be abandoned and the error returned
207756 ** to the RBU user.
207757 **
207758 ** Passing a NULL pointer in place of the xRename argument to this function
207759 ** restores the default behaviour.
207760 */
207761 SQLITE_API void sqlite3rbu_rename_handler(
207762 sqlite3rbu *pRbu,
207763 void *pArg,
207764 int (*xRename)(void *pArg, const char *zOld, const char *zNew)
207765 );
207766
207767
207768 /*
207769 ** Create an RBU VFS named zName that accesses the underlying file-system
207770 ** via existing VFS zParent. Or, if the zParent parameter is passed NULL,
207771 ** then the new RBU VFS uses the default system VFS to access the file-system.
@@ -208100,10 +208130,12 @@
208130 const char *zVfsName; /* Name of automatically created rbu vfs */
208131 rbu_file *pTargetFd; /* File handle open on target db */
208132 int nPagePerSector; /* Pages per sector for pTargetFd */
208133 i64 iOalSz;
208134 i64 nPhaseOneStep;
208135 void *pRenameArg;
208136 int (*xRename)(void*, const char*, const char*);
208137
208138 /* The following state variables are used as part of the incremental
208139 ** checkpoint stage (eStage==RBU_STAGE_CKPT). See comments surrounding
208140 ** function rbuSetupCheckpoint() for details. */
208141 u32 iMaxFrame; /* Largest iWalFrame value in aFrame[] */
@@ -210948,36 +210980,11 @@
210980 assert( p->rc==SQLITE_OK );
210981 p->rc = rbuLockDatabase(dbMain);
210982 }
210983
210984 if( p->rc==SQLITE_OK ){
210985 p->rc = p->xRename(p->pRenameArg, zOal, zWal);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
210986 }
210987
210988 if( p->rc!=SQLITE_OK
210989 || rbuIsVacuum(p)
210990 || rbuExclusiveCheckpoint(dbMain)==0
@@ -211712,10 +211719,11 @@
211719 if( p ){
211720 RbuState *pState = 0;
211721
211722 /* Create the custom VFS. */
211723 memset(p, 0, sizeof(sqlite3rbu));
211724 sqlite3rbu_rename_handler(p, 0, 0);
211725 rbuCreateVfs(p);
211726
211727 /* Open the target, RBU and state databases */
211728 if( p->rc==SQLITE_OK ){
211729 char *pCsr = (char*)&p[1];
@@ -212102,10 +212110,58 @@
212110 }
212111
212112 p->rc = rc;
212113 return rc;
212114 }
212115
212116 /*
212117 ** Default xRename callback for RBU.
212118 */
212119 static int xDefaultRename(void *pArg, const char *zOld, const char *zNew){
212120 int rc = SQLITE_OK;
212121 #if defined(_WIN32_WCE)
212122 {
212123 LPWSTR zWideOld;
212124 LPWSTR zWideNew;
212125
212126 zWideOld = rbuWinUtf8ToUnicode(zOld);
212127 if( zWideOld ){
212128 zWideNew = rbuWinUtf8ToUnicode(zNew);
212129 if( zWideNew ){
212130 if( MoveFileW(zWideOld, zWideNew) ){
212131 rc = SQLITE_OK;
212132 }else{
212133 rc = SQLITE_IOERR;
212134 }
212135 sqlite3_free(zWideNew);
212136 }else{
212137 rc = SQLITE_IOERR_NOMEM;
212138 }
212139 sqlite3_free(zWideOld);
212140 }else{
212141 rc = SQLITE_IOERR_NOMEM;
212142 }
212143 }
212144 #else
212145 rc = rename(zOld, zNew) ? SQLITE_IOERR : SQLITE_OK;
212146 #endif
212147 return rc;
212148 }
212149
212150 SQLITE_API void sqlite3rbu_rename_handler(
212151 sqlite3rbu *pRbu,
212152 void *pArg,
212153 int (*xRename)(void *pArg, const char *zOld, const char *zNew)
212154 ){
212155 if( xRename ){
212156 pRbu->xRename = xRename;
212157 pRbu->pRenameArg = pArg;
212158 }else{
212159 pRbu->xRename = xDefaultRename;
212160 pRbu->pRenameArg = 0;
212161 }
212162 }
212163
212164 /**************************************************************************
212165 ** Beginning of RBU VFS shim methods. The VFS shim modifies the behaviour
212166 ** of a standard VFS in the following ways:
212167 **
@@ -238472,11 +238528,11 @@
238528 int nArg, /* Number of args */
238529 sqlite3_value **apUnused /* Function arguments */
238530 ){
238531 assert( nArg==0 );
238532 UNUSED_PARAM2(nArg, apUnused);
238533 sqlite3_result_text(pCtx, "fts5: 2022-11-07 18:36:02 3645585f37631d60cefab1d55cdb1ee060aae87317b9b158a01329ca8a4d3e1e", -1, SQLITE_TRANSIENT);
238534 }
238535
238536 /*
238537 ** Return true if zName is the extension on one of the shadow tables used
238538 ** by this module.
238539
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,11 +146,11 @@
146146
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147147
** [sqlite_version()] and [sqlite_source_id()].
148148
*/
149149
#define SQLITE_VERSION "3.40.0"
150150
#define SQLITE_VERSION_NUMBER 3040000
151
-#define SQLITE_SOURCE_ID "2022-11-04 16:39:39 0e5597ce5353dea2cdb092b166b57ba1d60f8115eb468349f2b2869803691a2c"
151
+#define SQLITE_SOURCE_ID "2022-11-07 18:36:02 3645585f37631d60cefab1d55cdb1ee060aae87317b9b158a01329ca8a4d3e1e"
152152
153153
/*
154154
** CAPI3REF: Run-Time Library Version Numbers
155155
** KEYWORDS: sqlite3_version sqlite3_sourceid
156156
**
@@ -5872,13 +5872,14 @@
58725872
** application-defined function to be a text string in an encoding
58735873
** specified by the fifth (and last) parameter, which must be one
58745874
** of [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE].
58755875
** ^SQLite takes the text result from the application from
58765876
** the 2nd parameter of the sqlite3_result_text* interfaces.
5877
-** ^If the 3rd parameter to the sqlite3_result_text* interfaces
5878
-** is negative, then SQLite takes result text from the 2nd parameter
5879
-** through the first zero character.
5877
+** ^If the 3rd parameter to any of the sqlite3_result_text* interfaces
5878
+** other than sqlite3_result_text64() is negative, then SQLite computes
5879
+** the string length itself by searching the 2nd parameter for the first
5880
+** zero character.
58805881
** ^If the 3rd parameter to the sqlite3_result_text* interfaces
58815882
** is non-negative, then as many bytes (not characters) of the text
58825883
** pointed to by the 2nd parameter are taken as the application-defined
58835884
** function result. If the 3rd parameter is non-negative, then it
58845885
** must be the byte offset into the string where the NUL terminator would
58855886
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,11 +146,11 @@
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.40.0"
150 #define SQLITE_VERSION_NUMBER 3040000
151 #define SQLITE_SOURCE_ID "2022-11-04 16:39:39 0e5597ce5353dea2cdb092b166b57ba1d60f8115eb468349f2b2869803691a2c"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
@@ -5872,13 +5872,14 @@
5872 ** application-defined function to be a text string in an encoding
5873 ** specified by the fifth (and last) parameter, which must be one
5874 ** of [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE].
5875 ** ^SQLite takes the text result from the application from
5876 ** the 2nd parameter of the sqlite3_result_text* interfaces.
5877 ** ^If the 3rd parameter to the sqlite3_result_text* interfaces
5878 ** is negative, then SQLite takes result text from the 2nd parameter
5879 ** through the first zero character.
 
5880 ** ^If the 3rd parameter to the sqlite3_result_text* interfaces
5881 ** is non-negative, then as many bytes (not characters) of the text
5882 ** pointed to by the 2nd parameter are taken as the application-defined
5883 ** function result. If the 3rd parameter is non-negative, then it
5884 ** must be the byte offset into the string where the NUL terminator would
5885
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,11 +146,11 @@
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.40.0"
150 #define SQLITE_VERSION_NUMBER 3040000
151 #define SQLITE_SOURCE_ID "2022-11-07 18:36:02 3645585f37631d60cefab1d55cdb1ee060aae87317b9b158a01329ca8a4d3e1e"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
@@ -5872,13 +5872,14 @@
5872 ** application-defined function to be a text string in an encoding
5873 ** specified by the fifth (and last) parameter, which must be one
5874 ** of [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE].
5875 ** ^SQLite takes the text result from the application from
5876 ** the 2nd parameter of the sqlite3_result_text* interfaces.
5877 ** ^If the 3rd parameter to any of the sqlite3_result_text* interfaces
5878 ** other than sqlite3_result_text64() is negative, then SQLite computes
5879 ** the string length itself by searching the 2nd parameter for the first
5880 ** zero character.
5881 ** ^If the 3rd parameter to the sqlite3_result_text* interfaces
5882 ** is non-negative, then as many bytes (not characters) of the text
5883 ** pointed to by the 2nd parameter are taken as the application-defined
5884 ** function result. If the 3rd parameter is non-negative, then it
5885 ** must be the byte offset into the string where the NUL terminator would
5886

Keyboard Shortcuts

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