Fossil SCM

Update the built-in SQLite to the latest trunk version that includes enhancements that allow a CREATE INDEX statement to occur without interrupting a running SELECT statement. This is important for correct operation of "fossil rebuild" since the forumpost table is created on demand in the middle of a query over the blob table.

drh 2018-07-24 22:05 forum-v2
Commit e2d87cdd76bbbadad4d65bab12e2ef812e2b4a740b989221fe971bb9a162dac1
3 files changed +20 +142 -83 +28 -27
+20
--- src/shell.c
+++ src/shell.c
@@ -95,16 +95,19 @@
9595
# endif
9696
#endif
9797
#if (!defined(_WIN32) && !defined(WIN32)) || defined(__MINGW32__)
9898
# include <unistd.h>
9999
# include <dirent.h>
100
+# define GETPID getpid
100101
# if defined(__MINGW32__)
101102
# define DIRENT dirent
102103
# ifndef S_ISLNK
103104
# define S_ISLNK(mode) (0)
104105
# endif
105106
# endif
107
+#else
108
+# define GETPID (int)GetCurrentProcessId
106109
#endif
107110
#include <sys/types.h>
108111
#include <sys/stat.h>
109112
110113
#if HAVE_READLINE
@@ -15847,10 +15850,27 @@
1584715850
1584815851
setBinaryMode(stdin, 0);
1584915852
setvbuf(stderr, 0, _IONBF, 0); /* Make sure stderr is unbuffered */
1585015853
stdin_is_interactive = isatty(0);
1585115854
stdout_is_console = isatty(1);
15855
+
15856
+#if !defined(_WIN32_WCE)
15857
+ if( getenv("SQLITE_DEBUG_BREAK") ){
15858
+ if( isatty(0) && isatty(2) ){
15859
+ fprintf(stderr,
15860
+ "attach debugger to process %d and press any key to continue.\n",
15861
+ GETPID());
15862
+ fgetc(stdin);
15863
+ }else{
15864
+#if defined(_WIN32) || defined(WIN32)
15865
+ DebugBreak();
15866
+#elif defined(SIGTRAP)
15867
+ raise(SIGTRAP);
15868
+#endif
15869
+ }
15870
+ }
15871
+#endif
1585215872
1585315873
#if USE_SYSTEM_SQLITE+0!=1
1585415874
if( strncmp(sqlite3_sourceid(),SQLITE_SOURCE_ID,60)!=0 ){
1585515875
utf8_printf(stderr, "SQLite header and source version mismatch\n%s\n%s\n",
1585615876
sqlite3_sourceid(), SQLITE_SOURCE_ID);
1585715877
--- src/shell.c
+++ src/shell.c
@@ -95,16 +95,19 @@
95 # endif
96 #endif
97 #if (!defined(_WIN32) && !defined(WIN32)) || defined(__MINGW32__)
98 # include <unistd.h>
99 # include <dirent.h>
 
100 # if defined(__MINGW32__)
101 # define DIRENT dirent
102 # ifndef S_ISLNK
103 # define S_ISLNK(mode) (0)
104 # endif
105 # endif
 
 
106 #endif
107 #include <sys/types.h>
108 #include <sys/stat.h>
109
110 #if HAVE_READLINE
@@ -15847,10 +15850,27 @@
15847
15848 setBinaryMode(stdin, 0);
15849 setvbuf(stderr, 0, _IONBF, 0); /* Make sure stderr is unbuffered */
15850 stdin_is_interactive = isatty(0);
15851 stdout_is_console = isatty(1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15852
15853 #if USE_SYSTEM_SQLITE+0!=1
15854 if( strncmp(sqlite3_sourceid(),SQLITE_SOURCE_ID,60)!=0 ){
15855 utf8_printf(stderr, "SQLite header and source version mismatch\n%s\n%s\n",
15856 sqlite3_sourceid(), SQLITE_SOURCE_ID);
15857
--- src/shell.c
+++ src/shell.c
@@ -95,16 +95,19 @@
95 # endif
96 #endif
97 #if (!defined(_WIN32) && !defined(WIN32)) || defined(__MINGW32__)
98 # include <unistd.h>
99 # include <dirent.h>
100 # define GETPID getpid
101 # if defined(__MINGW32__)
102 # define DIRENT dirent
103 # ifndef S_ISLNK
104 # define S_ISLNK(mode) (0)
105 # endif
106 # endif
107 #else
108 # define GETPID (int)GetCurrentProcessId
109 #endif
110 #include <sys/types.h>
111 #include <sys/stat.h>
112
113 #if HAVE_READLINE
@@ -15847,10 +15850,27 @@
15850
15851 setBinaryMode(stdin, 0);
15852 setvbuf(stderr, 0, _IONBF, 0); /* Make sure stderr is unbuffered */
15853 stdin_is_interactive = isatty(0);
15854 stdout_is_console = isatty(1);
15855
15856 #if !defined(_WIN32_WCE)
15857 if( getenv("SQLITE_DEBUG_BREAK") ){
15858 if( isatty(0) && isatty(2) ){
15859 fprintf(stderr,
15860 "attach debugger to process %d and press any key to continue.\n",
15861 GETPID());
15862 fgetc(stdin);
15863 }else{
15864 #if defined(_WIN32) || defined(WIN32)
15865 DebugBreak();
15866 #elif defined(SIGTRAP)
15867 raise(SIGTRAP);
15868 #endif
15869 }
15870 }
15871 #endif
15872
15873 #if USE_SYSTEM_SQLITE+0!=1
15874 if( strncmp(sqlite3_sourceid(),SQLITE_SOURCE_ID,60)!=0 ){
15875 utf8_printf(stderr, "SQLite header and source version mismatch\n%s\n%s\n",
15876 sqlite3_sourceid(), SQLITE_SOURCE_ID);
15877
+142 -83
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -53,10 +53,16 @@
5353
/* These macros are provided to "stringify" the value of the define
5454
** for those options in which the value is meaningful. */
5555
#define CTIMEOPT_VAL_(opt) #opt
5656
#define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt)
5757
58
+/* Like CTIMEOPT_VAL, but especially for SQLITE_DEFAULT_LOOKASIDE. This
59
+** option requires a separate macro because legal values contain a single
60
+** comma. e.g. (-DSQLITE_DEFAULT_LOOKASIDE="100,100") */
61
+#define CTIMEOPT_VAL2_(opt1,opt2) #opt1 "," #opt2
62
+#define CTIMEOPT_VAL2(opt) CTIMEOPT_VAL2_(opt)
63
+
5864
/*
5965
** An array of names of all compile-time options. This array should
6066
** be sorted A-Z.
6167
**
6268
** This array looks large, but in a typical installation actually uses
@@ -136,11 +142,11 @@
136142
#endif
137143
#ifdef SQLITE_DEFAULT_LOCKING_MODE
138144
"DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE),
139145
#endif
140146
#ifdef SQLITE_DEFAULT_LOOKASIDE
141
- "DEFAULT_LOOKASIDE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOOKASIDE),
147
+ "DEFAULT_LOOKASIDE=" CTIMEOPT_VAL2(SQLITE_DEFAULT_LOOKASIDE),
142148
#endif
143149
#if SQLITE_DEFAULT_MEMSTATUS
144150
"DEFAULT_MEMSTATUS",
145151
#endif
146152
#ifdef SQLITE_DEFAULT_MMAP_SIZE
@@ -1150,11 +1156,11 @@
11501156
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
11511157
** [sqlite_version()] and [sqlite_source_id()].
11521158
*/
11531159
#define SQLITE_VERSION "3.25.0"
11541160
#define SQLITE_VERSION_NUMBER 3025000
1155
-#define SQLITE_SOURCE_ID "2018-07-18 19:09:07 a5087c5c87ad65f92e3bc96bbc84afb43faf10ab6b9ed3ba16304b5c60ad069f"
1161
+#define SQLITE_SOURCE_ID "2018-07-24 22:02:12 2bd593332da0aade467e7a4ee89e966aa6302f37540a2c5e23671f98a6cb599c"
11561162
11571163
/*
11581164
** CAPI3REF: Run-Time Library Version Numbers
11591165
** KEYWORDS: sqlite3_version sqlite3_sourceid
11601166
**
@@ -1912,11 +1918,12 @@
19121918
** interrogated. The zDbName parameter is ignored.
19131919
**
19141920
** <li>[[SQLITE_FCNTL_PERSIST_WAL]]
19151921
** ^The [SQLITE_FCNTL_PERSIST_WAL] opcode is used to set or query the
19161922
** persistent [WAL | Write Ahead Log] setting. By default, the auxiliary
1917
-** write ahead log and shared memory files used for transaction control
1923
+** write ahead log ([WAL file]) and shared memory
1924
+** files used for transaction control
19181925
** are automatically deleted when the latest connection to the database
19191926
** closes. Setting persistent WAL mode causes those files to persist after
19201927
** close. Persisting the files is useful when other processes that do not
19211928
** have write permission on the directory containing the database file want
19221929
** to read the database file, as the WAL and shared memory files must exist
@@ -9985,11 +9992,10 @@
99859992
SQLITE_API int sqlite3_system_errno(sqlite3*);
99869993
99879994
/*
99889995
** CAPI3REF: Database Snapshot
99899996
** KEYWORDS: {snapshot} {sqlite3_snapshot}
9990
-** EXPERIMENTAL
99919997
**
99929998
** An instance of the snapshot object records the state of a [WAL mode]
99939999
** database for some specific point in history.
999410000
**
999510001
** In [WAL mode], multiple [database connections] that are open on the
@@ -10002,23 +10008,18 @@
1000210008
**
1000310009
** The sqlite3_snapshot object records state information about an historical
1000410010
** version of the database file so that it is possible to later open a new read
1000510011
** transaction that sees that historical version of the database rather than
1000610012
** the most recent version.
10007
-**
10008
-** The constructor for this object is [sqlite3_snapshot_get()]. The
10009
-** [sqlite3_snapshot_open()] method causes a fresh read transaction to refer
10010
-** to an historical snapshot (if possible). The destructor for
10011
-** sqlite3_snapshot objects is [sqlite3_snapshot_free()].
1001210013
*/
1001310014
typedef struct sqlite3_snapshot {
1001410015
unsigned char hidden[48];
1001510016
} sqlite3_snapshot;
1001610017
1001710018
/*
1001810019
** CAPI3REF: Record A Database Snapshot
10019
-** EXPERIMENTAL
10020
+** CONSTRUCTOR: sqlite3_snapshot
1002010021
**
1002110022
** ^The [sqlite3_snapshot_get(D,S,P)] interface attempts to make a
1002210023
** new [sqlite3_snapshot] object that records the current state of
1002310024
** schema S in database connection D. ^On success, the
1002410025
** [sqlite3_snapshot_get(D,S,P)] interface writes a pointer to the newly
@@ -10053,21 +10054,21 @@
1005310054
** The [sqlite3_snapshot] object returned from a successful call to
1005410055
** [sqlite3_snapshot_get()] must be freed using [sqlite3_snapshot_free()]
1005510056
** to avoid a memory leak.
1005610057
**
1005710058
** The [sqlite3_snapshot_get()] interface is only available when the
10058
-** SQLITE_ENABLE_SNAPSHOT compile-time option is used.
10059
+** [SQLITE_ENABLE_SNAPSHOT] compile-time option is used.
1005910060
*/
1006010061
SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_get(
1006110062
sqlite3 *db,
1006210063
const char *zSchema,
1006310064
sqlite3_snapshot **ppSnapshot
1006410065
);
1006510066
1006610067
/*
1006710068
** CAPI3REF: Start a read transaction on an historical snapshot
10068
-** EXPERIMENTAL
10069
+** METHOD: sqlite3_snapshot
1006910070
**
1007010071
** ^The [sqlite3_snapshot_open(D,S,P)] interface starts a
1007110072
** read transaction for schema S of
1007210073
** [database connection] D such that the read transaction
1007310074
** refers to historical [snapshot] P, rather than the most
@@ -10091,34 +10092,34 @@
1009110092
** after the most recent I/O on the database connection.)^
1009210093
** (Hint: Run "[PRAGMA application_id]" against a newly opened
1009310094
** database connection in order to make it ready to use snapshots.)
1009410095
**
1009510096
** The [sqlite3_snapshot_open()] interface is only available when the
10096
-** SQLITE_ENABLE_SNAPSHOT compile-time option is used.
10097
+** [SQLITE_ENABLE_SNAPSHOT] compile-time option is used.
1009710098
*/
1009810099
SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_open(
1009910100
sqlite3 *db,
1010010101
const char *zSchema,
1010110102
sqlite3_snapshot *pSnapshot
1010210103
);
1010310104
1010410105
/*
1010510106
** CAPI3REF: Destroy a snapshot
10106
-** EXPERIMENTAL
10107
+** DESTRUCTOR: sqlite3_snapshot
1010710108
**
1010810109
** ^The [sqlite3_snapshot_free(P)] interface destroys [sqlite3_snapshot] P.
1010910110
** The application must eventually free every [sqlite3_snapshot] object
1011010111
** using this routine to avoid a memory leak.
1011110112
**
1011210113
** The [sqlite3_snapshot_free()] interface is only available when the
10113
-** SQLITE_ENABLE_SNAPSHOT compile-time option is used.
10114
+** [SQLITE_ENABLE_SNAPSHOT] compile-time option is used.
1011410115
*/
1011510116
SQLITE_API SQLITE_EXPERIMENTAL void sqlite3_snapshot_free(sqlite3_snapshot*);
1011610117
1011710118
/*
1011810119
** CAPI3REF: Compare the ages of two snapshot handles.
10119
-** EXPERIMENTAL
10120
+** METHOD: sqlite3_snapshot
1012010121
**
1012110122
** The sqlite3_snapshot_cmp(P1, P2) interface is used to compare the ages
1012210123
** of two valid snapshot handles.
1012310124
**
1012410125
** If the two snapshot handles are not associated with the same database
@@ -10133,35 +10134,41 @@
1013310134
** is undefined.
1013410135
**
1013510136
** Otherwise, this API returns a negative value if P1 refers to an older
1013610137
** snapshot than P2, zero if the two handles refer to the same database
1013710138
** snapshot, and a positive value if P1 is a newer snapshot than P2.
10139
+**
10140
+** This interface is only available if SQLite is compiled with the
10141
+** [SQLITE_ENABLE_SNAPSHOT] option.
1013810142
*/
1013910143
SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_cmp(
1014010144
sqlite3_snapshot *p1,
1014110145
sqlite3_snapshot *p2
1014210146
);
1014310147
1014410148
/*
1014510149
** CAPI3REF: Recover snapshots from a wal file
10146
-** EXPERIMENTAL
10147
-**
10148
-** If all connections disconnect from a database file but do not perform
10149
-** a checkpoint, the existing wal file is opened along with the database
10150
-** file the next time the database is opened. At this point it is only
10151
-** possible to successfully call sqlite3_snapshot_open() to open the most
10152
-** recent snapshot of the database (the one at the head of the wal file),
10153
-** even though the wal file may contain other valid snapshots for which
10154
-** clients have sqlite3_snapshot handles.
10155
-**
10156
-** This function attempts to scan the wal file associated with database zDb
10150
+** METHOD: sqlite3_snapshot
10151
+**
10152
+** If a [WAL file] remains on disk after all database connections close
10153
+** (either through the use of the [SQLITE_FCNTL_PERSIST_WAL] [file control]
10154
+** or because the last process to have the database opened exited without
10155
+** calling [sqlite3_close()]) and a new connection is subsequently opened
10156
+** on that database and [WAL file], the [sqlite3_snapshot_open()] interface
10157
+** will only be able to open the last transaction added to the WAL file
10158
+** even though the WAL file contains other valid transactions.
10159
+**
10160
+** This function attempts to scan the WAL file associated with database zDb
1015710161
** of database handle db and make all valid snapshots available to
1015810162
** sqlite3_snapshot_open(). It is an error if there is already a read
10159
-** transaction open on the database, or if the database is not a wal mode
10163
+** transaction open on the database, or if the database is not a WAL mode
1016010164
** database.
1016110165
**
1016210166
** SQLITE_OK is returned if successful, or an SQLite error code otherwise.
10167
+**
10168
+** This interface is only available if SQLite is compiled with the
10169
+** [SQLITE_ENABLE_SNAPSHOT] option.
1016310170
*/
1016410171
SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const char *zDb);
1016510172
1016610173
/*
1016710174
** CAPI3REF: Serialize a database
@@ -18937,11 +18944,11 @@
1893718944
SQLITE_PRIVATE void sqlite3Reindex(Parse*, Token*, Token*);
1893818945
SQLITE_PRIVATE void sqlite3AlterFunctions(void);
1893918946
SQLITE_PRIVATE void sqlite3AlterRenameTable(Parse*, SrcList*, Token*);
1894018947
SQLITE_PRIVATE int sqlite3GetToken(const unsigned char *, int *);
1894118948
SQLITE_PRIVATE void sqlite3NestedParse(Parse*, const char*, ...);
18942
-SQLITE_PRIVATE void sqlite3ExpirePreparedStatements(sqlite3*);
18949
+SQLITE_PRIVATE void sqlite3ExpirePreparedStatements(sqlite3*, int);
1894318950
SQLITE_PRIVATE int sqlite3CodeSubselect(Parse*, Expr *, int, int);
1894418951
SQLITE_PRIVATE void sqlite3SelectPrep(Parse*, Select*, NameContext*);
1894518952
SQLITE_PRIVATE void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p);
1894618953
SQLITE_PRIVATE int sqlite3MatchSpanName(const char*, const char*, const char*, const char*);
1894718954
SQLITE_PRIVATE int sqlite3ResolveExprNames(NameContext*, Expr*);
@@ -20025,13 +20032,13 @@
2002520032
#endif
2002620033
u16 nResColumn; /* Number of columns in one row of the result set */
2002720034
u8 errorAction; /* Recovery action to do in case of an error */
2002820035
u8 minWriteFileFormat; /* Minimum file format for writable database files */
2002920036
u8 prepFlags; /* SQLITE_PREPARE_* flags */
20030
- bft expired:1; /* True if the VM needs to be recompiled */
20031
- bft doingRerun:1; /* True if rerunning after an auto-reprepare */
20037
+ bft expired:2; /* 1: recompile VM immediately 2: when convenient */
2003220038
bft explain:2; /* True if EXPLAIN present on SQL command */
20039
+ bft doingRerun:1; /* True if rerunning after an auto-reprepare */
2003320040
bft changeCntOn:1; /* True to update the change-counter */
2003420041
bft runOnlyOnce:1; /* Automatically expire on reset */
2003520042
bft usesStmtJournal:1; /* True if uses a statement journal */
2003620043
bft readOnly:1; /* True for statements that do not write */
2003720044
bft bIsReader:1; /* True for statements that read */
@@ -28640,11 +28647,11 @@
2864028647
sqlite3TreeViewLine(pView, "FUNCTION %Q", pExpr->u.zToken);
2864128648
}
2864228649
if( pFarg ){
2864328650
sqlite3TreeViewExprList(pView, pFarg, pWin!=0, 0);
2864428651
}
28645
-#ifndef SQLITe_OMIT_WINDOWFUNC
28652
+#ifndef SQLITE_OMIT_WINDOWFUNC
2864628653
if( pWin ){
2864728654
sqlite3TreeViewWindow(pView, pWin, 0);
2864828655
}
2864928656
#endif
2865028657
break;
@@ -42948,10 +42955,13 @@
4294842955
*/
4294942956
static int winTruncate(sqlite3_file *id, sqlite3_int64 nByte){
4295042957
winFile *pFile = (winFile*)id; /* File handle object */
4295142958
int rc = SQLITE_OK; /* Return code for this function */
4295242959
DWORD lastErrno;
42960
+#if SQLITE_MAX_MMAP_SIZE>0
42961
+ sqlite3_int64 oldMmapSize;
42962
+#endif
4295342963
4295442964
assert( pFile );
4295542965
SimulateIOError(return SQLITE_IOERR_TRUNCATE);
4295642966
OSTRACE(("TRUNCATE pid=%lu, pFile=%p, file=%p, size=%lld, lock=%d\n",
4295742967
osGetCurrentProcessId(), pFile, pFile->h, nByte, pFile->locktype));
@@ -42962,10 +42972,19 @@
4296242972
** size).
4296342973
*/
4296442974
if( pFile->szChunk>0 ){
4296542975
nByte = ((nByte + pFile->szChunk - 1)/pFile->szChunk) * pFile->szChunk;
4296642976
}
42977
+
42978
+#if SQLITE_MAX_MMAP_SIZE>0
42979
+ if( pFile->pMapRegion ){
42980
+ oldMmapSize = pFile->mmapSize;
42981
+ }else{
42982
+ oldMmapSize = 0;
42983
+ }
42984
+ winUnmapfile(pFile);
42985
+#endif
4296742986
4296842987
/* SetEndOfFile() returns non-zero when successful, or zero when it fails. */
4296942988
if( winSeekFile(pFile, nByte) ){
4297042989
rc = winLogError(SQLITE_IOERR_TRUNCATE, pFile->lastErrno,
4297142990
"winTruncate1", pFile->zPath);
@@ -42975,16 +42994,16 @@
4297542994
rc = winLogError(SQLITE_IOERR_TRUNCATE, pFile->lastErrno,
4297642995
"winTruncate2", pFile->zPath);
4297742996
}
4297842997
4297942998
#if SQLITE_MAX_MMAP_SIZE>0
42980
- /* If the file was truncated to a size smaller than the currently
42981
- ** mapped region, reduce the effective mapping size as well. SQLite will
42982
- ** use read() and write() to access data beyond this point from now on.
42983
- */
42984
- if( pFile->pMapRegion && nByte<pFile->mmapSize ){
42985
- pFile->mmapSize = nByte;
42999
+ if( rc==SQLITE_OK && oldMmapSize>0 ){
43000
+ if( oldMmapSize>nByte ){
43001
+ winMapfile(pFile, -1);
43002
+ }else{
43003
+ winMapfile(pFile, oldMmapSize);
43004
+ }
4298643005
}
4298743006
#endif
4298843007
4298943008
OSTRACE(("TRUNCATE pid=%lu, pFile=%p, file=%p, rc=%s\n",
4299043009
osGetCurrentProcessId(), pFile, pFile->h, sqlite3ErrName(rc)));
@@ -56461,22 +56480,22 @@
5646156480
5646256481
if( (rc&0xFF)==SQLITE_IOERR && rc!=SQLITE_IOERR_NOMEM ){
5646356482
rc = sqlite3JournalCreate(pPager->jfd);
5646456483
if( rc!=SQLITE_OK ){
5646556484
sqlite3OsClose(pPager->jfd);
56485
+ goto commit_phase_one_exit;
5646656486
}
5646756487
bBatch = 0;
5646856488
}else{
5646956489
sqlite3OsClose(pPager->jfd);
5647056490
}
5647156491
}
5647256492
#endif /* SQLITE_ENABLE_BATCH_ATOMIC_WRITE */
5647356493
56474
- if( bBatch==0 && rc==SQLITE_OK ){
56494
+ if( bBatch==0 ){
5647556495
rc = pager_write_pagelist(pPager, pList);
5647656496
}
56477
-
5647856497
if( rc!=SQLITE_OK ){
5647956498
assert( rc!=SQLITE_IOERR_BLOCKED );
5648056499
goto commit_phase_one_exit;
5648156500
}
5648256501
sqlite3PcacheCleanAll(pPager->pPCache);
@@ -65751,10 +65770,16 @@
6575165770
*/
6575265771
if( p->inTrans==TRANS_WRITE || (p->inTrans==TRANS_READ && !wrflag) ){
6575365772
goto trans_begun;
6575465773
}
6575565774
assert( pBt->inTransaction==TRANS_WRITE || IfNotOmitAV(pBt->bDoTruncate)==0 );
65775
+
65776
+ if( (p->db->flags & SQLITE_ResetDatabase)
65777
+ && sqlite3PagerIsreadonly(pBt->pPager)==0
65778
+ ){
65779
+ pBt->btsFlags &= ~BTS_READ_ONLY;
65780
+ }
6575665781
6575765782
/* Write transactions are not possible on a read-only database */
6575865783
if( (pBt->btsFlags & BTS_READ_ONLY)!=0 && wrflag ){
6575965784
rc = SQLITE_READONLY;
6576065785
goto trans_begun;
@@ -71767,12 +71792,11 @@
7176771792
** if this is the first reference to the page.
7176871793
**
7176971794
** Also check that the page number is in bounds.
7177071795
*/
7177171796
static int checkRef(IntegrityCk *pCheck, Pgno iPage){
71772
- if( iPage==0 ) return 1;
71773
- if( iPage>pCheck->nPage ){
71797
+ if( iPage>pCheck->nPage || iPage==0 ){
7177471798
checkAppendMsg(pCheck, "invalid page number %d", iPage);
7177571799
return 1;
7177671800
}
7177771801
if( getPageReferenced(pCheck, iPage) ){
7177871802
checkAppendMsg(pCheck, "2nd reference to page %d", iPage);
@@ -71823,21 +71847,16 @@
7182371847
int iPage, /* Page number for first page in the list */
7182471848
int N /* Expected number of pages in the list */
7182571849
){
7182671850
int i;
7182771851
int expected = N;
71828
- int iFirst = iPage;
71829
- while( N-- > 0 && pCheck->mxErr ){
71852
+ int nErrAtStart = pCheck->nErr;
71853
+ while( iPage!=0 && pCheck->mxErr ){
7183071854
DbPage *pOvflPage;
7183171855
unsigned char *pOvflData;
71832
- if( iPage<1 ){
71833
- checkAppendMsg(pCheck,
71834
- "%d of %d pages missing from overflow list starting at %d",
71835
- N+1, expected, iFirst);
71836
- break;
71837
- }
7183871856
if( checkRef(pCheck, iPage) ) break;
71857
+ N--;
7183971858
if( sqlite3PagerGet(pCheck->pPager, (Pgno)iPage, &pOvflPage, 0) ){
7184071859
checkAppendMsg(pCheck, "failed to get page %d", iPage);
7184171860
break;
7184271861
}
7184371862
pOvflData = (unsigned char *)sqlite3PagerGetData(pOvflPage);
@@ -71877,14 +71896,16 @@
7187771896
}
7187871897
}
7187971898
#endif
7188071899
iPage = get4byte(pOvflData);
7188171900
sqlite3PagerUnref(pOvflPage);
71882
-
71883
- if( isFreeList && N<(iPage!=0) ){
71884
- checkAppendMsg(pCheck, "free-page count in header is too small");
71885
- }
71901
+ }
71902
+ if( N && nErrAtStart==pCheck->nErr ){
71903
+ checkAppendMsg(pCheck,
71904
+ "%s is %d but should be %d",
71905
+ isFreeList ? "size" : "overflow list length",
71906
+ expected-N, expected);
7188671907
}
7188771908
}
7188871909
#endif /* SQLITE_OMIT_INTEGRITY_CHECK */
7188971910
7189071911
/*
@@ -72274,10 +72295,28 @@
7227472295
get4byte(&pBt->pPage1->aData[36]));
7227572296
sCheck.zPfx = 0;
7227672297
7227772298
/* Check all the tables.
7227872299
*/
72300
+#ifndef SQLITE_OMIT_AUTOVACUUM
72301
+ if( pBt->autoVacuum ){
72302
+ int mx = 0;
72303
+ int mxInHdr;
72304
+ for(i=0; (int)i<nRoot; i++) if( mx<aRoot[i] ) mx = aRoot[i];
72305
+ mxInHdr = get4byte(&pBt->pPage1->aData[52]);
72306
+ if( mx!=mxInHdr ){
72307
+ checkAppendMsg(&sCheck,
72308
+ "max rootpage (%d) disagrees with header (%d)",
72309
+ mx, mxInHdr
72310
+ );
72311
+ }
72312
+ }else if( get4byte(&pBt->pPage1->aData[64])!=0 ){
72313
+ checkAppendMsg(&sCheck,
72314
+ "incremental_vacuum enabled with a max rootpage of zero"
72315
+ );
72316
+ }
72317
+#endif
7227972318
testcase( pBt->db->flags & SQLITE_CellSizeCk );
7228072319
pBt->db->flags &= ~SQLITE_CellSizeCk;
7228172320
for(i=0; (int)i<nRoot && sCheck.mxErr; i++){
7228272321
i64 notUsed;
7228372322
if( aRoot[i]==0 ) continue;
@@ -79974,15 +80013,23 @@
7997480013
** An expired statement means that recompilation of the statement is
7997580014
** recommend. Statements expire when things happen that make their
7997680015
** programs obsolete. Removing user-defined functions or collating
7997780016
** sequences, or changing an authorization function are the types of
7997880017
** things that make prepared statements obsolete.
80018
+**
80019
+** If iCode is 1, then expiration is advisory. The statement should
80020
+** be reprepared before being restarted, but if it is already running
80021
+** it is allowed to run to completion.
80022
+**
80023
+** Internally, this function just sets the Vdbe.expired flag on all
80024
+** prepared statements. The flag is set to 1 for an immediate expiration
80025
+** and set to 2 for an advisory expiration.
7997980026
*/
79980
-SQLITE_PRIVATE void sqlite3ExpirePreparedStatements(sqlite3 *db){
80027
+SQLITE_PRIVATE void sqlite3ExpirePreparedStatements(sqlite3 *db, int iCode){
7998180028
Vdbe *p;
7998280029
for(p = db->pVdbe; p; p=p->pNext){
79983
- p->expired = 1;
80030
+ p->expired = iCode+1;
7998480031
}
7998580032
}
7998680033
7998780034
/*
7998880035
** Return the database associated with the Vdbe.
@@ -85520,11 +85567,11 @@
8552085567
if( rc!=SQLITE_OK ){
8552185568
goto abort_due_to_error;
8552285569
}
8552385570
}
8552485571
if( isSchemaChange ){
85525
- sqlite3ExpirePreparedStatements(db);
85572
+ sqlite3ExpirePreparedStatements(db, 0);
8552685573
sqlite3ResetAllSchemasOfConnection(db);
8552785574
db->mDbFlags |= DBFLAG_SchemaChange;
8552885575
}
8552985576
}
8553085577
@@ -85809,11 +85856,11 @@
8580985856
pDb->pSchema->file_format = pOp->p3;
8581085857
}
8581185858
if( pOp->p1==1 ){
8581285859
/* Invalidate all prepared statements whenever the TEMP database
8581385860
** schema is changed. Ticket #1644 */
85814
- sqlite3ExpirePreparedStatements(db);
85861
+ sqlite3ExpirePreparedStatements(db, 0);
8581585862
p->expired = 0;
8581685863
}
8581785864
if( rc ) goto abort_due_to_error;
8581885865
break;
8581985866
}
@@ -85927,11 +85974,11 @@
8592785974
assert( pOp->opcode==OP_OpenWrite || pOp->p5==0 || pOp->p5==OPFLAG_SEEKEQ );
8592885975
assert( p->bIsReader );
8592985976
assert( pOp->opcode==OP_OpenRead || pOp->opcode==OP_ReopenIdx
8593085977
|| p->readOnly==0 );
8593185978
85932
- if( p->expired ){
85979
+ if( p->expired==1 ){
8593385980
rc = SQLITE_ABORT_ROLLBACK;
8593485981
goto abort_due_to_error;
8593585982
}
8593685983
8593785984
nField = 0;
@@ -89108,25 +89155,32 @@
8910889155
}
8910989156
break;
8911089157
}
8911189158
#endif
8911289159
89113
-/* Opcode: Expire P1 * * * *
89160
+/* Opcode: Expire P1 P2 * * *
8911489161
**
8911589162
** Cause precompiled statements to expire. When an expired statement
8911689163
** is executed using sqlite3_step() it will either automatically
8911789164
** reprepare itself (if it was originally created using sqlite3_prepare_v2())
8911889165
** or it will fail with SQLITE_SCHEMA.
8911989166
**
8912089167
** If P1 is 0, then all SQL statements become expired. If P1 is non-zero,
8912189168
** then only the currently executing statement is expired.
89169
+**
89170
+** If P2 is 0, then SQL statements are expired immediately. If P2 is 1,
89171
+** then running SQL statements are allowed to continue to run to completion.
89172
+** The P2==1 case occurs when a CREATE INDEX or similar schema change happens
89173
+** that might help the statement run faster but which does not affect the
89174
+** correctness of operation.
8912289175
*/
8912389176
case OP_Expire: {
89177
+ assert( pOp->p2==0 || pOp->p2==1 );
8912489178
if( !pOp->p1 ){
89125
- sqlite3ExpirePreparedStatements(db);
89179
+ sqlite3ExpirePreparedStatements(db, pOp->p2);
8912689180
}else{
89127
- p->expired = 1;
89181
+ p->expired = pOp->p2+1;
8912889182
}
8912989183
break;
8913089184
}
8913189185
8913289186
#ifndef SQLITE_OMIT_SHARED_CACHE
@@ -103813,11 +103867,11 @@
103813103867
if( !pIdx->hasStat1 ) sqlite3DefaultRowEst(pIdx);
103814103868
}
103815103869
103816103870
/* Load the statistics from the sqlite_stat4 table. */
103817103871
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
103818
- if( rc==SQLITE_OK && OptimizationEnabled(db, SQLITE_Stat34) ){
103872
+ if( rc==SQLITE_OK ){
103819103873
db->lookaside.bDisable++;
103820103874
rc = loadStat4(db, sInfo.zDatabase);
103821103875
db->lookaside.bDisable--;
103822103876
}
103823103877
for(i=sqliteHashFirst(&pSchema->idxHash); i; i=sqliteHashNext(i)){
@@ -104545,11 +104599,11 @@
104545104599
if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
104546104600
#endif
104547104601
sqlite3_mutex_enter(db->mutex);
104548104602
db->xAuth = (sqlite3_xauth)xAuth;
104549104603
db->pAuthArg = pArg;
104550
- sqlite3ExpirePreparedStatements(db);
104604
+ sqlite3ExpirePreparedStatements(db, 0);
104551104605
sqlite3_mutex_leave(db->mutex);
104552104606
return SQLITE_OK;
104553104607
}
104554104608
104555104609
/*
@@ -108209,11 +108263,11 @@
108209108263
if( pTblName ){
108210108264
sqlite3RefillIndex(pParse, pIndex, iMem);
108211108265
sqlite3ChangeCookie(pParse, iDb);
108212108266
sqlite3VdbeAddParseSchemaOp(v, iDb,
108213108267
sqlite3MPrintf(db, "name='%q' AND type='index'", pIndex->zName));
108214
- sqlite3VdbeAddOp0(v, OP_Expire);
108268
+ sqlite3VdbeAddOp2(v, OP_Expire, 0, 1);
108215108269
}
108216108270
108217108271
sqlite3VdbeJumpHere(v, pIndex->tnum);
108218108272
}
108219108273
@@ -131894,11 +131948,11 @@
131894131948
131895131949
assert( sqlite3BtreeHoldsAllMutexes(db) );
131896131950
assert( sqlite3_mutex_held(db->mutex) );
131897131951
131898131952
if( p ){
131899
- sqlite3ExpirePreparedStatements(db);
131953
+ sqlite3ExpirePreparedStatements(db, 0);
131900131954
do {
131901131955
VTable *pNext = p->pNext;
131902131956
sqlite3VtabUnlock(p);
131903131957
p = pNext;
131904131958
}while( p );
@@ -138680,11 +138734,13 @@
138680138734
138681138735
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
138682138736
Index *p = pLoop->u.btree.pIndex;
138683138737
int nEq = pLoop->u.btree.nEq;
138684138738
138685
- if( p->nSample>0 && nEq<p->nSampleCol ){
138739
+ if( p->nSample>0 && nEq<p->nSampleCol
138740
+ && OptimizationEnabled(pParse->db, SQLITE_Stat34)
138741
+ ){
138686138742
if( nEq==pBuilder->nRecValid ){
138687138743
UnpackedRecord *pRec = pBuilder->pRec;
138688138744
tRowcnt a[2];
138689138745
int nBtm = pLoop->u.btree.nBtm;
138690138746
int nTop = pLoop->u.btree.nTop;
@@ -139828,10 +139884,11 @@
139828139884
tRowcnt nOut = 0;
139829139885
if( nInMul==0
139830139886
&& pProbe->nSample
139831139887
&& pNew->u.btree.nEq<=pProbe->nSampleCol
139832139888
&& ((eOp & WO_IN)==0 || !ExprHasProperty(pTerm->pExpr, EP_xIsSelect))
139889
+ && OptimizationEnabled(db, SQLITE_Stat34)
139833139890
){
139834139891
Expr *pExpr = pTerm->pExpr;
139835139892
if( (eOp & (WO_EQ|WO_ISNULL|WO_IS))!=0 ){
139836139893
testcase( eOp & WO_EQ );
139837139894
testcase( eOp & WO_IS );
@@ -146916,11 +146973,11 @@
146916146973
146917146974
/*
146918146975
** Find the appropriate action for a parser given the non-terminal
146919146976
** look-ahead token iLookAhead.
146920146977
*/
146921
-static int yy_find_reduce_action(
146978
+static YYACTIONTYPE yy_find_reduce_action(
146922146979
YYACTIONTYPE stateno, /* Current state number */
146923146980
YYCODETYPE iLookAhead /* The look-ahead token */
146924146981
){
146925146982
int i;
146926146983
#ifdef YYERRORSYMBOL
@@ -147421,11 +147478,11 @@
147421147478
int yyLookahead, /* Lookahead token, or YYNOCODE if none */
147422147479
sqlite3ParserTOKENTYPE yyLookaheadToken /* Value of the lookahead token */
147423147480
sqlite3ParserCTX_PDECL /* %extra_context */
147424147481
){
147425147482
int yygoto; /* The next state */
147426
- int yyact; /* The next action */
147483
+ YYACTIONTYPE yyact; /* The next action */
147427147484
yyStackEntry *yymsp; /* The top of the parser's stack */
147428147485
int yysize; /* Amount to pop the stack */
147429147486
sqlite3ParserARG_FETCH
147430147487
(void)yyLookahead;
147431147488
(void)yyLookaheadToken;
@@ -148980,16 +149037,16 @@
148980149037
}
148981149038
#endif
148982149039
148983149040
do{
148984149041
assert( yyact==yypParser->yytos->stateno );
148985
- yyact = yy_find_shift_action(yymajor,yyact);
149042
+ yyact = yy_find_shift_action((YYCODETYPE)yymajor,yyact);
148986149043
if( yyact >= YY_MIN_REDUCE ){
148987149044
yyact = yy_reduce(yypParser,yyact-YY_MIN_REDUCE,yymajor,
148988149045
yyminor sqlite3ParserCTX_PARAM);
148989149046
}else if( yyact <= YY_MAX_SHIFTREDUCE ){
148990
- yy_shift(yypParser,yyact,yymajor,yyminor);
149047
+ yy_shift(yypParser,yyact,(YYCODETYPE)yymajor,yyminor);
148991149048
#ifndef YYNOERRORRECOVERY
148992149049
yypParser->yyerrcnt--;
148993149050
#endif
148994149051
break;
148995149052
}else if( yyact==YY_ACCEPT_ACTION ){
@@ -151421,11 +151478,11 @@
151421151478
db->flags |= aFlagOp[i].mask;
151422151479
}else if( onoff==0 ){
151423151480
db->flags &= ~aFlagOp[i].mask;
151424151481
}
151425151482
if( oldFlags!=db->flags ){
151426
- sqlite3ExpirePreparedStatements(db);
151483
+ sqlite3ExpirePreparedStatements(db, 0);
151427151484
}
151428151485
if( pRes ){
151429151486
*pRes = (db->flags & aFlagOp[i].mask)!=0;
151430151487
}
151431151488
rc = SQLITE_OK;
@@ -151864,11 +151921,11 @@
151864151921
}
151865151922
sqlite3VtabRollback(db);
151866151923
sqlite3EndBenignMalloc();
151867151924
151868151925
if( schemaChange ){
151869
- sqlite3ExpirePreparedStatements(db);
151926
+ sqlite3ExpirePreparedStatements(db, 0);
151870151927
sqlite3ResetAllSchemasOfConnection(db);
151871151928
}
151872151929
sqlite3BtreeLeaveAll(db);
151873151930
151874151931
/* Any deferred constraint violations have now been resolved. */
@@ -152319,11 +152376,11 @@
152319152376
sqlite3ErrorWithMsg(db, SQLITE_BUSY,
152320152377
"unable to delete/modify user-function due to active statements");
152321152378
assert( !db->mallocFailed );
152322152379
return SQLITE_BUSY;
152323152380
}else{
152324
- sqlite3ExpirePreparedStatements(db);
152381
+ sqlite3ExpirePreparedStatements(db, 0);
152325152382
}
152326152383
}
152327152384
152328152385
p = sqlite3FindFunction(db, zFunctionName, nArg, (u8)enc, 1);
152329152386
assert(p || db->mallocFailed);
@@ -153094,11 +153151,11 @@
153094153151
if( db->nVdbeActive ){
153095153152
sqlite3ErrorWithMsg(db, SQLITE_BUSY,
153096153153
"unable to delete/modify collation sequence due to active statements");
153097153154
return SQLITE_BUSY;
153098153155
}
153099
- sqlite3ExpirePreparedStatements(db);
153156
+ sqlite3ExpirePreparedStatements(db, 0);
153100153157
153101153158
/* If collation sequence pColl was created directly by a call to
153102153159
** sqlite3_create_collation, and not generated by synthCollSeq(),
153103153160
** then any copies made by synthCollSeq() need to be invalidated.
153104153161
** Also, collation destructor - CollSeq.xDel() - function may need
@@ -194031,16 +194088,18 @@
194031194088
rc = sqlite3_create_function(db, aFunc[i].zName, aFunc[i].nArg,
194032194089
SQLITE_UTF8 | SQLITE_DETERMINISTIC,
194033194090
(void*)&aFunc[i].flag,
194034194091
aFunc[i].xFunc, 0, 0);
194035194092
}
194093
+#ifndef SQLITE_OMIT_WINDOWFUNC
194036194094
for(i=0; i<sizeof(aAgg)/sizeof(aAgg[0]) && rc==SQLITE_OK; i++){
194037194095
rc = sqlite3_create_window_function(db, aAgg[i].zName, aAgg[i].nArg,
194038194096
SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
194039194097
aAgg[i].xStep, aAgg[i].xFinal,
194040194098
aAgg[i].xValue, jsonGroupInverse, 0);
194041194099
}
194100
+#endif
194042194101
#ifndef SQLITE_OMIT_VIRTUALTABLE
194043194102
for(i=0; i<sizeof(aMod)/sizeof(aMod[0]) && rc==SQLITE_OK; i++){
194044194103
rc = sqlite3_create_module(db, aMod[i].zName, aMod[i].pModule, 0);
194045194104
}
194046194105
#endif
@@ -196237,11 +196296,11 @@
196237196296
196238196297
/*
196239196298
** Find the appropriate action for a parser given the non-terminal
196240196299
** look-ahead token iLookAhead.
196241196300
*/
196242
-static int fts5yy_find_reduce_action(
196301
+static fts5YYACTIONTYPE fts5yy_find_reduce_action(
196243196302
fts5YYACTIONTYPE stateno, /* Current state number */
196244196303
fts5YYCODETYPE iLookAhead /* The look-ahead token */
196245196304
){
196246196305
int i;
196247196306
#ifdef fts5YYERRORSYMBOL
@@ -196405,11 +196464,11 @@
196405196464
int fts5yyLookahead, /* Lookahead token, or fts5YYNOCODE if none */
196406196465
sqlite3Fts5ParserFTS5TOKENTYPE fts5yyLookaheadToken /* Value of the lookahead token */
196407196466
sqlite3Fts5ParserCTX_PDECL /* %extra_context */
196408196467
){
196409196468
int fts5yygoto; /* The next state */
196410
- int fts5yyact; /* The next action */
196469
+ fts5YYACTIONTYPE fts5yyact; /* The next action */
196411196470
fts5yyStackEntry *fts5yymsp; /* The top of the parser's stack */
196412196471
int fts5yysize; /* Amount to pop the stack */
196413196472
sqlite3Fts5ParserARG_FETCH
196414196473
(void)fts5yyLookahead;
196415196474
(void)fts5yyLookaheadToken;
@@ -196761,16 +196820,16 @@
196761196820
}
196762196821
#endif
196763196822
196764196823
do{
196765196824
assert( fts5yyact==fts5yypParser->fts5yytos->stateno );
196766
- fts5yyact = fts5yy_find_shift_action(fts5yymajor,fts5yyact);
196825
+ fts5yyact = fts5yy_find_shift_action((fts5YYCODETYPE)fts5yymajor,fts5yyact);
196767196826
if( fts5yyact >= fts5YY_MIN_REDUCE ){
196768196827
fts5yyact = fts5yy_reduce(fts5yypParser,fts5yyact-fts5YY_MIN_REDUCE,fts5yymajor,
196769196828
fts5yyminor sqlite3Fts5ParserCTX_PARAM);
196770196829
}else if( fts5yyact <= fts5YY_MAX_SHIFTREDUCE ){
196771
- fts5yy_shift(fts5yypParser,fts5yyact,fts5yymajor,fts5yyminor);
196830
+ fts5yy_shift(fts5yypParser,fts5yyact,(fts5YYCODETYPE)fts5yymajor,fts5yyminor);
196772196831
#ifndef fts5YYNOERRORRECOVERY
196773196832
fts5yypParser->fts5yyerrcnt--;
196774196833
#endif
196775196834
break;
196776196835
}else if( fts5yyact==fts5YY_ACCEPT_ACTION ){
@@ -211513,11 +211572,11 @@
211513211572
int nArg, /* Number of args */
211514211573
sqlite3_value **apUnused /* Function arguments */
211515211574
){
211516211575
assert( nArg==0 );
211517211576
UNUSED_PARAM2(nArg, apUnused);
211518
- sqlite3_result_text(pCtx, "fts5: 2018-07-18 19:09:07 a5087c5c87ad65f92e3bc96bbc84afb43faf10ab6b9ed3ba16304b5c60ad069f", -1, SQLITE_TRANSIENT);
211577
+ sqlite3_result_text(pCtx, "fts5: 2018-07-24 22:02:12 2bd593332da0aade467e7a4ee89e966aa6302f37540a2c5e23671f98a6cb599c", -1, SQLITE_TRANSIENT);
211519211578
}
211520211579
211521211580
static int fts5Init(sqlite3 *db){
211522211581
static const sqlite3_module fts5Mod = {
211523211582
/* iVersion */ 2,
@@ -214799,11 +214858,11 @@
214799214858
int iTbl = 0;
214800214859
while( i<128 ){
214801214860
int bToken = aArray[ aFts5UnicodeData[iTbl] & 0x1F ];
214802214861
int n = (aFts5UnicodeData[iTbl] >> 5) + i;
214803214862
for(; i<128 && i<n; i++){
214804
- aAscii[i] = bToken;
214863
+ aAscii[i] = (u8)bToken;
214805214864
}
214806214865
iTbl++;
214807214866
}
214808214867
}
214809214868
@@ -216223,12 +216282,12 @@
216223216282
}
216224216283
#endif /* SQLITE_CORE */
216225216284
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
216226216285
216227216286
/************** End of stmt.c ************************************************/
216228
-#if __LINE__!=216228
216287
+#if __LINE__!=216287
216229216288
#undef SQLITE_SOURCE_ID
216230
-#define SQLITE_SOURCE_ID "2018-07-18 19:09:07 a5087c5c87ad65f92e3bc96bbc84afb43faf10ab6b9ed3ba16304b5c60adalt2"
216289
+#define SQLITE_SOURCE_ID "2018-07-24 22:02:12 2bd593332da0aade467e7a4ee89e966aa6302f37540a2c5e23671f98a6cbalt2"
216231216290
#endif
216232216291
/* Return the source-id for this library */
216233216292
SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
216234216293
/************************** End of sqlite3.c ******************************/
216235216294
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -53,10 +53,16 @@
53 /* These macros are provided to "stringify" the value of the define
54 ** for those options in which the value is meaningful. */
55 #define CTIMEOPT_VAL_(opt) #opt
56 #define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt)
57
 
 
 
 
 
 
58 /*
59 ** An array of names of all compile-time options. This array should
60 ** be sorted A-Z.
61 **
62 ** This array looks large, but in a typical installation actually uses
@@ -136,11 +142,11 @@
136 #endif
137 #ifdef SQLITE_DEFAULT_LOCKING_MODE
138 "DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE),
139 #endif
140 #ifdef SQLITE_DEFAULT_LOOKASIDE
141 "DEFAULT_LOOKASIDE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOOKASIDE),
142 #endif
143 #if SQLITE_DEFAULT_MEMSTATUS
144 "DEFAULT_MEMSTATUS",
145 #endif
146 #ifdef SQLITE_DEFAULT_MMAP_SIZE
@@ -1150,11 +1156,11 @@
1150 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1151 ** [sqlite_version()] and [sqlite_source_id()].
1152 */
1153 #define SQLITE_VERSION "3.25.0"
1154 #define SQLITE_VERSION_NUMBER 3025000
1155 #define SQLITE_SOURCE_ID "2018-07-18 19:09:07 a5087c5c87ad65f92e3bc96bbc84afb43faf10ab6b9ed3ba16304b5c60ad069f"
1156
1157 /*
1158 ** CAPI3REF: Run-Time Library Version Numbers
1159 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1160 **
@@ -1912,11 +1918,12 @@
1912 ** interrogated. The zDbName parameter is ignored.
1913 **
1914 ** <li>[[SQLITE_FCNTL_PERSIST_WAL]]
1915 ** ^The [SQLITE_FCNTL_PERSIST_WAL] opcode is used to set or query the
1916 ** persistent [WAL | Write Ahead Log] setting. By default, the auxiliary
1917 ** write ahead log and shared memory files used for transaction control
 
1918 ** are automatically deleted when the latest connection to the database
1919 ** closes. Setting persistent WAL mode causes those files to persist after
1920 ** close. Persisting the files is useful when other processes that do not
1921 ** have write permission on the directory containing the database file want
1922 ** to read the database file, as the WAL and shared memory files must exist
@@ -9985,11 +9992,10 @@
9985 SQLITE_API int sqlite3_system_errno(sqlite3*);
9986
9987 /*
9988 ** CAPI3REF: Database Snapshot
9989 ** KEYWORDS: {snapshot} {sqlite3_snapshot}
9990 ** EXPERIMENTAL
9991 **
9992 ** An instance of the snapshot object records the state of a [WAL mode]
9993 ** database for some specific point in history.
9994 **
9995 ** In [WAL mode], multiple [database connections] that are open on the
@@ -10002,23 +10008,18 @@
10002 **
10003 ** The sqlite3_snapshot object records state information about an historical
10004 ** version of the database file so that it is possible to later open a new read
10005 ** transaction that sees that historical version of the database rather than
10006 ** the most recent version.
10007 **
10008 ** The constructor for this object is [sqlite3_snapshot_get()]. The
10009 ** [sqlite3_snapshot_open()] method causes a fresh read transaction to refer
10010 ** to an historical snapshot (if possible). The destructor for
10011 ** sqlite3_snapshot objects is [sqlite3_snapshot_free()].
10012 */
10013 typedef struct sqlite3_snapshot {
10014 unsigned char hidden[48];
10015 } sqlite3_snapshot;
10016
10017 /*
10018 ** CAPI3REF: Record A Database Snapshot
10019 ** EXPERIMENTAL
10020 **
10021 ** ^The [sqlite3_snapshot_get(D,S,P)] interface attempts to make a
10022 ** new [sqlite3_snapshot] object that records the current state of
10023 ** schema S in database connection D. ^On success, the
10024 ** [sqlite3_snapshot_get(D,S,P)] interface writes a pointer to the newly
@@ -10053,21 +10054,21 @@
10053 ** The [sqlite3_snapshot] object returned from a successful call to
10054 ** [sqlite3_snapshot_get()] must be freed using [sqlite3_snapshot_free()]
10055 ** to avoid a memory leak.
10056 **
10057 ** The [sqlite3_snapshot_get()] interface is only available when the
10058 ** SQLITE_ENABLE_SNAPSHOT compile-time option is used.
10059 */
10060 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_get(
10061 sqlite3 *db,
10062 const char *zSchema,
10063 sqlite3_snapshot **ppSnapshot
10064 );
10065
10066 /*
10067 ** CAPI3REF: Start a read transaction on an historical snapshot
10068 ** EXPERIMENTAL
10069 **
10070 ** ^The [sqlite3_snapshot_open(D,S,P)] interface starts a
10071 ** read transaction for schema S of
10072 ** [database connection] D such that the read transaction
10073 ** refers to historical [snapshot] P, rather than the most
@@ -10091,34 +10092,34 @@
10091 ** after the most recent I/O on the database connection.)^
10092 ** (Hint: Run "[PRAGMA application_id]" against a newly opened
10093 ** database connection in order to make it ready to use snapshots.)
10094 **
10095 ** The [sqlite3_snapshot_open()] interface is only available when the
10096 ** SQLITE_ENABLE_SNAPSHOT compile-time option is used.
10097 */
10098 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_open(
10099 sqlite3 *db,
10100 const char *zSchema,
10101 sqlite3_snapshot *pSnapshot
10102 );
10103
10104 /*
10105 ** CAPI3REF: Destroy a snapshot
10106 ** EXPERIMENTAL
10107 **
10108 ** ^The [sqlite3_snapshot_free(P)] interface destroys [sqlite3_snapshot] P.
10109 ** The application must eventually free every [sqlite3_snapshot] object
10110 ** using this routine to avoid a memory leak.
10111 **
10112 ** The [sqlite3_snapshot_free()] interface is only available when the
10113 ** SQLITE_ENABLE_SNAPSHOT compile-time option is used.
10114 */
10115 SQLITE_API SQLITE_EXPERIMENTAL void sqlite3_snapshot_free(sqlite3_snapshot*);
10116
10117 /*
10118 ** CAPI3REF: Compare the ages of two snapshot handles.
10119 ** EXPERIMENTAL
10120 **
10121 ** The sqlite3_snapshot_cmp(P1, P2) interface is used to compare the ages
10122 ** of two valid snapshot handles.
10123 **
10124 ** If the two snapshot handles are not associated with the same database
@@ -10133,35 +10134,41 @@
10133 ** is undefined.
10134 **
10135 ** Otherwise, this API returns a negative value if P1 refers to an older
10136 ** snapshot than P2, zero if the two handles refer to the same database
10137 ** snapshot, and a positive value if P1 is a newer snapshot than P2.
 
 
 
10138 */
10139 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_cmp(
10140 sqlite3_snapshot *p1,
10141 sqlite3_snapshot *p2
10142 );
10143
10144 /*
10145 ** CAPI3REF: Recover snapshots from a wal file
10146 ** EXPERIMENTAL
10147 **
10148 ** If all connections disconnect from a database file but do not perform
10149 ** a checkpoint, the existing wal file is opened along with the database
10150 ** file the next time the database is opened. At this point it is only
10151 ** possible to successfully call sqlite3_snapshot_open() to open the most
10152 ** recent snapshot of the database (the one at the head of the wal file),
10153 ** even though the wal file may contain other valid snapshots for which
10154 ** clients have sqlite3_snapshot handles.
10155 **
10156 ** This function attempts to scan the wal file associated with database zDb
10157 ** of database handle db and make all valid snapshots available to
10158 ** sqlite3_snapshot_open(). It is an error if there is already a read
10159 ** transaction open on the database, or if the database is not a wal mode
10160 ** database.
10161 **
10162 ** SQLITE_OK is returned if successful, or an SQLite error code otherwise.
 
 
 
10163 */
10164 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const char *zDb);
10165
10166 /*
10167 ** CAPI3REF: Serialize a database
@@ -18937,11 +18944,11 @@
18937 SQLITE_PRIVATE void sqlite3Reindex(Parse*, Token*, Token*);
18938 SQLITE_PRIVATE void sqlite3AlterFunctions(void);
18939 SQLITE_PRIVATE void sqlite3AlterRenameTable(Parse*, SrcList*, Token*);
18940 SQLITE_PRIVATE int sqlite3GetToken(const unsigned char *, int *);
18941 SQLITE_PRIVATE void sqlite3NestedParse(Parse*, const char*, ...);
18942 SQLITE_PRIVATE void sqlite3ExpirePreparedStatements(sqlite3*);
18943 SQLITE_PRIVATE int sqlite3CodeSubselect(Parse*, Expr *, int, int);
18944 SQLITE_PRIVATE void sqlite3SelectPrep(Parse*, Select*, NameContext*);
18945 SQLITE_PRIVATE void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p);
18946 SQLITE_PRIVATE int sqlite3MatchSpanName(const char*, const char*, const char*, const char*);
18947 SQLITE_PRIVATE int sqlite3ResolveExprNames(NameContext*, Expr*);
@@ -20025,13 +20032,13 @@
20025 #endif
20026 u16 nResColumn; /* Number of columns in one row of the result set */
20027 u8 errorAction; /* Recovery action to do in case of an error */
20028 u8 minWriteFileFormat; /* Minimum file format for writable database files */
20029 u8 prepFlags; /* SQLITE_PREPARE_* flags */
20030 bft expired:1; /* True if the VM needs to be recompiled */
20031 bft doingRerun:1; /* True if rerunning after an auto-reprepare */
20032 bft explain:2; /* True if EXPLAIN present on SQL command */
 
20033 bft changeCntOn:1; /* True to update the change-counter */
20034 bft runOnlyOnce:1; /* Automatically expire on reset */
20035 bft usesStmtJournal:1; /* True if uses a statement journal */
20036 bft readOnly:1; /* True for statements that do not write */
20037 bft bIsReader:1; /* True for statements that read */
@@ -28640,11 +28647,11 @@
28640 sqlite3TreeViewLine(pView, "FUNCTION %Q", pExpr->u.zToken);
28641 }
28642 if( pFarg ){
28643 sqlite3TreeViewExprList(pView, pFarg, pWin!=0, 0);
28644 }
28645 #ifndef SQLITe_OMIT_WINDOWFUNC
28646 if( pWin ){
28647 sqlite3TreeViewWindow(pView, pWin, 0);
28648 }
28649 #endif
28650 break;
@@ -42948,10 +42955,13 @@
42948 */
42949 static int winTruncate(sqlite3_file *id, sqlite3_int64 nByte){
42950 winFile *pFile = (winFile*)id; /* File handle object */
42951 int rc = SQLITE_OK; /* Return code for this function */
42952 DWORD lastErrno;
 
 
 
42953
42954 assert( pFile );
42955 SimulateIOError(return SQLITE_IOERR_TRUNCATE);
42956 OSTRACE(("TRUNCATE pid=%lu, pFile=%p, file=%p, size=%lld, lock=%d\n",
42957 osGetCurrentProcessId(), pFile, pFile->h, nByte, pFile->locktype));
@@ -42962,10 +42972,19 @@
42962 ** size).
42963 */
42964 if( pFile->szChunk>0 ){
42965 nByte = ((nByte + pFile->szChunk - 1)/pFile->szChunk) * pFile->szChunk;
42966 }
 
 
 
 
 
 
 
 
 
42967
42968 /* SetEndOfFile() returns non-zero when successful, or zero when it fails. */
42969 if( winSeekFile(pFile, nByte) ){
42970 rc = winLogError(SQLITE_IOERR_TRUNCATE, pFile->lastErrno,
42971 "winTruncate1", pFile->zPath);
@@ -42975,16 +42994,16 @@
42975 rc = winLogError(SQLITE_IOERR_TRUNCATE, pFile->lastErrno,
42976 "winTruncate2", pFile->zPath);
42977 }
42978
42979 #if SQLITE_MAX_MMAP_SIZE>0
42980 /* If the file was truncated to a size smaller than the currently
42981 ** mapped region, reduce the effective mapping size as well. SQLite will
42982 ** use read() and write() to access data beyond this point from now on.
42983 */
42984 if( pFile->pMapRegion && nByte<pFile->mmapSize ){
42985 pFile->mmapSize = nByte;
42986 }
42987 #endif
42988
42989 OSTRACE(("TRUNCATE pid=%lu, pFile=%p, file=%p, rc=%s\n",
42990 osGetCurrentProcessId(), pFile, pFile->h, sqlite3ErrName(rc)));
@@ -56461,22 +56480,22 @@
56461
56462 if( (rc&0xFF)==SQLITE_IOERR && rc!=SQLITE_IOERR_NOMEM ){
56463 rc = sqlite3JournalCreate(pPager->jfd);
56464 if( rc!=SQLITE_OK ){
56465 sqlite3OsClose(pPager->jfd);
 
56466 }
56467 bBatch = 0;
56468 }else{
56469 sqlite3OsClose(pPager->jfd);
56470 }
56471 }
56472 #endif /* SQLITE_ENABLE_BATCH_ATOMIC_WRITE */
56473
56474 if( bBatch==0 && rc==SQLITE_OK ){
56475 rc = pager_write_pagelist(pPager, pList);
56476 }
56477
56478 if( rc!=SQLITE_OK ){
56479 assert( rc!=SQLITE_IOERR_BLOCKED );
56480 goto commit_phase_one_exit;
56481 }
56482 sqlite3PcacheCleanAll(pPager->pPCache);
@@ -65751,10 +65770,16 @@
65751 */
65752 if( p->inTrans==TRANS_WRITE || (p->inTrans==TRANS_READ && !wrflag) ){
65753 goto trans_begun;
65754 }
65755 assert( pBt->inTransaction==TRANS_WRITE || IfNotOmitAV(pBt->bDoTruncate)==0 );
 
 
 
 
 
 
65756
65757 /* Write transactions are not possible on a read-only database */
65758 if( (pBt->btsFlags & BTS_READ_ONLY)!=0 && wrflag ){
65759 rc = SQLITE_READONLY;
65760 goto trans_begun;
@@ -71767,12 +71792,11 @@
71767 ** if this is the first reference to the page.
71768 **
71769 ** Also check that the page number is in bounds.
71770 */
71771 static int checkRef(IntegrityCk *pCheck, Pgno iPage){
71772 if( iPage==0 ) return 1;
71773 if( iPage>pCheck->nPage ){
71774 checkAppendMsg(pCheck, "invalid page number %d", iPage);
71775 return 1;
71776 }
71777 if( getPageReferenced(pCheck, iPage) ){
71778 checkAppendMsg(pCheck, "2nd reference to page %d", iPage);
@@ -71823,21 +71847,16 @@
71823 int iPage, /* Page number for first page in the list */
71824 int N /* Expected number of pages in the list */
71825 ){
71826 int i;
71827 int expected = N;
71828 int iFirst = iPage;
71829 while( N-- > 0 && pCheck->mxErr ){
71830 DbPage *pOvflPage;
71831 unsigned char *pOvflData;
71832 if( iPage<1 ){
71833 checkAppendMsg(pCheck,
71834 "%d of %d pages missing from overflow list starting at %d",
71835 N+1, expected, iFirst);
71836 break;
71837 }
71838 if( checkRef(pCheck, iPage) ) break;
 
71839 if( sqlite3PagerGet(pCheck->pPager, (Pgno)iPage, &pOvflPage, 0) ){
71840 checkAppendMsg(pCheck, "failed to get page %d", iPage);
71841 break;
71842 }
71843 pOvflData = (unsigned char *)sqlite3PagerGetData(pOvflPage);
@@ -71877,14 +71896,16 @@
71877 }
71878 }
71879 #endif
71880 iPage = get4byte(pOvflData);
71881 sqlite3PagerUnref(pOvflPage);
71882
71883 if( isFreeList && N<(iPage!=0) ){
71884 checkAppendMsg(pCheck, "free-page count in header is too small");
71885 }
 
 
71886 }
71887 }
71888 #endif /* SQLITE_OMIT_INTEGRITY_CHECK */
71889
71890 /*
@@ -72274,10 +72295,28 @@
72274 get4byte(&pBt->pPage1->aData[36]));
72275 sCheck.zPfx = 0;
72276
72277 /* Check all the tables.
72278 */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72279 testcase( pBt->db->flags & SQLITE_CellSizeCk );
72280 pBt->db->flags &= ~SQLITE_CellSizeCk;
72281 for(i=0; (int)i<nRoot && sCheck.mxErr; i++){
72282 i64 notUsed;
72283 if( aRoot[i]==0 ) continue;
@@ -79974,15 +80013,23 @@
79974 ** An expired statement means that recompilation of the statement is
79975 ** recommend. Statements expire when things happen that make their
79976 ** programs obsolete. Removing user-defined functions or collating
79977 ** sequences, or changing an authorization function are the types of
79978 ** things that make prepared statements obsolete.
 
 
 
 
 
 
 
 
79979 */
79980 SQLITE_PRIVATE void sqlite3ExpirePreparedStatements(sqlite3 *db){
79981 Vdbe *p;
79982 for(p = db->pVdbe; p; p=p->pNext){
79983 p->expired = 1;
79984 }
79985 }
79986
79987 /*
79988 ** Return the database associated with the Vdbe.
@@ -85520,11 +85567,11 @@
85520 if( rc!=SQLITE_OK ){
85521 goto abort_due_to_error;
85522 }
85523 }
85524 if( isSchemaChange ){
85525 sqlite3ExpirePreparedStatements(db);
85526 sqlite3ResetAllSchemasOfConnection(db);
85527 db->mDbFlags |= DBFLAG_SchemaChange;
85528 }
85529 }
85530
@@ -85809,11 +85856,11 @@
85809 pDb->pSchema->file_format = pOp->p3;
85810 }
85811 if( pOp->p1==1 ){
85812 /* Invalidate all prepared statements whenever the TEMP database
85813 ** schema is changed. Ticket #1644 */
85814 sqlite3ExpirePreparedStatements(db);
85815 p->expired = 0;
85816 }
85817 if( rc ) goto abort_due_to_error;
85818 break;
85819 }
@@ -85927,11 +85974,11 @@
85927 assert( pOp->opcode==OP_OpenWrite || pOp->p5==0 || pOp->p5==OPFLAG_SEEKEQ );
85928 assert( p->bIsReader );
85929 assert( pOp->opcode==OP_OpenRead || pOp->opcode==OP_ReopenIdx
85930 || p->readOnly==0 );
85931
85932 if( p->expired ){
85933 rc = SQLITE_ABORT_ROLLBACK;
85934 goto abort_due_to_error;
85935 }
85936
85937 nField = 0;
@@ -89108,25 +89155,32 @@
89108 }
89109 break;
89110 }
89111 #endif
89112
89113 /* Opcode: Expire P1 * * * *
89114 **
89115 ** Cause precompiled statements to expire. When an expired statement
89116 ** is executed using sqlite3_step() it will either automatically
89117 ** reprepare itself (if it was originally created using sqlite3_prepare_v2())
89118 ** or it will fail with SQLITE_SCHEMA.
89119 **
89120 ** If P1 is 0, then all SQL statements become expired. If P1 is non-zero,
89121 ** then only the currently executing statement is expired.
 
 
 
 
 
 
89122 */
89123 case OP_Expire: {
 
89124 if( !pOp->p1 ){
89125 sqlite3ExpirePreparedStatements(db);
89126 }else{
89127 p->expired = 1;
89128 }
89129 break;
89130 }
89131
89132 #ifndef SQLITE_OMIT_SHARED_CACHE
@@ -103813,11 +103867,11 @@
103813 if( !pIdx->hasStat1 ) sqlite3DefaultRowEst(pIdx);
103814 }
103815
103816 /* Load the statistics from the sqlite_stat4 table. */
103817 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
103818 if( rc==SQLITE_OK && OptimizationEnabled(db, SQLITE_Stat34) ){
103819 db->lookaside.bDisable++;
103820 rc = loadStat4(db, sInfo.zDatabase);
103821 db->lookaside.bDisable--;
103822 }
103823 for(i=sqliteHashFirst(&pSchema->idxHash); i; i=sqliteHashNext(i)){
@@ -104545,11 +104599,11 @@
104545 if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
104546 #endif
104547 sqlite3_mutex_enter(db->mutex);
104548 db->xAuth = (sqlite3_xauth)xAuth;
104549 db->pAuthArg = pArg;
104550 sqlite3ExpirePreparedStatements(db);
104551 sqlite3_mutex_leave(db->mutex);
104552 return SQLITE_OK;
104553 }
104554
104555 /*
@@ -108209,11 +108263,11 @@
108209 if( pTblName ){
108210 sqlite3RefillIndex(pParse, pIndex, iMem);
108211 sqlite3ChangeCookie(pParse, iDb);
108212 sqlite3VdbeAddParseSchemaOp(v, iDb,
108213 sqlite3MPrintf(db, "name='%q' AND type='index'", pIndex->zName));
108214 sqlite3VdbeAddOp0(v, OP_Expire);
108215 }
108216
108217 sqlite3VdbeJumpHere(v, pIndex->tnum);
108218 }
108219
@@ -131894,11 +131948,11 @@
131894
131895 assert( sqlite3BtreeHoldsAllMutexes(db) );
131896 assert( sqlite3_mutex_held(db->mutex) );
131897
131898 if( p ){
131899 sqlite3ExpirePreparedStatements(db);
131900 do {
131901 VTable *pNext = p->pNext;
131902 sqlite3VtabUnlock(p);
131903 p = pNext;
131904 }while( p );
@@ -138680,11 +138734,13 @@
138680
138681 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
138682 Index *p = pLoop->u.btree.pIndex;
138683 int nEq = pLoop->u.btree.nEq;
138684
138685 if( p->nSample>0 && nEq<p->nSampleCol ){
 
 
138686 if( nEq==pBuilder->nRecValid ){
138687 UnpackedRecord *pRec = pBuilder->pRec;
138688 tRowcnt a[2];
138689 int nBtm = pLoop->u.btree.nBtm;
138690 int nTop = pLoop->u.btree.nTop;
@@ -139828,10 +139884,11 @@
139828 tRowcnt nOut = 0;
139829 if( nInMul==0
139830 && pProbe->nSample
139831 && pNew->u.btree.nEq<=pProbe->nSampleCol
139832 && ((eOp & WO_IN)==0 || !ExprHasProperty(pTerm->pExpr, EP_xIsSelect))
 
139833 ){
139834 Expr *pExpr = pTerm->pExpr;
139835 if( (eOp & (WO_EQ|WO_ISNULL|WO_IS))!=0 ){
139836 testcase( eOp & WO_EQ );
139837 testcase( eOp & WO_IS );
@@ -146916,11 +146973,11 @@
146916
146917 /*
146918 ** Find the appropriate action for a parser given the non-terminal
146919 ** look-ahead token iLookAhead.
146920 */
146921 static int yy_find_reduce_action(
146922 YYACTIONTYPE stateno, /* Current state number */
146923 YYCODETYPE iLookAhead /* The look-ahead token */
146924 ){
146925 int i;
146926 #ifdef YYERRORSYMBOL
@@ -147421,11 +147478,11 @@
147421 int yyLookahead, /* Lookahead token, or YYNOCODE if none */
147422 sqlite3ParserTOKENTYPE yyLookaheadToken /* Value of the lookahead token */
147423 sqlite3ParserCTX_PDECL /* %extra_context */
147424 ){
147425 int yygoto; /* The next state */
147426 int yyact; /* The next action */
147427 yyStackEntry *yymsp; /* The top of the parser's stack */
147428 int yysize; /* Amount to pop the stack */
147429 sqlite3ParserARG_FETCH
147430 (void)yyLookahead;
147431 (void)yyLookaheadToken;
@@ -148980,16 +149037,16 @@
148980 }
148981 #endif
148982
148983 do{
148984 assert( yyact==yypParser->yytos->stateno );
148985 yyact = yy_find_shift_action(yymajor,yyact);
148986 if( yyact >= YY_MIN_REDUCE ){
148987 yyact = yy_reduce(yypParser,yyact-YY_MIN_REDUCE,yymajor,
148988 yyminor sqlite3ParserCTX_PARAM);
148989 }else if( yyact <= YY_MAX_SHIFTREDUCE ){
148990 yy_shift(yypParser,yyact,yymajor,yyminor);
148991 #ifndef YYNOERRORRECOVERY
148992 yypParser->yyerrcnt--;
148993 #endif
148994 break;
148995 }else if( yyact==YY_ACCEPT_ACTION ){
@@ -151421,11 +151478,11 @@
151421 db->flags |= aFlagOp[i].mask;
151422 }else if( onoff==0 ){
151423 db->flags &= ~aFlagOp[i].mask;
151424 }
151425 if( oldFlags!=db->flags ){
151426 sqlite3ExpirePreparedStatements(db);
151427 }
151428 if( pRes ){
151429 *pRes = (db->flags & aFlagOp[i].mask)!=0;
151430 }
151431 rc = SQLITE_OK;
@@ -151864,11 +151921,11 @@
151864 }
151865 sqlite3VtabRollback(db);
151866 sqlite3EndBenignMalloc();
151867
151868 if( schemaChange ){
151869 sqlite3ExpirePreparedStatements(db);
151870 sqlite3ResetAllSchemasOfConnection(db);
151871 }
151872 sqlite3BtreeLeaveAll(db);
151873
151874 /* Any deferred constraint violations have now been resolved. */
@@ -152319,11 +152376,11 @@
152319 sqlite3ErrorWithMsg(db, SQLITE_BUSY,
152320 "unable to delete/modify user-function due to active statements");
152321 assert( !db->mallocFailed );
152322 return SQLITE_BUSY;
152323 }else{
152324 sqlite3ExpirePreparedStatements(db);
152325 }
152326 }
152327
152328 p = sqlite3FindFunction(db, zFunctionName, nArg, (u8)enc, 1);
152329 assert(p || db->mallocFailed);
@@ -153094,11 +153151,11 @@
153094 if( db->nVdbeActive ){
153095 sqlite3ErrorWithMsg(db, SQLITE_BUSY,
153096 "unable to delete/modify collation sequence due to active statements");
153097 return SQLITE_BUSY;
153098 }
153099 sqlite3ExpirePreparedStatements(db);
153100
153101 /* If collation sequence pColl was created directly by a call to
153102 ** sqlite3_create_collation, and not generated by synthCollSeq(),
153103 ** then any copies made by synthCollSeq() need to be invalidated.
153104 ** Also, collation destructor - CollSeq.xDel() - function may need
@@ -194031,16 +194088,18 @@
194031 rc = sqlite3_create_function(db, aFunc[i].zName, aFunc[i].nArg,
194032 SQLITE_UTF8 | SQLITE_DETERMINISTIC,
194033 (void*)&aFunc[i].flag,
194034 aFunc[i].xFunc, 0, 0);
194035 }
 
194036 for(i=0; i<sizeof(aAgg)/sizeof(aAgg[0]) && rc==SQLITE_OK; i++){
194037 rc = sqlite3_create_window_function(db, aAgg[i].zName, aAgg[i].nArg,
194038 SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
194039 aAgg[i].xStep, aAgg[i].xFinal,
194040 aAgg[i].xValue, jsonGroupInverse, 0);
194041 }
 
194042 #ifndef SQLITE_OMIT_VIRTUALTABLE
194043 for(i=0; i<sizeof(aMod)/sizeof(aMod[0]) && rc==SQLITE_OK; i++){
194044 rc = sqlite3_create_module(db, aMod[i].zName, aMod[i].pModule, 0);
194045 }
194046 #endif
@@ -196237,11 +196296,11 @@
196237
196238 /*
196239 ** Find the appropriate action for a parser given the non-terminal
196240 ** look-ahead token iLookAhead.
196241 */
196242 static int fts5yy_find_reduce_action(
196243 fts5YYACTIONTYPE stateno, /* Current state number */
196244 fts5YYCODETYPE iLookAhead /* The look-ahead token */
196245 ){
196246 int i;
196247 #ifdef fts5YYERRORSYMBOL
@@ -196405,11 +196464,11 @@
196405 int fts5yyLookahead, /* Lookahead token, or fts5YYNOCODE if none */
196406 sqlite3Fts5ParserFTS5TOKENTYPE fts5yyLookaheadToken /* Value of the lookahead token */
196407 sqlite3Fts5ParserCTX_PDECL /* %extra_context */
196408 ){
196409 int fts5yygoto; /* The next state */
196410 int fts5yyact; /* The next action */
196411 fts5yyStackEntry *fts5yymsp; /* The top of the parser's stack */
196412 int fts5yysize; /* Amount to pop the stack */
196413 sqlite3Fts5ParserARG_FETCH
196414 (void)fts5yyLookahead;
196415 (void)fts5yyLookaheadToken;
@@ -196761,16 +196820,16 @@
196761 }
196762 #endif
196763
196764 do{
196765 assert( fts5yyact==fts5yypParser->fts5yytos->stateno );
196766 fts5yyact = fts5yy_find_shift_action(fts5yymajor,fts5yyact);
196767 if( fts5yyact >= fts5YY_MIN_REDUCE ){
196768 fts5yyact = fts5yy_reduce(fts5yypParser,fts5yyact-fts5YY_MIN_REDUCE,fts5yymajor,
196769 fts5yyminor sqlite3Fts5ParserCTX_PARAM);
196770 }else if( fts5yyact <= fts5YY_MAX_SHIFTREDUCE ){
196771 fts5yy_shift(fts5yypParser,fts5yyact,fts5yymajor,fts5yyminor);
196772 #ifndef fts5YYNOERRORRECOVERY
196773 fts5yypParser->fts5yyerrcnt--;
196774 #endif
196775 break;
196776 }else if( fts5yyact==fts5YY_ACCEPT_ACTION ){
@@ -211513,11 +211572,11 @@
211513 int nArg, /* Number of args */
211514 sqlite3_value **apUnused /* Function arguments */
211515 ){
211516 assert( nArg==0 );
211517 UNUSED_PARAM2(nArg, apUnused);
211518 sqlite3_result_text(pCtx, "fts5: 2018-07-18 19:09:07 a5087c5c87ad65f92e3bc96bbc84afb43faf10ab6b9ed3ba16304b5c60ad069f", -1, SQLITE_TRANSIENT);
211519 }
211520
211521 static int fts5Init(sqlite3 *db){
211522 static const sqlite3_module fts5Mod = {
211523 /* iVersion */ 2,
@@ -214799,11 +214858,11 @@
214799 int iTbl = 0;
214800 while( i<128 ){
214801 int bToken = aArray[ aFts5UnicodeData[iTbl] & 0x1F ];
214802 int n = (aFts5UnicodeData[iTbl] >> 5) + i;
214803 for(; i<128 && i<n; i++){
214804 aAscii[i] = bToken;
214805 }
214806 iTbl++;
214807 }
214808 }
214809
@@ -216223,12 +216282,12 @@
216223 }
216224 #endif /* SQLITE_CORE */
216225 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
216226
216227 /************** End of stmt.c ************************************************/
216228 #if __LINE__!=216228
216229 #undef SQLITE_SOURCE_ID
216230 #define SQLITE_SOURCE_ID "2018-07-18 19:09:07 a5087c5c87ad65f92e3bc96bbc84afb43faf10ab6b9ed3ba16304b5c60adalt2"
216231 #endif
216232 /* Return the source-id for this library */
216233 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
216234 /************************** End of sqlite3.c ******************************/
216235
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -53,10 +53,16 @@
53 /* These macros are provided to "stringify" the value of the define
54 ** for those options in which the value is meaningful. */
55 #define CTIMEOPT_VAL_(opt) #opt
56 #define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt)
57
58 /* Like CTIMEOPT_VAL, but especially for SQLITE_DEFAULT_LOOKASIDE. This
59 ** option requires a separate macro because legal values contain a single
60 ** comma. e.g. (-DSQLITE_DEFAULT_LOOKASIDE="100,100") */
61 #define CTIMEOPT_VAL2_(opt1,opt2) #opt1 "," #opt2
62 #define CTIMEOPT_VAL2(opt) CTIMEOPT_VAL2_(opt)
63
64 /*
65 ** An array of names of all compile-time options. This array should
66 ** be sorted A-Z.
67 **
68 ** This array looks large, but in a typical installation actually uses
@@ -136,11 +142,11 @@
142 #endif
143 #ifdef SQLITE_DEFAULT_LOCKING_MODE
144 "DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE),
145 #endif
146 #ifdef SQLITE_DEFAULT_LOOKASIDE
147 "DEFAULT_LOOKASIDE=" CTIMEOPT_VAL2(SQLITE_DEFAULT_LOOKASIDE),
148 #endif
149 #if SQLITE_DEFAULT_MEMSTATUS
150 "DEFAULT_MEMSTATUS",
151 #endif
152 #ifdef SQLITE_DEFAULT_MMAP_SIZE
@@ -1150,11 +1156,11 @@
1156 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1157 ** [sqlite_version()] and [sqlite_source_id()].
1158 */
1159 #define SQLITE_VERSION "3.25.0"
1160 #define SQLITE_VERSION_NUMBER 3025000
1161 #define SQLITE_SOURCE_ID "2018-07-24 22:02:12 2bd593332da0aade467e7a4ee89e966aa6302f37540a2c5e23671f98a6cb599c"
1162
1163 /*
1164 ** CAPI3REF: Run-Time Library Version Numbers
1165 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1166 **
@@ -1912,11 +1918,12 @@
1918 ** interrogated. The zDbName parameter is ignored.
1919 **
1920 ** <li>[[SQLITE_FCNTL_PERSIST_WAL]]
1921 ** ^The [SQLITE_FCNTL_PERSIST_WAL] opcode is used to set or query the
1922 ** persistent [WAL | Write Ahead Log] setting. By default, the auxiliary
1923 ** write ahead log ([WAL file]) and shared memory
1924 ** files used for transaction control
1925 ** are automatically deleted when the latest connection to the database
1926 ** closes. Setting persistent WAL mode causes those files to persist after
1927 ** close. Persisting the files is useful when other processes that do not
1928 ** have write permission on the directory containing the database file want
1929 ** to read the database file, as the WAL and shared memory files must exist
@@ -9985,11 +9992,10 @@
9992 SQLITE_API int sqlite3_system_errno(sqlite3*);
9993
9994 /*
9995 ** CAPI3REF: Database Snapshot
9996 ** KEYWORDS: {snapshot} {sqlite3_snapshot}
 
9997 **
9998 ** An instance of the snapshot object records the state of a [WAL mode]
9999 ** database for some specific point in history.
10000 **
10001 ** In [WAL mode], multiple [database connections] that are open on the
@@ -10002,23 +10008,18 @@
10008 **
10009 ** The sqlite3_snapshot object records state information about an historical
10010 ** version of the database file so that it is possible to later open a new read
10011 ** transaction that sees that historical version of the database rather than
10012 ** the most recent version.
 
 
 
 
 
10013 */
10014 typedef struct sqlite3_snapshot {
10015 unsigned char hidden[48];
10016 } sqlite3_snapshot;
10017
10018 /*
10019 ** CAPI3REF: Record A Database Snapshot
10020 ** CONSTRUCTOR: sqlite3_snapshot
10021 **
10022 ** ^The [sqlite3_snapshot_get(D,S,P)] interface attempts to make a
10023 ** new [sqlite3_snapshot] object that records the current state of
10024 ** schema S in database connection D. ^On success, the
10025 ** [sqlite3_snapshot_get(D,S,P)] interface writes a pointer to the newly
@@ -10053,21 +10054,21 @@
10054 ** The [sqlite3_snapshot] object returned from a successful call to
10055 ** [sqlite3_snapshot_get()] must be freed using [sqlite3_snapshot_free()]
10056 ** to avoid a memory leak.
10057 **
10058 ** The [sqlite3_snapshot_get()] interface is only available when the
10059 ** [SQLITE_ENABLE_SNAPSHOT] compile-time option is used.
10060 */
10061 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_get(
10062 sqlite3 *db,
10063 const char *zSchema,
10064 sqlite3_snapshot **ppSnapshot
10065 );
10066
10067 /*
10068 ** CAPI3REF: Start a read transaction on an historical snapshot
10069 ** METHOD: sqlite3_snapshot
10070 **
10071 ** ^The [sqlite3_snapshot_open(D,S,P)] interface starts a
10072 ** read transaction for schema S of
10073 ** [database connection] D such that the read transaction
10074 ** refers to historical [snapshot] P, rather than the most
@@ -10091,34 +10092,34 @@
10092 ** after the most recent I/O on the database connection.)^
10093 ** (Hint: Run "[PRAGMA application_id]" against a newly opened
10094 ** database connection in order to make it ready to use snapshots.)
10095 **
10096 ** The [sqlite3_snapshot_open()] interface is only available when the
10097 ** [SQLITE_ENABLE_SNAPSHOT] compile-time option is used.
10098 */
10099 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_open(
10100 sqlite3 *db,
10101 const char *zSchema,
10102 sqlite3_snapshot *pSnapshot
10103 );
10104
10105 /*
10106 ** CAPI3REF: Destroy a snapshot
10107 ** DESTRUCTOR: sqlite3_snapshot
10108 **
10109 ** ^The [sqlite3_snapshot_free(P)] interface destroys [sqlite3_snapshot] P.
10110 ** The application must eventually free every [sqlite3_snapshot] object
10111 ** using this routine to avoid a memory leak.
10112 **
10113 ** The [sqlite3_snapshot_free()] interface is only available when the
10114 ** [SQLITE_ENABLE_SNAPSHOT] compile-time option is used.
10115 */
10116 SQLITE_API SQLITE_EXPERIMENTAL void sqlite3_snapshot_free(sqlite3_snapshot*);
10117
10118 /*
10119 ** CAPI3REF: Compare the ages of two snapshot handles.
10120 ** METHOD: sqlite3_snapshot
10121 **
10122 ** The sqlite3_snapshot_cmp(P1, P2) interface is used to compare the ages
10123 ** of two valid snapshot handles.
10124 **
10125 ** If the two snapshot handles are not associated with the same database
@@ -10133,35 +10134,41 @@
10134 ** is undefined.
10135 **
10136 ** Otherwise, this API returns a negative value if P1 refers to an older
10137 ** snapshot than P2, zero if the two handles refer to the same database
10138 ** snapshot, and a positive value if P1 is a newer snapshot than P2.
10139 **
10140 ** This interface is only available if SQLite is compiled with the
10141 ** [SQLITE_ENABLE_SNAPSHOT] option.
10142 */
10143 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_cmp(
10144 sqlite3_snapshot *p1,
10145 sqlite3_snapshot *p2
10146 );
10147
10148 /*
10149 ** CAPI3REF: Recover snapshots from a wal file
10150 ** METHOD: sqlite3_snapshot
10151 **
10152 ** If a [WAL file] remains on disk after all database connections close
10153 ** (either through the use of the [SQLITE_FCNTL_PERSIST_WAL] [file control]
10154 ** or because the last process to have the database opened exited without
10155 ** calling [sqlite3_close()]) and a new connection is subsequently opened
10156 ** on that database and [WAL file], the [sqlite3_snapshot_open()] interface
10157 ** will only be able to open the last transaction added to the WAL file
10158 ** even though the WAL file contains other valid transactions.
10159 **
10160 ** This function attempts to scan the WAL file associated with database zDb
10161 ** of database handle db and make all valid snapshots available to
10162 ** sqlite3_snapshot_open(). It is an error if there is already a read
10163 ** transaction open on the database, or if the database is not a WAL mode
10164 ** database.
10165 **
10166 ** SQLITE_OK is returned if successful, or an SQLite error code otherwise.
10167 **
10168 ** This interface is only available if SQLite is compiled with the
10169 ** [SQLITE_ENABLE_SNAPSHOT] option.
10170 */
10171 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const char *zDb);
10172
10173 /*
10174 ** CAPI3REF: Serialize a database
@@ -18937,11 +18944,11 @@
18944 SQLITE_PRIVATE void sqlite3Reindex(Parse*, Token*, Token*);
18945 SQLITE_PRIVATE void sqlite3AlterFunctions(void);
18946 SQLITE_PRIVATE void sqlite3AlterRenameTable(Parse*, SrcList*, Token*);
18947 SQLITE_PRIVATE int sqlite3GetToken(const unsigned char *, int *);
18948 SQLITE_PRIVATE void sqlite3NestedParse(Parse*, const char*, ...);
18949 SQLITE_PRIVATE void sqlite3ExpirePreparedStatements(sqlite3*, int);
18950 SQLITE_PRIVATE int sqlite3CodeSubselect(Parse*, Expr *, int, int);
18951 SQLITE_PRIVATE void sqlite3SelectPrep(Parse*, Select*, NameContext*);
18952 SQLITE_PRIVATE void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p);
18953 SQLITE_PRIVATE int sqlite3MatchSpanName(const char*, const char*, const char*, const char*);
18954 SQLITE_PRIVATE int sqlite3ResolveExprNames(NameContext*, Expr*);
@@ -20025,13 +20032,13 @@
20032 #endif
20033 u16 nResColumn; /* Number of columns in one row of the result set */
20034 u8 errorAction; /* Recovery action to do in case of an error */
20035 u8 minWriteFileFormat; /* Minimum file format for writable database files */
20036 u8 prepFlags; /* SQLITE_PREPARE_* flags */
20037 bft expired:2; /* 1: recompile VM immediately 2: when convenient */
 
