1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

Merge the PRAGMA data_version redefinition and other fixes from trunk.

FossilOrigin-Name: 315243e49d30abd0eb31e3795ecf492aee179e4b
This commit is contained in:
drh
2014-12-22 18:48:48 +00:00
13 changed files with 184 additions and 107 deletions

View File

@@ -108,11 +108,12 @@ WIN32HEAP = 0
# levels. Currently, the recognized values for DEBUG are:
#
# 0 == NDEBUG: Disables assert() and other runtime diagnostics.
# 1 == Disables NDEBUG and all optimizations and then enables PDBs.
# 2 == SQLITE_DEBUG: Enables various diagnostics messages and code.
# 3 == SQLITE_WIN32_MALLOC_VALIDATE: Validate the Win32 native heap per call.
# 4 == SQLITE_DEBUG_OS_TRACE: Enables output from the OSTRACE() macros.
# 5 == SQLITE_ENABLE_IOTRACE: Enables output from the IOTRACE() macros.
# 1 == SQLITE_ENABLE_API_ARMOR: extra attempts to detect misuse of the API.
# 2 == Disables NDEBUG and all optimizations and then enables PDBs.
# 3 == SQLITE_DEBUG: Enables various diagnostics messages and code.
# 4 == SQLITE_WIN32_MALLOC_VALIDATE: Validate the Win32 native heap per call.
# 5 == SQLITE_DEBUG_OS_TRACE: Enables output from the OSTRACE() macros.
# 6 == SQLITE_ENABLE_IOTRACE: Enables output from the IOTRACE() macros.
#
!IFNDEF DEBUG
DEBUG = 0
@@ -280,7 +281,7 @@ RCC = $(RCC) -DWINAPI_FAMILY=WINAPI_FAMILY_APP
# MSVC runtime library.
#
!IF $(FOR_WINRT)!=0 || $(USE_CRT_DLL)!=0
!IF $(DEBUG)>0
!IF $(DEBUG)>1
TCC = $(TCC) -MDd
BCC = $(BCC) -MDd
!ELSE
@@ -288,7 +289,7 @@ TCC = $(TCC) -MD
BCC = $(BCC) -MD
!ENDIF
!ELSE
!IF $(DEBUG)>0
!IF $(DEBUG)>1
TCC = $(TCC) -MTd
BCC = $(BCC) -MTd
!ELSE
@@ -315,7 +316,7 @@ RCC = $(RCC) -I$(TOP)\ext\session
# options are necessary in order to allow debugging symbols to
# work correctly with Visual Studio when using the amalgamation.
#
!IF $(DEBUG)>0
!IF $(DEBUG)>1
MKSQLITE3C_ARGS = --linemacros
!ELSE
MKSQLITE3C_ARGS =
@@ -331,17 +332,22 @@ BCC = $(BCC) -DNDEBUG
RCC = $(RCC) -DNDEBUG
!ENDIF
!IF $(DEBUG)>1
!IF $(DEBUG)>0
TCC = $(TCC) -DSQLITE_ENABLE_API_ARMOR
RCC = $(RCC) -DSQLITE_ENABLE_API_ARMOR
!ENDIF
!IF $(DEBUG)>2
TCC = $(TCC) -DSQLITE_DEBUG
RCC = $(RCC) -DSQLITE_DEBUG
!ENDIF
!IF $(DEBUG)>3
!IF $(DEBUG)>4
TCC = $(TCC) -DSQLITE_DEBUG_OS_TRACE=1
RCC = $(RCC) -DSQLITE_DEBUG_OS_TRACE=1
!ENDIF
!IF $(DEBUG)>4
!IF $(DEBUG)>5
TCC = $(TCC) -DSQLITE_ENABLE_IOTRACE
RCC = $(RCC) -DSQLITE_ENABLE_IOTRACE
!ENDIF
@@ -373,7 +379,7 @@ RCC = $(RCC) -DSQLITE_WIN32_MALLOC=1
# Validate the heap on every call into the native Win32 heap subsystem?
#
!IF $(DEBUG)>2
!IF $(DEBUG)>3
TCC = $(TCC) -DSQLITE_WIN32_MALLOC_VALIDATE=1
RCC = $(RCC) -DSQLITE_WIN32_MALLOC_VALIDATE=1
!ENDIF
@@ -492,7 +498,7 @@ RCC = $(RCC) $(OPTS)
# If compiling for debugging, add some defines.
#
!IF $(DEBUG)>0
!IF $(DEBUG)>1
TCC = $(TCC) -D_DEBUG
BCC = $(BCC) -D_DEBUG
RCC = $(RCC) -D_DEBUG
@@ -501,7 +507,7 @@ RCC = $(RCC) -D_DEBUG
# If optimizations are enabled or disabled (either implicitly or
# explicitly), add the necessary flags.
#
!IF $(DEBUG)>0 || $(OPTIMIZATIONS)==0
!IF $(DEBUG)>1 || $(OPTIMIZATIONS)==0
TCC = $(TCC) -Od
BCC = $(BCC) -Od
!ELSEIF $(OPTIMIZATIONS)>=3
@@ -517,7 +523,7 @@ BCC = $(BCC) -O1
# If symbols are enabled (or compiling for debugging), enable PDBs.
#
!IF $(DEBUG)>0 || $(SYMBOLS)!=0
!IF $(DEBUG)>1 || $(SYMBOLS)!=0
TCC = $(TCC) -Zi
BCC = $(BCC) -Zi
!ENDIF
@@ -602,7 +608,7 @@ LTLINKOPTS = $(LTLINKOPTS) /NODEFAULTLIB:kernel32.lib /NODEFAULTLIB:ole32.lib
# If either debugging or symbols are enabled, enable PDBs.
#
!IF $(DEBUG)>0 || $(SYMBOLS)!=0
!IF $(DEBUG)>1 || $(SYMBOLS)!=0
LDFLAGS = /DEBUG
!ENDIF

