Fossil SCM

Update SQLite to version 3.6.10.

drh 2009-01-15 16:03 trunk
Commit c002a008e6ed671efe86b19e3de5fb0d89e758c4
2 files changed +116 -15 +2 -2
+116 -15
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
11
/******************************************************************************
22
** This file is an amalgamation of many separate C source files from SQLite
3
-** version 3.6.8. By combining all the individual C code files into this
3
+** version 3.6.10. By combining all the individual C code files into this
44
** single large file, the entire code can be compiled as a one translation
55
** unit. This allows many compilers to do optimizations that would not be
66
** possible if the files were compiled separately. Performance improvements
77
** of 5% are more are commonly seen when SQLite is compiled as a single
88
** translation unit.
@@ -15,11 +15,11 @@
1515
** needed if you want a wrapper to interface SQLite with your choice of
1616
** programming language. The code for the "sqlite3" command-line shell
1717
** is also in a separate file. This file contains only code for the core
1818
** SQLite library.
1919
**
20
-** This amalgamation was generated on 2009-01-14 00:59:32 UTC.
20
+** This amalgamation was generated on 2009-01-15 16:00:39 UTC.
2121
*/
2222
#define SQLITE_CORE 1
2323
#define SQLITE_AMALGAMATION 1
2424
#ifndef SQLITE_PRIVATE
2525
# define SQLITE_PRIVATE static
@@ -39,11 +39,11 @@
3939
** May you share freely, never taking more than you give.
4040
**
4141
*************************************************************************
4242
** Internal interface definitions for SQLite.
4343
**
44
-** @(#) $Id: sqliteInt.h,v 1.823 2009/01/10 16:15:22 drh Exp $
44
+** @(#) $Id: sqliteInt.h,v 1.824 2009/01/14 23:03:41 drh Exp $
4545
*/
4646
#ifndef _SQLITEINT_H_
4747
#define _SQLITEINT_H_
4848
4949
/*
@@ -422,20 +422,26 @@
422422
** bitmask tests, testcase() can be used to make sure each bit
423423
** is significant and used at least once. On switch statements
424424
** where multiple cases go to the same block of code, testcase()
425425
** can insure that all cases are evaluated.
426426
**
427
-** The TESTONLY macro is used to enclose variable declarations or
428
-** other bits of code that are needed to support the arguments
429
-** within testcase() macros.
430427
*/
431428
#ifdef SQLITE_COVERAGE_TEST
432429
SQLITE_PRIVATE void sqlite3Coverage(int);
433430
# define testcase(X) if( X ){ sqlite3Coverage(__LINE__); }
434
-# define TESTONLY(X) X
435431
#else
436432
# define testcase(X)
433
+#endif
434
+
435
+/*
436
+** The TESTONLY macro is used to enclose variable declarations or
437
+** other bits of code that are needed to support the arguments
438
+** within testcase() and assert() macros.
439
+*/
440
+#if !defined(NDEBUG) || defined(SQLITE_COVERAGE_TEST)
441
+# define TESTONLY(X) X
442
+#else
437443
# define TESTONLY(X)
438444
#endif
439445
440446
/*
441447
** The ALWAYS and NEVER macros surround boolean expressions which
@@ -601,12 +607,12 @@
601607
**
602608
** {H10014} The SQLITE_VERSION_NUMBER #define shall resolve to an integer
603609
** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z
604610
** are the major version, minor version, and release number.
605611
*/
606
-#define SQLITE_VERSION "3.6.8"
607
-#define SQLITE_VERSION_NUMBER 3006008
612
+#define SQLITE_VERSION "3.6.10"
613
+#define SQLITE_VERSION_NUMBER 3006010
608614
609615
/*
610616
** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100>
611617
** KEYWORDS: sqlite3_version
612618
**
@@ -8746,11 +8752,11 @@
87468752
** the SQLite library will work on both POSIX and windows systems.
87478753
**
87488754
** This header file is #include-ed by sqliteInt.h and thus ends up
87498755
** being included by every source file.
87508756
**
8751
-** $Id: os.h,v 1.106 2008/12/08 18:19:18 drh Exp $
8757
+** $Id: os.h,v 1.107 2009/01/14 23:03:41 drh Exp $
87528758
*/
87538759
#ifndef _SQLITE_OS_H_
87548760
#define _SQLITE_OS_H_
87558761
87568762
/*
@@ -8974,10 +8980,11 @@
89748980
SQLITE_PRIVATE int sqlite3OsFileSize(sqlite3_file*, i64 *pSize);
89758981
SQLITE_PRIVATE int sqlite3OsLock(sqlite3_file*, int);
89768982
SQLITE_PRIVATE int sqlite3OsUnlock(sqlite3_file*, int);
89778983
SQLITE_PRIVATE int sqlite3OsCheckReservedLock(sqlite3_file *id, int *pResOut);
89788984
SQLITE_PRIVATE int sqlite3OsFileControl(sqlite3_file*,int,void*);
8985
+#define SQLITE_FCNTL_DB_UNCHANGED 0xca093fa0
89798986
SQLITE_PRIVATE int sqlite3OsSectorSize(sqlite3_file *id);
89808987
SQLITE_PRIVATE int sqlite3OsDeviceCharacteristics(sqlite3_file *id);
89818988
89828989
/*
89838990
** Functions for accessing sqlite3_vfs methods
@@ -21580,11 +21587,11 @@
2158021587
** * sqlite3_vfs method implementations.
2158121588
** * Locking primitives for the proxy uber-locking-method. (MacOSX only)
2158221589
** * Definitions of sqlite3_vfs objects for all locking methods
2158321590
** plus implementations of sqlite3_os_init() and sqlite3_os_end().
2158421591
**
21585
-** $Id: os_unix.c,v 1.235 2009/01/09 21:41:17 drh Exp $
21592
+** $Id: os_unix.c,v 1.237 2009/01/15 04:30:03 drh Exp $
2158621593
*/
2158721594
#if SQLITE_OS_UNIX /* This file is used on unix only */
2158821595
2158921596
/*
2159021597
** There are various methods for file locking used for concurrency
@@ -21725,10 +21732,22 @@
2172521732
#endif
2172621733
#if OS_VXWORKS
2172721734
int isDelete; /* Delete on close if true */
2172821735
struct vxworksFileId *pId; /* Unique file ID */
2172921736
#endif
21737
+#ifndef NDEBUG
21738
+ /* The next group of variables are used to track whether or not the
21739
+ ** transaction counter in bytes 24-27 of database files are updated
21740
+ ** whenever any part of the database changes. An assertion fault will
21741
+ ** occur if a file is updated without also updating the transaction
21742
+ ** counter. This test is made to avoid new problems similar to the
21743
+ ** one described by ticket #3584.
21744
+ */
21745
+ unsigned char transCntrChng; /* True if the transaction counter changed */
21746
+ unsigned char dbUpdate; /* True if any part of database file changed */
21747
+ unsigned char inNormalWrite; /* True if in a normal write operation */
21748
+#endif
2173021749
#ifdef SQLITE_TEST
2173121750
/* In test mode, increase the size of this structure a bit so that
2173221751
** it is larger than the struct CrashFile defined in test6.c.
2173321752
*/
2173421753
char aPadding[32];
@@ -23084,10 +23103,28 @@
2308423103
pFile->lastErrno = tErrno;
2308523104
}
2308623105
}
2308723106
}
2308823107
23108
+
23109
+#ifndef NDEBUG
23110
+ /* Set up the transaction-counter change checking flags when
23111
+ ** transitioning from a SHARED to a RESERVED lock. The change
23112
+ ** from SHARED to RESERVED marks the beginning of a normal
23113
+ ** write operation (not a hot journal rollback).
23114
+ */
23115
+ if( rc==SQLITE_OK
23116
+ && pFile->locktype<=SHARED_LOCK
23117
+ && locktype==RESERVED_LOCK
23118
+ ){
23119
+ pFile->transCntrChng = 0;
23120
+ pFile->dbUpdate = 0;
23121
+ pFile->inNormalWrite = 1;
23122
+ }
23123
+#endif
23124
+
23125
+
2308923126
if( rc==SQLITE_OK ){
2309023127
pFile->locktype = locktype;
2309123128
pLock->locktype = locktype;
2309223129
}else if( locktype==EXCLUSIVE_LOCK ){
2309323130
pFile->locktype = PENDING_LOCK;
@@ -23133,10 +23170,27 @@
2313323170
if( pFile->locktype>SHARED_LOCK ){
2313423171
assert( pLock->locktype==pFile->locktype );
2313523172
SimulateIOErrorBenign(1);
2313623173
SimulateIOError( h=(-1) )
2313723174
SimulateIOErrorBenign(0);
23175
+
23176
+#ifndef NDEBUG
23177
+ /* When reducing a lock such that other processes can start
23178
+ ** reading the database file again, make sure that the
23179
+ ** transaction counter was updated if any part of the database
23180
+ ** file changed. If the transaction counter is not updated,
23181
+ ** other connections to the same file might not realize that
23182
+ ** the file has changed and hence might not know to flush their
23183
+ ** cache. The use of a stale cache can lead to database corruption.
23184
+ */
23185
+ assert( pFile->inNormalWrite==0
23186
+ || pFile->dbUpdate==0
23187
+ || pFile->transCntrChng==1 );
23188
+ pFile->inNormalWrite = 0;
23189
+#endif
23190
+
23191
+
2313823192
if( locktype==SHARED_LOCK ){
2313923193
lock.l_type = F_RDLCK;
2314023194
lock.l_whence = SEEK_SET;
2314123195
lock.l_start = SHARED_FIRST;
2314223196
lock.l_len = SHARED_SIZE;
@@ -24465,10 +24519,33 @@
2446524519
sqlite3_int64 offset
2446624520
){
2446724521
int wrote = 0;
2446824522
assert( id );
2446924523
assert( amt>0 );
24524
+
24525
+#ifndef NDEBUG
24526
+ /* If we are doing a normal write to a database file (as opposed to
24527
+ ** doing a hot-journal rollback or a write to some file other than a
24528
+ ** normal database file) then record the fact that the database
24529
+ ** has changed. If the transaction counter is modified, record that
24530
+ ** fact too.
24531
+ */
24532
+ if( ((unixFile*)id)->inNormalWrite ){
24533
+ unixFile *pFile = (unixFile*)id;
24534
+ pFile->dbUpdate = 1; /* The database has been modified */
24535
+ if( offset<=24 && offset+amt>=27 ){
24536
+ char oldCntr[4];
24537
+ SimulateIOErrorBenign(1);
24538
+ seekAndRead(pFile, 24, oldCntr, 4);
24539
+ SimulateIOErrorBenign(0);
24540
+ if( memcmp(oldCntr, &((char*)pBuf)[24-offset], 4)!=0 ){
24541
+ pFile->transCntrChng = 1; /* The transaction counter has changed */
24542
+ }
24543
+ }
24544
+ }
24545
+#endif
24546
+
2447024547
while( amt>0 && (wrote = seekAndWrite((unixFile*)id, offset, pBuf, amt))>0 ){
2447124548
amt -= wrote;
2447224549
offset += wrote;
2447324550
pBuf = &((char*)pBuf)[wrote];
2447424551
}
@@ -24574,13 +24651,15 @@
2457424651
if( rc ) rc = fsync(fd);
2457524652
2457624653
#else
2457724654
if( dataOnly ){
2457824655
rc = fdatasync(fd);
24579
- if( OS_VXWORKS && rc==-1 && errno==ENOTSUP ){
24656
+#if OS_VXWORKS
24657
+ if( rc==-1 && errno==ENOTSUP ){
2458024658
rc = fsync(fd);
2458124659
}
24660
+#endif
2458224661
}else{
2458324662
rc = fsync(fd);
2458424663
}
2458524664
#endif /* ifdef SQLITE_NO_SYNC elif HAVE_FULLFSYNC */
2458624665
@@ -24724,10 +24803,21 @@
2472424803
}
2472524804
case SQLITE_LAST_ERRNO: {
2472624805
*(int*)pArg = ((unixFile*)id)->lastErrno;
2472724806
return SQLITE_OK;
2472824807
}
24808
+#ifndef NDEBUG
24809
+ /* The pager calls this method to signal that it has done
24810
+ ** a rollback and that the database is therefore unchanged and
24811
+ ** it hence it is OK for the transaction change counter to be
24812
+ ** unchanged.
24813
+ */
24814
+ case SQLITE_FCNTL_DB_UNCHANGED: {
24815
+ ((unixFile*)id)->dbUpdate = 0;
24816
+ return SQLITE_OK;
24817
+ }
24818
+#endif
2472924819
#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)
2473024820
case SQLITE_SET_LOCKPROXYFILE:
2473124821
case SQLITE_GET_LOCKPROXYFILE: {
2473224822
return proxyFileControl(id,op,pArg);
2473324823
}
@@ -30679,11 +30769,11 @@
3067930769
** is separate from the database file. The pager also implements file
3068030770
** locking to prevent two processes from writing the same database
3068130771
** file simultaneously, or one process from reading the database while
3068230772
** another is writing.
3068330773
**
30684
-** @(#) $Id: pager.c,v 1.549 2009/01/13 16:03:44 danielk1977 Exp $
30774
+** @(#) $Id: pager.c,v 1.551 2009/01/14 23:03:41 drh Exp $
3068530775
*/
3068630776
#ifndef SQLITE_OMIT_DISKIO
3068730777
3068830778
/*
3068930779
** Macros for troubleshooting. Normally turned off
@@ -31765,10 +31855,11 @@
3176531855
}
3176631856
3176731857
if( !pPager->exclusiveMode ){
3176831858
rc2 = osUnlock(pPager->fd, SHARED_LOCK);
3176931859
pPager->state = PAGER_SHARED;
31860
+ pPager->changeCountDone = 0;
3177031861
}else if( pPager->state==PAGER_SYNCED ){
3177131862
pPager->state = PAGER_EXCLUSIVE;
3177231863
}
3177331864
pPager->dbOrigSize = 0;
3177431865
pPager->setMaster = 0;
@@ -32382,10 +32473,20 @@
3238232473
}
3238332474
/*NOTREACHED*/
3238432475
assert( 0 );
3238532476
3238632477
end_playback:
32478
+ /* Following a rollback, the database file should be back in its original
32479
+ ** state prior to the start of the transaction, so invoke the
32480
+ ** SQLITE_FCNTL_DB_UNCHANGED file-control method to disable the
32481
+ ** assertion that the transaction counter was modified.
32482
+ */
32483
+ assert(
32484
+ pPager->fd->pMethods==0 ||
32485
+ sqlite3OsFileControl(pPager->fd,SQLITE_FCNTL_DB_UNCHANGED,0)>=SQLITE_OK
32486
+ );
32487
+
3238732488
if( rc==SQLITE_OK ){
3238832489
zMaster = pPager->pTmpSpace;
3238932490
rc = readMasterJournal(pPager->jfd, zMaster, pPager->pVfs->mxPathname+1);
3239032491
}
3239132492
if( rc==SQLITE_OK ){
@@ -89509,12 +89610,12 @@
8950989610
** If the root node is a leaf node, then start_block,
8951089611
** leaves_end_block, and end_block are all 0.
8951189612
**
8951289613
**
8951389614
**** Segment merging ****
89514
-** To amortize update costs, segments are groups into levels and
89515
-** merged in matches. Each increase in level represents exponentially
89615
+** To amortize update costs, segments are grouped into levels and
89616
+** merged in batches. Each increase in level represents exponentially
8951689617
** more documents.
8951789618
**
8951889619
** New documents (actually, document updates) are tokenized and
8951989620
** written individually (using LeafWriter) to a level 0 segment, with
8952089621
** incrementing idx. When idx reaches MERGE_COUNT (default 16), all
8952189622
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
1 /******************************************************************************
2 ** This file is an amalgamation of many separate C source files from SQLite
3 ** version 3.6.8. By combining all the individual C code files into this
4 ** single large file, the entire code can be compiled as a one translation
5 ** unit. This allows many compilers to do optimizations that would not be
6 ** possible if the files were compiled separately. Performance improvements
7 ** of 5% are more are commonly seen when SQLite is compiled as a single
8 ** translation unit.
@@ -15,11 +15,11 @@
15 ** needed if you want a wrapper to interface SQLite with your choice of
16 ** programming language. The code for the "sqlite3" command-line shell
17 ** is also in a separate file. This file contains only code for the core
18 ** SQLite library.
19 **
20 ** This amalgamation was generated on 2009-01-14 00:59:32 UTC.
21 */
22 #define SQLITE_CORE 1
23 #define SQLITE_AMALGAMATION 1
24 #ifndef SQLITE_PRIVATE
25 # define SQLITE_PRIVATE static
@@ -39,11 +39,11 @@
39 ** May you share freely, never taking more than you give.
40 **
41 *************************************************************************
42 ** Internal interface definitions for SQLite.
43 **
44 ** @(#) $Id: sqliteInt.h,v 1.823 2009/01/10 16:15:22 drh Exp $
45 */
46 #ifndef _SQLITEINT_H_
47 #define _SQLITEINT_H_
48
49 /*
@@ -422,20 +422,26 @@
422 ** bitmask tests, testcase() can be used to make sure each bit
423 ** is significant and used at least once. On switch statements
424 ** where multiple cases go to the same block of code, testcase()
425 ** can insure that all cases are evaluated.
426 **
427 ** The TESTONLY macro is used to enclose variable declarations or
428 ** other bits of code that are needed to support the arguments
429 ** within testcase() macros.
430 */
431 #ifdef SQLITE_COVERAGE_TEST
432 SQLITE_PRIVATE void sqlite3Coverage(int);
433 # define testcase(X) if( X ){ sqlite3Coverage(__LINE__); }
434 # define TESTONLY(X) X
435 #else
436 # define testcase(X)
 
 
 
 
 
 
 
 
 
 
437 # define TESTONLY(X)
438 #endif
439
440 /*
441 ** The ALWAYS and NEVER macros surround boolean expressions which
@@ -601,12 +607,12 @@
601 **
602 ** {H10014} The SQLITE_VERSION_NUMBER #define shall resolve to an integer
603 ** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z
604 ** are the major version, minor version, and release number.
605 */
606 #define SQLITE_VERSION "3.6.8"
607 #define SQLITE_VERSION_NUMBER 3006008
608
609 /*
610 ** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100>
611 ** KEYWORDS: sqlite3_version
612 **
@@ -8746,11 +8752,11 @@
8746 ** the SQLite library will work on both POSIX and windows systems.
8747 **
8748 ** This header file is #include-ed by sqliteInt.h and thus ends up
8749 ** being included by every source file.
8750 **
8751 ** $Id: os.h,v 1.106 2008/12/08 18:19:18 drh Exp $
8752 */
8753 #ifndef _SQLITE_OS_H_
8754 #define _SQLITE_OS_H_
8755
8756 /*
@@ -8974,10 +8980,11 @@
8974 SQLITE_PRIVATE int sqlite3OsFileSize(sqlite3_file*, i64 *pSize);
8975 SQLITE_PRIVATE int sqlite3OsLock(sqlite3_file*, int);
8976 SQLITE_PRIVATE int sqlite3OsUnlock(sqlite3_file*, int);
8977 SQLITE_PRIVATE int sqlite3OsCheckReservedLock(sqlite3_file *id, int *pResOut);
8978 SQLITE_PRIVATE int sqlite3OsFileControl(sqlite3_file*,int,void*);
 
8979 SQLITE_PRIVATE int sqlite3OsSectorSize(sqlite3_file *id);
8980 SQLITE_PRIVATE int sqlite3OsDeviceCharacteristics(sqlite3_file *id);
8981
8982 /*
8983 ** Functions for accessing sqlite3_vfs methods
@@ -21580,11 +21587,11 @@
21580 ** * sqlite3_vfs method implementations.
21581 ** * Locking primitives for the proxy uber-locking-method. (MacOSX only)
21582 ** * Definitions of sqlite3_vfs objects for all locking methods
21583 ** plus implementations of sqlite3_os_init() and sqlite3_os_end().
21584 **
21585 ** $Id: os_unix.c,v 1.235 2009/01/09 21:41:17 drh Exp $
21586 */
21587 #if SQLITE_OS_UNIX /* This file is used on unix only */
21588
21589 /*
21590 ** There are various methods for file locking used for concurrency
@@ -21725,10 +21732,22 @@
21725 #endif
21726 #if OS_VXWORKS
21727 int isDelete; /* Delete on close if true */
21728 struct vxworksFileId *pId; /* Unique file ID */
21729 #endif
 
 
 
 
 
 
 
 
 
 
 
 
21730 #ifdef SQLITE_TEST
21731 /* In test mode, increase the size of this structure a bit so that
21732 ** it is larger than the struct CrashFile defined in test6.c.
21733 */
21734 char aPadding[32];
@@ -23084,10 +23103,28 @@
23084 pFile->lastErrno = tErrno;
23085 }
23086 }
23087 }
23088
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23089 if( rc==SQLITE_OK ){
23090 pFile->locktype = locktype;
23091 pLock->locktype = locktype;
23092 }else if( locktype==EXCLUSIVE_LOCK ){
23093 pFile->locktype = PENDING_LOCK;
@@ -23133,10 +23170,27 @@
23133 if( pFile->locktype>SHARED_LOCK ){
23134 assert( pLock->locktype==pFile->locktype );
23135 SimulateIOErrorBenign(1);
23136 SimulateIOError( h=(-1) )
23137 SimulateIOErrorBenign(0);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23138 if( locktype==SHARED_LOCK ){
23139 lock.l_type = F_RDLCK;
23140 lock.l_whence = SEEK_SET;
23141 lock.l_start = SHARED_FIRST;
23142 lock.l_len = SHARED_SIZE;
@@ -24465,10 +24519,33 @@
24465 sqlite3_int64 offset
24466 ){
24467 int wrote = 0;
24468 assert( id );
24469 assert( amt>0 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24470 while( amt>0 && (wrote = seekAndWrite((unixFile*)id, offset, pBuf, amt))>0 ){
24471 amt -= wrote;
24472 offset += wrote;
24473 pBuf = &((char*)pBuf)[wrote];
24474 }
@@ -24574,13 +24651,15 @@
24574 if( rc ) rc = fsync(fd);
24575
24576 #else
24577 if( dataOnly ){
24578 rc = fdatasync(fd);
24579 if( OS_VXWORKS && rc==-1 && errno==ENOTSUP ){
 
24580 rc = fsync(fd);
24581 }
 
24582 }else{
24583 rc = fsync(fd);
24584 }
24585 #endif /* ifdef SQLITE_NO_SYNC elif HAVE_FULLFSYNC */
24586
@@ -24724,10 +24803,21 @@
24724 }
24725 case SQLITE_LAST_ERRNO: {
24726 *(int*)pArg = ((unixFile*)id)->lastErrno;
24727 return SQLITE_OK;
24728 }
 
 
 
 
 
 
 
 
 
 
 
24729 #if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)
24730 case SQLITE_SET_LOCKPROXYFILE:
24731 case SQLITE_GET_LOCKPROXYFILE: {
24732 return proxyFileControl(id,op,pArg);
24733 }
@@ -30679,11 +30769,11 @@
30679 ** is separate from the database file. The pager also implements file
30680 ** locking to prevent two processes from writing the same database
30681 ** file simultaneously, or one process from reading the database while
30682 ** another is writing.
30683 **
30684 ** @(#) $Id: pager.c,v 1.549 2009/01/13 16:03:44 danielk1977 Exp $
30685 */
30686 #ifndef SQLITE_OMIT_DISKIO
30687
30688 /*
30689 ** Macros for troubleshooting. Normally turned off
@@ -31765,10 +31855,11 @@
31765 }
31766
31767 if( !pPager->exclusiveMode ){
31768 rc2 = osUnlock(pPager->fd, SHARED_LOCK);
31769 pPager->state = PAGER_SHARED;
 
31770 }else if( pPager->state==PAGER_SYNCED ){
31771 pPager->state = PAGER_EXCLUSIVE;
31772 }
31773 pPager->dbOrigSize = 0;
31774 pPager->setMaster = 0;
@@ -32382,10 +32473,20 @@
32382 }
32383 /*NOTREACHED*/
32384 assert( 0 );
32385
32386 end_playback:
 
 
 
 
 
 
 
 
 
 
32387 if( rc==SQLITE_OK ){
32388 zMaster = pPager->pTmpSpace;
32389 rc = readMasterJournal(pPager->jfd, zMaster, pPager->pVfs->mxPathname+1);
32390 }
32391 if( rc==SQLITE_OK ){
@@ -89509,12 +89610,12 @@
89509 ** If the root node is a leaf node, then start_block,
89510 ** leaves_end_block, and end_block are all 0.
89511 **
89512 **
89513 **** Segment merging ****
89514 ** To amortize update costs, segments are groups into levels and
89515 ** merged in matches. Each increase in level represents exponentially
89516 ** more documents.
89517 **
89518 ** New documents (actually, document updates) are tokenized and
89519 ** written individually (using LeafWriter) to a level 0 segment, with
89520 ** incrementing idx. When idx reaches MERGE_COUNT (default 16), all
89521
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
1 /******************************************************************************
2 ** This file is an amalgamation of many separate C source files from SQLite
3 ** version 3.6.10. By combining all the individual C code files into this
4 ** single large file, the entire code can be compiled as a one translation
5 ** unit. This allows many compilers to do optimizations that would not be
6 ** possible if the files were compiled separately. Performance improvements
7 ** of 5% are more are commonly seen when SQLite is compiled as a single
8 ** translation unit.
@@ -15,11 +15,11 @@
15 ** needed if you want a wrapper to interface SQLite with your choice of
16 ** programming language. The code for the "sqlite3" command-line shell
17 ** is also in a separate file. This file contains only code for the core
18 ** SQLite library.
19 **
20 ** This amalgamation was generated on 2009-01-15 16:00:39 UTC.
21 */
22 #define SQLITE_CORE 1
23 #define SQLITE_AMALGAMATION 1
24 #ifndef SQLITE_PRIVATE
25 # define SQLITE_PRIVATE static
@@ -39,11 +39,11 @@
39 ** May you share freely, never taking more than you give.
40 **
41 *************************************************************************
42 ** Internal interface definitions for SQLite.
43 **
44 ** @(#) $Id: sqliteInt.h,v 1.824 2009/01/14 23:03:41 drh Exp $
45 */
46 #ifndef _SQLITEINT_H_
47 #define _SQLITEINT_H_
48
49 /*
@@ -422,20 +422,26 @@
422 ** bitmask tests, testcase() can be used to make sure each bit
423 ** is significant and used at least once. On switch statements
424 ** where multiple cases go to the same block of code, testcase()
425 ** can insure that all cases are evaluated.
426 **
 
 
 
427 */
428 #ifdef SQLITE_COVERAGE_TEST
429 SQLITE_PRIVATE void sqlite3Coverage(int);
430 # define testcase(X) if( X ){ sqlite3Coverage(__LINE__); }
 
431 #else
432 # define testcase(X)
433 #endif
434
435 /*
436 ** The TESTONLY macro is used to enclose variable declarations or
437 ** other bits of code that are needed to support the arguments
438 ** within testcase() and assert() macros.
439 */
440 #if !defined(NDEBUG) || defined(SQLITE_COVERAGE_TEST)
441 # define TESTONLY(X) X
442 #else
443 # define TESTONLY(X)
444 #endif
445
446 /*
447 ** The ALWAYS and NEVER macros surround boolean expressions which
@@ -601,12 +607,12 @@
607 **
608 ** {H10014} The SQLITE_VERSION_NUMBER #define shall resolve to an integer
609 ** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z
610 ** are the major version, minor version, and release number.
611 */
612 #define SQLITE_VERSION "3.6.10"
613 #define SQLITE_VERSION_NUMBER 3006010
614
615 /*
616 ** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100>
617 ** KEYWORDS: sqlite3_version
618 **
@@ -8746,11 +8752,11 @@
8752 ** the SQLite library will work on both POSIX and windows systems.
8753 **
8754 ** This header file is #include-ed by sqliteInt.h and thus ends up
8755 ** being included by every source file.
8756 **
8757 ** $Id: os.h,v 1.107 2009/01/14 23:03:41 drh Exp $
8758 */
8759 #ifndef _SQLITE_OS_H_
8760 #define _SQLITE_OS_H_
8761
8762 /*
@@ -8974,10 +8980,11 @@
8980 SQLITE_PRIVATE int sqlite3OsFileSize(sqlite3_file*, i64 *pSize);
8981 SQLITE_PRIVATE int sqlite3OsLock(sqlite3_file*, int);
8982 SQLITE_PRIVATE int sqlite3OsUnlock(sqlite3_file*, int);
8983 SQLITE_PRIVATE int sqlite3OsCheckReservedLock(sqlite3_file *id, int *pResOut);
8984 SQLITE_PRIVATE int sqlite3OsFileControl(sqlite3_file*,int,void*);
8985 #define SQLITE_FCNTL_DB_UNCHANGED 0xca093fa0
8986 SQLITE_PRIVATE int sqlite3OsSectorSize(sqlite3_file *id);
8987 SQLITE_PRIVATE int sqlite3OsDeviceCharacteristics(sqlite3_file *id);
8988
8989 /*
8990 ** Functions for accessing sqlite3_vfs methods
@@ -21580,11 +21587,11 @@
21587 ** * sqlite3_vfs method implementations.
21588 ** * Locking primitives for the proxy uber-locking-method. (MacOSX only)
21589 ** * Definitions of sqlite3_vfs objects for all locking methods
21590 ** plus implementations of sqlite3_os_init() and sqlite3_os_end().
21591 **
21592 ** $Id: os_unix.c,v 1.237 2009/01/15 04:30:03 drh Exp $
21593 */
21594 #if SQLITE_OS_UNIX /* This file is used on unix only */
21595
21596 /*
21597 ** There are various methods for file locking used for concurrency
@@ -21725,10 +21732,22 @@
21732 #endif
21733 #if OS_VXWORKS
21734 int isDelete; /* Delete on close if true */
21735 struct vxworksFileId *pId; /* Unique file ID */
21736 #endif
21737 #ifndef NDEBUG
21738 /* The next group of variables are used to track whether or not the
21739 ** transaction counter in bytes 24-27 of database files are updated
21740 ** whenever any part of the database changes. An assertion fault will
21741 ** occur if a file is updated without also updating the transaction
21742 ** counter. This test is made to avoid new problems similar to the
21743 ** one described by ticket #3584.
21744 */
21745 unsigned char transCntrChng; /* True if the transaction counter changed */
21746 unsigned char dbUpdate; /* True if any part of database file changed */
21747 unsigned char inNormalWrite; /* True if in a normal write operation */
21748 #endif
21749 #ifdef SQLITE_TEST
21750 /* In test mode, increase the size of this structure a bit so that
21751 ** it is larger than the struct CrashFile defined in test6.c.
21752 */
21753 char aPadding[32];
@@ -23084,10 +23103,28 @@
23103 pFile->lastErrno = tErrno;
23104 }
23105 }
23106 }
23107
23108
23109 #ifndef NDEBUG
23110 /* Set up the transaction-counter change checking flags when
23111 ** transitioning from a SHARED to a RESERVED lock. The change
23112 ** from SHARED to RESERVED marks the beginning of a normal
23113 ** write operation (not a hot journal rollback).
23114 */
23115 if( rc==SQLITE_OK
23116 && pFile->locktype<=SHARED_LOCK
23117 && locktype==RESERVED_LOCK
23118 ){
23119 pFile->transCntrChng = 0;
23120 pFile->dbUpdate = 0;
23121 pFile->inNormalWrite = 1;
23122 }
23123 #endif
23124
23125
23126 if( rc==SQLITE_OK ){
23127 pFile->locktype = locktype;
23128 pLock->locktype = locktype;
23129 }else if( locktype==EXCLUSIVE_LOCK ){
23130 pFile->locktype = PENDING_LOCK;
@@ -23133,10 +23170,27 @@
23170 if( pFile->locktype>SHARED_LOCK ){
23171 assert( pLock->locktype==pFile->locktype );
23172 SimulateIOErrorBenign(1);
23173 SimulateIOError( h=(-1) )
23174 SimulateIOErrorBenign(0);
23175
23176 #ifndef NDEBUG
23177 /* When reducing a lock such that other processes can start
23178 ** reading the database file again, make sure that the
23179 ** transaction counter was updated if any part of the database
23180 ** file changed. If the transaction counter is not updated,
23181 ** other connections to the same file might not realize that
23182 ** the file has changed and hence might not know to flush their
23183 ** cache. The use of a stale cache can lead to database corruption.
23184 */
23185 assert( pFile->inNormalWrite==0
23186 || pFile->dbUpdate==0
23187 || pFile->transCntrChng==1 );
23188 pFile->inNormalWrite = 0;
23189 #endif
23190
23191
23192 if( locktype==SHARED_LOCK ){
23193 lock.l_type = F_RDLCK;
23194 lock.l_whence = SEEK_SET;
23195 lock.l_start = SHARED_FIRST;
23196 lock.l_len = SHARED_SIZE;
@@ -24465,10 +24519,33 @@
24519 sqlite3_int64 offset
24520 ){
24521 int wrote = 0;
24522 assert( id );
24523 assert( amt>0 );
24524
24525 #ifndef NDEBUG
24526 /* If we are doing a normal write to a database file (as opposed to
24527 ** doing a hot-journal rollback or a write to some file other than a
24528 ** normal database file) then record the fact that the database
24529 ** has changed. If the transaction counter is modified, record that
24530 ** fact too.
24531 */
24532 if( ((unixFile*)id)->inNormalWrite ){
24533 unixFile *pFile = (unixFile*)id;
24534 pFile->dbUpdate = 1; /* The database has been modified */
24535 if( offset<=24 && offset+amt>=27 ){
24536 char oldCntr[4];
24537 SimulateIOErrorBenign(1);
24538 seekAndRead(pFile, 24, oldCntr, 4);
24539 SimulateIOErrorBenign(0);
24540 if( memcmp(oldCntr, &((char*)pBuf)[24-offset], 4)!=0 ){
24541 pFile->transCntrChng = 1; /* The transaction counter has changed */
24542 }
24543 }
24544 }
24545 #endif
24546
24547 while( amt>0 && (wrote = seekAndWrite((unixFile*)id, offset, pBuf, amt))>0 ){
24548 amt -= wrote;
24549 offset += wrote;
24550 pBuf = &((char*)pBuf)[wrote];
24551 }
@@ -24574,13 +24651,15 @@
24651 if( rc ) rc = fsync(fd);
24652
24653 #else
24654 if( dataOnly ){
24655 rc = fdatasync(fd);
24656 #if OS_VXWORKS
24657 if( rc==-1 && errno==ENOTSUP ){
24658 rc = fsync(fd);
24659 }
24660 #endif
24661 }else{
24662 rc = fsync(fd);
24663 }
24664 #endif /* ifdef SQLITE_NO_SYNC elif HAVE_FULLFSYNC */
24665
@@ -24724,10 +24803,21 @@
24803 }
24804 case SQLITE_LAST_ERRNO: {
24805 *(int*)pArg = ((unixFile*)id)->lastErrno;
24806 return SQLITE_OK;
24807 }
24808 #ifndef NDEBUG
24809 /* The pager calls this method to signal that it has done
24810 ** a rollback and that the database is therefore unchanged and
24811 ** it hence it is OK for the transaction change counter to be
24812 ** unchanged.
24813 */
24814 case SQLITE_FCNTL_DB_UNCHANGED: {
24815 ((unixFile*)id)->dbUpdate = 0;
24816 return SQLITE_OK;
24817 }
24818 #endif
24819 #if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)
24820 case SQLITE_SET_LOCKPROXYFILE:
24821 case SQLITE_GET_LOCKPROXYFILE: {
24822 return proxyFileControl(id,op,pArg);
24823 }
@@ -30679,11 +30769,11 @@
30769 ** is separate from the database file. The pager also implements file
30770 ** locking to prevent two processes from writing the same database
30771 ** file simultaneously, or one process from reading the database while
30772 ** another is writing.
30773 **
30774 ** @(#) $Id: pager.c,v 1.551 2009/01/14 23:03:41 drh Exp $
30775 */
30776 #ifndef SQLITE_OMIT_DISKIO
30777
30778 /*
30779 ** Macros for troubleshooting. Normally turned off
@@ -31765,10 +31855,11 @@
31855 }
31856
31857 if( !pPager->exclusiveMode ){
31858 rc2 = osUnlock(pPager->fd, SHARED_LOCK);
31859 pPager->state = PAGER_SHARED;
31860 pPager->changeCountDone = 0;
31861 }else if( pPager->state==PAGER_SYNCED ){
31862 pPager->state = PAGER_EXCLUSIVE;
31863 }
31864 pPager->dbOrigSize = 0;
31865 pPager->setMaster = 0;
@@ -32382,10 +32473,20 @@
32473 }
32474 /*NOTREACHED*/
32475 assert( 0 );
32476
32477 end_playback:
32478 /* Following a rollback, the database file should be back in its original
32479 ** state prior to the start of the transaction, so invoke the
32480 ** SQLITE_FCNTL_DB_UNCHANGED file-control method to disable the
32481 ** assertion that the transaction counter was modified.
32482 */
32483 assert(
32484 pPager->fd->pMethods==0 ||
32485 sqlite3OsFileControl(pPager->fd,SQLITE_FCNTL_DB_UNCHANGED,0)>=SQLITE_OK
32486 );
32487
32488 if( rc==SQLITE_OK ){
32489 zMaster = pPager->pTmpSpace;
32490 rc = readMasterJournal(pPager->jfd, zMaster, pPager->pVfs->mxPathname+1);
32491 }
32492 if( rc==SQLITE_OK ){
@@ -89509,12 +89610,12 @@
89610 ** If the root node is a leaf node, then start_block,
89611 ** leaves_end_block, and end_block are all 0.
89612 **
89613 **
89614 **** Segment merging ****
89615 ** To amortize update costs, segments are grouped into levels and
89616 ** merged in batches. Each increase in level represents exponentially
89617 ** more documents.
89618 **
89619 ** New documents (actually, document updates) are tokenized and
89620 ** written individually (using LeafWriter) to a level 0 segment, with
89621 ** incrementing idx. When idx reaches MERGE_COUNT (default 16), all
89622
+2 -2
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -105,12 +105,12 @@
105105
**
106106
** {H10014} The SQLITE_VERSION_NUMBER #define shall resolve to an integer
107107
** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z
108108
** are the major version, minor version, and release number.
109109
*/
110
-#define SQLITE_VERSION "3.6.8"
111
-#define SQLITE_VERSION_NUMBER 3006008
110
+#define SQLITE_VERSION "3.6.10"
111
+#define SQLITE_VERSION_NUMBER 3006010
112112
113113
/*
114114
** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100>
115115
** KEYWORDS: sqlite3_version
116116
**
117117
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -105,12 +105,12 @@
105 **
106 ** {H10014} The SQLITE_VERSION_NUMBER #define shall resolve to an integer
107 ** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z
108 ** are the major version, minor version, and release number.
109 */
110 #define SQLITE_VERSION "3.6.8"
111 #define SQLITE_VERSION_NUMBER 3006008
112
113 /*
114 ** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100>
115 ** KEYWORDS: sqlite3_version
116 **
117
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -105,12 +105,12 @@
105 **
106 ** {H10014} The SQLITE_VERSION_NUMBER #define shall resolve to an integer
107 ** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z
108 ** are the major version, minor version, and release number.
109 */
110 #define SQLITE_VERSION "3.6.10"
111 #define SQLITE_VERSION_NUMBER 3006010
112
113 /*
114 ** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100>
115 ** KEYWORDS: sqlite3_version
116 **
117

Keyboard Shortcuts

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