20038 bft explain:2; /* True if EXPLAIN present on SQL command */
20039 bft doingRerun:1; /* True if rerunning after an auto-reprepare */
20040 bft changeCntOn:1; /* True to update the change-counter */
20041 bft runOnlyOnce:1; /* Automatically expire on reset */
20042 bft usesStmtJournal:1; /* True if uses a statement journal */
20043 bft readOnly:1; /* True for statements that do not write */
20044 bft bIsReader:1; /* True for statements that read */
@@ -28640,11 +28647,11 @@
28647 sqlite3TreeViewLine(pView, "FUNCTION %Q", pExpr->u.zToken);
28648 }
28649 if( pFarg ){
28650 sqlite3TreeViewExprList(pView, pFarg, pWin!=0, 0);
28651 }
28652 #ifndef SQLITE_OMIT_WINDOWFUNC
28653 if( pWin ){
28654 sqlite3TreeViewWindow(pView, pWin, 0);
28655 }
28656 #endif
28657 break;
@@ -42948,10 +42955,13 @@
42955 */
42956 static int winTruncate(sqlite3_file *id, sqlite3_int64 nByte){
42957 winFile *pFile = (winFile*)id; /* File handle object */
42958 int rc = SQLITE_OK; /* Return code for this function */
42959 DWORD lastErrno;
42960 #if SQLITE_MAX_MMAP_SIZE>0
42961 sqlite3_int64 oldMmapSize;
42962 #endif
42963
42964 assert( pFile );
42965 SimulateIOError(return SQLITE_IOERR_TRUNCATE);
42966 OSTRACE(("TRUNCATE pid=%lu, pFile=%p, file=%p, size=%lld, lock=%d\n",
42967 osGetCurrentProcessId(), pFile, pFile->h, nByte, pFile->locktype));
@@ -42962,10 +42972,19 @@
42972 ** size).
42973 */
42974 if( pFile->szChunk>0 ){
42975 nByte = ((nByte + pFile->szChunk - 1)/pFile->szChunk) * pFile->szChunk;
42976 }
42977
42978 #if SQLITE_MAX_MMAP_SIZE>0
42979 if( pFile->pMapRegion ){
42980 oldMmapSize = pFile->mmapSize;
42981 }else{
42982 oldMmapSize = 0;
42983 }
42984 winUnmapfile(pFile);
42985 #endif
42986
42987 /* SetEndOfFile() returns non-zero when successful, or zero when it fails. */
42988 if( winSeekFile(pFile, nByte) ){
42989 rc = winLogError(SQLITE_IOERR_TRUNCATE, pFile->lastErrno,
42990 "winTruncate1", pFile->zPath);
@@ -42975,16 +42994,16 @@
42994 rc = winLogError(SQLITE_IOERR_TRUNCATE, pFile->lastErrno,
42995 "winTruncate2", pFile->zPath);
42996 }
42997
42998 #if SQLITE_MAX_MMAP_SIZE>0
42999 if( rc==SQLITE_OK && oldMmapSize>0 ){
43000 if( oldMmapSize>nByte ){
43001 winMapfile(pFile, -1);
43002 }else{
43003 winMapfile(pFile, oldMmapSize);
43004 }
43005 }
43006 #endif
43007
43008 OSTRACE(("TRUNCATE pid=%lu, pFile=%p, file=%p, rc=%s\n",
43009 osGetCurrentProcessId(), pFile, pFile->h, sqlite3ErrName(rc)));
@@ -56461,22 +56480,22 @@
56480
56481 if( (rc&0xFF)==SQLITE_IOERR && rc!=SQLITE_IOERR_NOMEM ){
56482 rc = sqlite3JournalCreate(pPager->jfd);
56483 if( rc!=SQLITE_OK ){
56484 sqlite3OsClose(pPager->jfd);
56485 goto commit_phase_one_exit;
56486 }
56487 bBatch = 0;
56488 }else{
56489 sqlite3OsClose(pPager->jfd);
56490 }
56491 }
56492 #endif /* SQLITE_ENABLE_BATCH_ATOMIC_WRITE */
56493
56494 if( bBatch==0 ){
56495 rc = pager_write_pagelist(pPager, pList);
56496 }
 