View File

@@ -53,10 +53,10 @@ to the "sqlite3.dll" command line above. When debugging into the SQLite
code, adding the "DEBUG=1" argument to one of the above command lines is
recommended.
SQLite does not require Tcl to run, but a Tcl installation is required
by the makefiles (including those for MSVC). SQLite contains a lot of
generated code and Tcl is used to do much of that code generation. The
makefiles also require AWK.
SQLite does not require [Tcl](http://www.tcl.tk/) to run, but a Tcl installation
is required by the makefiles (including those for MSVC). SQLite contains
a lot of generated code and Tcl is used to do much of that code generation.
The makefiles also require AWK.
## Source Code Tour
@@ -95,14 +95,14 @@ manually-edited files and automatically-generated files.
The SQLite interface is defined by the **sqlite3.h** header file, which is
generated from src/sqlite.h.in, ./manifest.uuid, and ./VERSION. The
Tcl script at tool/mksqlite3h.tcl does the conversion. The manifest.uuid
file contains the SHA1 hash of the particular check-in and is used to generate
the SQLITE_SOURCE_ID macro. The VERSION file contains the current SQLite
version number. The sqlite3.h header is really just a copy of src/sqlite.h.in
with the source-id and version number inserted at just the right spots.
Note that comment text in the sqlite3.h file is used to generate much of
the SQLite API documentation. The Tcl scripts used to generate that
documentation are in a separate source repository.
[Tcl script](http://www.tcl.tk) at tool/mksqlite3h.tcl does the conversion.
The manifest.uuid file contains the SHA1 hash of the particular check-in
and is used to generate the SQLITE\_SOURCE\_ID macro. The VERSION file
contains the current SQLite version number. The sqlite3.h header is really
just a copy of src/sqlite.h.in with the source-id and version number inserted
at just the right spots. Note that comment text in the sqlite3.h file is
used to generate much of the SQLite API documentation. The Tcl scripts
used to generate that documentation are in a separate source repository.
The SQL language parser is **parse.c** which is generate from a grammar in
the src/parse.y file. The conversion of "parse.y" into "parse.c" is done

View File

@@ -1,11 +1,11 @@
C Merge\sthe\sPRAGMA\sdata_version\scommand\sand\sthe\senhancements\sto\sFK\squery\splanning\nfrom\strunk\sinto\sthe\ssessions\sbranch.
D 2014-12-20T14:58:32.049
C Merge\sthe\sPRAGMA\sdata_version\sredefinition\sand\sother\sfixes\sfrom\strunk.
D 2014-12-22T18:48:48.561
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 0869fe2a3b7853f048a945fd9cdf671a329b7351
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
F Makefile.msc 212dc90adfad8988134bf3d901a78270d7a9c267
F Makefile.msc 883be4b5950a20bc7e4d72a49ffc5e5905728b54
F Makefile.vxworks 034289efa9d591b04b1a73598623119c306cbba0
F README.md 64f270c43c38c46de749e419c22f0ae2f4499fe8
F README.md d58e3bebc0a4145e0f2a87994015fdb575a8e866
F VERSION d846487aff892625eb8e75960234e7285f0462fe
F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50
F addopcodes.awk 9eb448a552d5c0185cf62c463f9c173cedae3811
@@ -190,12 +190,12 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240
F src/backup.c 7ddee9c7d505e07e959a575b18498f17c71e53ea
F src/bitvec.c 19a4ba637bd85f8f63fc8c9bae5ade9fb05ec1cb
F src/btmutex.c 49ca66250c7dfa844a4d4cb8272b87420d27d3a5
F src/btree.c b2b2bd0aa02430fe86bc891295db919fcafb0d64
F src/btree.c 1de0560426ecde85ff3ea95d7c94261d7652e284
F src/btree.h 94277c1d30c0b75705974bcc8b0c05e79c03d474
F src/btreeInt.h 3363e18fd76f69a27a870b25221b2345b3fd4d21
F src/btreeInt.h a3d0ae1d511365e1a2b76ad10960dbe55c286f34
F src/build.c 162d84e4833b03f9d07192ef06057b0226f6e543
F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0
F src/complete.c c4ba6e0626bb94bc77a0861735f3382fcf7cc818
F src/complete.c 198a0066ba60ab06fc00fba1998d870a4d575463
F src/ctime.c df19848891c8a553c80e6f5a035e768280952d1a
F src/date.c 93594514aae68de117ca4a2a0d6cc63eddf26744
F src/delete.c 20a360262b62051afacb44122b3593a8bd9be131
@@ -212,7 +212,7 @@ F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d
F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e
F src/lempar.c 7274c97d24bb46631e504332ccd3bd1b37841770
F src/loadext.c 86bd4e2fccd520b748cba52492ab60c4a770f660
F src/main.c ef3c25ce021d5ab6ffd29fcf993183bd31e2f9aa
F src/main.c 569d43f0a07b26bfdf12d8571453100e0c18868e
F src/malloc.c 740db54387204c9a2eb67c6d98e68b08e9ef4eab
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
F src/mem1.c faf615aafd8be74a71494dfa027c113ea5c6615f
@@ -224,14 +224,14 @@ F src/mutex.c 19bf9acba69ca2f367c3761080f8a9f0cf4670a8
F src/mutex.h 779d588e3b7756ec3ecf7d78cde1d84aba414f85
F src/mutex_noop.c f3f09fd7a2eb4287cfc799753ffc30380e7b71a1
F src/mutex_unix.c 551e2f25f0fa0ee8fd7a43f50fc3d8be00e95dde
F src/mutex_w32.c 06bfff9a3a83b53389a51a967643db3967032e1e
F src/mutex_w32.c df48fe07562a45c5c927c45b8d5873a27f98bbb0
F src/notify.c 9711a7575036f0d3040ba61bc6e217f13a9888e7
F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8
F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf
F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04
F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa
F src/os_unix.c fb587121840f690101336879adfa6d0b2cd0e8c7
F src/os_win.c ecb04a0dad2fa6fa659931a9d8f0f3aca33f908a
F src/os_win.c 91d3d08e33ec0258d180d4c8255492f47d15e007
F src/os_win.h 09e751b20bbc107ffbd46e13555dc73576d88e21
F src/pager.c 2cbaf886a6157c53a8061ea7e677f81620ff46eb
F src/pager.h c3476e7c89cdf1c6914e50a11f3714e30b4e0a77
@@ -253,7 +253,7 @@ F src/sqlite3ext.h 17d487c3c91b0b8c584a32fbeb393f6f795eea7d
F src/sqliteInt.h 69c302a3b13d06ebaada7f85497106077df00a24
F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d
F src/status.c 81712116e826b0089bb221b018929536b2b5406f
F src/table.c f142bba7903e93ca8d113a5b8877a108ad1a27dc
F src/table.c e7a09215315a978057fb42c640f890160dbcc45e
F src/tclsqlite.c 95452a59e1afd0cbce10d5243c480b0d5e1e5f59
F src/test1.c 56e33bf6b1827c6ca7520c189131ddd778fb2267
F src/test2.c 98049e51a17dc62606a99a9eb95ee477f9996712
@@ -302,7 +302,7 @@ F src/test_vfs.c f84075a388527892ff184988f43b69ce69b8083c
F src/test_vfstrace.c bab9594adc976cbe696ff3970728830b4c5ed698
F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9
F src/threads.c 6de09362b657f19ba83e5fa521ee715787ce9fee
F src/tokenize.c cc9016e5007fc5e76789079616d2f26741bcc689
F src/tokenize.c e00458c9938072b0ea711c850b8dcf4ddcb5fe18
F src/trigger.c 25571661fdeae8c7f975ff40ffec205520a3f92f
F src/update.c d207deb7a031f698104bee879de0632b611e72dd
F src/utf.c fc6b889ba0779b7722634cdeaa25f1930d93820c
@@ -802,7 +802,7 @@ F test/percentile.test b98fc868d71eb5619d42a1702e9ab91718cbed54
F test/permutations.test 5e60eb6ca8429453ab20525dc6ac93d9c41dac6e
F test/pragma.test aa16dedfe01c02c8895169012f7dfde9c163f0d5
F test/pragma2.test aea7b3d82c76034a2df2b38a13745172ddc0bc13
F test/pragma3.test 1935dfdd0082250df4cf4caed52bdfef527c34ff
F test/pragma3.test 3da08d907ba027c50ede8d6e95418f32898971a5
F test/printf.test ec9870c4dce8686a37818e0bf1aba6e6a1863552
F test/printf2.test b4acd4bf8734243257f01ddefa17c4fb090acc8a
F test/progress.test a282973d1d17f08071bc58a77d6b80f2a81c354d
@@ -1252,7 +1252,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P 9817a2864eebe2dc90ce505fe0faa8b069ff48ff de50f25ce3226fa4929b8236c72c88b739859d5f
R 86fc2b8e0d7a1d7a54ccc5d8e79b042d
P d4f82af0a4a9db222e3405cff05c41157e7bd5d9 7a97826f33460f3b4f3890c9cf97116c3355eeda
R 9a054ca44b6e0d7ecf483bae22df2dab
U drh
Z 22a0372b728dfee7ca4ae6444bd43345
Z 6ad5f73c282563e802f6faa1901969e7

View File

@@ -1 +1 @@
d4f82af0a4a9db222e3405cff05c41157e7bd5d9
315243e49d30abd0eb31e3795ecf492aee179e4b

View File

@@ -3550,6 +3550,7 @@ int sqlite3BtreeCommitPhaseTwo(Btree *p, int bCleanup){
sqlite3BtreeLeave(p);
return rc;
}
p->iDataVersion--; /* Compensate for pPager->iDataVersion++; */
pBt->inTransaction = TRANS_READ;
btreeClearHasContent(pBt);
}
@@ -8195,7 +8196,7 @@ void sqlite3BtreeGetMeta(Btree *p, int idx, u32 *pMeta){
assert( idx>=0 && idx<=15 );
if( idx==BTREE_DATA_VERSION ){
*pMeta = sqlite3PagerDataVersion(pBt->pPager);
*pMeta = sqlite3PagerDataVersion(pBt->pPager) + p->iDataVersion;
}else{
*pMeta = get4byte(&pBt->pPage1->aData[36 + idx*4]);
}

View File

@@ -351,6 +351,7 @@ struct Btree {
u8 locked; /* True if db currently has pBt locked */
int wantToLock; /* Number of nested calls to sqlite3BtreeEnter() */
int nBackup; /* Number of backup operations reading this btree */
u32 iDataVersion; /* Combines with pBt->pPager->iDataVersion */
Btree *pNext; /* List of other sharable Btrees from the same db */
Btree *pPrev; /* Back pointer of the same list */
#ifndef SQLITE_OMIT_SHARED_CACHE

View File

@@ -105,13 +105,6 @@ int sqlite3_complete(const char *zSql){
u8 state = 0; /* Current state, using numbers defined in header comment */
u8 token; /* Value of the next token */
#ifdef SQLITE_ENABLE_API_ARMOR
if( zSql==0 ){
(void)SQLITE_MISUSE_BKPT;
return 0;
}
#endif
#ifndef SQLITE_OMIT_TRIGGER
/* A complex statement machine used to detect the end of a CREATE TRIGGER
** statement. This is the normal case.
@@ -141,6 +134,13 @@ int sqlite3_complete(const char *zSql){
};
#endif /* SQLITE_OMIT_TRIGGER */
#ifdef SQLITE_ENABLE_API_ARMOR
if( zSql==0 ){
(void)SQLITE_MISUSE_BKPT;
return 0;
}
#endif
while( *zSql ){
switch( *zSql ){
case ';': { /* A semicolon */

View File

@@ -3680,13 +3680,14 @@ Btree *sqlite3DbNameToBtree(sqlite3 *db, const char *zDbName){
** connection.
*/
const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName){
Btree *pBt;
#ifdef SQLITE_ENABLE_API_ARMOR
if( !sqlite3SafetyCheckOk(db) ){
(void)SQLITE_MISUSE_BKPT;
return 0;
}
#endif
Btree *pBt = sqlite3DbNameToBtree(db, zDbName);
pBt = sqlite3DbNameToBtree(db, zDbName);
return pBt ? sqlite3BtreeGetFilename(pBt) : 0;
}
@@ -3695,12 +3696,13 @@ const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName){
** no such database exists.
*/
int sqlite3_db_readonly(sqlite3 *db, const char *zDbName){
Btree *pBt;
#ifdef SQLITE_ENABLE_API_ARMOR
if( !sqlite3SafetyCheckOk(db) ){
(void)SQLITE_MISUSE_BKPT;
return -1;
}
#endif
Btree *pBt = sqlite3DbNameToBtree(db, zDbName);
pBt = sqlite3DbNameToBtree(db, zDbName);
return pBt ? sqlite3BtreeIsReadonly(pBt) : -1;
}

View File

@@ -209,6 +209,12 @@ static sqlite3_mutex *winMutexAlloc(int iType){
break;
}
default: {
#ifdef SQLITE_ENABLE_API_ARMOR
if( iType-2<0 || iType-2>=ArraySize(winMutex_staticMutexes) ){
(void)SQLITE_MISUSE_BKPT;
return 0;
}
#endif
assert( iType-2 >= 0 );
assert( iType-2 < ArraySize(winMutex_staticMutexes) );
assert( winMutex_isInit==1 );

View File

@@ -2479,7 +2479,7 @@ static int winRead(
int amt, /* Number of bytes to read */
sqlite3_int64 offset /* Begin reading at this offset */
){
#if !SQLITE_OS_WINCE
#if !SQLITE_OS_WINCE && !defined(SQLITE_WIN32_NO_OVERLAPPED)
OVERLAPPED overlapped; /* The offset for ReadFile. */
#endif
winFile *pFile = (winFile*)id; /* file handle */
@@ -2511,7 +2511,7 @@ static int winRead(
}
#endif
#if SQLITE_OS_WINCE
#if SQLITE_OS_WINCE || defined(SQLITE_WIN32_NO_OVERLAPPED)
if( winSeekFile(pFile, offset) ){
OSTRACE(("READ file=%p, rc=SQLITE_FULL\n", pFile->h));
return SQLITE_FULL;
@@ -2583,13 +2583,13 @@ static int winWrite(
}
#endif
#if SQLITE_OS_WINCE
#if SQLITE_OS_WINCE || defined(SQLITE_WIN32_NO_OVERLAPPED)
rc = winSeekFile(pFile, offset);
if( rc==0 ){
#else
{
#endif
#if !SQLITE_OS_WINCE
#if !SQLITE_OS_WINCE && !defined(SQLITE_WIN32_NO_OVERLAPPED)
OVERLAPPED overlapped; /* The offset for WriteFile. */
#endif
u8 *aRem = (u8 *)pBuf; /* Data yet to be written */
@@ -2597,14 +2597,14 @@ static int winWrite(
DWORD nWrite; /* Bytes written by each WriteFile() call */
DWORD lastErrno = NO_ERROR; /* Value returned by GetLastError() */
#if !SQLITE_OS_WINCE
#if !SQLITE_OS_WINCE && !defined(SQLITE_WIN32_NO_OVERLAPPED)
memset(&overlapped, 0, sizeof(OVERLAPPED));
overlapped.Offset = (LONG)(offset & 0xffffffff);
overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff);
#endif
while( nRem>0 ){
#if SQLITE_OS_WINCE
#if SQLITE_OS_WINCE || defined(SQLITE_WIN32_NO_OVERLAPPED)
if( !osWriteFile(pFile->h, aRem, nRem, &nWrite, 0) ){
#else
if( !osWriteFile(pFile->h, aRem, nRem, &nWrite, &overlapped) ){
@@ -2617,7 +2617,7 @@ static int winWrite(
lastErrno = osGetLastError();
break;
}
#if !SQLITE_OS_WINCE
#if !SQLITE_OS_WINCE && !defined(SQLITE_WIN32_NO_OVERLAPPED)
offset += nWrite;
overlapped.Offset = (LONG)(offset & 0xffffffff);
overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff);

View File

@@ -127,7 +127,7 @@ int sqlite3_get_table(
TabResult res;
#ifdef SQLITE_ENABLE_API_ARMOR
if( pazResult==0 ) return SQLITE_MISUSE_BKPT;
if( !sqlite3SafetyCheckOk(db) || pazResult==0 ) return SQLITE_MISUSE_BKPT;
#endif
*pazResult = 0;
if( pnColumn ) *pnColumn = 0;

View File

@@ -391,6 +391,9 @@ int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){
int mxSqlLen; /* Max length of an SQL string */
#ifdef SQLITE_ENABLE_API_ARMOR
if( zSql==0 || pzErrMsg==0 ) return SQLITE_MISUSE_BKPT;
#endif
mxSqlLen = db->aLimit[SQLITE_LIMIT_SQL_LENGTH];
if( db->nVdbeActive==0 ){
db->u1.isInterrupted = 0;

View File

@@ -32,25 +32,20 @@ do_execsql_test pragma3-102 {
# EVIDENCE-OF: R-27726-60934 The "PRAGMA data_version" command provides
# an indication that the database file has been modified.
#
# EVIDENCE-OF: R-30058-27547 The integer values returned by two
# invocations of "PRAGMA data_version" will be different if changes
# where committed to that database in between the two invocations.
#
# EVIDENCE-OF: R-10201-09349 The "PRAGMA data_version" command responses
# to changes committed by the same database connection, by database
# connections sharing a cache in shared cache mode, and by completely
# independent database connections including connections in separate
# threads and processes.
#
# In this test, it response to two separate changes on the same database
# connection.
# EVIDENCE-OF: R-25838-33704 The "PRAGMA data_version" value is
# unchanced for commits made on the same database connection.
#
do_execsql_test pragma3-110 {
PRAGMA data_version;
BEGIN IMMEDIATE;
PRAGMA data_version;
CREATE TABLE t1(a);
INSERT INTO t1 VALUES(100),(200),(300);
PRAGMA data_version;
COMMIT;
SELECT * FROM t1;
PRAGMA data_version;
} {100 200 300 3}
} {1 1 1 100 200 300 1}
sqlite3 db2 test.db
do_test pragma3-120 {
@@ -61,44 +56,88 @@ do_test pragma3-120 {
} {100 200 300 1}
do_execsql_test pragma3-130 {
PRAGMA data_version;
BEGIN IMMEDIATE;
PRAGMA data_version;
INSERT INTO t1 VALUES(400),(500);
PRAGMA data_version;
COMMIT;
SELECT * FROM t1;
PRAGMA data_version;
} {100 200 300 400 500 4}
} {1 1 1 100 200 300 400 500 1}
# EVIDENCE-OF: R-10201-09349 The "PRAGMA data_version" command responses
# to changes committed by the same database connection, by database
# connections sharing a cache in shared cache mode, and by completely
# independent database connections including connections in separate
# threads and processes.
# EVIDENCE-OF: R-63005-41812 The integer values returned by two
# invocations of "PRAGMA data_version" from the same connection will be
# different if changes were committed to the database by any other
# connection in the interim.
#
# In these test, it response to changes in a different database connection
# part of the same process.
# Value went from 1 in pragma3-120 to 2 here.
#
do_test pragma3-140 {
db2 eval {
SELECT * FROM t1;
PRAGMA data_version;
BEGIN IMMEDIATE;
PRAGMA data_version;
UPDATE t1 SET a=a+1;
COMMIT;
SELECT * FROM t1;
PRAGMA data_version;
}
} {100 200 300 400 500 2 101 201 301 401 501 3}
} {100 200 300 400 500 2 2 101 201 301 401 501 2}
do_execsql_test pragma3-150 {
SELECT * FROM t1;
PRAGMA data_version;
} {101 201 301 401 501 5}
} {101 201 301 401 501 2}
# EVIDENCE-OF: R-10201-09349 The "PRAGMA data_version" command responses
# to changes committed by the same database connection, by database
# connections sharing a cache in shared cache mode, and by completely
# independent database connections including connections in separate
# threads and processes.
#
# This test verifies behavior when a separate process changes the database
# file.
do_test pragma3-160 {
db eval {
BEGIN;
PRAGMA data_version;
UPDATE t1 SET a=555 WHERE a=501;
PRAGMA data_version;
SELECT * FROM t1 ORDER BY a;
PRAGMA data_version;
}
} {2 2 101 201 301 401 555 2}
do_test pragma3-170 {
db2 eval {
PRAGMA data_version;
}
} {2}
do_test pragma3-180 {
db eval {
COMMIT;
PRAGMA data_version;
}
} {2}
do_test pragma3-190 {
db2 eval {
PRAGMA data_version;
}
} {3}
# EVIDENCE-OF: R-19326-44825 The "PRAGMA data_version" value is a local
# property of each database connection and so values returned by two
# concurrent invocations of "PRAGMA data_version" on separate database
# connections are often different even though the underlying database is
# identical.
#
do_test pragma3-195 {
expr {[db eval {PRAGMA data_version}]!=[db2 eval {PRAGMA data_version}]}
} {1}
# EVIDENCE-OF: R-54562-06892 The behavior of "PRAGMA data_version" is
# the same for all database connections, including database connections
# in separate processes and shared cache database connections.
#
# The next block checks the behavior for separate processes.
#
do_test pragma3-200 {
db eval {PRAGMA data_version; SELECT * FROM t1;}
} {2 101 201 301 401 555}
do_test pragma3-201 {
set fd [open pragma3.txt wb]
puts $fd {
sqlite3 db test.db;
@@ -113,18 +152,15 @@ do_test pragma3-200 {
PRAGMA data_version;
SELECT * FROM t1;
}
} {6 101 201}
} {3 101 201}
db2 close
db close
# EVIDENCE-OF: R-10201-09349 The "PRAGMA data_version" command responses
# to changes committed by the same database connection, by database
# connections sharing a cache in shared cache mode, and by completely
# independent database connections including connections in separate
# threads and processes.
# EVIDENCE-OF: R-54562-06892 The behavior of "PRAGMA data_version" is
# the same for all database connections, including database connections
# in separate processes and shared cache database connections.
#
# The next series of tests verifies the behavior for shared-cache
# database connections.
# The next block checks that behavior is the same for shared-cache.
#
ifcapable shared_cache {
set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
@@ -133,24 +169,46 @@ ifcapable shared_cache {
do_test pragma3-300 {
db eval {
PRAGMA data_version;
BEGIN;
CREATE TABLE t3(a,b,c);
CREATE TABLE t4(x,y,z);
INSERT INTO t4 VALUES(123,456,789);
PRAGMA data_version;
COMMIT;
PRAGMA data_version;
}
} {1 2}
} {1 1 1}
do_test pragma3-310 {
db2 eval {
PRAGMA data_version;
BEGIN;
INSERT INTO t3(a,b,c) VALUES('abc','def','ghi');
SELECT * FROM t3;
PRAGMA data_version;
}
} {2 abc def ghi 3}
} {2 abc def ghi 2}
# The transaction in db2 has not yet committed, so the data_version in
# db is unchanged.
do_test pragma3-320 {
db eval {
PRAGMA data_version;
SELECT * FROM t3;
SELECT * FROM t4;
}
} {3 abc def ghi}
} {1 123 456 789}
do_test pragma3-330 {
db2 eval {
COMMIT;
PRAGMA data_version;
SELECT * FROM t4;
}
} {2 123 456 789}
do_test pragma3-340 {
db eval {
PRAGMA data_version;
SELECT * FROM t3;
SELECT * FROM t4;
}
} {2 abc def ghi 123 456 789}
db2 close
db close
sqlite3_enable_shared_cache $::enable_shared_cache
@@ -168,7 +226,7 @@ ifcapable wal {
PRAGMA journal_mode;
SELECT * FROM t1;
}
} {3 wal 101 201}
} {2 wal 101 201}
do_test pragma3-410 {
db2 eval {
PRAGMA data_version;
@@ -178,7 +236,7 @@ ifcapable wal {
} {2 wal 101 201}
do_test pragma3-420 {
db eval {UPDATE t1 SET a=111*(a/100); PRAGMA data_version; SELECT * FROM t1}
} {4 111 222}
} {2 111 222}
do_test pragma3-430 {
db2 eval {PRAGMA data_version; SELECT * FROM t1;}
} {3 111 222}