56497 if( rc!=SQLITE_OK ){
56498 assert( rc!=SQLITE_IOERR_BLOCKED );
56499 goto commit_phase_one_exit;
56500 }
56501 sqlite3PcacheCleanAll(pPager->pPCache);
@@ -65751,10 +65770,16 @@
65770 */
65771 if( p->inTrans==TRANS_WRITE || (p->inTrans==TRANS_READ && !wrflag) ){
65772 goto trans_begun;
65773 }
65774 assert( pBt->inTransaction==TRANS_WRITE || IfNotOmitAV(pBt->bDoTruncate)==0 );
65775
65776 if( (p->db->flags & SQLITE_ResetDatabase)
65777 && sqlite3PagerIsreadonly(pBt->pPager)==0
65778 ){
65779 pBt->btsFlags &= ~BTS_READ_ONLY;
65780 }
65781
65782 /* Write transactions are not possible on a read-only database */
65783 if( (pBt->btsFlags & BTS_READ_ONLY)!=0 && wrflag ){
65784 rc = SQLITE_READONLY;
65785 goto trans_begun;
@@ -71767,12 +71792,11 @@
71792 ** if this is the first reference to the page.
71793 **
71794 ** Also check that the page number is in bounds.
71795 */
71796 static int checkRef(IntegrityCk *pCheck, Pgno iPage){
71797 if( iPage>pCheck->nPage || iPage==0 ){
 
71798 checkAppendMsg(pCheck, "invalid page number %d", iPage);
71799 return 1;
71800 }
71801 if( getPageReferenced(pCheck, iPage) ){
71802 checkAppendMsg(pCheck, "2nd reference to page %d", iPage);
@@ -71823,21 +71847,16 @@
71847 int iPage, /* Page number for first page in the list */
71848 int N /* Expected number of pages in the list */
71849 ){
71850 int i;
71851 int expected = N;
71852 int nErrAtStart = pCheck->nErr;
71853 while( iPage!=0 && pCheck->mxErr ){
71854 DbPage *pOvflPage;
71855 unsigned char *pOvflData;
 
 
 
 
 
 
71856 if( checkRef(pCheck, iPage) ) break;
71857 N--;
71858 if( sqlite3PagerGet(pCheck->pPager, (Pgno)iPage, &pOvflPage, 0) ){
71859 checkAppendMsg(pCheck, "failed to get page %d", iPage);
71860 break;
71861 }
71862 pOvflData = (unsigned char *)sqlite3PagerGetData(pOvflPage);
@@ -71877,14 +71896,16 @@
71896 }
71897 }
71898 #endif
71899 iPage = get4byte(pOvflData);
71900 sqlite3PagerUnref(pOvflPage);
71901 }
71902 if( N && nErrAtStart==pCheck->nErr ){
71903 checkAppendMsg(pCheck,
71904 "%s is %d but should be %d",
71905 isFreeList ? "size" : "overflow list length",
71906 expected-N, expected);
71907 }
71908 }
71909 #endif /* SQLITE_OMIT_INTEGRITY_CHECK */
71910
71911 /*
@@ -72274,10 +72295,28 @@
72295 get4byte(&pBt->pPage1->aData[36]));
72296 sCheck.zPfx = 0;
72297
72298 /* Check all the tables.
72299 */
72300 #ifndef SQLITE_OMIT_AUTOVACUUM
72301 if( pBt->autoVacuum ){
72302 int mx = 0;
72303 int mxInHdr;
72304 for(i=0; (int)i<nRoot; i++) if( mx<aRoot[i] ) mx = aRoot[i];
72305 mxInHdr = get4byte(&pBt->pPage1->aData[52]);
72306 if( mx!=mxInHdr ){
72307 checkAppendMsg(&sCheck,
72308 "max rootpage (%d) disagrees with header (%d)",
72309 mx, mxInHdr
72310 );
72311 }
72312 }else if( get4byte(&pBt->pPage1->aData[64])!=0 ){
72313 checkAppendMsg(&sCheck,
72314 "incremental_vacuum enabled with a max rootpage of zero"
72315 );
72316 }
72317 #endif
72318 testcase( pBt->db->flags & SQLITE_CellSizeCk );
72319 pBt->db->flags &= ~SQLITE_CellSizeCk;
72320 for(i=0; (int)i<nRoot && sCheck.mxErr; i++){
72321 i64 notUsed;
72322 if( aRoot[i]==0 ) continue;
@@ -79974,15 +80013,23 @@
80013 ** An expired statement means that recompilation of the statement is
80014 ** recommend. Statements expire when things happen that make their
80015 ** programs obsolete. Removing user-defined functions or collating
80016 ** sequences, or changing an authorization function are the types of
80017 ** things that make prepared statements obsolete.
80018 **
80019 ** If iCode is 1, then expiration is advisory. The statement should
80020 ** be reprepared before being restarted, but if it is already running
80021 ** it is allowed to run to completion.
80022 **
80023 ** Internally, this function just sets the Vdbe.expired flag on all
80024 ** prepared statements. The flag is set to 1 for an immediate expiration
80025 ** and set to 2 for an advisory expiration.
80026 */
80027 SQLITE_PRIVATE void sqlite3ExpirePreparedStatements(sqlite3 *db, int iCode){
80028 Vdbe *p;
80029 for(p = db->pVdbe; p; p=p->pNext){
80030 p->expired = iCode+1;
80031 }
80032 }
80033
80034 /*
80035 ** Return the database associated with the Vdbe.
@@ -85520,11 +85567,11 @@
85567 if( rc!=SQLITE_OK ){
85568 goto abort_due_to_error;
85569 }
85570 }
85571 if( isSchemaChange ){
85572 sqlite3ExpirePreparedStatements(db, 0);
85573 sqlite3ResetAllSchemasOfConnection(db);
85574 db->mDbFlags |= DBFLAG_SchemaChange;
85575 }
85576 }
85577
@@ -85809,11 +85856,11 @@
85856 pDb->pSchema->file_format = pOp->p3;
85857 }
85858 if( pOp->p1==1 ){
85859 /* Invalidate all prepared statements whenever the TEMP database
85860 ** schema is changed. Ticket #1644 */
85861 sqlite3ExpirePreparedStatements(db, 0);
85862 p->expired = 0;
85863 }
85864 if( rc ) goto abort_due_to_error;
85865 break;
85866 }
@@ -85927,11 +85974,11 @@
85974 assert( pOp->opcode==OP_OpenWrite || pOp->p5==0 || pOp->p5==OPFLAG_SEEKEQ );
85975 assert( p->bIsReader );
85976 assert( pOp->opcode==OP_OpenRead || pOp->opcode==OP_ReopenIdx
85977 || p->readOnly==0 );
85978
85979 if( p->expired==1 ){
85980 rc = SQLITE_ABORT_ROLLBACK;
85981 goto abort_due_to_error;
85982 }
85983
85984 nField = 0;
@@ -89108,25 +89155,32 @@
89155 }
89156 break;
89157 }
89158 #endif
89159
89160 /* Opcode: Expire P1 P2 * * *
89161 **
89162 ** Cause precompiled statements to expire. When an expired statement
89163 ** is executed using sqlite3_step() it will either automatically
89164 ** reprepare itself (if it was originally created using sqlite3_prepare_v2())
89165 ** or it will fail with SQLITE_SCHEMA.
89166 **
89167 ** If P1 is 0, then all SQL statements become expired. If P1 is non-zero,
89168 ** then only the currently executing statement is expired.
89169 **
89170 ** If P2 is 0, then SQL statements are expired immediately. If P2 is 1,
89171 ** then running SQL statements are allowed to continue to run to completion.
89172 ** The P2==1 case occurs when a CREATE INDEX or similar schema change happens
89173 ** that might help the statement run faster but which does not affect the
89174 ** correctness of operation.
89175 */
89176 case OP_Expire: {
89177 assert( pOp->p2==0 || pOp->p2==1 );
89178 if( !pOp->p1 ){
89179 sqlite3ExpirePreparedStatements(db, pOp->p2);
89180 }else{
89181 p->expired = pOp->p2+1;
89182 }
89183 break;
89184 }
89185
89186 #ifndef SQLITE_OMIT_SHARED_CACHE
@@ -103813,11 +103867,11 @@
103867 if( !pIdx->hasStat1 ) sqlite3DefaultRowEst(pIdx);
103868 }
103869
103870 /* Load the statistics from the sqlite_stat4 table. */
103871 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
103872 if( rc==SQLITE_OK ){
103873 db->lookaside.bDisable++;
103874 rc = loadStat4(db, sInfo.zDatabase);
103875 db->lookaside.bDisable--;
103876 }
103877 for(i=sqliteHashFirst(&pSchema->idxHash); i; i=sqliteHashNext(i)){
@@ -104545,11 +104599,11 @@
104599 if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
104600 #endif
104601 sqlite3_mutex_enter(db->mutex);
104602 db->xAuth = (sqlite3_xauth)xAuth;
104603 db->pAuthArg = pArg;
104604 sqlite3ExpirePreparedStatements(db, 0);
104605 sqlite3_mutex_leave(db->mutex);
104606 return SQLITE_OK;
104607 }
104608
104609 /*
@@ -108209,11 +108263,11 @@
108263 if( pTblName ){
108264 sqlite3RefillIndex(pParse, pIndex, iMem);
108265 sqlite3ChangeCookie(pParse, iDb);
108266 sqlite3VdbeAddParseSchemaOp(v, iDb,
108267 sqlite3MPrintf(db, "name='%q' AND type='index'", pIndex->zName));
108268 sqlite3VdbeAddOp2(v, OP_Expire, 0, 1);
108269 }
108270
108271 sqlite3VdbeJumpHere(v, pIndex->tnum);
108272 }
108273
@@ -131894,11 +131948,11 @@
131948
131949 assert( sqlite3BtreeHoldsAllMutexes(db) );
131950 assert( sqlite3_mutex_held(db->mutex) );
131951
131952 if( p ){
131953 sqlite3ExpirePreparedStatements(db, 0);
131954 do {
131955 VTable *pNext = p->pNext;
131956 sqlite3VtabUnlock(p);
131957 p = pNext;
131958 }while( p );
@@ -138680,11 +138734,13 @@
138734
138735 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
138736 Index *p = pLoop->u.btree.pIndex;
138737 int nEq = pLoop->u.btree.nEq;
138738
138739 if( p->nSample>0 && nEq<p->nSampleCol
138740 && OptimizationEnabled(pParse->db, SQLITE_Stat34)
138741 ){
138742 if( nEq==pBuilder->nRecValid ){
138743 UnpackedRecord *pRec = pBuilder->pRec;
138744 tRowcnt a[2];
138745 int nBtm = pLoop->u.btree.nBtm;
138746 int nTop = pLoop->u.btree.nTop;
@@ -139828,10 +139884,11 @@
139884 tRowcnt nOut = 0;
139885 if( nInMul==0
139886 && pProbe->nSample
139887 && pNew->u.btree.nEq<=pProbe->nSampleCol
139888 && ((eOp & WO_IN)==0 || !ExprHasProperty(pTerm->pExpr, EP_xIsSelect))
139889 && OptimizationEnabled(db, SQLITE_Stat34)
139890 ){
139891 Expr *pExpr = pTerm->pExpr;
139892 if( (eOp & (WO_EQ|WO_ISNULL|WO_IS))!=0 ){
139893 testcase( eOp & WO_EQ );
139894 testcase( eOp & WO_IS );
@@ -146916,11 +146973,11 @@
146973
146974 /*
146975 ** Find the appropriate action for a parser given the non-terminal
146976 ** look-ahead token iLookAhead.
146977 */
146978 static YYACTIONTYPE yy_find_reduce_action(
146979 YYACTIONTYPE stateno, /* Current state number */
146980 YYCODETYPE iLookAhead /* The look-ahead token */
146981 ){
146982 int i;
146983 #ifdef YYERRORSYMBOL
@@ -147421,11 +147478,11 @@
147478 int yyLookahead, /* Lookahead token, or YYNOCODE if none */
147479 sqlite3ParserTOKENTYPE yyLookaheadToken /* Value of the lookahead token */
147480 sqlite3ParserCTX_PDECL /* %extra_context */
147481 ){
147482 int yygoto; /* The next state */
147483 YYACTIONTYPE yyact; /* The next action */
147484 yyStackEntry *yymsp; /* The top of the parser's stack */
147485 int yysize; /* Amount to pop the stack */
147486 sqlite3ParserARG_FETCH
147487 (void)yyLookahead;
147488 (void)yyLookaheadToken;
@@ -148980,16 +149037,16 @@
149037 }
149038 #endif
149039
149040 do{
149041 assert( yyact==yypParser->yytos->stateno );
149042 yyact = yy_find_shift_action((YYCODETYPE)yymajor,yyact);
149043 if( yyact >= YY_MIN_REDUCE ){
149044 yyact = yy_reduce(yypParser,yyact-YY_MIN_REDUCE,yymajor,
149045 yyminor sqlite3ParserCTX_PARAM);
149046 }else if( yyact <= YY_MAX_SHIFTREDUCE ){
149047 yy_shift(yypParser,yyact,(YYCODETYPE)yymajor,yyminor);
149048 #ifndef YYNOERRORRECOVERY
149049 yypParser->yyerrcnt--;
149050 #endif
149051 break;
149052 }else if( yyact==YY_ACCEPT_ACTION ){
@@ -151421,11 +151478,11 @@
151478 db->flags |= aFlagOp[i].mask;
151479 }else if( onoff==0 ){
151480 db->flags &= ~aFlagOp[i].mask;
151481 }
151482 if( oldFlags!=db->flags ){
151483 sqlite3ExpirePreparedStatements(db, 0);
151484 }
151485 if( pRes ){
151486 *pRes = (db->flags & aFlagOp[i].mask)!=0;
151487 }
151488 rc = SQLITE_OK;
@@ -151864,11 +151921,11 @@
151921 }
151922 sqlite3VtabRollback(db);
151923 sqlite3EndBenignMalloc();
151924
151925 if( schemaChange ){
151926 sqlite3ExpirePreparedStatements(db, 0);
151927 sqlite3ResetAllSchemasOfConnection(db);
151928 }
151929 sqlite3BtreeLeaveAll(db);
151930
151931 /* Any deferred constraint violations have now been resolved. */
@@ -152319,11 +152376,11 @@
152376 sqlite3ErrorWithMsg(db, SQLITE_BUSY,
152377 "unable to delete/modify user-function due to active statements");
152378 assert( !db->mallocFailed );
152379 return SQLITE_BUSY;
152380 }else{
152381 sqlite3ExpirePreparedStatements(db, 0);
152382 }
152383 }
152384
152385 p = sqlite3FindFunction(db, zFunctionName, nArg, (u8)enc, 1);
152386 assert(p || db->mallocFailed);
@@ -153094,11 +153151,11 @@
153151 if( db->nVdbeActive ){
153152 sqlite3ErrorWithMsg(db, SQLITE_BUSY,
153153 "unable to delete/modify collation sequence due to active statements");
153154 return SQLITE_BUSY;
153155 }
153156 sqlite3ExpirePreparedStatements(db, 0);
153157
153158 /* If collation sequence pColl was created directly by a call to
153159 ** sqlite3_create_collation, and not generated by synthCollSeq(),
153160 ** then any copies made by synthCollSeq() need to be invalidated.
153161 ** Also, collation destructor - CollSeq.xDel() - function may need
@@ -194031,16 +194088,18 @@
194088 rc = sqlite3_create_function(db, aFunc[i].zName, aFunc[i].nArg,
194089 SQLITE_UTF8 | SQLITE_DETERMINISTIC,
194090 (void*)&aFunc[i].flag,
194091 aFunc[i].xFunc, 0, 0);
194092 }
194093 #ifndef SQLITE_OMIT_WINDOWFUNC
194094 for(i=0; i<sizeof(aAgg)/sizeof(aAgg[0]) && rc==SQLITE_OK; i++){
194095 rc = sqlite3_create_window_function(db, aAgg[i].zName, aAgg[i].nArg,
194096 SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
194097 aAgg[i].xStep, aAgg[i].xFinal,
194098 aAgg[i].xValue, jsonGroupInverse, 0);
194099 }
194100 #endif
194101 #ifndef SQLITE_OMIT_VIRTUALTABLE
194102 for(i=0; i<sizeof(aMod)/sizeof(aMod[0]) && rc==SQLITE_OK; i++){
194103 rc = sqlite3_create_module(db, aMod[i].zName, aMod[i].pModule, 0);
194104 }
194105 #endif
@@ -196237,11 +196296,11 @@
196296
196297 /*
196298 ** Find the appropriate action for a parser given the non-terminal
196299 ** look-ahead token iLookAhead.
196300 */
196301 static fts5YYACTIONTYPE fts5yy_find_reduce_action(
196302 fts5YYACTIONTYPE stateno, /* Current state number */
196303 fts5YYCODETYPE iLookAhead /* The look-ahead token */
196304 ){
196305 int i;
196306 #ifdef fts5YYERRORSYMBOL
@@ -196405,11 +196464,11 @@
196464 int fts5yyLookahead, /* Lookahead token, or fts5YYNOCODE if none */
196465 sqlite3Fts5ParserFTS5TOKENTYPE fts5yyLookaheadToken /* Value of the lookahead token */
196466 sqlite3Fts5ParserCTX_PDECL /* %extra_context */
196467 ){
196468 int fts5yygoto; /* The next state */
196469 fts5YYACTIONTYPE fts5yyact; /* The next action */
196470 fts5yyStackEntry *fts5yymsp; /* The top of the parser's stack */
196471 int fts5yysize; /* Amount to pop the stack */
196472 sqlite3Fts5ParserARG_FETCH
196473 (void)fts5yyLookahead;
196474 (void)fts5yyLookaheadToken;
@@ -196761,16 +196820,16 @@
196820 }
196821 #endif
196822
196823 do{
196824 assert( fts5yyact==fts5yypParser->fts5yytos->stateno );
196825 fts5yyact = fts5yy_find_shift_action((fts5YYCODETYPE)fts5yymajor,fts5yyact);
196826 if( fts5yyact >= fts5YY_MIN_REDUCE ){
196827 fts5yyact = fts5yy_reduce(fts5yypParser,fts5yyact-fts5YY_MIN_REDUCE,fts5yymajor,
196828 fts5yyminor sqlite3Fts5ParserCTX_PARAM);
196829 }else if( fts5yyact <= fts5YY_MAX_SHIFTREDUCE ){
196830 fts5yy_shift(fts5yypParser,fts5yyact,(fts5YYCODETYPE)fts5yymajor,fts5yyminor);
196831 #ifndef fts5YYNOERRORRECOVERY
196832 fts5yypParser->fts5yyerrcnt--;
196833 #endif
196834 break;
196835 }else if( fts5yyact==fts5YY_ACCEPT_ACTION ){
@@ -211513,11 +211572,11 @@
211572 int nArg, /* Number of args */
211573 sqlite3_value **apUnused /* Function arguments */
211574 ){
211575 assert( nArg==0 );
211576 UNUSED_PARAM2(nArg, apUnused);
211577 sqlite3_result_text(pCtx, "fts5: 2018-07-24 22:02:12 2bd593332da0aade467e7a4ee89e966aa6302f37540a2c5e23671f98a6cb599c", -1, SQLITE_TRANSIENT);
211578 }
211579
211580 static int fts5Init(sqlite3 *db){
211581 static const sqlite3_module fts5Mod = {
211582 /* iVersion */ 2,
@@ -214799,11 +214858,11 @@
214858 int iTbl = 0;
214859 while( i<128 ){
214860 int bToken = aArray[ aFts5UnicodeData[iTbl] & 0x1F ];
214861 int n = (aFts5UnicodeData[iTbl] >> 5) + i;
214862 for(; i<128 && i<n; i++){
214863 aAscii[i] = (u8)bToken;
214864 }
214865 iTbl++;
214866 }
214867 }
214868
@@ -216223,12 +216282,12 @@
216282 }
216283 #endif /* SQLITE_CORE */
216284 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
216285
216286 /************** End of stmt.c ************************************************/
216287 #if __LINE__!=216287
216288 #undef SQLITE_SOURCE_ID
216289 #define SQLITE_SOURCE_ID "2018-07-24 22:02:12 2bd593332da0aade467e7a4ee89e966aa6302f37540a2c5e23671f98a6cbalt2"
216290 #endif
216291 /* Return the source-id for this library */
216292 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
216293 /************************** End of sqlite3.c ******************************/
216294
+28 -27
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -123,11 +123,11 @@
123123
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124124
** [sqlite_version()] and [sqlite_source_id()].
125125
*/
126126
#define SQLITE_VERSION "3.25.0"
127127
#define SQLITE_VERSION_NUMBER 3025000
128
-#define SQLITE_SOURCE_ID "2018-07-18 19:09:07 a5087c5c87ad65f92e3bc96bbc84afb43faf10ab6b9ed3ba16304b5c60ad069f"
128
+#define SQLITE_SOURCE_ID "2018-07-24 22:02:12 2bd593332da0aade467e7a4ee89e966aa6302f37540a2c5e23671f98a6cb599c"
129129
130130
/*
131131
** CAPI3REF: Run-Time Library Version Numbers
132132
** KEYWORDS: sqlite3_version sqlite3_sourceid
133133
**
@@ -885,11 +885,12 @@
885885
** interrogated. The zDbName parameter is ignored.
886886
**
887887
** <li>[[SQLITE_FCNTL_PERSIST_WAL]]
888888
** ^The [SQLITE_FCNTL_PERSIST_WAL] opcode is used to set or query the
889889
** persistent [WAL | Write Ahead Log] setting. By default, the auxiliary
890
-** write ahead log and shared memory files used for transaction control
890
+** write ahead log ([WAL file]) and shared memory
891
+** files used for transaction control
891892
** are automatically deleted when the latest connection to the database
892893
** closes. Setting persistent WAL mode causes those files to persist after
893894
** close. Persisting the files is useful when other processes that do not
894895
** have write permission on the directory containing the database file want
895896
** to read the database file, as the WAL and shared memory files must exist
@@ -8958,11 +8959,10 @@
89588959
SQLITE_API int sqlite3_system_errno(sqlite3*);
89598960
89608961
/*
89618962
** CAPI3REF: Database Snapshot
89628963
** KEYWORDS: {snapshot} {sqlite3_snapshot}
8963
-** EXPERIMENTAL
89648964
**
89658965
** An instance of the snapshot object records the state of a [WAL mode]
89668966
** database for some specific point in history.
89678967
**
89688968
** In [WAL mode], multiple [database connections] that are open on the
@@ -8975,23 +8975,18 @@
89758975
**
89768976
** The sqlite3_snapshot object records state information about an historical
89778977
** version of the database file so that it is possible to later open a new read
89788978
** transaction that sees that historical version of the database rather than
89798979
** the most recent version.
8980
-**
8981
-** The constructor for this object is [sqlite3_snapshot_get()]. The
8982
-** [sqlite3_snapshot_open()] method causes a fresh read transaction to refer
8983
-** to an historical snapshot (if possible). The destructor for
8984
-** sqlite3_snapshot objects is [sqlite3_snapshot_free()].
89858980
*/
89868981
typedef struct sqlite3_snapshot {
89878982
unsigned char hidden[48];
89888983
} sqlite3_snapshot;
89898984
89908985
/*
89918986
** CAPI3REF: Record A Database Snapshot
8992
-** EXPERIMENTAL
8987
+** CONSTRUCTOR: sqlite3_snapshot
89938988
**
89948989
** ^The [sqlite3_snapshot_get(D,S,P)] interface attempts to make a
89958990
** new [sqlite3_snapshot] object that records the current state of
89968991
** schema S in database connection D. ^On success, the
89978992
** [sqlite3_snapshot_get(D,S,P)] interface writes a pointer to the newly
@@ -9026,21 +9021,21 @@
90269021
** The [sqlite3_snapshot] object returned from a successful call to
90279022
** [sqlite3_snapshot_get()] must be freed using [sqlite3_snapshot_free()]
90289023
** to avoid a memory leak.
90299024
**
90309025
** The [sqlite3_snapshot_get()] interface is only available when the
9031
-** SQLITE_ENABLE_SNAPSHOT compile-time option is used.
9026
+** [SQLITE_ENABLE_SNAPSHOT] compile-time option is used.
90329027
*/
90339028
SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_get(
90349029
sqlite3 *db,
90359030
const char *zSchema,
90369031
sqlite3_snapshot **ppSnapshot
90379032
);
90389033
90399034
/*
90409035
** CAPI3REF: Start a read transaction on an historical snapshot
9041
-** EXPERIMENTAL
9036
+** METHOD: sqlite3_snapshot
90429037
**
90439038
** ^The [sqlite3_snapshot_open(D,S,P)] interface starts a
90449039
** read transaction for schema S of
90459040
** [database connection] D such that the read transaction
90469041
** refers to historical [snapshot] P, rather than the most
@@ -9064,34 +9059,34 @@
90649059
** after the most recent I/O on the database connection.)^
90659060
** (Hint: Run "[PRAGMA application_id]" against a newly opened
90669061
** database connection in order to make it ready to use snapshots.)
90679062
**
90689063
** The [sqlite3_snapshot_open()] interface is only available when the
9069
-** SQLITE_ENABLE_SNAPSHOT compile-time option is used.
9064
+** [SQLITE_ENABLE_SNAPSHOT] compile-time option is used.
90709065
*/
90719066
SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_open(
90729067
sqlite3 *db,
90739068
const char *zSchema,
90749069
sqlite3_snapshot *pSnapshot
90759070
);
90769071
90779072
/*
90789073
** CAPI3REF: Destroy a snapshot
9079
-** EXPERIMENTAL
9074
+** DESTRUCTOR: sqlite3_snapshot
90809075
**
90819076
** ^The [sqlite3_snapshot_free(P)] interface destroys [sqlite3_snapshot] P.
90829077
** The application must eventually free every [sqlite3_snapshot] object
90839078
** using this routine to avoid a memory leak.
90849079
**
90859080
** The [sqlite3_snapshot_free()] interface is only available when the
9086
-** SQLITE_ENABLE_SNAPSHOT compile-time option is used.
9081
+** [SQLITE_ENABLE_SNAPSHOT] compile-time option is used.
90879082
*/
90889083
SQLITE_API SQLITE_EXPERIMENTAL void sqlite3_snapshot_free(sqlite3_snapshot*);
90899084
90909085
/*
90919086
** CAPI3REF: Compare the ages of two snapshot handles.
9092
-** EXPERIMENTAL
9087
+** METHOD: sqlite3_snapshot
90939088
**
90949089
** The sqlite3_snapshot_cmp(P1, P2) interface is used to compare the ages
90959090
** of two valid snapshot handles.
90969091
**
90979092
** If the two snapshot handles are not associated with the same database
@@ -9106,35 +9101,41 @@
91069101
** is undefined.
91079102
**
91089103
** Otherwise, this API returns a negative value if P1 refers to an older
91099104
** snapshot than P2, zero if the two handles refer to the same database
91109105
** snapshot, and a positive value if P1 is a newer snapshot than P2.
9106
+**
9107
+** This interface is only available if SQLite is compiled with the
9108
+** [SQLITE_ENABLE_SNAPSHOT] option.
91119109
*/
91129110
SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_cmp(
91139111
sqlite3_snapshot *p1,
91149112
sqlite3_snapshot *p2
91159113
);
91169114
91179115
/*
91189116
** CAPI3REF: Recover snapshots from a wal file
9119
-** EXPERIMENTAL
9120
-**
9121
-** If all connections disconnect from a database file but do not perform
9122
-** a checkpoint, the existing wal file is opened along with the database
9123
-** file the next time the database is opened. At this point it is only
9124
-** possible to successfully call sqlite3_snapshot_open() to open the most
9125
-** recent snapshot of the database (the one at the head of the wal file),
9126
-** even though the wal file may contain other valid snapshots for which
9127
-** clients have sqlite3_snapshot handles.
9128
-**
9129
-** This function attempts to scan the wal file associated with database zDb
9117
+** METHOD: sqlite3_snapshot
9118
+**
9119
+** If a [WAL file] remains on disk after all database connections close
9120
+** (either through the use of the [SQLITE_FCNTL_PERSIST_WAL] [file control]
9121
+** or because the last process to have the database opened exited without
9122
+** calling [sqlite3_close()]) and a new connection is subsequently opened
9123
+** on that database and [WAL file], the [sqlite3_snapshot_open()] interface
9124
+** will only be able to open the last transaction added to the WAL file
9125
+** even though the WAL file contains other valid transactions.
9126
+**
9127
+** This function attempts to scan the WAL file associated with database zDb
91309128
** of database handle db and make all valid snapshots available to
91319129
** sqlite3_snapshot_open(). It is an error if there is already a read
9132
-** transaction open on the database, or if the database is not a wal mode
9130
+** transaction open on the database, or if the database is not a WAL mode
91339131
** database.
91349132
**
91359133
** SQLITE_OK is returned if successful, or an SQLite error code otherwise.
9134
+**
9135
+** This interface is only available if SQLite is compiled with the
9136
+** [SQLITE_ENABLE_SNAPSHOT] option.
91369137
*/
91379138
SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const char *zDb);
91389139
91399140
/*
91409141
** CAPI3REF: Serialize a database
91419142
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -123,11 +123,11 @@
123 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124 ** [sqlite_version()] and [sqlite_source_id()].
125 */
126 #define SQLITE_VERSION "3.25.0"
127 #define SQLITE_VERSION_NUMBER 3025000
128 #define SQLITE_SOURCE_ID "2018-07-18 19:09:07 a5087c5c87ad65f92e3bc96bbc84afb43faf10ab6b9ed3ba16304b5c60ad069f"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
@@ -885,11 +885,12 @@
885 ** interrogated. The zDbName parameter is ignored.
886 **
887 ** <li>[[SQLITE_FCNTL_PERSIST_WAL]]
888 ** ^The [SQLITE_FCNTL_PERSIST_WAL] opcode is used to set or query the
889 ** persistent [WAL | Write Ahead Log] setting. By default, the auxiliary
890 ** write ahead log and shared memory files used for transaction control
 
891 ** are automatically deleted when the latest connection to the database
892 ** closes. Setting persistent WAL mode causes those files to persist after
893 ** close. Persisting the files is useful when other processes that do not
894 ** have write permission on the directory containing the database file want
895 ** to read the database file, as the WAL and shared memory files must exist
@@ -8958,11 +8959,10 @@
8958 SQLITE_API int sqlite3_system_errno(sqlite3*);
8959
8960 /*
8961 ** CAPI3REF: Database Snapshot
8962 ** KEYWORDS: {snapshot} {sqlite3_snapshot}
8963 ** EXPERIMENTAL
8964 **
8965 ** An instance of the snapshot object records the state of a [WAL mode]
8966 ** database for some specific point in history.
8967 **
8968 ** In [WAL mode], multiple [database connections] that are open on the
@@ -8975,23 +8975,18 @@
8975 **
8976 ** The sqlite3_snapshot object records state information about an historical
8977 ** version of the database file so that it is possible to later open a new read
8978 ** transaction that sees that historical version of the database rather than
8979 ** the most recent version.
8980 **
8981 ** The constructor for this object is [sqlite3_snapshot_get()]. The
8982 ** [sqlite3_snapshot_open()] method causes a fresh read transaction to refer
8983 ** to an historical snapshot (if possible). The destructor for
8984 ** sqlite3_snapshot objects is [sqlite3_snapshot_free()].
8985 */
8986 typedef struct sqlite3_snapshot {
8987 unsigned char hidden[48];
8988 } sqlite3_snapshot;
8989
8990 /*
8991 ** CAPI3REF: Record A Database Snapshot
8992 ** EXPERIMENTAL
8993 **
8994 ** ^The [sqlite3_snapshot_get(D,S,P)] interface attempts to make a
8995 ** new [sqlite3_snapshot] object that records the current state of
8996 ** schema S in database connection D. ^On success, the
8997 ** [sqlite3_snapshot_get(D,S,P)] interface writes a pointer to the newly
@@ -9026,21 +9021,21 @@
9026 ** The [sqlite3_snapshot] object returned from a successful call to
9027 ** [sqlite3_snapshot_get()] must be freed using [sqlite3_snapshot_free()]
9028 ** to avoid a memory leak.
9029 **
9030 ** The [sqlite3_snapshot_get()] interface is only available when the
9031 ** SQLITE_ENABLE_SNAPSHOT compile-time option is used.
9032 */
9033 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_get(
9034 sqlite3 *db,
9035 const char *zSchema,
9036 sqlite3_snapshot **ppSnapshot
9037 );
9038
9039 /*
9040 ** CAPI3REF: Start a read transaction on an historical snapshot
9041 ** EXPERIMENTAL
9042 **
9043 ** ^The [sqlite3_snapshot_open(D,S,P)] interface starts a
9044 ** read transaction for schema S of
9045 ** [database connection] D such that the read transaction
9046 ** refers to historical [snapshot] P, rather than the most
@@ -9064,34 +9059,34 @@
9064 ** after the most recent I/O on the database connection.)^
9065 ** (Hint: Run "[PRAGMA application_id]" against a newly opened
9066 ** database connection in order to make it ready to use snapshots.)
9067 **
9068 ** The [sqlite3_snapshot_open()] interface is only available when the
9069 ** SQLITE_ENABLE_SNAPSHOT compile-time option is used.
9070 */
9071 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_open(
9072 sqlite3 *db,
9073 const char *zSchema,
9074 sqlite3_snapshot *pSnapshot
9075 );
9076
9077 /*
9078 ** CAPI3REF: Destroy a snapshot
9079 ** EXPERIMENTAL
9080 **
9081 ** ^The [sqlite3_snapshot_free(P)] interface destroys [sqlite3_snapshot] P.
9082 ** The application must eventually free every [sqlite3_snapshot] object
9083 ** using this routine to avoid a memory leak.
9084 **
9085 ** The [sqlite3_snapshot_free()] interface is only available when the
9086 ** SQLITE_ENABLE_SNAPSHOT compile-time option is used.
9087 */
9088 SQLITE_API SQLITE_EXPERIMENTAL void sqlite3_snapshot_free(sqlite3_snapshot*);
9089
9090 /*
9091 ** CAPI3REF: Compare the ages of two snapshot handles.
9092 ** EXPERIMENTAL
9093 **
9094 ** The sqlite3_snapshot_cmp(P1, P2) interface is used to compare the ages
9095 ** of two valid snapshot handles.
9096 **
9097 ** If the two snapshot handles are not associated with the same database
@@ -9106,35 +9101,41 @@
9106 ** is undefined.
9107 **
9108 ** Otherwise, this API returns a negative value if P1 refers to an older
9109 ** snapshot than P2, zero if the two handles refer to the same database
9110 ** snapshot, and a positive value if P1 is a newer snapshot than P2.
 
 
 
9111 */
9112 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_cmp(
9113 sqlite3_snapshot *p1,
9114 sqlite3_snapshot *p2
9115 );
9116
9117 /*
9118 ** CAPI3REF: Recover snapshots from a wal file
9119 ** EXPERIMENTAL
9120 **
9121 ** If all connections disconnect from a database file but do not perform
9122 ** a checkpoint, the existing wal file is opened along with the database
9123 ** file the next time the database is opened. At this point it is only
9124 ** possible to successfully call sqlite3_snapshot_open() to open the most
9125 ** recent snapshot of the database (the one at the head of the wal file),
9126 ** even though the wal file may contain other valid snapshots for which
9127 ** clients have sqlite3_snapshot handles.
9128 **
9129 ** This function attempts to scan the wal file associated with database zDb
9130 ** of database handle db and make all valid snapshots available to
9131 ** sqlite3_snapshot_open(). It is an error if there is already a read
9132 ** transaction open on the database, or if the database is not a wal mode
9133 ** database.
9134 **
9135 ** SQLITE_OK is returned if successful, or an SQLite error code otherwise.
 
 
 
9136 */
9137 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const char *zDb);
9138
9139 /*
9140 ** CAPI3REF: Serialize a database
9141
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -123,11 +123,11 @@
123 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124 ** [sqlite_version()] and [sqlite_source_id()].
125 */
126 #define SQLITE_VERSION "3.25.0"
127 #define SQLITE_VERSION_NUMBER 3025000
128 #define SQLITE_SOURCE_ID "2018-07-24 22:02:12 2bd593332da0aade467e7a4ee89e966aa6302f37540a2c5e23671f98a6cb599c"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
@@ -885,11 +885,12 @@
885 ** interrogated. The zDbName parameter is ignored.
886 **
887 ** <li>[[SQLITE_FCNTL_PERSIST_WAL]]
888 ** ^The [SQLITE_FCNTL_PERSIST_WAL] opcode is used to set or query the
889 ** persistent [WAL | Write Ahead Log] setting. By default, the auxiliary
890 ** write ahead log ([WAL file]) and shared memory
891 ** files used for transaction control
892 ** are automatically deleted when the latest connection to the database
893 ** closes. Setting persistent WAL mode causes those files to persist after
894 ** close. Persisting the files is useful when other processes that do not
895 ** have write permission on the directory containing the database file want
896 ** to read the database file, as the WAL and shared memory files must exist
@@ -8958,11 +8959,10 @@
8959 SQLITE_API int sqlite3_system_errno(sqlite3*);
8960
8961 /*
8962 ** CAPI3REF: Database Snapshot
8963 ** KEYWORDS: {snapshot} {sqlite3_snapshot}
 
8964 **
8965 ** An instance of the snapshot object records the state of a [WAL mode]
8966 ** database for some specific point in history.
8967 **
8968 ** In [WAL mode], multiple [database connections] that are open on the
@@ -8975,23 +8975,18 @@
8975 **
8976 ** The sqlite3_snapshot object records state information about an historical
8977 ** version of the database file so that it is possible to later open a new read
8978 ** transaction that sees that historical version of the database rather than
8979 ** the most recent version.
 
 
 
 
 
8980 */
8981 typedef struct sqlite3_snapshot {
8982 unsigned char hidden[48];
8983 } sqlite3_snapshot;
8984
8985 /*
8986 ** CAPI3REF: Record A Database Snapshot
8987 ** CONSTRUCTOR: sqlite3_snapshot
8988 **
8989 ** ^The [sqlite3_snapshot_get(D,S,P)] interface attempts to make a
8990 ** new [sqlite3_snapshot] object that records the current state of
8991 ** schema S in database connection D. ^On success, the
8992 ** [sqlite3_snapshot_get(D,S,P)] interface writes a pointer to the newly
@@ -9026,21 +9021,21 @@
9021 ** The [sqlite3_snapshot] object returned from a successful call to
9022 ** [sqlite3_snapshot_get()] must be freed using [sqlite3_snapshot_free()]
9023 ** to avoid a memory leak.
9024 **
9025 ** The [sqlite3_snapshot_get()] interface is only available when the
9026 ** [SQLITE_ENABLE_SNAPSHOT] compile-time option is used.
9027 */
9028 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_get(
9029 sqlite3 *db,
9030 const char *zSchema,
9031 sqlite3_snapshot **ppSnapshot
9032 );
9033
9034 /*
9035 ** CAPI3REF: Start a read transaction on an historical snapshot
9036 ** METHOD: sqlite3_snapshot
9037 **
9038 ** ^The [sqlite3_snapshot_open(D,S,P)] interface starts a
9039 ** read transaction for schema S of
9040 ** [database connection] D such that the read transaction
9041 ** refers to historical [snapshot] P, rather than the most
@@ -9064,34 +9059,34 @@
9059 ** after the most recent I/O on the database connection.)^
9060 ** (Hint: Run "[PRAGMA application_id]" against a newly opened
9061 ** database connection in order to make it ready to use snapshots.)
9062 **
9063 ** The [sqlite3_snapshot_open()] interface is only available when the
9064 ** [SQLITE_ENABLE_SNAPSHOT] compile-time option is used.
9065 */
9066 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_open(
9067 sqlite3 *db,
9068 const char *zSchema,
9069 sqlite3_snapshot *pSnapshot
9070 );
9071
9072 /*
9073 ** CAPI3REF: Destroy a snapshot
9074 ** DESTRUCTOR: sqlite3_snapshot
9075 **
9076 ** ^The [sqlite3_snapshot_free(P)] interface destroys [sqlite3_snapshot] P.
9077 ** The application must eventually free every [sqlite3_snapshot] object
9078 ** using this routine to avoid a memory leak.
9079 **
9080 ** The [sqlite3_snapshot_free()] interface is only available when the
9081 ** [SQLITE_ENABLE_SNAPSHOT] compile-time option is used.
9082 */
9083 SQLITE_API SQLITE_EXPERIMENTAL void sqlite3_snapshot_free(sqlite3_snapshot*);
9084
9085 /*
9086 ** CAPI3REF: Compare the ages of two snapshot handles.
9087 ** METHOD: sqlite3_snapshot
9088 **
9089 ** The sqlite3_snapshot_cmp(P1, P2) interface is used to compare the ages
9090 ** of two valid snapshot handles.
9091 **
9092 ** If the two snapshot handles are not associated with the same database
@@ -9106,35 +9101,41 @@
9101 ** is undefined.
9102 **
9103 ** Otherwise, this API returns a negative value if P1 refers to an older
9104 ** snapshot than P2, zero if the two handles refer to the same database
9105 ** snapshot, and a positive value if P1 is a newer snapshot than P2.
9106 **
9107 ** This interface is only available if SQLite is compiled with the
9108 ** [SQLITE_ENABLE_SNAPSHOT] option.
9109 */
9110 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_cmp(
9111 sqlite3_snapshot *p1,
9112 sqlite3_snapshot *p2
9113 );
9114
9115 /*
9116 ** CAPI3REF: Recover snapshots from a wal file
9117 ** METHOD: sqlite3_snapshot
9118 **
9119 ** If a [WAL file] remains on disk after all database connections close
9120 ** (either through the use of the [SQLITE_FCNTL_PERSIST_WAL] [file control]
9121 ** or because the last process to have the database opened exited without
9122 ** calling [sqlite3_close()]) and a new connection is subsequently opened
9123 ** on that database and [WAL file], the [sqlite3_snapshot_open()] interface
9124 ** will only be able to open the last transaction added to the WAL file
9125 ** even though the WAL file contains other valid transactions.
9126 **
9127 ** This function attempts to scan the WAL file associated with database zDb
9128 ** of database handle db and make all valid snapshots available to
9129 ** sqlite3_snapshot_open(). It is an error if there is already a read
9130 ** transaction open on the database, or if the database is not a WAL mode
9131 ** database.
9132 **
9133 ** SQLITE_OK is returned if successful, or an SQLite error code otherwise.
9134 **
9135 ** This interface is only available if SQLite is compiled with the
9136 ** [SQLITE_ENABLE_SNAPSHOT] option.
9137 */
9138 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const char *zDb);
9139
9140 /*
9141 ** CAPI3REF: Serialize a database
9142

Keyboard Shortcuts

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