Fossil SCM

Update the built-in SQLite to the latest 3.7.10 beta.

drh 2012-01-05 13:08 trunk
Commit 8a8685d1035b4cc8d50b5a564dc44774b0932831
2 files changed +119 -213 +19 -22
+119 -213
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -657,11 +657,11 @@
657657
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
658658
** [sqlite_version()] and [sqlite_source_id()].
659659
*/
660660
#define SQLITE_VERSION "3.7.10"
661661
#define SQLITE_VERSION_NUMBER 3007010
662
-#define SQLITE_SOURCE_ID "2011-12-23 13:32:07 1f24ae716df6232de768e245ea990049deee3c22"
662
+#define SQLITE_SOURCE_ID "2012-01-05 12:38:02 1378f905d37544701776d38987fe7a312b255983"
663663
664664
/*
665665
** CAPI3REF: Run-Time Library Version Numbers
666666
** KEYWORDS: sqlite3_version, sqlite3_sourceid
667667
**
@@ -725,11 +725,11 @@
725725
726726
/*
727727
** CAPI3REF: Test To See If The Library Is Threadsafe
728728
**
729729
** ^The sqlite3_threadsafe() function returns zero if and only if
730
-** SQLite was compiled mutexing code omitted due to the
730
+** SQLite was compiled with mutexing code omitted due to the
731731
** [SQLITE_THREADSAFE] compile-time option being set to 0.
732732
**
733733
** SQLite can be compiled with or without mutexes. When
734734
** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes
735735
** are enabled and SQLite is threadsafe. When the
@@ -919,11 +919,11 @@
919919
** CAPI3REF: Result Codes
920920
** KEYWORDS: SQLITE_OK {error code} {error codes}
921921
** KEYWORDS: {result code} {result codes}
922922
**
923923
** Many SQLite functions return an integer result code from the set shown
924
-** here in order to indicates success or failure.
924
+** here in order to indicate success or failure.
925925
**
926926
** New error codes may be added in future versions of SQLite.
927927
**
928928
** See also: [SQLITE_IOERR_READ | extended result codes],
929929
** [sqlite3_vtab_on_conflict()] [SQLITE_ROLLBACK | result codes].
@@ -1058,17 +1058,14 @@
10581058
** that when data is appended to a file, the data is appended
10591059
** first then the size of the file is extended, never the other
10601060
** way around. The SQLITE_IOCAP_SEQUENTIAL property means that
10611061
** information is written to disk in the same order as calls
10621062
** to xWrite(). The SQLITE_IOCAP_POWERSAFE_OVERWRITE property means that
1063
-** after reboot following a crash or power loss, the value of
1064
-** each byte in a file is a value that was actually written
1065
-** into that byte at some point. In other words, a crash will
1066
-** not cause unwritten bytes of the file to change nor introduce
1067
-** randomness into a file nor zero out parts of the file, and any byte of
1068
-** a file that are never written will not change values due to
1069
-** writes to nearby bytes.
1063
+** after reboot following a crash or power loss, the only bytes in a
1064
+** file that were written at the application level might have changed
1065
+** and that adjacent bytes, even bytes within the same sector are
1066
+** guaranteed to be unchanged.
10701067
*/
10711068
#define SQLITE_IOCAP_ATOMIC 0x00000001
10721069
#define SQLITE_IOCAP_ATOMIC512 0x00000002
10731070
#define SQLITE_IOCAP_ATOMIC1K 0x00000004
10741071
#define SQLITE_IOCAP_ATOMIC2K 0x00000008
@@ -1300,16 +1297,16 @@
13001297
** opcode as doing so may disrupt the operation of the specialized VFSes
13011298
** that do require it.
13021299
**
13031300
** ^The [SQLITE_FCNTL_WIN32_AV_RETRY] opcode is used to configure automatic
13041301
** retry counts and intervals for certain disk I/O operations for the
1305
-** windows [VFS] in order to work to provide robustness against
1302
+** windows [VFS] in order to provide robustness in the presence of
13061303
** anti-virus programs. By default, the windows VFS will retry file read,
13071304
** file write, and file delete operations up to 10 times, with a delay
13081305
** of 25 milliseconds before the first retry and with the delay increasing
13091306
** by an additional 25 milliseconds with each subsequent retry. This
1310
-** opcode allows those to values (10 retries and 25 milliseconds of delay)
1307
+** opcode allows these two values (10 retries and 25 milliseconds of delay)
13111308
** to be adjusted. The values are changed for all database connections
13121309
** within the same process. The argument is a pointer to an array of two
13131310
** integers where the first integer i the new retry count and the second
13141311
** integer is the delay. If either integer is negative, then the setting
13151312
** is not changed but instead the prior value of that setting is written
@@ -1420,11 +1417,11 @@
14201417
** ^SQLite guarantees that the zFilename parameter to xOpen
14211418
** is either a NULL pointer or string obtained
14221419
** from xFullPathname() with an optional suffix added.
14231420
** ^If a suffix is added to the zFilename parameter, it will
14241421
** consist of a single "-" character followed by no more than
1425
-** 10 alphanumeric and/or "-" characters.
1422
+** 11 alphanumeric and/or "-" characters.
14261423
** ^SQLite further guarantees that
14271424
** the string will be valid and unchanged until xClose() is
14281425
** called. Because of the previous sentence,
14291426
** the [sqlite3_file] can safely store a pointer to the
14301427
** filename if it needs to remember the filename for some reason.
@@ -2571,11 +2568,11 @@
25712568
** These routines all implement some additional formatting
25722569
** options that are useful for constructing SQL statements.
25732570
** All of the usual printf() formatting options apply. In addition, there
25742571
** is are "%q", "%Q", and "%z" options.
25752572
**
2576
-** ^(The %q option works like %s in that it substitutes a null-terminated
2573
+** ^(The %q option works like %s in that it substitutes a nul-terminated
25772574
** string from the argument list. But %q also doubles every '\'' character.
25782575
** %q is designed for use inside a string literal.)^ By doubling each '\''
25792576
** character it escapes that character and allows it to be inserted into
25802577
** the string.
25812578
**
@@ -4091,11 +4088,11 @@
40914088
** of the string. ^For clarity: the values returned by
40924089
** [sqlite3_column_bytes()] and [sqlite3_column_bytes16()] are the number of
40934090
** bytes in the string, not the number of characters.
40944091
**
40954092
** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(),
4096
-** even empty strings, are always zero terminated. ^The return
4093
+** even empty strings, are always zero-terminated. ^The return
40974094
** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.
40984095
**
40994096
** ^The object returned by [sqlite3_column_value()] is an
41004097
** [unprotected sqlite3_value] object. An unprotected sqlite3_value object
41014098
** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()].
@@ -5171,11 +5168,11 @@
51715168
SQLITE_API int sqlite3_release_memory(int);
51725169
51735170
/*
51745171
** CAPI3REF: Free Memory Used By A Database Connection
51755172
**
5176
-** ^The sqlite3_db_shrink(D) interface attempts to free as much heap
5173
+** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap
51775174
** memory as possible from database connection D. Unlike the
51785175
** [sqlite3_release_memory()] interface, this interface is effect even
51795176
** when then [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is
51805177
** omitted.
51815178
**
@@ -5954,19 +5951,19 @@
59545951
** is selected automatically at compile-time. ^(The following
59555952
** implementations are available in the SQLite core:
59565953
**
59575954
** <ul>
59585955
** <li> SQLITE_MUTEX_OS2
5959
-** <li> SQLITE_MUTEX_PTHREAD
5956
+** <li> SQLITE_MUTEX_PTHREADS
59605957
** <li> SQLITE_MUTEX_W32
59615958
** <li> SQLITE_MUTEX_NOOP
59625959
** </ul>)^
59635960
**
59645961
** ^The SQLITE_MUTEX_NOOP implementation is a set of routines
59655962
** that does no real locking and is appropriate for use in
59665963
** a single-threaded application. ^The SQLITE_MUTEX_OS2,
5967
-** SQLITE_MUTEX_PTHREAD, and SQLITE_MUTEX_W32 implementations
5964
+** SQLITE_MUTEX_PTHREADS, and SQLITE_MUTEX_W32 implementations
59685965
** are appropriate for use on OS/2, Unix, and Windows.
59695966
**
59705967
** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor
59715968
** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex
59725969
** implementation is included with the library. In this case the
@@ -6152,11 +6149,11 @@
61526149
** defined and if NDEBUG is not defined.
61536150
**
61546151
** ^These routines should return true if the mutex in their argument
61556152
** is held or not held, respectively, by the calling thread.
61566153
**
6157
-** ^The implementation is not required to provided versions of these
6154
+** ^The implementation is not required to provide versions of these
61586155
** routines that actually work. If the implementation does not provide working
61596156
** versions of these routines, it should at least provide stubs that always
61606157
** return true so that one does not get spurious assertion failures.
61616158
**
61626159
** ^If the argument to sqlite3_mutex_held() is a NULL pointer then
@@ -6634,11 +6631,11 @@
66346631
**
66356632
** [[the xInit() page cache method]]
66366633
** ^(The xInit() method is called once for each effective
66376634
** call to [sqlite3_initialize()])^
66386635
** (usually only once during the lifetime of the process). ^(The xInit()
6639
-** method is passed a copy of the sqlite3_pcache_methods.pArg value.)^
6636
+** method is passed a copy of the sqlite3_pcache_methods2.pArg value.)^
66406637
** The intent of the xInit() method is to set up global data structures
66416638
** required by the custom page cache implementation.
66426639
** ^(If the xInit() method is NULL, then the
66436640
** built-in default page cache is used instead of the application defined
66446641
** page cache.)^
@@ -6660,11 +6657,11 @@
66606657
**
66616658
** [[the xCreate() page cache methods]]
66626659
** ^SQLite invokes the xCreate() method to construct a new cache instance.
66636660
** SQLite will typically create one cache instance for each open database file,
66646661
** though this is not guaranteed. ^The
6665
-** parameter parameter, szPage, is the size in bytes of the pages that must
6662
+** first parameter, szPage, is the size in bytes of the pages that must
66666663
** be allocated by the cache. ^szPage will always a power of two. ^The
66676664
** second parameter szExtra is a number of bytes of extra storage
66686665
** associated with each page cache entry. ^The szExtra parameter will
66696666
** a number less than 250. SQLite will use the
66706667
** extra szExtra bytes on each page to store metadata about the underlying
@@ -6755,11 +6752,11 @@
67556752
**
67566753
** [[the xDestroy() page cache method]]
67576754
** ^The xDestroy() method is used to delete a cache allocated by xCreate().
67586755
** All resources associated with the specified cache should be freed. ^After
67596756
** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*]
6760
-** handle invalid, and will not use it with any other sqlite3_pcache_methods
6757
+** handle invalid, and will not use it with any other sqlite3_pcache_methods2
67616758
** functions.
67626759
**
67636760
** [[the xShrink() page cache method]]
67646761
** ^SQLite invokes the xShrink() method when it wants the page cache to
67656762
** free up as much of heap memory as possible. The page cache implementation
@@ -9266,11 +9263,11 @@
92669263
92679264
/*
92689265
** The default size of a disk sector
92699266
*/
92709267
#ifndef SQLITE_DEFAULT_SECTOR_SIZE
9271
-# define SQLITE_DEFAULT_SECTOR_SIZE 512
9268
+# define SQLITE_DEFAULT_SECTOR_SIZE 4096
92729269
#endif
92739270
92749271
/*
92759272
** Temporary files are named starting with this prefix followed by 16 random
92769273
** alphanumeric characters, and no file extension. They are stored in the
@@ -13190,11 +13187,11 @@
1319013187
SQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem*);
1319113188
SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem*);
1319213189
SQLITE_PRIVATE int sqlite3VdbeMemFromBtree(BtCursor*,int,int,int,Mem*);
1319313190
SQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p);
1319413191
SQLITE_PRIVATE void sqlite3VdbeMemReleaseExternal(Mem *p);
13195
-#define MemReleaseExt(X) \
13192
+#define VdbeMemRelease(X) \
1319613193
if((X)->flags&(MEM_Agg|MEM_Dyn|MEM_RowSet|MEM_Frame)) \
1319713194
sqlite3VdbeMemReleaseExternal(X);
1319813195
SQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem*, FuncDef*);
1319913196
SQLITE_PRIVATE const char *sqlite3OpcodeName(int);
1320013197
SQLITE_PRIVATE int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve);
@@ -13229,11 +13226,11 @@
1322913226
# define sqlite3VdbeEnter(X)
1323013227
# define sqlite3VdbeLeave(X)
1323113228
#endif
1323213229
1323313230
#ifdef SQLITE_DEBUG
13234
-SQLITE_PRIVATE void sqlite3VdbeMemPrepareToChange(Vdbe*,Mem*);
13231
+SQLITE_PRIVATE void sqlite3VdbeMemAboutToChange(Vdbe*,Mem*);
1323513232
#endif
1323613233
1323713234
#ifndef SQLITE_OMIT_FOREIGN_KEY
1323813235
SQLITE_PRIVATE int sqlite3VdbeCheckFk(Vdbe *, int);
1323913236
#else
@@ -14762,11 +14759,11 @@
1476214759
int flags,
1476314760
int *pFlagsOut
1476414761
){
1476514762
int rc;
1476614763
DO_OS_MALLOC_TEST(0);
14767
- /* 0x87f3f is a mask of SQLITE_OPEN_ flags that are valid to be passed
14764
+ /* 0x87f7f is a mask of SQLITE_OPEN_ flags that are valid to be passed
1476814765
** down into the VFS layer. Some SQLITE_OPEN_ flags (for example,
1476914766
** SQLITE_OPEN_FULLMUTEX or SQLITE_OPEN_SHAREDCACHE) are blocked before
1477014767
** reaching the VFS. */
1477114768
rc = pVfs->xOpen(pVfs, zPath, pFile, flags & 0x87f7f, pFlagsOut);
1477214769
assert( rc==SQLITE_OK || pFile->pMethods==0 );
@@ -17316,11 +17313,11 @@
1731617313
SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex *p){
1731717314
return p==0 || sqlite3GlobalConfig.mutex.xMutexNotheld(p);
1731817315
}
1731917316
#endif
1732017317
17321
-#endif /* SQLITE_MUTEX_OMIT */
17318
+#endif /* !defined(SQLITE_MUTEX_OMIT) */
1732217319
1732317320
/************** End of mutex.c ***********************************************/
1732417321
/************** Begin file mutex_noop.c **************************************/
1732517322
/*
1732617323
** 2008 October 07
@@ -17523,12 +17520,12 @@
1752317520
*/
1752417521
#ifdef SQLITE_MUTEX_NOOP
1752517522
SQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void){
1752617523
return sqlite3NoopMutex();
1752717524
}
17528
-#endif /* SQLITE_MUTEX_NOOP */
17529
-#endif /* SQLITE_MUTEX_OMIT */
17525
+#endif /* defined(SQLITE_MUTEX_NOOP) */
17526
+#endif /* !defined(SQLITE_MUTEX_OMIT) */
1753017527
1753117528
/************** End of mutex_noop.c ******************************************/
1753217529
/************** Begin file mutex_os2.c ***************************************/
1753317530
/*
1753417531
** 2007 August 28
@@ -18153,11 +18150,11 @@
1815318150
};
1815418151
1815518152
return &sMutex;
1815618153
}
1815718154
18158
-#endif /* SQLITE_MUTEX_PTHREAD */
18155
+#endif /* SQLITE_MUTEX_PTHREADS */
1815918156
1816018157
/************** End of mutex_unix.c ******************************************/
1816118158
/************** Begin file mutex_w32.c ***************************************/
1816218159
/*
1816318160
** 2007 August 14
@@ -22116,26 +22113,31 @@
2211622113
** characters of the original suffix.
2211722114
**
2211822115
** If SQLITE_ENABLE_8_3_NAMES is set to 2 at compile-time, then always
2211922116
** do the suffix shortening regardless of URI parameter.
2212022117
**
22118
+** Assume that zBaseFilename contains two \000 terminator bytes (so that
22119
+** it can be harmlessly passed into sqlite3_uri_parameter()) and copy both
22120
+** zero terminator bytes into the end of the revised name.
22121
+**
2212122122
** Examples:
2212222123
**
2212322124
** test.db-journal => test.nal
2212422125
** test.db-wal => test.wal
2212522126
** test.db-shm => test.shm
2212622127
** test.db-mj7f3319fa => test.9fa
2212722128
*/
2212822129
SQLITE_PRIVATE void sqlite3FileSuffix3(const char *zBaseFilename, char *z){
22130
+ assert( zBaseFilename[strlen(zBaseFilename)+1]==0 );
2212922131
#if SQLITE_ENABLE_8_3_NAMES<2
22130
- if( sqlite3_uri_boolean(zBaseFilename, "8_3_names") )
22132
+ if( sqlite3_uri_boolean(zBaseFilename, "8_3_names", 0) )
2213122133
#endif
2213222134
{
2213322135
int i, sz;
2213422136
sz = sqlite3Strlen30(z);
2213522137
for(i=sz-1; i>0 && z[i]!='/' && z[i]!='.'; i--){}
22136
- if( z[i]=='.' && ALWAYS(sz>i+4) ) memmove(&z[i+1], &z[sz-3], 4);
22138
+ if( z[i]=='.' && ALWAYS(sz>i+4) ) memmove(&z[i+1], &z[sz-3], 5);
2213722139
}
2213822140
}
2213922141
#endif
2214022142
2214122143
/************** End of util.c ************************************************/
@@ -24836,13 +24838,10 @@
2483624838
#include <sys/time.h>
2483724839
#include <errno.h>
2483824840
#ifndef SQLITE_OMIT_WAL
2483924841
#include <sys/mman.h>
2484024842
#endif
24841
-#ifndef MISSING_STATVFS
24842
-#include <sys/statvfs.h>
24843
-#endif
2484424843
2484524844
2484624845
#if SQLITE_ENABLE_LOCKING_STYLE
2484724846
# include <sys/ioctl.h>
2484824847
# if OS_VXWORKS
@@ -24929,11 +24928,10 @@
2492924928
sqlite3_vfs *pVfs; /* The VFS that created this unixFile */
2493024929
unixInodeInfo *pInode; /* Info about locks on this inode */
2493124930
int h; /* The file descriptor */
2493224931
unsigned char eFileLock; /* The type of lock held on this fd */
2493324932
unsigned char ctrlFlags; /* Behavioral bits. UNIXFILE_* flags */
24934
- unsigned char szSector; /* Sectorsize/512 */
2493524933
int lastErrno; /* The unix errno from last I/O error */
2493624934
void *lockingContext; /* Locking style specific state */
2493724935
UnixUnusedFd *pUnused; /* Pre-allocated UnixUnusedFd */
2493824936
const char *zPath; /* Name of the file */
2493924937
unixShm *pShm; /* Shared memory segment information */
@@ -25342,18 +25340,10 @@
2534225340
#define osMkdir ((int(*)(const char*,mode_t))aSyscall[18].pCurrent)
2534325341
2534425342
{ "rmdir", (sqlite3_syscall_ptr)rmdir, 0 },
2534525343
#define osRmdir ((int(*)(const char*))aSyscall[19].pCurrent)
2534625344
25347
-#if defined(MISSING_STATVFS)
25348
- { "statvfs", (sqlite3_syscall_ptr)0, 0 },
25349
-#define osStatvfs ((int(*)(const char*,void*))aSyscall[20].pCurrent)
25350
-#else
25351
- { "statvfs", (sqlite3_syscall_ptr)statvfs, 0 },
25352
-#define osStatvfs ((int(*)(const char*,struct statvfs*))aSyscall[20].pCurrent)
25353
-#endif
25354
-
2535525345
}; /* End of the overrideable system calls */
2535625346
2535725347
/*
2535825348
** This is the xSetSystemCall() method of sqlite3_vfs for all of the
2535925349
** "unix" VFSes. Return SQLITE_OK opon successfully updating the
@@ -28504,13 +28494,10 @@
2850428494
case SQLITE_SET_LOCKPROXYFILE:
2850528495
case SQLITE_GET_LOCKPROXYFILE: {
2850628496
return proxyFileControl(id,op,pArg);
2850728497
}
2850828498
#endif /* SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__) */
28509
- case SQLITE_FCNTL_SYNC_OMITTED: {
28510
- return SQLITE_OK; /* A no-op */
28511
- }
2851228499
}
2851328500
return SQLITE_NOTFOUND;
2851428501
}
2851528502
2851628503
/*
@@ -28522,27 +28509,12 @@
2852228509
** if two files are created in the same file-system directory (i.e.
2852328510
** a database and its journal file) that the sector size will be the
2852428511
** same for both.
2852528512
*/
2852628513
static int unixSectorSize(sqlite3_file *pFile){
28527
- unixFile *p = (unixFile*)pFile;
28528
- if( p->szSector==0 ){
28529
-#ifdef MISSING_STATVFS
28530
- p->szSector = SQLITE_DEFAULT_SECTOR_SIZE/512;
28531
-#else
28532
- struct statvfs x;
28533
- int sz;
28534
- memset(&x, 0, sizeof(x));
28535
- osStatvfs(p->zPath, &x);
28536
- sz = (int)x.f_frsize;
28537
- if( sz<512 || sz>65536 || (sz&(sz-1))!=0 ){
28538
- sz = SQLITE_DEFAULT_SECTOR_SIZE;
28539
- }
28540
- p->szSector = sz/512;
28541
-#endif
28542
- }
28543
- return p->szSector*512;
28514
+ (void)pFile;
28515
+ return SQLITE_DEFAULT_SECTOR_SIZE;
2854428516
}
2854528517
2854628518
/*
2854728519
** Return the device characteristics for the file.
2854828520
**
@@ -28815,13 +28787,13 @@
2881528787
rc = SQLITE_IOERR_FSTAT;
2881628788
goto shm_open_err;
2881728789
}
2881828790
2881928791
#ifdef SQLITE_SHM_DIRECTORY
28820
- nShmFilename = sizeof(SQLITE_SHM_DIRECTORY) + 30;
28792
+ nShmFilename = sizeof(SQLITE_SHM_DIRECTORY) + 31;
2882128793
#else
28822
- nShmFilename = 5 + (int)strlen(pDbFd->zPath);
28794
+ nShmFilename = 6 + (int)strlen(pDbFd->zPath);
2882328795
#endif
2882428796
pShmNode = sqlite3_malloc( sizeof(*pShmNode) + nShmFilename );
2882528797
if( pShmNode==0 ){
2882628798
rc = SQLITE_NOMEM;
2882728799
goto shm_open_err;
@@ -31755,11 +31727,11 @@
3175531727
};
3175631728
unsigned int i; /* Loop counter */
3175731729
3175831730
/* Double-check that the aSyscall[] array has been constructed
3175931731
** correctly. See ticket [bb3a86e890c8e96ab] */
31760
- assert( ArraySize(aSyscall)==21 );
31732
+ assert( ArraySize(aSyscall)==20 );
3176131733
3176231734
/* Register all VFSes defined in the aVfs[] array */
3176331735
for(i=0; i<(sizeof(aVfs)/sizeof(sqlite3_vfs)); i++){
3176431736
sqlite3_vfs_register(&aVfs[i], i==0);
3176531737
}
@@ -32049,11 +32021,10 @@
3204932021
HANDLE h; /* Handle for accessing the file */
3205032022
u8 locktype; /* Type of lock currently held on this file */
3205132023
short sharedLockByte; /* Randomly chosen byte used as a shared lock */
3205232024
u8 ctrlFlags; /* Flags. See WINFILE_* below */
3205332025
DWORD lastErrno; /* The Windows errno from the last I/O error */
32054
- DWORD sectorSize; /* Sector size of the device file is on */
3205532026
winShm *pShm; /* Instance of shared memory on this file */
3205632027
const char *zPath; /* Full pathname of this file */
3205732028
int szChunk; /* Chunk size configured by FCNTL_CHUNK_SIZE */
3205832029
#if SQLITE_OS_WINCE
3205932030
LPWSTR zDeleteOnClose; /* Name of file to delete when closing */
@@ -32139,18 +32110,10 @@
3213932110
static void winMemShutdown(void *pAppData);
3214032111
3214132112
SQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetWin32(void);
3214232113
#endif /* SQLITE_WIN32_MALLOC */
3214332114
32144
-/*
32145
-** Forward prototypes.
32146
-*/
32147
-static int getSectorSize(
32148
- sqlite3_vfs *pVfs,
32149
- const char *zRelative /* UTF-8 file name */
32150
-);
32151
-
3215232115
/*
3215332116
** The following variable is (normally) set once and never changes
3215432117
** thereafter. It records whether the operating system is Win9x
3215532118
** or WinNT.
3215632119
**
@@ -34181,13 +34144,10 @@
3418134144
}
3418234145
case SQLITE_FCNTL_VFSNAME: {
3418334146
*(char**)pArg = sqlite3_mprintf("win32");
3418434147
return SQLITE_OK;
3418534148
}
34186
- case SQLITE_FCNTL_SYNC_OMITTED: {
34187
- return SQLITE_OK;
34188
- }
3418934149
case SQLITE_FCNTL_WIN32_AV_RETRY: {
3419034150
int *a = (int*)pArg;
3419134151
if( a[0]>0 ){
3419234152
win32IoerrRetry = a[0];
3419334153
}else{
@@ -34213,12 +34173,12 @@
3421334173
** if two files are created in the same file-system directory (i.e.
3421434174
** a database and its journal file) that the sector size will be the
3421534175
** same for both.
3421634176
*/
3421734177
static int winSectorSize(sqlite3_file *id){
34218
- assert( id!=0 );
34219
- return (int)(((winFile*)id)->sectorSize);
34178
+ (void)id;
34179
+ return SQLITE_DEFAULT_SECTOR_SIZE;
3422034180
}
3422134181
3422234182
/*
3422334183
** Return a vector of device characteristics.
3422434184
*/
@@ -34463,11 +34423,11 @@
3446334423
*/
3446434424
p = sqlite3_malloc( sizeof(*p) );
3446534425
if( p==0 ) return SQLITE_IOERR_NOMEM;
3446634426
memset(p, 0, sizeof(*p));
3446734427
nName = sqlite3Strlen30(pDbFd->zPath);
34468
- pNew = sqlite3_malloc( sizeof(*pShmNode) + nName + 15 );
34428
+ pNew = sqlite3_malloc( sizeof(*pShmNode) + nName + 16 );
3446934429
if( pNew==0 ){
3447034430
sqlite3_free(p);
3447134431
return SQLITE_IOERR_NOMEM;
3447234432
}
3447334433
memset(pNew, 0, sizeof(*pNew));
@@ -35191,11 +35151,10 @@
3519135151
pFile->pShm = 0;
3519235152
pFile->zPath = zName;
3519335153
if( sqlite3_uri_boolean(zName, "psow", SQLITE_POWERSAFE_OVERWRITE) ){
3519435154
pFile->ctrlFlags |= WINFILE_PSOW;
3519535155
}
35196
- pFile->sectorSize = getSectorSize(pVfs, zUtf8Name);
3519735156
3519835157
#if SQLITE_OS_WINCE
3519935158
if( isReadWrite && eType==SQLITE_OPEN_MAIN_DB
3520035159
&& !winceCreateLock(zName, pFile)
3520135160
){
@@ -35436,85 +35395,10 @@
3543635395
return SQLITE_IOERR_NOMEM;
3543735396
}
3543835397
#endif
3543935398
}
3544035399
35441
-/*
35442
-** Get the sector size of the device used to store
35443
-** file.
35444
-*/
35445
-static int getSectorSize(
35446
- sqlite3_vfs *pVfs,
35447
- const char *zRelative /* UTF-8 file name */
35448
-){
35449
- DWORD bytesPerSector = SQLITE_DEFAULT_SECTOR_SIZE;
35450
- /* GetDiskFreeSpace is not supported under WINCE */
35451
-#if SQLITE_OS_WINCE
35452
- UNUSED_PARAMETER(pVfs);
35453
- UNUSED_PARAMETER(zRelative);
35454
-#else
35455
- char zFullpath[MAX_PATH+1];
35456
- int rc;
35457
- DWORD dwRet = 0;
35458
- DWORD dwDummy;
35459
-
35460
- /*
35461
- ** We need to get the full path name of the file
35462
- ** to get the drive letter to look up the sector
35463
- ** size.
35464
- */
35465
- SimulateIOErrorBenign(1);
35466
- sqlite3BeginBenignMalloc();
35467
- rc = winFullPathname(pVfs, zRelative, MAX_PATH, zFullpath);
35468
- sqlite3EndBenignMalloc();
35469
- SimulateIOErrorBenign(0);
35470
- if( rc == SQLITE_OK )
35471
- {
35472
- void *zConverted;
35473
- sqlite3BeginBenignMalloc();
35474
- zConverted = convertUtf8Filename(zFullpath);
35475
- sqlite3EndBenignMalloc();
35476
- if( zConverted ){
35477
- if( isNT() ){
35478
- /* trim path to just drive reference */
35479
- LPWSTR p = zConverted;
35480
- for(;*p;p++){
35481
- if( *p == '\\' ){
35482
- *p = '\0';
35483
- break;
35484
- }
35485
- }
35486
- dwRet = osGetDiskFreeSpaceW((LPCWSTR)zConverted,
35487
- &dwDummy,
35488
- &bytesPerSector,
35489
- &dwDummy,
35490
- &dwDummy);
35491
- }else{
35492
- /* trim path to just drive reference */
35493
- char *p = (char *)zConverted;
35494
- for(;*p;p++){
35495
- if( *p == '\\' ){
35496
- *p = '\0';
35497
- break;
35498
- }
35499
- }
35500
- dwRet = osGetDiskFreeSpaceA((char*)zConverted,
35501
- &dwDummy,
35502
- &bytesPerSector,
35503
- &dwDummy,
35504
- &dwDummy);
35505
- }
35506
- sqlite3_free(zConverted);
35507
- }
35508
- if( !dwRet ){
35509
- bytesPerSector = SQLITE_DEFAULT_SECTOR_SIZE;
35510
- }
35511
- }
35512
-#endif
35513
- return (int) bytesPerSector;
35514
-}
35515
-
3551635400
#ifndef SQLITE_OMIT_LOAD_EXTENSION
3551735401
/*
3551835402
** Interfaces for opening a shared library, finding entry points
3551935403
** within the shared library, and closing the shared library.
3552035404
*/
@@ -36381,11 +36265,11 @@
3638136265
*/
3638236266
static int numberOfCachePages(PCache *p){
3638336267
if( p->szCache>=0 ){
3638436268
return p->szCache;
3638536269
}else{
36386
- return (-1024*p->szCache)/(p->szPage+p->szExtra);
36270
+ return (int)((-1024*(i64)p->szCache)/(p->szPage+p->szExtra));
3638736271
}
3638836272
}
3638936273
3639036274
/*
3639136275
** Try to obtain a page from the cache.
@@ -36845,14 +36729,14 @@
3684536729
** PGroup which is the pcache1.grp global variable and its mutex is
3684636730
** SQLITE_MUTEX_STATIC_LRU.
3684736731
*/
3684836732
struct PGroup {
3684936733
sqlite3_mutex *mutex; /* MUTEX_STATIC_LRU or NULL */
36850
- int nMaxPage; /* Sum of nMax for purgeable caches */
36851
- int nMinPage; /* Sum of nMin for purgeable caches */
36852
- int mxPinned; /* nMaxpage + 10 - nMinPage */
36853
- int nCurrentPage; /* Number of purgeable pages allocated */
36734
+ unsigned int nMaxPage; /* Sum of nMax for purgeable caches */
36735
+ unsigned int nMinPage; /* Sum of nMin for purgeable caches */
36736
+ unsigned int mxPinned; /* nMaxpage + 10 - nMinPage */
36737
+ unsigned int nCurrentPage; /* Number of purgeable pages allocated */
3685436738
PgHdr1 *pLruHead, *pLruTail; /* LRU list of unpinned pages */
3685536739
};
3685636740
3685736741
/* Each page cache is an instance of the following object. Every
3685836742
** open database file (including each in-memory database and each
@@ -37511,11 +37395,11 @@
3751137395
static sqlite3_pcache_page *pcache1Fetch(
3751237396
sqlite3_pcache *p,
3751337397
unsigned int iKey,
3751437398
int createFlag
3751537399
){
37516
- int nPinned;
37400
+ unsigned int nPinned;
3751737401
PCache1 *pCache = (PCache1 *)p;
3751837402
PGroup *pGroup;
3751937403
PgHdr1 *pPage = 0;
3752037404
3752137405
assert( pCache->bPurgeable || createFlag!=1 );
@@ -37546,17 +37430,17 @@
3754637430
#ifdef SQLITE_MUTEX_OMIT
3754737431
pGroup = pCache->pGroup;
3754837432
#endif
3754937433
3755037434
/* Step 3: Abort if createFlag is 1 but the cache is nearly full */
37435
+ assert( pCache->nPage >= pCache->nRecyclable );
3755137436
nPinned = pCache->nPage - pCache->nRecyclable;
37552
- assert( nPinned>=0 );
3755337437
assert( pGroup->mxPinned == pGroup->nMaxPage + 10 - pGroup->nMinPage );
3755437438
assert( pCache->n90pct == pCache->nMax*9/10 );
3755537439
if( createFlag==1 && (
3755637440
nPinned>=pGroup->mxPinned
37557
- || nPinned>=(int)pCache->n90pct
37441
+ || nPinned>=pCache->n90pct
3755837442
|| pcache1UnderMemoryPressure(pCache)
3755937443
)){
3756037444
goto fetch_out;
3756137445
}
3756237446
@@ -37725,11 +37609,13 @@
3772537609
PCache1 *pCache = (PCache1 *)p;
3772637610
PGroup *pGroup = pCache->pGroup;
3772737611
assert( pCache->bPurgeable || (pCache->nMax==0 && pCache->nMin==0) );
3772837612
pcache1EnterMutex(pGroup);
3772937613
pcache1TruncateUnsafe(pCache, 0);
37614
+ assert( pGroup->nMaxPage >= pCache->nMax );
3773037615
pGroup->nMaxPage -= pCache->nMax;
37616
+ assert( pGroup->nMinPage >= pCache->nMin );
3773137617
pGroup->nMinPage -= pCache->nMin;
3773237618
pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage;
3773337619
pcache1EnforceMaxPage(pGroup);
3773437620
pcache1LeaveMutex(pGroup);
3773537621
sqlite3_free(pCache->apHash);
@@ -37807,12 +37693,12 @@
3780737693
int nRecyclable = 0;
3780837694
for(p=pcache1.grp.pLruHead; p; p=p->pLruNext){
3780937695
nRecyclable++;
3781037696
}
3781137697
*pnCurrent = pcache1.grp.nCurrentPage;
37812
- *pnMax = pcache1.grp.nMaxPage;
37813
- *pnMin = pcache1.grp.nMinPage;
37698
+ *pnMax = (int)pcache1.grp.nMaxPage;
37699
+ *pnMin = (int)pcache1.grp.nMinPage;
3781437700
*pnRecyclable = nRecyclable;
3781537701
}
3781637702
#endif
3781737703
3781837704
/************** End of pcache1.c *********************************************/
@@ -38282,10 +38168,16 @@
3828238168
3828338169
#ifndef _WAL_H_
3828438170
#define _WAL_H_
3828538171
3828638172
38173
+/* Additional values that can be added to the sync_flags argument of
38174
+** sqlite3WalFrames():
38175
+*/
38176
+#define WAL_SYNC_TRANSACTIONS 0x20 /* Sync at the end of each transaction */
38177
+#define SQLITE_SYNC_MASK 0x13 /* Mask off the SQLITE_SYNC_* values */
38178
+
3828738179
#ifdef SQLITE_OMIT_WAL
3828838180
# define sqlite3WalOpen(x,y,z) 0
3828938181
# define sqlite3WalLimit(x,y)
3829038182
# define sqlite3WalClose(w,x,y,z) 0
3829138183
# define sqlite3WalBeginReadTransaction(y,z) 0
@@ -38350,16 +38242,10 @@
3835038242
SQLITE_PRIVATE int sqlite3WalSavepointUndo(Wal *pWal, u32 *aWalData);
3835138243
3835238244
/* Write a frame or frames to the log. */
3835338245
SQLITE_PRIVATE int sqlite3WalFrames(Wal *pWal, int, PgHdr *, Pgno, int, int);
3835438246
38355
-/* Additional values that can be added to the sync_flags argument of
38356
-** sqlite3WalFrames():
38357
-*/
38358
-#define WAL_SYNC_TRANSACTIONS 0x20 /* Sync at the end of each transaction */
38359
-#define SQLITE_SYNC_MASK 0x13 /* Mask off the SQLITE_SYNC_* values */
38360
-
3836138247
/* Copy pages from the log to the database file */
3836238248
SQLITE_PRIVATE int sqlite3WalCheckpoint(
3836338249
Wal *pWal, /* Write-ahead log connection */
3836438250
int eMode, /* One of PASSIVE, FULL and RESTART */
3836538251
int (*xBusy)(void*), /* Function to call when busy */
@@ -42400,11 +42286,13 @@
4240042286
** file size will be.
4240142287
*/
4240242288
assert( rc!=SQLITE_OK || isOpen(pPager->fd) );
4240342289
if( rc==SQLITE_OK && pPager->dbSize>pPager->dbHintSize ){
4240442290
sqlite3_int64 szFile = pPager->pageSize * (sqlite3_int64)pPager->dbSize;
42291
+ sqlite3BeginBenignMalloc();
4240542292
sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_SIZE_HINT, &szFile);
42293
+ sqlite3EndBenignMalloc();
4240642294
pPager->dbHintSize = pPager->dbSize;
4240742295
}
4240842296
4240942297
while( rc==SQLITE_OK && pList ){
4241042298
Pgno pgno = pList->pgno;
@@ -42741,11 +42629,12 @@
4274142629
z = zUri = &zFilename[sqlite3Strlen30(zFilename)+1];
4274242630
while( *z ){
4274342631
z += sqlite3Strlen30(z)+1;
4274442632
z += sqlite3Strlen30(z)+1;
4274542633
}
42746
- nUri = &z[1] - zUri;
42634
+ nUri = (int)(&z[1] - zUri);
42635
+ assert( nUri>=0 );
4274742636
if( rc==SQLITE_OK && nPathname+8>pVfs->mxPathname ){
4274842637
/* This branch is taken when the journal path required by
4274942638
** the database being opened will be more than pVfs->mxPathname
4275042639
** bytes in length. This means the database cannot be opened,
4275142640
** as it will not be possible to open the journal file or even
@@ -42775,13 +42664,13 @@
4277542664
ROUND8(sizeof(*pPager)) + /* Pager structure */
4277642665
ROUND8(pcacheSize) + /* PCache object */
4277742666
ROUND8(pVfs->szOsFile) + /* The main db file */
4277842667
journalFileSize * 2 + /* The two journal files */
4277942668
nPathname + 1 + nUri + /* zFilename */
42780
- nPathname + 8 + 1 /* zJournal */
42669
+ nPathname + 8 + 2 /* zJournal */
4278142670
#ifndef SQLITE_OMIT_WAL
42782
- + nPathname + 4 + 1 /* zWal */
42671
+ + nPathname + 4 + 2 /* zWal */
4278342672
#endif
4278442673
);
4278542674
assert( EIGHT_BYTE_ALIGNMENT(SQLITE_INT_TO_PTR(journalFileSize)) );
4278642675
if( !pPtr ){
4278742676
sqlite3_free(zPathname);
@@ -42800,16 +42689,16 @@
4280042689
assert( nPathname>0 );
4280142690
pPager->zJournal = (char*)(pPtr += nPathname + 1 + nUri);
4280242691
memcpy(pPager->zFilename, zPathname, nPathname);
4280342692
memcpy(&pPager->zFilename[nPathname+1], zUri, nUri);
4280442693
memcpy(pPager->zJournal, zPathname, nPathname);
42805
- memcpy(&pPager->zJournal[nPathname], "-journal", 8);
42694
+ memcpy(&pPager->zJournal[nPathname], "-journal\000", 8+1);
4280642695
sqlite3FileSuffix3(pPager->zFilename, pPager->zJournal);
4280742696
#ifndef SQLITE_OMIT_WAL
4280842697
pPager->zWal = &pPager->zJournal[nPathname+8+1];
4280942698
memcpy(pPager->zWal, zPathname, nPathname);
42810
- memcpy(&pPager->zWal[nPathname], "-wal", 4);
42699
+ memcpy(&pPager->zWal[nPathname], "-wal\000", 4+1);
4281142700
sqlite3FileSuffix3(pPager->zFilename, pPager->zWal);
4281242701
#endif
4281342702
sqlite3_free(zPathname);
4281442703
}
4281542704
pPager->pVfs = pVfs;
@@ -44064,11 +43953,14 @@
4406443953
if( !pPager->noSync ){
4406543954
assert( !MEMDB );
4406643955
rc = sqlite3OsSync(pPager->fd, pPager->syncFlags);
4406743956
}else if( isOpen(pPager->fd) ){
4406843957
assert( !MEMDB );
44069
- sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_SYNC_OMITTED, (void *)&rc);
43958
+ rc = sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_SYNC_OMITTED, 0);
43959
+ if( rc==SQLITE_NOTFOUND ){
43960
+ rc = SQLITE_OK;
43961
+ }
4407043962
}
4407143963
return rc;
4407243964
}
4407343965
4407443966
/*
@@ -48125,11 +48017,11 @@
4812548017
iFrame = pWal->hdr.mxFrame;
4812648018
for(p=pList; p && rc==SQLITE_OK; p=p->pDirty){
4812748019
iFrame++;
4812848020
rc = walIndexAppend(pWal, iFrame, p->pgno);
4812948021
}
48130
- while( nExtra>0 && rc==SQLITE_OK ){
48022
+ while( rc==SQLITE_OK && nExtra>0 ){
4813148023
iFrame++;
4813248024
nExtra--;
4813348025
rc = walIndexAppend(pWal, iFrame, pLast->pgno);
4813448026
}
4813548027
@@ -48726,11 +48618,11 @@
4872648618
#define TRANS_WRITE 2
4872748619
4872848620
/*
4872948621
** An instance of this object represents a single database file.
4873048622
**
48731
-** A single database file can be in use as the same time by two
48623
+** A single database file can be in use at the same time by two
4873248624
** or more database connections. When two or more connections are
4873348625
** sharing the same database file, each connection has it own
4873448626
** private Btree object for the file and each of those Btrees points
4873548627
** to this one BtShared object. BtShared.nRef is the number of
4873648628
** connections currently sharing this database file.
@@ -48832,11 +48724,11 @@
4883248724
** b-tree within a database file.
4883348725
**
4883448726
** The entry is identified by its MemPage and the index in
4883548727
** MemPage.aCell[] of the entry.
4883648728
**
48837
-** A single database file can shared by two more database connections,
48729
+** A single database file can be shared by two more database connections,
4883848730
** but cursors cannot be shared. Each cursor is associated with a
4883948731
** particular database connection identified BtCursor.pBtree.db.
4884048732
**
4884148733
** Fields in this structure are accessed under the BtShared.mutex
4884248734
** found at self->pBt->mutex.
@@ -48993,11 +48885,11 @@
4899348885
int mallocFailed; /* A memory allocation error has occurred */
4899448886
StrAccum errMsg; /* Accumulate the error message text here */
4899548887
};
4899648888
4899748889
/*
48998
-** Read or write a two- and four-byte big-endian integer values.
48890
+** Routines to read or write a two- and four-byte big-endian integer values.
4899948891
*/
4900048892
#define get2byte(x) ((x)[0]<<8 | (x)[1])
4900148893
#define put2byte(p,v) ((p)[0] = (u8)((v)>>8), (p)[1] = (u8)(v))
4900248894
#define get4byte sqlite3Get4byte
4900348895
#define put4byte sqlite3Put4byte
@@ -55478,12 +55370,18 @@
5547855370
}
5547955371
5548055372
/* Either we found one or more cells (cntnew[0])>0) or pPage is
5548155373
** a virtual root page. A virtual root page is when the real root
5548255374
** page is page 1 and we are the only child of that page.
55375
+ **
55376
+ ** UPDATE: The assert() below is not necessarily true if the database
55377
+ ** file is corrupt. The corruption will be detected and reported later
55378
+ ** in this procedure so there is no need to act upon it now.
5548355379
*/
55380
+#if 0
5548455381
assert( cntNew[0]>0 || (pParent->pgno==1 && pParent->nCell==0) );
55382
+#endif
5548555383
5548655384
TRACE(("BALANCE: old: %d %d %d ",
5548755385
apOld[0]->pgno,
5548855386
nOld>=2 ? apOld[1]->pgno : 0,
5548955387
nOld>=3 ? apOld[2]->pgno : 0
@@ -58194,11 +58092,13 @@
5819458092
5819558093
assert( sqlite3BtreeIsInTrans(pTo) );
5819658094
pFd = sqlite3PagerFile(sqlite3BtreePager(pTo));
5819758095
if( pFd->pMethods ){
5819858096
i64 nByte = sqlite3BtreeGetPageSize(pFrom)*(i64)sqlite3BtreeLastPage(pFrom);
58097
+ sqlite3BeginBenignMalloc();
5819958098
sqlite3OsFileControl(pFd, SQLITE_FCNTL_OVERWRITE, &nByte);
58099
+ sqlite3EndBenignMalloc();
5820058100
}
5820158101
5820258102
/* Set up an sqlite3_backup object. sqlite3_backup.pDestDb must be set
5820358103
** to 0. This is used by the implementations of sqlite3_backup_step()
5820458104
** and sqlite3_backup_finish() to detect that they are being called
@@ -58525,11 +58425,11 @@
5852558425
** Release any memory held by the Mem. This may leave the Mem in an
5852658426
** inconsistent state, for example with (Mem.z==0) and
5852758427
** (Mem.type==SQLITE_TEXT).
5852858428
*/
5852958429
SQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p){
58530
- MemReleaseExt(p);
58430
+ VdbeMemRelease(p);
5853158431
sqlite3DbFree(p->db, p->zMalloc);
5853258432
p->z = 0;
5853358433
p->zMalloc = 0;
5853458434
p->xDel = 0;
5853558435
}
@@ -58821,11 +58721,11 @@
5882158721
** copies of this cell as invalid.
5882258722
**
5882358723
** This is used for testing and debugging only - to make sure shallow
5882458724
** copies are not misused.
5882558725
*/
58826
-SQLITE_PRIVATE void sqlite3VdbeMemPrepareToChange(Vdbe *pVdbe, Mem *pMem){
58726
+SQLITE_PRIVATE void sqlite3VdbeMemAboutToChange(Vdbe *pVdbe, Mem *pMem){
5882758727
int i;
5882858728
Mem *pX;
5882958729
for(i=1, pX=&pVdbe->aMem[1]; i<=pVdbe->nMem; i++, pX++){
5883058730
if( pX->pScopyFrom==pMem ){
5883158731
pX->flags |= MEM_Invalid;
@@ -58847,11 +58747,11 @@
5884758747
** pFrom->z is used, then pTo->z points to the same thing as pFrom->z
5884858748
** and flags gets srcType (either MEM_Ephem or MEM_Static).
5884958749
*/
5885058750
SQLITE_PRIVATE void sqlite3VdbeMemShallowCopy(Mem *pTo, const Mem *pFrom, int srcType){
5885158751
assert( (pFrom->flags & MEM_RowSet)==0 );
58852
- MemReleaseExt(pTo);
58752
+ VdbeMemRelease(pTo);
5885358753
memcpy(pTo, pFrom, MEMCELLSIZE);
5885458754
pTo->xDel = 0;
5885558755
if( (pFrom->flags&MEM_Static)==0 ){
5885658756
pTo->flags &= ~(MEM_Dyn|MEM_Static|MEM_Ephem);
5885758757
assert( srcType==MEM_Ephem || srcType==MEM_Static );
@@ -58865,11 +58765,11 @@
5886558765
*/
5886658766
SQLITE_PRIVATE int sqlite3VdbeMemCopy(Mem *pTo, const Mem *pFrom){
5886758767
int rc = SQLITE_OK;
5886858768
5886958769
assert( (pFrom->flags & MEM_RowSet)==0 );
58870
- MemReleaseExt(pTo);
58770
+ VdbeMemRelease(pTo);
5887158771
memcpy(pTo, pFrom, MEMCELLSIZE);
5887258772
pTo->flags &= ~MEM_Dyn;
5887358773
5887458774
if( pTo->flags&(MEM_Str|MEM_Blob) ){
5887558775
if( 0==(pFrom->flags&MEM_Static) ){
@@ -59202,11 +59102,11 @@
5920259102
assert( (pVal->flags & (MEM_Ephem|MEM_Static))!=0 );
5920359103
if( sqlite3VdbeMemMakeWriteable(pVal)!=SQLITE_OK ){
5920459104
return 0;
5920559105
}
5920659106
}
59207
- sqlite3VdbeMemNulTerminate(pVal); /* IMP: R-59893-45467 */
59107
+ sqlite3VdbeMemNulTerminate(pVal); /* IMP: R-31275-44060 */
5920859108
}else{
5920959109
assert( (pVal->flags&MEM_Blob)==0 );
5921059110
sqlite3VdbeMemStringify(pVal, enc);
5921159111
assert( 0==(1&SQLITE_PTR_TO_INT(pVal->z)) );
5921259112
}
@@ -59583,11 +59483,12 @@
5958359483
return addr;
5958459484
}
5958559485
5958659486
/*
5958759487
** Add an OP_ParseSchema opcode. This routine is broken out from
59588
-** sqlite3VdbeAddOp4() since it needs to also local all btrees.
59488
+** sqlite3VdbeAddOp4() since it needs to also needs to mark all btrees
59489
+** as having been used.
5958959490
**
5959059491
** The zWhere string must have been obtained from sqlite3_malloc().
5959159492
** This routine will take ownership of the allocated memory.
5959259493
*/
5959359494
SQLITE_PRIVATE void sqlite3VdbeAddParseSchemaOp(Vdbe *p, int iDb, char *zWhere){
@@ -60350,12 +60251,13 @@
6035060251
6035160252
/*
6035260253
** Declare to the Vdbe that the BTree object at db->aDb[i] is used.
6035360254
**
6035460255
** The prepared statements need to know in advance the complete set of
60355
-** attached databases that they will be using. A mask of these databases
60356
-** is maintained in p->btreeMask and is used for locking and other purposes.
60256
+** attached databases that will be use. A mask of these databases
60257
+** is maintained in p->btreeMask. The p->lockMask value is the subset of
60258
+** p->btreeMask of databases that will require a lock.
6035760259
*/
6035860260
SQLITE_PRIVATE void sqlite3VdbeUsesBtree(Vdbe *p, int i){
6035960261
assert( i>=0 && i<p->db->nDb && i<(int)sizeof(yDbMask)*8 );
6036060262
assert( i<(int)sizeof(p->btreeMask)*8 );
6036160263
p->btreeMask |= ((yDbMask)1)<<i;
@@ -60874,10 +60776,11 @@
6087460776
nVar = pParse->nVar;
6087560777
nMem = pParse->nMem;
6087660778
nCursor = pParse->nTab;
6087760779
nArg = pParse->nMaxArg;
6087860780
nOnce = pParse->nOnce;
60781
+ if( nOnce==0 ) nOnce = 1; /* Ensure at least one byte in p->aOnceFlag[] */
6087960782
6088060783
/* For each cursor required, also allocate a memory cell. Memory
6088160784
** cells (nMem+1-nCursor)..nMem, inclusive, will never be used by
6088260785
** the vdbe program. Instead they are used to allocate space for
6088360786
** VdbeCursor/BtCursor structures. The blob of memory associated with
@@ -61225,11 +61128,11 @@
6122561128
int retryCount = 0;
6122661129
int nMainFile;
6122761130
6122861131
/* Select a master journal file name */
6122961132
nMainFile = sqlite3Strlen30(zMainFile);
61230
- zMaster = sqlite3MPrintf(db, "%s-mjXXXXXX9XX", zMainFile);
61133
+ zMaster = sqlite3MPrintf(db, "%s-mjXXXXXX9XXz", zMainFile);
6123161134
if( zMaster==0 ) return SQLITE_NOMEM;
6123261135
do {
6123361136
u32 iRandom;
6123461137
if( retryCount ){
6123561138
if( retryCount>100 ){
@@ -63013,11 +62916,11 @@
6301362916
** since any application that receives an SQLITE_MISUSE is broken by
6301462917
** definition.
6301562918
**
6301662919
** Nevertheless, some published applications that were originally written
6301762920
** for version 3.6.23 or earlier do in fact depend on SQLITE_MISUSE
63018
- ** returns, and the so were broken by the automatic-reset change. As a
62921
+ ** returns, and those were broken by the automatic-reset change. As a
6301962922
** a work-around, the SQLITE_OMIT_AUTORESET compile-time restores the
6302062923
** legacy behavior of returning SQLITE_MISUSE for cases where the
6302162924
** previous sqlite3_step() returned something other than a SQLITE_LOCKED
6302262925
** or SQLITE_BUSY error.
6302362926
*/
@@ -63359,17 +63262,17 @@
6335963262
pOut = &pVm->pResultSet[i];
6336063263
}else{
6336163264
/* If the value passed as the second argument is out of range, return
6336263265
** a pointer to the following static Mem object which contains the
6336363266
** value SQL NULL. Even though the Mem structure contains an element
63364
- ** of type i64, on certain architecture (x86) with certain compiler
63267
+ ** of type i64, on certain architectures (x86) with certain compiler
6336563268
** switches (-Os), gcc may align this Mem object on a 4-byte boundary
6336663269
** instead of an 8-byte one. This all works fine, except that when
6336763270
** running with SQLITE_DEBUG defined the SQLite code sometimes assert()s
6336863271
** that a Mem structure is located on an 8-byte boundary. To prevent
63369
- ** this assert() from failing, when building with SQLITE_DEBUG defined
63370
- ** using gcc, force nullMem to be 8-byte aligned using the magical
63272
+ ** these assert()s from failing, when building with SQLITE_DEBUG defined
63273
+ ** using gcc, we force nullMem to be 8-byte aligned using the magical
6337163274
** __attribute__((aligned(8))) macro. */
6337263275
static const Mem nullMem
6337363276
#if defined(SQLITE_DEBUG) && defined(__GNUC__)
6337463277
__attribute__((aligned(8)))
6337563278
#endif
@@ -64298,11 +64201,11 @@
6429864201
** Invoke this macro on memory cells just prior to changing the
6429964202
** value of the cell. This macro verifies that shallow copies are
6430064203
** not misused.
6430164204
*/
6430264205
#ifdef SQLITE_DEBUG
64303
-# define memAboutToChange(P,M) sqlite3VdbeMemPrepareToChange(P,M)
64206
+# define memAboutToChange(P,M) sqlite3VdbeMemAboutToChange(P,M)
6430464207
#else
6430564208
# define memAboutToChange(P,M)
6430664209
#endif
6430764210
6430864211
/*
@@ -64316,12 +64219,12 @@
6431664219
SQLITE_API int sqlite3_search_count = 0;
6431764220
#endif
6431864221
6431964222
/*
6432064223
** When this global variable is positive, it gets decremented once before
64321
-** each instruction in the VDBE. When reaches zero, the u1.isInterrupted
64322
-** field of the sqlite3 structure is set in order to simulate and interrupt.
64224
+** each instruction in the VDBE. When it reaches zero, the u1.isInterrupted
64225
+** field of the sqlite3 structure is set in order to simulate an interrupt.
6432364226
**
6432464227
** This facility is used for testing purposes only. It does not function
6432564228
** in an ordinary build.
6432664229
*/
6432764230
#ifdef SQLITE_TEST
@@ -64442,11 +64345,11 @@
6444264345
*/
6444364346
static VdbeCursor *allocateCursor(
6444464347
Vdbe *p, /* The virtual machine */
6444564348
int iCur, /* Index of the new VdbeCursor */
6444664349
int nField, /* Number of fields in the table or index */
64447
- int iDb, /* When database the cursor belongs to, or -1 */
64350
+ int iDb, /* Database the cursor belongs to, or -1 */
6444864351
int isBtreeCursor /* True for B-Tree. False for pseudo-table or vtab */
6444964352
){
6445064353
/* Find the memory cell that will be used to store the blob of memory
6445164354
** required for this VdbeCursor structure. It is convenient to use a
6445264355
** vdbe memory cell to manage the memory allocation required for a
@@ -64813,11 +64716,11 @@
6481364716
** sqlite3_interrupt() routine has been called. If it has been, then
6481464717
** processing of the VDBE program is interrupted.
6481564718
**
6481664719
** This macro added to every instruction that does a jump in order to
6481764720
** implement a loop. This test used to be on every single instruction,
64818
-** but that meant we more testing that we needed. By only testing the
64721
+** but that meant we more testing than we needed. By only testing the
6481964722
** flag on jump instructions, we get a (small) speed improvement.
6482064723
*/
6482164724
#define CHECK_FOR_INTERRUPT \
6482264725
if( db->u1.isInterrupted ) goto abort_due_to_interrupt;
6482364726
@@ -65430,11 +65333,11 @@
6543065333
if( pOp->opflags & OPFLG_OUT2_PRERELEASE ){
6543165334
assert( pOp->p2>0 );
6543265335
assert( pOp->p2<=p->nMem );
6543365336
pOut = &aMem[pOp->p2];
6543465337
memAboutToChange(p, pOut);
65435
- MemReleaseExt(pOut);
65338
+ VdbeMemRelease(pOut);
6543665339
pOut->flags = MEM_Int;
6543765340
}
6543865341
6543965342
/* Sanity checking on other operands */
6544065343
#ifdef SQLITE_DEBUG
@@ -65738,11 +65641,11 @@
6573865641
assert( pOp->p3<=p->nMem );
6573965642
pOut->flags = MEM_Null;
6574065643
while( u.ab.cnt>0 ){
6574165644
pOut++;
6574265645
memAboutToChange(p, pOut);
65743
- MemReleaseExt(pOut);
65646
+ VdbeMemRelease(pOut);
6574465647
pOut->flags = MEM_Null;
6574565648
u.ab.cnt--;
6574665649
}
6574765650
break;
6574865651
}
@@ -65919,11 +65822,11 @@
6591965822
/* Invalidate all ephemeral cursor row caches */
6592065823
p->cacheCtr = (p->cacheCtr + 2)|1;
6592165824
6592265825
/* Make sure the results of the current row are \000 terminated
6592365826
** and have an assigned type. The results are de-ephemeralized as
65924
- ** as side effect.
65827
+ ** a side effect.
6592565828
*/
6592665829
u.ae.pMem = p->pResultSet = &aMem[pOp->p1];
6592765830
for(u.ae.i=0; u.ae.i<pOp->p2; u.ae.i++){
6592865831
assert( memIsValid(&u.ae.pMem[u.ae.i]) );
6592965832
Deephemeralize(&u.ae.pMem[u.ae.i]);
@@ -67160,11 +67063,11 @@
6716067063
** a pointer to a Mem object.
6716167064
*/
6716267065
if( u.an.aOffset[u.an.p2] ){
6716367066
assert( rc==SQLITE_OK );
6716467067
if( u.an.zRec ){
67165
- MemReleaseExt(u.an.pDest);
67068
+ VdbeMemRelease(u.an.pDest);
6716667069
sqlite3VdbeSerialGet((u8 *)&u.an.zRec[u.an.aOffset[u.an.p2]], u.an.aType[u.an.p2], u.an.pDest);
6716767070
}else{
6716867071
u.an.len = sqlite3VdbeSerialTypeLen(u.an.aType[u.an.p2]);
6716967072
sqlite3VdbeMemMove(&u.an.sMem, u.an.pDest);
6717067073
rc = sqlite3VdbeMemFromBtree(u.an.pCrsr, u.an.aOffset[u.an.p2], u.an.len, u.an.pC->isIndex, &u.an.sMem);
@@ -83758,11 +83661,11 @@
8375883661
** Allocate the index structure.
8375983662
*/
8376083663
nName = sqlite3Strlen30(zName);
8376183664
nCol = pList->nExpr;
8376283665
pIndex = sqlite3DbMallocZero(db,
83763
- sizeof(Index) + /* Index structure */
83666
+ ROUND8(sizeof(Index)) + /* Index structure */
8376483667
ROUND8(sizeof(tRowcnt)*(nCol+1)) + /* Index.aiRowEst */
8376583668
sizeof(char *)*nCol + /* Index.azColl */
8376683669
sizeof(int)*nCol + /* Index.aiColumn */
8376783670
sizeof(u8)*nCol + /* Index.aSortOrder */
8376883671
nName + 1 + /* Index.zName */
@@ -83769,11 +83672,12 @@
8376983672
nExtra /* Collation sequence names */
8377083673
);
8377183674
if( db->mallocFailed ){
8377283675
goto exit_create_index;
8377383676
}
83774
- pIndex->aiRowEst = (tRowcnt*)(&pIndex[1]);
83677
+ zExtra = (char*)pIndex;
83678
+ pIndex->aiRowEst = (tRowcnt*)&zExtra[ROUND8(sizeof(Index))];
8377583679
pIndex->azColl = (char**)
8377683680
((char*)pIndex->aiRowEst + ROUND8(sizeof(tRowcnt)*nCol+1));
8377783681
assert( EIGHT_BYTE_ALIGNMENT(pIndex->aiRowEst) );
8377883682
assert( EIGHT_BYTE_ALIGNMENT(pIndex->azColl) );
8377983683
pIndex->aiColumn = (int *)(&pIndex->azColl[nCol]);
@@ -89966,11 +89870,11 @@
8996689870
** any ABORT Back out changes from the current command
8996789871
** only (do not do a complete rollback) then
8996889872
** cause sqlite3_exec() to return immediately
8996989873
** with SQLITE_CONSTRAINT.
8997089874
**
89971
-** any FAIL Sqlite_exec() returns immediately with a
89875
+** any FAIL Sqlite3_exec() returns immediately with a
8997289876
** return code of SQLITE_CONSTRAINT. The
8997389877
** transaction is not rolled back and any
8997489878
** prior changes are retained.
8997589879
**
8997689880
** any IGNORE The record number and data is popped from
@@ -111450,11 +111354,11 @@
111450111354
*tokenType = TK_SPACE;
111451111355
return i;
111452111356
}
111453111357
case '-': {
111454111358
if( z[1]=='-' ){
111455
- /* IMP: R-15891-05542 -- syntax diagram for comments */
111359
+ /* IMP: R-50417-27976 -- syntax diagram for comments */
111456111360
for(i=2; (c=z[i])!=0 && c!='\n'; i++){}
111457111361
*tokenType = TK_SPACE; /* IMP: R-22934-25134 */
111458111362
return i;
111459111363
}
111460111364
*tokenType = TK_MINUS;
@@ -111483,11 +111387,11 @@
111483111387
case '/': {
111484111388
if( z[1]!='*' || z[2]==0 ){
111485111389
*tokenType = TK_SLASH;
111486111390
return 1;
111487111391
}
111488
- /* IMP: R-15891-05542 -- syntax diagram for comments */
111392
+ /* IMP: R-50417-27976 -- syntax diagram for comments */
111489111393
for(i=3, c=z[2]; (c!='*' || z[i]!='/') && (c=z[i])!=0; i++){}
111490111394
if( c ) i++;
111491111395
*tokenType = TK_SPACE; /* IMP: R-22934-25134 */
111492111396
return i;
111493111397
}
@@ -112277,12 +112181,12 @@
112277112181
/* IMPLEMENTATION-OF: R-35210-63508 The sqlite3_libversion_number() function
112278112182
** returns an integer equal to SQLITE_VERSION_NUMBER.
112279112183
*/
112280112184
SQLITE_API int sqlite3_libversion_number(void){ return SQLITE_VERSION_NUMBER; }
112281112185
112282
-/* IMPLEMENTATION-OF: R-54823-41343 The sqlite3_threadsafe() function returns
112283
-** zero if and only if SQLite was compiled mutexing code omitted due to
112186
+/* IMPLEMENTATION-OF: R-20790-14025 The sqlite3_threadsafe() function returns
112187
+** zero if and only if SQLite was compiled with mutexing code omitted due to
112284112188
** the SQLITE_THREADSAFE compile-time option being set to 0.
112285112189
*/
112286112190
SQLITE_API int sqlite3_threadsafe(void){ return SQLITE_THREADSAFE; }
112287112191
112288112192
#if !defined(SQLITE_OMIT_TRACE) && defined(SQLITE_ENABLE_IOTRACE)
@@ -112768,19 +112672,21 @@
112768112672
** Free up as much memory as we can from the given database
112769112673
** connection.
112770112674
*/
112771112675
SQLITE_API int sqlite3_db_release_memory(sqlite3 *db){
112772112676
int i;
112677
+ sqlite3_mutex_enter(db->mutex);
112773112678
sqlite3BtreeEnterAll(db);
112774112679
for(i=0; i<db->nDb; i++){
112775112680
Btree *pBt = db->aDb[i].pBt;
112776112681
if( pBt ){
112777112682
Pager *pPager = sqlite3BtreePager(pBt);
112778112683
sqlite3PagerShrink(pPager);
112779112684
}
112780112685
}
112781112686
sqlite3BtreeLeaveAll(db);
112687
+ sqlite3_mutex_leave(db->mutex);
112782112688
return SQLITE_OK;
112783112689
}
112784112690
112785112691
/*
112786112692
** Configuration settings for an individual database connection
112787112693
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -657,11 +657,11 @@
657 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
658 ** [sqlite_version()] and [sqlite_source_id()].
659 */
660 #define SQLITE_VERSION "3.7.10"
661 #define SQLITE_VERSION_NUMBER 3007010
662 #define SQLITE_SOURCE_ID "2011-12-23 13:32:07 1f24ae716df6232de768e245ea990049deee3c22"
663
664 /*
665 ** CAPI3REF: Run-Time Library Version Numbers
666 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
667 **
@@ -725,11 +725,11 @@
725
726 /*
727 ** CAPI3REF: Test To See If The Library Is Threadsafe
728 **
729 ** ^The sqlite3_threadsafe() function returns zero if and only if
730 ** SQLite was compiled mutexing code omitted due to the
731 ** [SQLITE_THREADSAFE] compile-time option being set to 0.
732 **
733 ** SQLite can be compiled with or without mutexes. When
734 ** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes
735 ** are enabled and SQLite is threadsafe. When the
@@ -919,11 +919,11 @@
919 ** CAPI3REF: Result Codes
920 ** KEYWORDS: SQLITE_OK {error code} {error codes}
921 ** KEYWORDS: {result code} {result codes}
922 **
923 ** Many SQLite functions return an integer result code from the set shown
924 ** here in order to indicates success or failure.
925 **
926 ** New error codes may be added in future versions of SQLite.
927 **
928 ** See also: [SQLITE_IOERR_READ | extended result codes],
929 ** [sqlite3_vtab_on_conflict()] [SQLITE_ROLLBACK | result codes].
@@ -1058,17 +1058,14 @@
1058 ** that when data is appended to a file, the data is appended
1059 ** first then the size of the file is extended, never the other
1060 ** way around. The SQLITE_IOCAP_SEQUENTIAL property means that
1061 ** information is written to disk in the same order as calls
1062 ** to xWrite(). The SQLITE_IOCAP_POWERSAFE_OVERWRITE property means that
1063 ** after reboot following a crash or power loss, the value of
1064 ** each byte in a file is a value that was actually written
1065 ** into that byte at some point. In other words, a crash will
1066 ** not cause unwritten bytes of the file to change nor introduce
1067 ** randomness into a file nor zero out parts of the file, and any byte of
1068 ** a file that are never written will not change values due to
1069 ** writes to nearby bytes.
1070 */
1071 #define SQLITE_IOCAP_ATOMIC 0x00000001
1072 #define SQLITE_IOCAP_ATOMIC512 0x00000002
1073 #define SQLITE_IOCAP_ATOMIC1K 0x00000004
1074 #define SQLITE_IOCAP_ATOMIC2K 0x00000008
@@ -1300,16 +1297,16 @@
1300 ** opcode as doing so may disrupt the operation of the specialized VFSes
1301 ** that do require it.
1302 **
1303 ** ^The [SQLITE_FCNTL_WIN32_AV_RETRY] opcode is used to configure automatic
1304 ** retry counts and intervals for certain disk I/O operations for the
1305 ** windows [VFS] in order to work to provide robustness against
1306 ** anti-virus programs. By default, the windows VFS will retry file read,
1307 ** file write, and file delete operations up to 10 times, with a delay
1308 ** of 25 milliseconds before the first retry and with the delay increasing
1309 ** by an additional 25 milliseconds with each subsequent retry. This
1310 ** opcode allows those to values (10 retries and 25 milliseconds of delay)
1311 ** to be adjusted. The values are changed for all database connections
1312 ** within the same process. The argument is a pointer to an array of two
1313 ** integers where the first integer i the new retry count and the second
1314 ** integer is the delay. If either integer is negative, then the setting
1315 ** is not changed but instead the prior value of that setting is written
@@ -1420,11 +1417,11 @@
1420 ** ^SQLite guarantees that the zFilename parameter to xOpen
1421 ** is either a NULL pointer or string obtained
1422 ** from xFullPathname() with an optional suffix added.
1423 ** ^If a suffix is added to the zFilename parameter, it will
1424 ** consist of a single "-" character followed by no more than
1425 ** 10 alphanumeric and/or "-" characters.
1426 ** ^SQLite further guarantees that
1427 ** the string will be valid and unchanged until xClose() is
1428 ** called. Because of the previous sentence,
1429 ** the [sqlite3_file] can safely store a pointer to the
1430 ** filename if it needs to remember the filename for some reason.
@@ -2571,11 +2568,11 @@
2571 ** These routines all implement some additional formatting
2572 ** options that are useful for constructing SQL statements.
2573 ** All of the usual printf() formatting options apply. In addition, there
2574 ** is are "%q", "%Q", and "%z" options.
2575 **
2576 ** ^(The %q option works like %s in that it substitutes a null-terminated
2577 ** string from the argument list. But %q also doubles every '\'' character.
2578 ** %q is designed for use inside a string literal.)^ By doubling each '\''
2579 ** character it escapes that character and allows it to be inserted into
2580 ** the string.
2581 **
@@ -4091,11 +4088,11 @@
4091 ** of the string. ^For clarity: the values returned by
4092 ** [sqlite3_column_bytes()] and [sqlite3_column_bytes16()] are the number of
4093 ** bytes in the string, not the number of characters.
4094 **
4095 ** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(),
4096 ** even empty strings, are always zero terminated. ^The return
4097 ** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.
4098 **
4099 ** ^The object returned by [sqlite3_column_value()] is an
4100 ** [unprotected sqlite3_value] object. An unprotected sqlite3_value object
4101 ** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()].
@@ -5171,11 +5168,11 @@
5171 SQLITE_API int sqlite3_release_memory(int);
5172
5173 /*
5174 ** CAPI3REF: Free Memory Used By A Database Connection
5175 **
5176 ** ^The sqlite3_db_shrink(D) interface attempts to free as much heap
5177 ** memory as possible from database connection D. Unlike the
5178 ** [sqlite3_release_memory()] interface, this interface is effect even
5179 ** when then [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is
5180 ** omitted.
5181 **
@@ -5954,19 +5951,19 @@
5954 ** is selected automatically at compile-time. ^(The following
5955 ** implementations are available in the SQLite core:
5956 **
5957 ** <ul>
5958 ** <li> SQLITE_MUTEX_OS2
5959 ** <li> SQLITE_MUTEX_PTHREAD
5960 ** <li> SQLITE_MUTEX_W32
5961 ** <li> SQLITE_MUTEX_NOOP
5962 ** </ul>)^
5963 **
5964 ** ^The SQLITE_MUTEX_NOOP implementation is a set of routines
5965 ** that does no real locking and is appropriate for use in
5966 ** a single-threaded application. ^The SQLITE_MUTEX_OS2,
5967 ** SQLITE_MUTEX_PTHREAD, and SQLITE_MUTEX_W32 implementations
5968 ** are appropriate for use on OS/2, Unix, and Windows.
5969 **
5970 ** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor
5971 ** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex
5972 ** implementation is included with the library. In this case the
@@ -6152,11 +6149,11 @@
6152 ** defined and if NDEBUG is not defined.
6153 **
6154 ** ^These routines should return true if the mutex in their argument
6155 ** is held or not held, respectively, by the calling thread.
6156 **
6157 ** ^The implementation is not required to provided versions of these
6158 ** routines that actually work. If the implementation does not provide working
6159 ** versions of these routines, it should at least provide stubs that always
6160 ** return true so that one does not get spurious assertion failures.
6161 **
6162 ** ^If the argument to sqlite3_mutex_held() is a NULL pointer then
@@ -6634,11 +6631,11 @@
6634 **
6635 ** [[the xInit() page cache method]]
6636 ** ^(The xInit() method is called once for each effective
6637 ** call to [sqlite3_initialize()])^
6638 ** (usually only once during the lifetime of the process). ^(The xInit()
6639 ** method is passed a copy of the sqlite3_pcache_methods.pArg value.)^
6640 ** The intent of the xInit() method is to set up global data structures
6641 ** required by the custom page cache implementation.
6642 ** ^(If the xInit() method is NULL, then the
6643 ** built-in default page cache is used instead of the application defined
6644 ** page cache.)^
@@ -6660,11 +6657,11 @@
6660 **
6661 ** [[the xCreate() page cache methods]]
6662 ** ^SQLite invokes the xCreate() method to construct a new cache instance.
6663 ** SQLite will typically create one cache instance for each open database file,
6664 ** though this is not guaranteed. ^The
6665 ** parameter parameter, szPage, is the size in bytes of the pages that must
6666 ** be allocated by the cache. ^szPage will always a power of two. ^The
6667 ** second parameter szExtra is a number of bytes of extra storage
6668 ** associated with each page cache entry. ^The szExtra parameter will
6669 ** a number less than 250. SQLite will use the
6670 ** extra szExtra bytes on each page to store metadata about the underlying
@@ -6755,11 +6752,11 @@
6755 **
6756 ** [[the xDestroy() page cache method]]
6757 ** ^The xDestroy() method is used to delete a cache allocated by xCreate().
6758 ** All resources associated with the specified cache should be freed. ^After
6759 ** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*]
6760 ** handle invalid, and will not use it with any other sqlite3_pcache_methods
6761 ** functions.
6762 **
6763 ** [[the xShrink() page cache method]]
6764 ** ^SQLite invokes the xShrink() method when it wants the page cache to
6765 ** free up as much of heap memory as possible. The page cache implementation
@@ -9266,11 +9263,11 @@
9266
9267 /*
9268 ** The default size of a disk sector
9269 */
9270 #ifndef SQLITE_DEFAULT_SECTOR_SIZE
9271 # define SQLITE_DEFAULT_SECTOR_SIZE 512
9272 #endif
9273
9274 /*
9275 ** Temporary files are named starting with this prefix followed by 16 random
9276 ** alphanumeric characters, and no file extension. They are stored in the
@@ -13190,11 +13187,11 @@
13190 SQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem*);
13191 SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem*);
13192 SQLITE_PRIVATE int sqlite3VdbeMemFromBtree(BtCursor*,int,int,int,Mem*);
13193 SQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p);
13194 SQLITE_PRIVATE void sqlite3VdbeMemReleaseExternal(Mem *p);
13195 #define MemReleaseExt(X) \
13196 if((X)->flags&(MEM_Agg|MEM_Dyn|MEM_RowSet|MEM_Frame)) \
13197 sqlite3VdbeMemReleaseExternal(X);
13198 SQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem*, FuncDef*);
13199 SQLITE_PRIVATE const char *sqlite3OpcodeName(int);
13200 SQLITE_PRIVATE int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve);
@@ -13229,11 +13226,11 @@
13229 # define sqlite3VdbeEnter(X)
13230 # define sqlite3VdbeLeave(X)
13231 #endif
13232
13233 #ifdef SQLITE_DEBUG
13234 SQLITE_PRIVATE void sqlite3VdbeMemPrepareToChange(Vdbe*,Mem*);
13235 #endif
13236
13237 #ifndef SQLITE_OMIT_FOREIGN_KEY
13238 SQLITE_PRIVATE int sqlite3VdbeCheckFk(Vdbe *, int);
13239 #else
@@ -14762,11 +14759,11 @@
14762 int flags,
14763 int *pFlagsOut
14764 ){
14765 int rc;
14766 DO_OS_MALLOC_TEST(0);
14767 /* 0x87f3f is a mask of SQLITE_OPEN_ flags that are valid to be passed
14768 ** down into the VFS layer. Some SQLITE_OPEN_ flags (for example,
14769 ** SQLITE_OPEN_FULLMUTEX or SQLITE_OPEN_SHAREDCACHE) are blocked before
14770 ** reaching the VFS. */
14771 rc = pVfs->xOpen(pVfs, zPath, pFile, flags & 0x87f7f, pFlagsOut);
14772 assert( rc==SQLITE_OK || pFile->pMethods==0 );
@@ -17316,11 +17313,11 @@
17316 SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex *p){
17317 return p==0 || sqlite3GlobalConfig.mutex.xMutexNotheld(p);
17318 }
17319 #endif
17320
17321 #endif /* SQLITE_MUTEX_OMIT */
17322
17323 /************** End of mutex.c ***********************************************/
17324 /************** Begin file mutex_noop.c **************************************/
17325 /*
17326 ** 2008 October 07
@@ -17523,12 +17520,12 @@
17523 */
17524 #ifdef SQLITE_MUTEX_NOOP
17525 SQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void){
17526 return sqlite3NoopMutex();
17527 }
17528 #endif /* SQLITE_MUTEX_NOOP */
17529 #endif /* SQLITE_MUTEX_OMIT */
17530
17531 /************** End of mutex_noop.c ******************************************/
17532 /************** Begin file mutex_os2.c ***************************************/
17533 /*
17534 ** 2007 August 28
@@ -18153,11 +18150,11 @@
18153 };
18154
18155 return &sMutex;
18156 }
18157
18158 #endif /* SQLITE_MUTEX_PTHREAD */
18159
18160 /************** End of mutex_unix.c ******************************************/
18161 /************** Begin file mutex_w32.c ***************************************/
18162 /*
18163 ** 2007 August 14
@@ -22116,26 +22113,31 @@
22116 ** characters of the original suffix.
22117 **
22118 ** If SQLITE_ENABLE_8_3_NAMES is set to 2 at compile-time, then always
22119 ** do the suffix shortening regardless of URI parameter.
22120 **
 
 
 
 
22121 ** Examples:
22122 **
22123 ** test.db-journal => test.nal
22124 ** test.db-wal => test.wal
22125 ** test.db-shm => test.shm
22126 ** test.db-mj7f3319fa => test.9fa
22127 */
22128 SQLITE_PRIVATE void sqlite3FileSuffix3(const char *zBaseFilename, char *z){
 
22129 #if SQLITE_ENABLE_8_3_NAMES<2
22130 if( sqlite3_uri_boolean(zBaseFilename, "8_3_names") )
22131 #endif
22132 {
22133 int i, sz;
22134 sz = sqlite3Strlen30(z);
22135 for(i=sz-1; i>0 && z[i]!='/' && z[i]!='.'; i--){}
22136 if( z[i]=='.' && ALWAYS(sz>i+4) ) memmove(&z[i+1], &z[sz-3], 4);
22137 }
22138 }
22139 #endif
22140
22141 /************** End of util.c ************************************************/
@@ -24836,13 +24838,10 @@
24836 #include <sys/time.h>
24837 #include <errno.h>
24838 #ifndef SQLITE_OMIT_WAL
24839 #include <sys/mman.h>
24840 #endif
24841 #ifndef MISSING_STATVFS
24842 #include <sys/statvfs.h>
24843 #endif
24844
24845
24846 #if SQLITE_ENABLE_LOCKING_STYLE
24847 # include <sys/ioctl.h>
24848 # if OS_VXWORKS
@@ -24929,11 +24928,10 @@
24929 sqlite3_vfs *pVfs; /* The VFS that created this unixFile */
24930 unixInodeInfo *pInode; /* Info about locks on this inode */
24931 int h; /* The file descriptor */
24932 unsigned char eFileLock; /* The type of lock held on this fd */
24933 unsigned char ctrlFlags; /* Behavioral bits. UNIXFILE_* flags */
24934 unsigned char szSector; /* Sectorsize/512 */
24935 int lastErrno; /* The unix errno from last I/O error */
24936 void *lockingContext; /* Locking style specific state */
24937 UnixUnusedFd *pUnused; /* Pre-allocated UnixUnusedFd */
24938 const char *zPath; /* Name of the file */
24939 unixShm *pShm; /* Shared memory segment information */
@@ -25342,18 +25340,10 @@
25342 #define osMkdir ((int(*)(const char*,mode_t))aSyscall[18].pCurrent)
25343
25344 { "rmdir", (sqlite3_syscall_ptr)rmdir, 0 },
25345 #define osRmdir ((int(*)(const char*))aSyscall[19].pCurrent)
25346
25347 #if defined(MISSING_STATVFS)
25348 { "statvfs", (sqlite3_syscall_ptr)0, 0 },
25349 #define osStatvfs ((int(*)(const char*,void*))aSyscall[20].pCurrent)
25350 #else
25351 { "statvfs", (sqlite3_syscall_ptr)statvfs, 0 },
25352 #define osStatvfs ((int(*)(const char*,struct statvfs*))aSyscall[20].pCurrent)
25353 #endif
25354
25355 }; /* End of the overrideable system calls */
25356
25357 /*
25358 ** This is the xSetSystemCall() method of sqlite3_vfs for all of the
25359 ** "unix" VFSes. Return SQLITE_OK opon successfully updating the
@@ -28504,13 +28494,10 @@
28504 case SQLITE_SET_LOCKPROXYFILE:
28505 case SQLITE_GET_LOCKPROXYFILE: {
28506 return proxyFileControl(id,op,pArg);
28507 }
28508 #endif /* SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__) */
28509 case SQLITE_FCNTL_SYNC_OMITTED: {
28510 return SQLITE_OK; /* A no-op */
28511 }
28512 }
28513 return SQLITE_NOTFOUND;
28514 }
28515
28516 /*
@@ -28522,27 +28509,12 @@
28522 ** if two files are created in the same file-system directory (i.e.
28523 ** a database and its journal file) that the sector size will be the
28524 ** same for both.
28525 */
28526 static int unixSectorSize(sqlite3_file *pFile){
28527 unixFile *p = (unixFile*)pFile;
28528 if( p->szSector==0 ){
28529 #ifdef MISSING_STATVFS
28530 p->szSector = SQLITE_DEFAULT_SECTOR_SIZE/512;
28531 #else
28532 struct statvfs x;
28533 int sz;
28534 memset(&x, 0, sizeof(x));
28535 osStatvfs(p->zPath, &x);
28536 sz = (int)x.f_frsize;
28537 if( sz<512 || sz>65536 || (sz&(sz-1))!=0 ){
28538 sz = SQLITE_DEFAULT_SECTOR_SIZE;
28539 }
28540 p->szSector = sz/512;
28541 #endif
28542 }
28543 return p->szSector*512;
28544 }
28545
28546 /*
28547 ** Return the device characteristics for the file.
28548 **
@@ -28815,13 +28787,13 @@
28815 rc = SQLITE_IOERR_FSTAT;
28816 goto shm_open_err;
28817 }
28818
28819 #ifdef SQLITE_SHM_DIRECTORY
28820 nShmFilename = sizeof(SQLITE_SHM_DIRECTORY) + 30;
28821 #else
28822 nShmFilename = 5 + (int)strlen(pDbFd->zPath);
28823 #endif
28824 pShmNode = sqlite3_malloc( sizeof(*pShmNode) + nShmFilename );
28825 if( pShmNode==0 ){
28826 rc = SQLITE_NOMEM;
28827 goto shm_open_err;
@@ -31755,11 +31727,11 @@
31755 };
31756 unsigned int i; /* Loop counter */
31757
31758 /* Double-check that the aSyscall[] array has been constructed
31759 ** correctly. See ticket [bb3a86e890c8e96ab] */
31760 assert( ArraySize(aSyscall)==21 );
31761
31762 /* Register all VFSes defined in the aVfs[] array */
31763 for(i=0; i<(sizeof(aVfs)/sizeof(sqlite3_vfs)); i++){
31764 sqlite3_vfs_register(&aVfs[i], i==0);
31765 }
@@ -32049,11 +32021,10 @@
32049 HANDLE h; /* Handle for accessing the file */
32050 u8 locktype; /* Type of lock currently held on this file */
32051 short sharedLockByte; /* Randomly chosen byte used as a shared lock */
32052 u8 ctrlFlags; /* Flags. See WINFILE_* below */
32053 DWORD lastErrno; /* The Windows errno from the last I/O error */
32054 DWORD sectorSize; /* Sector size of the device file is on */
32055 winShm *pShm; /* Instance of shared memory on this file */
32056 const char *zPath; /* Full pathname of this file */
32057 int szChunk; /* Chunk size configured by FCNTL_CHUNK_SIZE */
32058 #if SQLITE_OS_WINCE
32059 LPWSTR zDeleteOnClose; /* Name of file to delete when closing */
@@ -32139,18 +32110,10 @@
32139 static void winMemShutdown(void *pAppData);
32140
32141 SQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetWin32(void);
32142 #endif /* SQLITE_WIN32_MALLOC */
32143
32144 /*
32145 ** Forward prototypes.
32146 */
32147 static int getSectorSize(
32148 sqlite3_vfs *pVfs,
32149 const char *zRelative /* UTF-8 file name */
32150 );
32151
32152 /*
32153 ** The following variable is (normally) set once and never changes
32154 ** thereafter. It records whether the operating system is Win9x
32155 ** or WinNT.
32156 **
@@ -34181,13 +34144,10 @@
34181 }
34182 case SQLITE_FCNTL_VFSNAME: {
34183 *(char**)pArg = sqlite3_mprintf("win32");
34184 return SQLITE_OK;
34185 }
34186 case SQLITE_FCNTL_SYNC_OMITTED: {
34187 return SQLITE_OK;
34188 }
34189 case SQLITE_FCNTL_WIN32_AV_RETRY: {
34190 int *a = (int*)pArg;
34191 if( a[0]>0 ){
34192 win32IoerrRetry = a[0];
34193 }else{
@@ -34213,12 +34173,12 @@
34213 ** if two files are created in the same file-system directory (i.e.
34214 ** a database and its journal file) that the sector size will be the
34215 ** same for both.
34216 */
34217 static int winSectorSize(sqlite3_file *id){
34218 assert( id!=0 );
34219 return (int)(((winFile*)id)->sectorSize);
34220 }
34221
34222 /*
34223 ** Return a vector of device characteristics.
34224 */
@@ -34463,11 +34423,11 @@
34463 */
34464 p = sqlite3_malloc( sizeof(*p) );
34465 if( p==0 ) return SQLITE_IOERR_NOMEM;
34466 memset(p, 0, sizeof(*p));
34467 nName = sqlite3Strlen30(pDbFd->zPath);
34468 pNew = sqlite3_malloc( sizeof(*pShmNode) + nName + 15 );
34469 if( pNew==0 ){
34470 sqlite3_free(p);
34471 return SQLITE_IOERR_NOMEM;
34472 }
34473 memset(pNew, 0, sizeof(*pNew));
@@ -35191,11 +35151,10 @@
35191 pFile->pShm = 0;
35192 pFile->zPath = zName;
35193 if( sqlite3_uri_boolean(zName, "psow", SQLITE_POWERSAFE_OVERWRITE) ){
35194 pFile->ctrlFlags |= WINFILE_PSOW;
35195 }
35196 pFile->sectorSize = getSectorSize(pVfs, zUtf8Name);
35197
35198 #if SQLITE_OS_WINCE
35199 if( isReadWrite && eType==SQLITE_OPEN_MAIN_DB
35200 && !winceCreateLock(zName, pFile)
35201 ){
@@ -35436,85 +35395,10 @@
35436 return SQLITE_IOERR_NOMEM;
35437 }
35438 #endif
35439 }
35440
35441 /*
35442 ** Get the sector size of the device used to store
35443 ** file.
35444 */
35445 static int getSectorSize(
35446 sqlite3_vfs *pVfs,
35447 const char *zRelative /* UTF-8 file name */
35448 ){
35449 DWORD bytesPerSector = SQLITE_DEFAULT_SECTOR_SIZE;
35450 /* GetDiskFreeSpace is not supported under WINCE */
35451 #if SQLITE_OS_WINCE
35452 UNUSED_PARAMETER(pVfs);
35453 UNUSED_PARAMETER(zRelative);
35454 #else
35455 char zFullpath[MAX_PATH+1];
35456 int rc;
35457 DWORD dwRet = 0;
35458 DWORD dwDummy;
35459
35460 /*
35461 ** We need to get the full path name of the file
35462 ** to get the drive letter to look up the sector
35463 ** size.
35464 */
35465 SimulateIOErrorBenign(1);
35466 sqlite3BeginBenignMalloc();
35467 rc = winFullPathname(pVfs, zRelative, MAX_PATH, zFullpath);
35468 sqlite3EndBenignMalloc();
35469 SimulateIOErrorBenign(0);
35470 if( rc == SQLITE_OK )
35471 {
35472 void *zConverted;
35473 sqlite3BeginBenignMalloc();
35474 zConverted = convertUtf8Filename(zFullpath);
35475 sqlite3EndBenignMalloc();
35476 if( zConverted ){
35477 if( isNT() ){
35478 /* trim path to just drive reference */
35479 LPWSTR p = zConverted;
35480 for(;*p;p++){
35481 if( *p == '\\' ){
35482 *p = '\0';
35483 break;
35484 }
35485 }
35486 dwRet = osGetDiskFreeSpaceW((LPCWSTR)zConverted,
35487 &dwDummy,
35488 &bytesPerSector,
35489 &dwDummy,
35490 &dwDummy);
35491 }else{
35492 /* trim path to just drive reference */
35493 char *p = (char *)zConverted;
35494 for(;*p;p++){
35495 if( *p == '\\' ){
35496 *p = '\0';
35497 break;
35498 }
35499 }
35500 dwRet = osGetDiskFreeSpaceA((char*)zConverted,
35501 &dwDummy,
35502 &bytesPerSector,
35503 &dwDummy,
35504 &dwDummy);
35505 }
35506 sqlite3_free(zConverted);
35507 }
35508 if( !dwRet ){
35509 bytesPerSector = SQLITE_DEFAULT_SECTOR_SIZE;
35510 }
35511 }
35512 #endif
35513 return (int) bytesPerSector;
35514 }
35515
35516 #ifndef SQLITE_OMIT_LOAD_EXTENSION
35517 /*
35518 ** Interfaces for opening a shared library, finding entry points
35519 ** within the shared library, and closing the shared library.
35520 */
@@ -36381,11 +36265,11 @@
36381 */
36382 static int numberOfCachePages(PCache *p){
36383 if( p->szCache>=0 ){
36384 return p->szCache;
36385 }else{
36386 return (-1024*p->szCache)/(p->szPage+p->szExtra);
36387 }
36388 }
36389
36390 /*
36391 ** Try to obtain a page from the cache.
@@ -36845,14 +36729,14 @@
36845 ** PGroup which is the pcache1.grp global variable and its mutex is
36846 ** SQLITE_MUTEX_STATIC_LRU.
36847 */
36848 struct PGroup {
36849 sqlite3_mutex *mutex; /* MUTEX_STATIC_LRU or NULL */
36850 int nMaxPage; /* Sum of nMax for purgeable caches */
36851 int nMinPage; /* Sum of nMin for purgeable caches */
36852 int mxPinned; /* nMaxpage + 10 - nMinPage */
36853 int nCurrentPage; /* Number of purgeable pages allocated */
36854 PgHdr1 *pLruHead, *pLruTail; /* LRU list of unpinned pages */
36855 };
36856
36857 /* Each page cache is an instance of the following object. Every
36858 ** open database file (including each in-memory database and each
@@ -37511,11 +37395,11 @@
37511 static sqlite3_pcache_page *pcache1Fetch(
37512 sqlite3_pcache *p,
37513 unsigned int iKey,
37514 int createFlag
37515 ){
37516 int nPinned;
37517 PCache1 *pCache = (PCache1 *)p;
37518 PGroup *pGroup;
37519 PgHdr1 *pPage = 0;
37520
37521 assert( pCache->bPurgeable || createFlag!=1 );
@@ -37546,17 +37430,17 @@
37546 #ifdef SQLITE_MUTEX_OMIT
37547 pGroup = pCache->pGroup;
37548 #endif
37549
37550 /* Step 3: Abort if createFlag is 1 but the cache is nearly full */
 
37551 nPinned = pCache->nPage - pCache->nRecyclable;
37552 assert( nPinned>=0 );
37553 assert( pGroup->mxPinned == pGroup->nMaxPage + 10 - pGroup->nMinPage );
37554 assert( pCache->n90pct == pCache->nMax*9/10 );
37555 if( createFlag==1 && (
37556 nPinned>=pGroup->mxPinned
37557 || nPinned>=(int)pCache->n90pct
37558 || pcache1UnderMemoryPressure(pCache)
37559 )){
37560 goto fetch_out;
37561 }
37562
@@ -37725,11 +37609,13 @@
37725 PCache1 *pCache = (PCache1 *)p;
37726 PGroup *pGroup = pCache->pGroup;
37727 assert( pCache->bPurgeable || (pCache->nMax==0 && pCache->nMin==0) );
37728 pcache1EnterMutex(pGroup);
37729 pcache1TruncateUnsafe(pCache, 0);
 
37730 pGroup->nMaxPage -= pCache->nMax;
 
37731 pGroup->nMinPage -= pCache->nMin;
37732 pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage;
37733 pcache1EnforceMaxPage(pGroup);
37734 pcache1LeaveMutex(pGroup);
37735 sqlite3_free(pCache->apHash);
@@ -37807,12 +37693,12 @@
37807 int nRecyclable = 0;
37808 for(p=pcache1.grp.pLruHead; p; p=p->pLruNext){
37809 nRecyclable++;
37810 }
37811 *pnCurrent = pcache1.grp.nCurrentPage;
37812 *pnMax = pcache1.grp.nMaxPage;
37813 *pnMin = pcache1.grp.nMinPage;
37814 *pnRecyclable = nRecyclable;
37815 }
37816 #endif
37817
37818 /************** End of pcache1.c *********************************************/
@@ -38282,10 +38168,16 @@
38282
38283 #ifndef _WAL_H_
38284 #define _WAL_H_
38285
38286
 
 
 
 
 
 
38287 #ifdef SQLITE_OMIT_WAL
38288 # define sqlite3WalOpen(x,y,z) 0
38289 # define sqlite3WalLimit(x,y)
38290 # define sqlite3WalClose(w,x,y,z) 0
38291 # define sqlite3WalBeginReadTransaction(y,z) 0
@@ -38350,16 +38242,10 @@
38350 SQLITE_PRIVATE int sqlite3WalSavepointUndo(Wal *pWal, u32 *aWalData);
38351
38352 /* Write a frame or frames to the log. */
38353 SQLITE_PRIVATE int sqlite3WalFrames(Wal *pWal, int, PgHdr *, Pgno, int, int);
38354
38355 /* Additional values that can be added to the sync_flags argument of
38356 ** sqlite3WalFrames():
38357 */
38358 #define WAL_SYNC_TRANSACTIONS 0x20 /* Sync at the end of each transaction */
38359 #define SQLITE_SYNC_MASK 0x13 /* Mask off the SQLITE_SYNC_* values */
38360
38361 /* Copy pages from the log to the database file */
38362 SQLITE_PRIVATE int sqlite3WalCheckpoint(
38363 Wal *pWal, /* Write-ahead log connection */
38364 int eMode, /* One of PASSIVE, FULL and RESTART */
38365 int (*xBusy)(void*), /* Function to call when busy */
@@ -42400,11 +42286,13 @@
42400 ** file size will be.
42401 */
42402 assert( rc!=SQLITE_OK || isOpen(pPager->fd) );
42403 if( rc==SQLITE_OK && pPager->dbSize>pPager->dbHintSize ){
42404 sqlite3_int64 szFile = pPager->pageSize * (sqlite3_int64)pPager->dbSize;
 
42405 sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_SIZE_HINT, &szFile);
 
42406 pPager->dbHintSize = pPager->dbSize;
42407 }
42408
42409 while( rc==SQLITE_OK && pList ){
42410 Pgno pgno = pList->pgno;
@@ -42741,11 +42629,12 @@
42741 z = zUri = &zFilename[sqlite3Strlen30(zFilename)+1];
42742 while( *z ){
42743 z += sqlite3Strlen30(z)+1;
42744 z += sqlite3Strlen30(z)+1;
42745 }
42746 nUri = &z[1] - zUri;
 
42747 if( rc==SQLITE_OK && nPathname+8>pVfs->mxPathname ){
42748 /* This branch is taken when the journal path required by
42749 ** the database being opened will be more than pVfs->mxPathname
42750 ** bytes in length. This means the database cannot be opened,
42751 ** as it will not be possible to open the journal file or even
@@ -42775,13 +42664,13 @@
42775 ROUND8(sizeof(*pPager)) + /* Pager structure */
42776 ROUND8(pcacheSize) + /* PCache object */
42777 ROUND8(pVfs->szOsFile) + /* The main db file */
42778 journalFileSize * 2 + /* The two journal files */
42779 nPathname + 1 + nUri + /* zFilename */
42780 nPathname + 8 + 1 /* zJournal */
42781 #ifndef SQLITE_OMIT_WAL
42782 + nPathname + 4 + 1 /* zWal */
42783 #endif
42784 );
42785 assert( EIGHT_BYTE_ALIGNMENT(SQLITE_INT_TO_PTR(journalFileSize)) );
42786 if( !pPtr ){
42787 sqlite3_free(zPathname);
@@ -42800,16 +42689,16 @@
42800 assert( nPathname>0 );
42801 pPager->zJournal = (char*)(pPtr += nPathname + 1 + nUri);
42802 memcpy(pPager->zFilename, zPathname, nPathname);
42803 memcpy(&pPager->zFilename[nPathname+1], zUri, nUri);
42804 memcpy(pPager->zJournal, zPathname, nPathname);
42805 memcpy(&pPager->zJournal[nPathname], "-journal", 8);
42806 sqlite3FileSuffix3(pPager->zFilename, pPager->zJournal);
42807 #ifndef SQLITE_OMIT_WAL
42808 pPager->zWal = &pPager->zJournal[nPathname+8+1];
42809 memcpy(pPager->zWal, zPathname, nPathname);
42810 memcpy(&pPager->zWal[nPathname], "-wal", 4);
42811 sqlite3FileSuffix3(pPager->zFilename, pPager->zWal);
42812 #endif
42813 sqlite3_free(zPathname);
42814 }
42815 pPager->pVfs = pVfs;
@@ -44064,11 +43953,14 @@
44064 if( !pPager->noSync ){
44065 assert( !MEMDB );
44066 rc = sqlite3OsSync(pPager->fd, pPager->syncFlags);
44067 }else if( isOpen(pPager->fd) ){
44068 assert( !MEMDB );
44069 sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_SYNC_OMITTED, (void *)&rc);
 
 
 
44070 }
44071 return rc;
44072 }
44073
44074 /*
@@ -48125,11 +48017,11 @@
48125 iFrame = pWal->hdr.mxFrame;
48126 for(p=pList; p && rc==SQLITE_OK; p=p->pDirty){
48127 iFrame++;
48128 rc = walIndexAppend(pWal, iFrame, p->pgno);
48129 }
48130 while( nExtra>0 && rc==SQLITE_OK ){
48131 iFrame++;
48132 nExtra--;
48133 rc = walIndexAppend(pWal, iFrame, pLast->pgno);
48134 }
48135
@@ -48726,11 +48618,11 @@
48726 #define TRANS_WRITE 2
48727
48728 /*
48729 ** An instance of this object represents a single database file.
48730 **
48731 ** A single database file can be in use as the same time by two
48732 ** or more database connections. When two or more connections are
48733 ** sharing the same database file, each connection has it own
48734 ** private Btree object for the file and each of those Btrees points
48735 ** to this one BtShared object. BtShared.nRef is the number of
48736 ** connections currently sharing this database file.
@@ -48832,11 +48724,11 @@
48832 ** b-tree within a database file.
48833 **
48834 ** The entry is identified by its MemPage and the index in
48835 ** MemPage.aCell[] of the entry.
48836 **
48837 ** A single database file can shared by two more database connections,
48838 ** but cursors cannot be shared. Each cursor is associated with a
48839 ** particular database connection identified BtCursor.pBtree.db.
48840 **
48841 ** Fields in this structure are accessed under the BtShared.mutex
48842 ** found at self->pBt->mutex.
@@ -48993,11 +48885,11 @@
48993 int mallocFailed; /* A memory allocation error has occurred */
48994 StrAccum errMsg; /* Accumulate the error message text here */
48995 };
48996
48997 /*
48998 ** Read or write a two- and four-byte big-endian integer values.
48999 */
49000 #define get2byte(x) ((x)[0]<<8 | (x)[1])
49001 #define put2byte(p,v) ((p)[0] = (u8)((v)>>8), (p)[1] = (u8)(v))
49002 #define get4byte sqlite3Get4byte
49003 #define put4byte sqlite3Put4byte
@@ -55478,12 +55370,18 @@
55478 }
55479
55480 /* Either we found one or more cells (cntnew[0])>0) or pPage is
55481 ** a virtual root page. A virtual root page is when the real root
55482 ** page is page 1 and we are the only child of that page.
 
 
 
 
55483 */
 
55484 assert( cntNew[0]>0 || (pParent->pgno==1 && pParent->nCell==0) );
 
55485
55486 TRACE(("BALANCE: old: %d %d %d ",
55487 apOld[0]->pgno,
55488 nOld>=2 ? apOld[1]->pgno : 0,
55489 nOld>=3 ? apOld[2]->pgno : 0
@@ -58194,11 +58092,13 @@
58194
58195 assert( sqlite3BtreeIsInTrans(pTo) );
58196 pFd = sqlite3PagerFile(sqlite3BtreePager(pTo));
58197 if( pFd->pMethods ){
58198 i64 nByte = sqlite3BtreeGetPageSize(pFrom)*(i64)sqlite3BtreeLastPage(pFrom);
 
58199 sqlite3OsFileControl(pFd, SQLITE_FCNTL_OVERWRITE, &nByte);
 
58200 }
58201
58202 /* Set up an sqlite3_backup object. sqlite3_backup.pDestDb must be set
58203 ** to 0. This is used by the implementations of sqlite3_backup_step()
58204 ** and sqlite3_backup_finish() to detect that they are being called
@@ -58525,11 +58425,11 @@
58525 ** Release any memory held by the Mem. This may leave the Mem in an
58526 ** inconsistent state, for example with (Mem.z==0) and
58527 ** (Mem.type==SQLITE_TEXT).
58528 */
58529 SQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p){
58530 MemReleaseExt(p);
58531 sqlite3DbFree(p->db, p->zMalloc);
58532 p->z = 0;
58533 p->zMalloc = 0;
58534 p->xDel = 0;
58535 }
@@ -58821,11 +58721,11 @@
58821 ** copies of this cell as invalid.
58822 **
58823 ** This is used for testing and debugging only - to make sure shallow
58824 ** copies are not misused.
58825 */
58826 SQLITE_PRIVATE void sqlite3VdbeMemPrepareToChange(Vdbe *pVdbe, Mem *pMem){
58827 int i;
58828 Mem *pX;
58829 for(i=1, pX=&pVdbe->aMem[1]; i<=pVdbe->nMem; i++, pX++){
58830 if( pX->pScopyFrom==pMem ){
58831 pX->flags |= MEM_Invalid;
@@ -58847,11 +58747,11 @@
58847 ** pFrom->z is used, then pTo->z points to the same thing as pFrom->z
58848 ** and flags gets srcType (either MEM_Ephem or MEM_Static).
58849 */
58850 SQLITE_PRIVATE void sqlite3VdbeMemShallowCopy(Mem *pTo, const Mem *pFrom, int srcType){
58851 assert( (pFrom->flags & MEM_RowSet)==0 );
58852 MemReleaseExt(pTo);
58853 memcpy(pTo, pFrom, MEMCELLSIZE);
58854 pTo->xDel = 0;
58855 if( (pFrom->flags&MEM_Static)==0 ){
58856 pTo->flags &= ~(MEM_Dyn|MEM_Static|MEM_Ephem);
58857 assert( srcType==MEM_Ephem || srcType==MEM_Static );
@@ -58865,11 +58765,11 @@
58865 */
58866 SQLITE_PRIVATE int sqlite3VdbeMemCopy(Mem *pTo, const Mem *pFrom){
58867 int rc = SQLITE_OK;
58868
58869 assert( (pFrom->flags & MEM_RowSet)==0 );
58870 MemReleaseExt(pTo);
58871 memcpy(pTo, pFrom, MEMCELLSIZE);
58872 pTo->flags &= ~MEM_Dyn;
58873
58874 if( pTo->flags&(MEM_Str|MEM_Blob) ){
58875 if( 0==(pFrom->flags&MEM_Static) ){
@@ -59202,11 +59102,11 @@
59202 assert( (pVal->flags & (MEM_Ephem|MEM_Static))!=0 );
59203 if( sqlite3VdbeMemMakeWriteable(pVal)!=SQLITE_OK ){
59204 return 0;
59205 }
59206 }
59207 sqlite3VdbeMemNulTerminate(pVal); /* IMP: R-59893-45467 */
59208 }else{
59209 assert( (pVal->flags&MEM_Blob)==0 );
59210 sqlite3VdbeMemStringify(pVal, enc);
59211 assert( 0==(1&SQLITE_PTR_TO_INT(pVal->z)) );
59212 }
@@ -59583,11 +59483,12 @@
59583 return addr;
59584 }
59585
59586 /*
59587 ** Add an OP_ParseSchema opcode. This routine is broken out from
59588 ** sqlite3VdbeAddOp4() since it needs to also local all btrees.
 
59589 **
59590 ** The zWhere string must have been obtained from sqlite3_malloc().
59591 ** This routine will take ownership of the allocated memory.
59592 */
59593 SQLITE_PRIVATE void sqlite3VdbeAddParseSchemaOp(Vdbe *p, int iDb, char *zWhere){
@@ -60350,12 +60251,13 @@
60350
60351 /*
60352 ** Declare to the Vdbe that the BTree object at db->aDb[i] is used.
60353 **
60354 ** The prepared statements need to know in advance the complete set of
60355 ** attached databases that they will be using. A mask of these databases
60356 ** is maintained in p->btreeMask and is used for locking and other purposes.
 
60357 */
60358 SQLITE_PRIVATE void sqlite3VdbeUsesBtree(Vdbe *p, int i){
60359 assert( i>=0 && i<p->db->nDb && i<(int)sizeof(yDbMask)*8 );
60360 assert( i<(int)sizeof(p->btreeMask)*8 );
60361 p->btreeMask |= ((yDbMask)1)<<i;
@@ -60874,10 +60776,11 @@
60874 nVar = pParse->nVar;
60875 nMem = pParse->nMem;
60876 nCursor = pParse->nTab;
60877 nArg = pParse->nMaxArg;
60878 nOnce = pParse->nOnce;
 
60879
60880 /* For each cursor required, also allocate a memory cell. Memory
60881 ** cells (nMem+1-nCursor)..nMem, inclusive, will never be used by
60882 ** the vdbe program. Instead they are used to allocate space for
60883 ** VdbeCursor/BtCursor structures. The blob of memory associated with
@@ -61225,11 +61128,11 @@
61225 int retryCount = 0;
61226 int nMainFile;
61227
61228 /* Select a master journal file name */
61229 nMainFile = sqlite3Strlen30(zMainFile);
61230 zMaster = sqlite3MPrintf(db, "%s-mjXXXXXX9XX", zMainFile);
61231 if( zMaster==0 ) return SQLITE_NOMEM;
61232 do {
61233 u32 iRandom;
61234 if( retryCount ){
61235 if( retryCount>100 ){
@@ -63013,11 +62916,11 @@
63013 ** since any application that receives an SQLITE_MISUSE is broken by
63014 ** definition.
63015 **
63016 ** Nevertheless, some published applications that were originally written
63017 ** for version 3.6.23 or earlier do in fact depend on SQLITE_MISUSE
63018 ** returns, and the so were broken by the automatic-reset change. As a
63019 ** a work-around, the SQLITE_OMIT_AUTORESET compile-time restores the
63020 ** legacy behavior of returning SQLITE_MISUSE for cases where the
63021 ** previous sqlite3_step() returned something other than a SQLITE_LOCKED
63022 ** or SQLITE_BUSY error.
63023 */
@@ -63359,17 +63262,17 @@
63359 pOut = &pVm->pResultSet[i];
63360 }else{
63361 /* If the value passed as the second argument is out of range, return
63362 ** a pointer to the following static Mem object which contains the
63363 ** value SQL NULL. Even though the Mem structure contains an element
63364 ** of type i64, on certain architecture (x86) with certain compiler
63365 ** switches (-Os), gcc may align this Mem object on a 4-byte boundary
63366 ** instead of an 8-byte one. This all works fine, except that when
63367 ** running with SQLITE_DEBUG defined the SQLite code sometimes assert()s
63368 ** that a Mem structure is located on an 8-byte boundary. To prevent
63369 ** this assert() from failing, when building with SQLITE_DEBUG defined
63370 ** using gcc, force nullMem to be 8-byte aligned using the magical
63371 ** __attribute__((aligned(8))) macro. */
63372 static const Mem nullMem
63373 #if defined(SQLITE_DEBUG) && defined(__GNUC__)
63374 __attribute__((aligned(8)))
63375 #endif
@@ -64298,11 +64201,11 @@
64298 ** Invoke this macro on memory cells just prior to changing the
64299 ** value of the cell. This macro verifies that shallow copies are
64300 ** not misused.
64301 */
64302 #ifdef SQLITE_DEBUG
64303 # define memAboutToChange(P,M) sqlite3VdbeMemPrepareToChange(P,M)
64304 #else
64305 # define memAboutToChange(P,M)
64306 #endif
64307
64308 /*
@@ -64316,12 +64219,12 @@
64316 SQLITE_API int sqlite3_search_count = 0;
64317 #endif
64318
64319 /*
64320 ** When this global variable is positive, it gets decremented once before
64321 ** each instruction in the VDBE. When reaches zero, the u1.isInterrupted
64322 ** field of the sqlite3 structure is set in order to simulate and interrupt.
64323 **
64324 ** This facility is used for testing purposes only. It does not function
64325 ** in an ordinary build.
64326 */
64327 #ifdef SQLITE_TEST
@@ -64442,11 +64345,11 @@
64442 */
64443 static VdbeCursor *allocateCursor(
64444 Vdbe *p, /* The virtual machine */
64445 int iCur, /* Index of the new VdbeCursor */
64446 int nField, /* Number of fields in the table or index */
64447 int iDb, /* When database the cursor belongs to, or -1 */
64448 int isBtreeCursor /* True for B-Tree. False for pseudo-table or vtab */
64449 ){
64450 /* Find the memory cell that will be used to store the blob of memory
64451 ** required for this VdbeCursor structure. It is convenient to use a
64452 ** vdbe memory cell to manage the memory allocation required for a
@@ -64813,11 +64716,11 @@
64813 ** sqlite3_interrupt() routine has been called. If it has been, then
64814 ** processing of the VDBE program is interrupted.
64815 **
64816 ** This macro added to every instruction that does a jump in order to
64817 ** implement a loop. This test used to be on every single instruction,
64818 ** but that meant we more testing that we needed. By only testing the
64819 ** flag on jump instructions, we get a (small) speed improvement.
64820 */
64821 #define CHECK_FOR_INTERRUPT \
64822 if( db->u1.isInterrupted ) goto abort_due_to_interrupt;
64823
@@ -65430,11 +65333,11 @@
65430 if( pOp->opflags & OPFLG_OUT2_PRERELEASE ){
65431 assert( pOp->p2>0 );
65432 assert( pOp->p2<=p->nMem );
65433 pOut = &aMem[pOp->p2];
65434 memAboutToChange(p, pOut);
65435 MemReleaseExt(pOut);
65436 pOut->flags = MEM_Int;
65437 }
65438
65439 /* Sanity checking on other operands */
65440 #ifdef SQLITE_DEBUG
@@ -65738,11 +65641,11 @@
65738 assert( pOp->p3<=p->nMem );
65739 pOut->flags = MEM_Null;
65740 while( u.ab.cnt>0 ){
65741 pOut++;
65742 memAboutToChange(p, pOut);
65743 MemReleaseExt(pOut);
65744 pOut->flags = MEM_Null;
65745 u.ab.cnt--;
65746 }
65747 break;
65748 }
@@ -65919,11 +65822,11 @@
65919 /* Invalidate all ephemeral cursor row caches */
65920 p->cacheCtr = (p->cacheCtr + 2)|1;
65921
65922 /* Make sure the results of the current row are \000 terminated
65923 ** and have an assigned type. The results are de-ephemeralized as
65924 ** as side effect.
65925 */
65926 u.ae.pMem = p->pResultSet = &aMem[pOp->p1];
65927 for(u.ae.i=0; u.ae.i<pOp->p2; u.ae.i++){
65928 assert( memIsValid(&u.ae.pMem[u.ae.i]) );
65929 Deephemeralize(&u.ae.pMem[u.ae.i]);
@@ -67160,11 +67063,11 @@
67160 ** a pointer to a Mem object.
67161 */
67162 if( u.an.aOffset[u.an.p2] ){
67163 assert( rc==SQLITE_OK );
67164 if( u.an.zRec ){
67165 MemReleaseExt(u.an.pDest);
67166 sqlite3VdbeSerialGet((u8 *)&u.an.zRec[u.an.aOffset[u.an.p2]], u.an.aType[u.an.p2], u.an.pDest);
67167 }else{
67168 u.an.len = sqlite3VdbeSerialTypeLen(u.an.aType[u.an.p2]);
67169 sqlite3VdbeMemMove(&u.an.sMem, u.an.pDest);
67170 rc = sqlite3VdbeMemFromBtree(u.an.pCrsr, u.an.aOffset[u.an.p2], u.an.len, u.an.pC->isIndex, &u.an.sMem);
@@ -83758,11 +83661,11 @@
83758 ** Allocate the index structure.
83759 */
83760 nName = sqlite3Strlen30(zName);
83761 nCol = pList->nExpr;
83762 pIndex = sqlite3DbMallocZero(db,
83763 sizeof(Index) + /* Index structure */
83764 ROUND8(sizeof(tRowcnt)*(nCol+1)) + /* Index.aiRowEst */
83765 sizeof(char *)*nCol + /* Index.azColl */
83766 sizeof(int)*nCol + /* Index.aiColumn */
83767 sizeof(u8)*nCol + /* Index.aSortOrder */
83768 nName + 1 + /* Index.zName */
@@ -83769,11 +83672,12 @@
83769 nExtra /* Collation sequence names */
83770 );
83771 if( db->mallocFailed ){
83772 goto exit_create_index;
83773 }
83774 pIndex->aiRowEst = (tRowcnt*)(&pIndex[1]);
 
83775 pIndex->azColl = (char**)
83776 ((char*)pIndex->aiRowEst + ROUND8(sizeof(tRowcnt)*nCol+1));
83777 assert( EIGHT_BYTE_ALIGNMENT(pIndex->aiRowEst) );
83778 assert( EIGHT_BYTE_ALIGNMENT(pIndex->azColl) );
83779 pIndex->aiColumn = (int *)(&pIndex->azColl[nCol]);
@@ -89966,11 +89870,11 @@
89966 ** any ABORT Back out changes from the current command
89967 ** only (do not do a complete rollback) then
89968 ** cause sqlite3_exec() to return immediately
89969 ** with SQLITE_CONSTRAINT.
89970 **
89971 ** any FAIL Sqlite_exec() returns immediately with a
89972 ** return code of SQLITE_CONSTRAINT. The
89973 ** transaction is not rolled back and any
89974 ** prior changes are retained.
89975 **
89976 ** any IGNORE The record number and data is popped from
@@ -111450,11 +111354,11 @@
111450 *tokenType = TK_SPACE;
111451 return i;
111452 }
111453 case '-': {
111454 if( z[1]=='-' ){
111455 /* IMP: R-15891-05542 -- syntax diagram for comments */
111456 for(i=2; (c=z[i])!=0 && c!='\n'; i++){}
111457 *tokenType = TK_SPACE; /* IMP: R-22934-25134 */
111458 return i;
111459 }
111460 *tokenType = TK_MINUS;
@@ -111483,11 +111387,11 @@
111483 case '/': {
111484 if( z[1]!='*' || z[2]==0 ){
111485 *tokenType = TK_SLASH;
111486 return 1;
111487 }
111488 /* IMP: R-15891-05542 -- syntax diagram for comments */
111489 for(i=3, c=z[2]; (c!='*' || z[i]!='/') && (c=z[i])!=0; i++){}
111490 if( c ) i++;
111491 *tokenType = TK_SPACE; /* IMP: R-22934-25134 */
111492 return i;
111493 }
@@ -112277,12 +112181,12 @@
112277 /* IMPLEMENTATION-OF: R-35210-63508 The sqlite3_libversion_number() function
112278 ** returns an integer equal to SQLITE_VERSION_NUMBER.
112279 */
112280 SQLITE_API int sqlite3_libversion_number(void){ return SQLITE_VERSION_NUMBER; }
112281
112282 /* IMPLEMENTATION-OF: R-54823-41343 The sqlite3_threadsafe() function returns
112283 ** zero if and only if SQLite was compiled mutexing code omitted due to
112284 ** the SQLITE_THREADSAFE compile-time option being set to 0.
112285 */
112286 SQLITE_API int sqlite3_threadsafe(void){ return SQLITE_THREADSAFE; }
112287
112288 #if !defined(SQLITE_OMIT_TRACE) && defined(SQLITE_ENABLE_IOTRACE)
@@ -112768,19 +112672,21 @@
112768 ** Free up as much memory as we can from the given database
112769 ** connection.
112770 */
112771 SQLITE_API int sqlite3_db_release_memory(sqlite3 *db){
112772 int i;
 
112773 sqlite3BtreeEnterAll(db);
112774 for(i=0; i<db->nDb; i++){
112775 Btree *pBt = db->aDb[i].pBt;
112776 if( pBt ){
112777 Pager *pPager = sqlite3BtreePager(pBt);
112778 sqlite3PagerShrink(pPager);
112779 }
112780 }
112781 sqlite3BtreeLeaveAll(db);
 
112782 return SQLITE_OK;
112783 }
112784
112785 /*
112786 ** Configuration settings for an individual database connection
112787
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -657,11 +657,11 @@
657 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
658 ** [sqlite_version()] and [sqlite_source_id()].
659 */
660 #define SQLITE_VERSION "3.7.10"
661 #define SQLITE_VERSION_NUMBER 3007010
662 #define SQLITE_SOURCE_ID "2012-01-05 12:38:02 1378f905d37544701776d38987fe7a312b255983"
663
664 /*
665 ** CAPI3REF: Run-Time Library Version Numbers
666 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
667 **
@@ -725,11 +725,11 @@
725
726 /*
727 ** CAPI3REF: Test To See If The Library Is Threadsafe
728 **
729 ** ^The sqlite3_threadsafe() function returns zero if and only if
730 ** SQLite was compiled with mutexing code omitted due to the
731 ** [SQLITE_THREADSAFE] compile-time option being set to 0.
732 **
733 ** SQLite can be compiled with or without mutexes. When
734 ** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes
735 ** are enabled and SQLite is threadsafe. When the
@@ -919,11 +919,11 @@
919 ** CAPI3REF: Result Codes
920 ** KEYWORDS: SQLITE_OK {error code} {error codes}
921 ** KEYWORDS: {result code} {result codes}
922 **
923 ** Many SQLite functions return an integer result code from the set shown
924 ** here in order to indicate success or failure.
925 **
926 ** New error codes may be added in future versions of SQLite.
927 **
928 ** See also: [SQLITE_IOERR_READ | extended result codes],
929 ** [sqlite3_vtab_on_conflict()] [SQLITE_ROLLBACK | result codes].
@@ -1058,17 +1058,14 @@
1058 ** that when data is appended to a file, the data is appended
1059 ** first then the size of the file is extended, never the other
1060 ** way around. The SQLITE_IOCAP_SEQUENTIAL property means that
1061 ** information is written to disk in the same order as calls
1062 ** to xWrite(). The SQLITE_IOCAP_POWERSAFE_OVERWRITE property means that
1063 ** after reboot following a crash or power loss, the only bytes in a
1064 ** file that were written at the application level might have changed
1065 ** and that adjacent bytes, even bytes within the same sector are
1066 ** guaranteed to be unchanged.
 
 
 
1067 */
1068 #define SQLITE_IOCAP_ATOMIC 0x00000001
1069 #define SQLITE_IOCAP_ATOMIC512 0x00000002
1070 #define SQLITE_IOCAP_ATOMIC1K 0x00000004
1071 #define SQLITE_IOCAP_ATOMIC2K 0x00000008
@@ -1300,16 +1297,16 @@
1297 ** opcode as doing so may disrupt the operation of the specialized VFSes
1298 ** that do require it.
1299 **
1300 ** ^The [SQLITE_FCNTL_WIN32_AV_RETRY] opcode is used to configure automatic
1301 ** retry counts and intervals for certain disk I/O operations for the
1302 ** windows [VFS] in order to provide robustness in the presence of
1303 ** anti-virus programs. By default, the windows VFS will retry file read,
1304 ** file write, and file delete operations up to 10 times, with a delay
1305 ** of 25 milliseconds before the first retry and with the delay increasing
1306 ** by an additional 25 milliseconds with each subsequent retry. This
1307 ** opcode allows these two values (10 retries and 25 milliseconds of delay)
1308 ** to be adjusted. The values are changed for all database connections
1309 ** within the same process. The argument is a pointer to an array of two
1310 ** integers where the first integer i the new retry count and the second
1311 ** integer is the delay. If either integer is negative, then the setting
1312 ** is not changed but instead the prior value of that setting is written
@@ -1420,11 +1417,11 @@
1417 ** ^SQLite guarantees that the zFilename parameter to xOpen
1418 ** is either a NULL pointer or string obtained
1419 ** from xFullPathname() with an optional suffix added.
1420 ** ^If a suffix is added to the zFilename parameter, it will
1421 ** consist of a single "-" character followed by no more than
1422 ** 11 alphanumeric and/or "-" characters.
1423 ** ^SQLite further guarantees that
1424 ** the string will be valid and unchanged until xClose() is
1425 ** called. Because of the previous sentence,
1426 ** the [sqlite3_file] can safely store a pointer to the
1427 ** filename if it needs to remember the filename for some reason.
@@ -2571,11 +2568,11 @@
2568 ** These routines all implement some additional formatting
2569 ** options that are useful for constructing SQL statements.
2570 ** All of the usual printf() formatting options apply. In addition, there
2571 ** is are "%q", "%Q", and "%z" options.
2572 **
2573 ** ^(The %q option works like %s in that it substitutes a nul-terminated
2574 ** string from the argument list. But %q also doubles every '\'' character.
2575 ** %q is designed for use inside a string literal.)^ By doubling each '\''
2576 ** character it escapes that character and allows it to be inserted into
2577 ** the string.
2578 **
@@ -4091,11 +4088,11 @@
4088 ** of the string. ^For clarity: the values returned by
4089 ** [sqlite3_column_bytes()] and [sqlite3_column_bytes16()] are the number of
4090 ** bytes in the string, not the number of characters.
4091 **
4092 ** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(),
4093 ** even empty strings, are always zero-terminated. ^The return
4094 ** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.
4095 **
4096 ** ^The object returned by [sqlite3_column_value()] is an
4097 ** [unprotected sqlite3_value] object. An unprotected sqlite3_value object
4098 ** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()].
@@ -5171,11 +5168,11 @@
5168 SQLITE_API int sqlite3_release_memory(int);
5169
5170 /*
5171 ** CAPI3REF: Free Memory Used By A Database Connection
5172 **
5173 ** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap
5174 ** memory as possible from database connection D. Unlike the
5175 ** [sqlite3_release_memory()] interface, this interface is effect even
5176 ** when then [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is
5177 ** omitted.
5178 **
@@ -5954,19 +5951,19 @@
5951 ** is selected automatically at compile-time. ^(The following
5952 ** implementations are available in the SQLite core:
5953 **
5954 ** <ul>
5955 ** <li> SQLITE_MUTEX_OS2
5956 ** <li> SQLITE_MUTEX_PTHREADS
5957 ** <li> SQLITE_MUTEX_W32
5958 ** <li> SQLITE_MUTEX_NOOP
5959 ** </ul>)^
5960 **
5961 ** ^The SQLITE_MUTEX_NOOP implementation is a set of routines
5962 ** that does no real locking and is appropriate for use in
5963 ** a single-threaded application. ^The SQLITE_MUTEX_OS2,
5964 ** SQLITE_MUTEX_PTHREADS, and SQLITE_MUTEX_W32 implementations
5965 ** are appropriate for use on OS/2, Unix, and Windows.
5966 **
5967 ** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor
5968 ** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex
5969 ** implementation is included with the library. In this case the
@@ -6152,11 +6149,11 @@
6149 ** defined and if NDEBUG is not defined.
6150 **
6151 ** ^These routines should return true if the mutex in their argument
6152 ** is held or not held, respectively, by the calling thread.
6153 **
6154 ** ^The implementation is not required to provide versions of these
6155 ** routines that actually work. If the implementation does not provide working
6156 ** versions of these routines, it should at least provide stubs that always
6157 ** return true so that one does not get spurious assertion failures.
6158 **
6159 ** ^If the argument to sqlite3_mutex_held() is a NULL pointer then
@@ -6634,11 +6631,11 @@
6631 **
6632 ** [[the xInit() page cache method]]
6633 ** ^(The xInit() method is called once for each effective
6634 ** call to [sqlite3_initialize()])^
6635 ** (usually only once during the lifetime of the process). ^(The xInit()
6636 ** method is passed a copy of the sqlite3_pcache_methods2.pArg value.)^
6637 ** The intent of the xInit() method is to set up global data structures
6638 ** required by the custom page cache implementation.
6639 ** ^(If the xInit() method is NULL, then the
6640 ** built-in default page cache is used instead of the application defined
6641 ** page cache.)^
@@ -6660,11 +6657,11 @@
6657 **
6658 ** [[the xCreate() page cache methods]]
6659 ** ^SQLite invokes the xCreate() method to construct a new cache instance.
6660 ** SQLite will typically create one cache instance for each open database file,
6661 ** though this is not guaranteed. ^The
6662 ** first parameter, szPage, is the size in bytes of the pages that must
6663 ** be allocated by the cache. ^szPage will always a power of two. ^The
6664 ** second parameter szExtra is a number of bytes of extra storage
6665 ** associated with each page cache entry. ^The szExtra parameter will
6666 ** a number less than 250. SQLite will use the
6667 ** extra szExtra bytes on each page to store metadata about the underlying
@@ -6755,11 +6752,11 @@
6752 **
6753 ** [[the xDestroy() page cache method]]
6754 ** ^The xDestroy() method is used to delete a cache allocated by xCreate().
6755 ** All resources associated with the specified cache should be freed. ^After
6756 ** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*]
6757 ** handle invalid, and will not use it with any other sqlite3_pcache_methods2
6758 ** functions.
6759 **
6760 ** [[the xShrink() page cache method]]
6761 ** ^SQLite invokes the xShrink() method when it wants the page cache to
6762 ** free up as much of heap memory as possible. The page cache implementation
@@ -9266,11 +9263,11 @@
9263
9264 /*
9265 ** The default size of a disk sector
9266 */
9267 #ifndef SQLITE_DEFAULT_SECTOR_SIZE
9268 # define SQLITE_DEFAULT_SECTOR_SIZE 4096
9269 #endif
9270
9271 /*
9272 ** Temporary files are named starting with this prefix followed by 16 random
9273 ** alphanumeric characters, and no file extension. They are stored in the
@@ -13190,11 +13187,11 @@
13187 SQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem*);
13188 SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem*);
13189 SQLITE_PRIVATE int sqlite3VdbeMemFromBtree(BtCursor*,int,int,int,Mem*);
13190 SQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p);
13191 SQLITE_PRIVATE void sqlite3VdbeMemReleaseExternal(Mem *p);
13192 #define VdbeMemRelease(X) \
13193 if((X)->flags&(MEM_Agg|MEM_Dyn|MEM_RowSet|MEM_Frame)) \
13194 sqlite3VdbeMemReleaseExternal(X);
13195 SQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem*, FuncDef*);
13196 SQLITE_PRIVATE const char *sqlite3OpcodeName(int);
13197 SQLITE_PRIVATE int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve);
@@ -13229,11 +13226,11 @@
13226 # define sqlite3VdbeEnter(X)
13227 # define sqlite3VdbeLeave(X)
13228 #endif
13229
13230 #ifdef SQLITE_DEBUG
13231 SQLITE_PRIVATE void sqlite3VdbeMemAboutToChange(Vdbe*,Mem*);
13232 #endif
13233
13234 #ifndef SQLITE_OMIT_FOREIGN_KEY
13235 SQLITE_PRIVATE int sqlite3VdbeCheckFk(Vdbe *, int);
13236 #else
@@ -14762,11 +14759,11 @@
14759 int flags,
14760 int *pFlagsOut
14761 ){
14762 int rc;
14763 DO_OS_MALLOC_TEST(0);
14764 /* 0x87f7f is a mask of SQLITE_OPEN_ flags that are valid to be passed
14765 ** down into the VFS layer. Some SQLITE_OPEN_ flags (for example,
14766 ** SQLITE_OPEN_FULLMUTEX or SQLITE_OPEN_SHAREDCACHE) are blocked before
14767 ** reaching the VFS. */
14768 rc = pVfs->xOpen(pVfs, zPath, pFile, flags & 0x87f7f, pFlagsOut);
14769 assert( rc==SQLITE_OK || pFile->pMethods==0 );
@@ -17316,11 +17313,11 @@
17313 SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex *p){
17314 return p==0 || sqlite3GlobalConfig.mutex.xMutexNotheld(p);
17315 }
17316 #endif
17317
17318 #endif /* !defined(SQLITE_MUTEX_OMIT) */
17319
17320 /************** End of mutex.c ***********************************************/
17321 /************** Begin file mutex_noop.c **************************************/
17322 /*
17323 ** 2008 October 07
@@ -17523,12 +17520,12 @@
17520 */
17521 #ifdef SQLITE_MUTEX_NOOP
17522 SQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void){
17523 return sqlite3NoopMutex();
17524 }
17525 #endif /* defined(SQLITE_MUTEX_NOOP) */
17526 #endif /* !defined(SQLITE_MUTEX_OMIT) */
17527
17528 /************** End of mutex_noop.c ******************************************/
17529 /************** Begin file mutex_os2.c ***************************************/
17530 /*
17531 ** 2007 August 28
@@ -18153,11 +18150,11 @@
18150 };
18151
18152 return &sMutex;
18153 }
18154
18155 #endif /* SQLITE_MUTEX_PTHREADS */
18156
18157 /************** End of mutex_unix.c ******************************************/
18158 /************** Begin file mutex_w32.c ***************************************/
18159 /*
18160 ** 2007 August 14
@@ -22116,26 +22113,31 @@
22113 ** characters of the original suffix.
22114 **
22115 ** If SQLITE_ENABLE_8_3_NAMES is set to 2 at compile-time, then always
22116 ** do the suffix shortening regardless of URI parameter.
22117 **
22118 ** Assume that zBaseFilename contains two \000 terminator bytes (so that
22119 ** it can be harmlessly passed into sqlite3_uri_parameter()) and copy both
22120 ** zero terminator bytes into the end of the revised name.
22121 **
22122 ** Examples:
22123 **
22124 ** test.db-journal => test.nal
22125 ** test.db-wal => test.wal
22126 ** test.db-shm => test.shm
22127 ** test.db-mj7f3319fa => test.9fa
22128 */
22129 SQLITE_PRIVATE void sqlite3FileSuffix3(const char *zBaseFilename, char *z){
22130 assert( zBaseFilename[strlen(zBaseFilename)+1]==0 );
22131 #if SQLITE_ENABLE_8_3_NAMES<2
22132 if( sqlite3_uri_boolean(zBaseFilename, "8_3_names", 0) )
22133 #endif
22134 {
22135 int i, sz;
22136 sz = sqlite3Strlen30(z);
22137 for(i=sz-1; i>0 && z[i]!='/' && z[i]!='.'; i--){}
22138 if( z[i]=='.' && ALWAYS(sz>i+4) ) memmove(&z[i+1], &z[sz-3], 5);
22139 }
22140 }
22141 #endif
22142
22143 /************** End of util.c ************************************************/
@@ -24836,13 +24838,10 @@
24838 #include <sys/time.h>
24839 #include <errno.h>
24840 #ifndef SQLITE_OMIT_WAL
24841 #include <sys/mman.h>
24842 #endif
 
 
 
24843
24844
24845 #if SQLITE_ENABLE_LOCKING_STYLE
24846 # include <sys/ioctl.h>
24847 # if OS_VXWORKS
@@ -24929,11 +24928,10 @@
24928 sqlite3_vfs *pVfs; /* The VFS that created this unixFile */
24929 unixInodeInfo *pInode; /* Info about locks on this inode */
24930 int h; /* The file descriptor */
24931 unsigned char eFileLock; /* The type of lock held on this fd */
24932 unsigned char ctrlFlags; /* Behavioral bits. UNIXFILE_* flags */
 
24933 int lastErrno; /* The unix errno from last I/O error */
24934 void *lockingContext; /* Locking style specific state */
24935 UnixUnusedFd *pUnused; /* Pre-allocated UnixUnusedFd */
24936 const char *zPath; /* Name of the file */
24937 unixShm *pShm; /* Shared memory segment information */
@@ -25342,18 +25340,10 @@
25340 #define osMkdir ((int(*)(const char*,mode_t))aSyscall[18].pCurrent)
25341
25342 { "rmdir", (sqlite3_syscall_ptr)rmdir, 0 },
25343 #define osRmdir ((int(*)(const char*))aSyscall[19].pCurrent)
25344
 
 
 
 
 
 
 
 
25345 }; /* End of the overrideable system calls */
25346
25347 /*
25348 ** This is the xSetSystemCall() method of sqlite3_vfs for all of the
25349 ** "unix" VFSes. Return SQLITE_OK opon successfully updating the
@@ -28504,13 +28494,10 @@
28494 case SQLITE_SET_LOCKPROXYFILE:
28495 case SQLITE_GET_LOCKPROXYFILE: {
28496 return proxyFileControl(id,op,pArg);
28497 }
28498 #endif /* SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__) */
 
 
 
28499 }
28500 return SQLITE_NOTFOUND;
28501 }
28502
28503 /*
@@ -28522,27 +28509,12 @@
28509 ** if two files are created in the same file-system directory (i.e.
28510 ** a database and its journal file) that the sector size will be the
28511 ** same for both.
28512 */
28513 static int unixSectorSize(sqlite3_file *pFile){
28514 (void)pFile;
28515 return SQLITE_DEFAULT_SECTOR_SIZE;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28516 }
28517
28518 /*
28519 ** Return the device characteristics for the file.
28520 **
@@ -28815,13 +28787,13 @@
28787 rc = SQLITE_IOERR_FSTAT;
28788 goto shm_open_err;
28789 }
28790
28791 #ifdef SQLITE_SHM_DIRECTORY
28792 nShmFilename = sizeof(SQLITE_SHM_DIRECTORY) + 31;
28793 #else
28794 nShmFilename = 6 + (int)strlen(pDbFd->zPath);
28795 #endif
28796 pShmNode = sqlite3_malloc( sizeof(*pShmNode) + nShmFilename );
28797 if( pShmNode==0 ){
28798 rc = SQLITE_NOMEM;
28799 goto shm_open_err;
@@ -31755,11 +31727,11 @@
31727 };
31728 unsigned int i; /* Loop counter */
31729
31730 /* Double-check that the aSyscall[] array has been constructed
31731 ** correctly. See ticket [bb3a86e890c8e96ab] */
31732 assert( ArraySize(aSyscall)==20 );
31733
31734 /* Register all VFSes defined in the aVfs[] array */
31735 for(i=0; i<(sizeof(aVfs)/sizeof(sqlite3_vfs)); i++){
31736 sqlite3_vfs_register(&aVfs[i], i==0);
31737 }
@@ -32049,11 +32021,10 @@
32021 HANDLE h; /* Handle for accessing the file */
32022 u8 locktype; /* Type of lock currently held on this file */
32023 short sharedLockByte; /* Randomly chosen byte used as a shared lock */
32024 u8 ctrlFlags; /* Flags. See WINFILE_* below */
32025 DWORD lastErrno; /* The Windows errno from the last I/O error */
 
32026 winShm *pShm; /* Instance of shared memory on this file */
32027 const char *zPath; /* Full pathname of this file */
32028 int szChunk; /* Chunk size configured by FCNTL_CHUNK_SIZE */
32029 #if SQLITE_OS_WINCE
32030 LPWSTR zDeleteOnClose; /* Name of file to delete when closing */
@@ -32139,18 +32110,10 @@
32110 static void winMemShutdown(void *pAppData);
32111
32112 SQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetWin32(void);
32113 #endif /* SQLITE_WIN32_MALLOC */
32114
 
 
 
 
 
 
 
 
32115 /*
32116 ** The following variable is (normally) set once and never changes
32117 ** thereafter. It records whether the operating system is Win9x
32118 ** or WinNT.
32119 **
@@ -34181,13 +34144,10 @@
34144 }
34145 case SQLITE_FCNTL_VFSNAME: {
34146 *(char**)pArg = sqlite3_mprintf("win32");
34147 return SQLITE_OK;
34148 }
 
 
 
34149 case SQLITE_FCNTL_WIN32_AV_RETRY: {
34150 int *a = (int*)pArg;
34151 if( a[0]>0 ){
34152 win32IoerrRetry = a[0];
34153 }else{
@@ -34213,12 +34173,12 @@
34173 ** if two files are created in the same file-system directory (i.e.
34174 ** a database and its journal file) that the sector size will be the
34175 ** same for both.
34176 */
34177 static int winSectorSize(sqlite3_file *id){
34178 (void)id;
34179 return SQLITE_DEFAULT_SECTOR_SIZE;
34180 }
34181
34182 /*
34183 ** Return a vector of device characteristics.
34184 */
@@ -34463,11 +34423,11 @@
34423 */
34424 p = sqlite3_malloc( sizeof(*p) );
34425 if( p==0 ) return SQLITE_IOERR_NOMEM;
34426 memset(p, 0, sizeof(*p));
34427 nName = sqlite3Strlen30(pDbFd->zPath);
34428 pNew = sqlite3_malloc( sizeof(*pShmNode) + nName + 16 );
34429 if( pNew==0 ){
34430 sqlite3_free(p);
34431 return SQLITE_IOERR_NOMEM;
34432 }
34433 memset(pNew, 0, sizeof(*pNew));
@@ -35191,11 +35151,10 @@
35151 pFile->pShm = 0;
35152 pFile->zPath = zName;
35153 if( sqlite3_uri_boolean(zName, "psow", SQLITE_POWERSAFE_OVERWRITE) ){
35154 pFile->ctrlFlags |= WINFILE_PSOW;
35155 }
 
35156
35157 #if SQLITE_OS_WINCE
35158 if( isReadWrite && eType==SQLITE_OPEN_MAIN_DB
35159 && !winceCreateLock(zName, pFile)
35160 ){
@@ -35436,85 +35395,10 @@
35395 return SQLITE_IOERR_NOMEM;
35396 }
35397 #endif
35398 }
35399
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35400 #ifndef SQLITE_OMIT_LOAD_EXTENSION
35401 /*
35402 ** Interfaces for opening a shared library, finding entry points
35403 ** within the shared library, and closing the shared library.
35404 */
@@ -36381,11 +36265,11 @@
36265 */
36266 static int numberOfCachePages(PCache *p){
36267 if( p->szCache>=0 ){
36268 return p->szCache;
36269 }else{
36270 return (int)((-1024*(i64)p->szCache)/(p->szPage+p->szExtra));
36271 }
36272 }
36273
36274 /*
36275 ** Try to obtain a page from the cache.
@@ -36845,14 +36729,14 @@
36729 ** PGroup which is the pcache1.grp global variable and its mutex is
36730 ** SQLITE_MUTEX_STATIC_LRU.
36731 */
36732 struct PGroup {
36733 sqlite3_mutex *mutex; /* MUTEX_STATIC_LRU or NULL */
36734 unsigned int nMaxPage; /* Sum of nMax for purgeable caches */
36735 unsigned int nMinPage; /* Sum of nMin for purgeable caches */
36736 unsigned int mxPinned; /* nMaxpage + 10 - nMinPage */
36737 unsigned int nCurrentPage; /* Number of purgeable pages allocated */
36738 PgHdr1 *pLruHead, *pLruTail; /* LRU list of unpinned pages */
36739 };
36740
36741 /* Each page cache is an instance of the following object. Every
36742 ** open database file (including each in-memory database and each
@@ -37511,11 +37395,11 @@
37395 static sqlite3_pcache_page *pcache1Fetch(
37396 sqlite3_pcache *p,
37397 unsigned int iKey,
37398 int createFlag
37399 ){
37400 unsigned int nPinned;
37401 PCache1 *pCache = (PCache1 *)p;
37402 PGroup *pGroup;
37403 PgHdr1 *pPage = 0;
37404
37405 assert( pCache->bPurgeable || createFlag!=1 );
@@ -37546,17 +37430,17 @@
37430 #ifdef SQLITE_MUTEX_OMIT
37431 pGroup = pCache->pGroup;
37432 #endif
37433
37434 /* Step 3: Abort if createFlag is 1 but the cache is nearly full */
37435 assert( pCache->nPage >= pCache->nRecyclable );
37436 nPinned = pCache->nPage - pCache->nRecyclable;
 
37437 assert( pGroup->mxPinned == pGroup->nMaxPage + 10 - pGroup->nMinPage );
37438 assert( pCache->n90pct == pCache->nMax*9/10 );
37439 if( createFlag==1 && (
37440 nPinned>=pGroup->mxPinned
37441 || nPinned>=pCache->n90pct
37442 || pcache1UnderMemoryPressure(pCache)
37443 )){
37444 goto fetch_out;
37445 }
37446
@@ -37725,11 +37609,13 @@
37609 PCache1 *pCache = (PCache1 *)p;
37610 PGroup *pGroup = pCache->pGroup;
37611 assert( pCache->bPurgeable || (pCache->nMax==0 && pCache->nMin==0) );
37612 pcache1EnterMutex(pGroup);
37613 pcache1TruncateUnsafe(pCache, 0);
37614 assert( pGroup->nMaxPage >= pCache->nMax );
37615 pGroup->nMaxPage -= pCache->nMax;
37616 assert( pGroup->nMinPage >= pCache->nMin );
37617 pGroup->nMinPage -= pCache->nMin;
37618 pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage;
37619 pcache1EnforceMaxPage(pGroup);
37620 pcache1LeaveMutex(pGroup);
37621 sqlite3_free(pCache->apHash);
@@ -37807,12 +37693,12 @@
37693 int nRecyclable = 0;
37694 for(p=pcache1.grp.pLruHead; p; p=p->pLruNext){
37695 nRecyclable++;
37696 }
37697 *pnCurrent = pcache1.grp.nCurrentPage;
37698 *pnMax = (int)pcache1.grp.nMaxPage;
37699 *pnMin = (int)pcache1.grp.nMinPage;
37700 *pnRecyclable = nRecyclable;
37701 }
37702 #endif
37703
37704 /************** End of pcache1.c *********************************************/
@@ -38282,10 +38168,16 @@
38168
38169 #ifndef _WAL_H_
38170 #define _WAL_H_
38171
38172
38173 /* Additional values that can be added to the sync_flags argument of
38174 ** sqlite3WalFrames():
38175 */
38176 #define WAL_SYNC_TRANSACTIONS 0x20 /* Sync at the end of each transaction */
38177 #define SQLITE_SYNC_MASK 0x13 /* Mask off the SQLITE_SYNC_* values */
38178
38179 #ifdef SQLITE_OMIT_WAL
38180 # define sqlite3WalOpen(x,y,z) 0
38181 # define sqlite3WalLimit(x,y)
38182 # define sqlite3WalClose(w,x,y,z) 0
38183 # define sqlite3WalBeginReadTransaction(y,z) 0
@@ -38350,16 +38242,10 @@
38242 SQLITE_PRIVATE int sqlite3WalSavepointUndo(Wal *pWal, u32 *aWalData);
38243
38244 /* Write a frame or frames to the log. */
38245 SQLITE_PRIVATE int sqlite3WalFrames(Wal *pWal, int, PgHdr *, Pgno, int, int);
38246
 
 
 
 
 
 
38247 /* Copy pages from the log to the database file */
38248 SQLITE_PRIVATE int sqlite3WalCheckpoint(
38249 Wal *pWal, /* Write-ahead log connection */
38250 int eMode, /* One of PASSIVE, FULL and RESTART */
38251 int (*xBusy)(void*), /* Function to call when busy */
@@ -42400,11 +42286,13 @@
42286 ** file size will be.
42287 */
42288 assert( rc!=SQLITE_OK || isOpen(pPager->fd) );
42289 if( rc==SQLITE_OK && pPager->dbSize>pPager->dbHintSize ){
42290 sqlite3_int64 szFile = pPager->pageSize * (sqlite3_int64)pPager->dbSize;
42291 sqlite3BeginBenignMalloc();
42292 sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_SIZE_HINT, &szFile);
42293 sqlite3EndBenignMalloc();
42294 pPager->dbHintSize = pPager->dbSize;
42295 }
42296
42297 while( rc==SQLITE_OK && pList ){
42298 Pgno pgno = pList->pgno;
@@ -42741,11 +42629,12 @@
42629 z = zUri = &zFilename[sqlite3Strlen30(zFilename)+1];
42630 while( *z ){
42631 z += sqlite3Strlen30(z)+1;
42632 z += sqlite3Strlen30(z)+1;
42633 }
42634 nUri = (int)(&z[1] - zUri);
42635 assert( nUri>=0 );
42636 if( rc==SQLITE_OK && nPathname+8>pVfs->mxPathname ){
42637 /* This branch is taken when the journal path required by
42638 ** the database being opened will be more than pVfs->mxPathname
42639 ** bytes in length. This means the database cannot be opened,
42640 ** as it will not be possible to open the journal file or even
@@ -42775,13 +42664,13 @@
42664 ROUND8(sizeof(*pPager)) + /* Pager structure */
42665 ROUND8(pcacheSize) + /* PCache object */
42666 ROUND8(pVfs->szOsFile) + /* The main db file */
42667 journalFileSize * 2 + /* The two journal files */
42668 nPathname + 1 + nUri + /* zFilename */
42669 nPathname + 8 + 2 /* zJournal */
42670 #ifndef SQLITE_OMIT_WAL
42671 + nPathname + 4 + 2 /* zWal */
42672 #endif
42673 );
42674 assert( EIGHT_BYTE_ALIGNMENT(SQLITE_INT_TO_PTR(journalFileSize)) );
42675 if( !pPtr ){
42676 sqlite3_free(zPathname);
@@ -42800,16 +42689,16 @@
42689 assert( nPathname>0 );
42690 pPager->zJournal = (char*)(pPtr += nPathname + 1 + nUri);
42691 memcpy(pPager->zFilename, zPathname, nPathname);
42692 memcpy(&pPager->zFilename[nPathname+1], zUri, nUri);
42693 memcpy(pPager->zJournal, zPathname, nPathname);
42694 memcpy(&pPager->zJournal[nPathname], "-journal\000", 8+1);
42695 sqlite3FileSuffix3(pPager->zFilename, pPager->zJournal);
42696 #ifndef SQLITE_OMIT_WAL
42697 pPager->zWal = &pPager->zJournal[nPathname+8+1];
42698 memcpy(pPager->zWal, zPathname, nPathname);
42699 memcpy(&pPager->zWal[nPathname], "-wal\000", 4+1);
42700 sqlite3FileSuffix3(pPager->zFilename, pPager->zWal);
42701 #endif
42702 sqlite3_free(zPathname);
42703 }
42704 pPager->pVfs = pVfs;
@@ -44064,11 +43953,14 @@
43953 if( !pPager->noSync ){
43954 assert( !MEMDB );
43955 rc = sqlite3OsSync(pPager->fd, pPager->syncFlags);
43956 }else if( isOpen(pPager->fd) ){
43957 assert( !MEMDB );
43958 rc = sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_SYNC_OMITTED, 0);
43959 if( rc==SQLITE_NOTFOUND ){
43960 rc = SQLITE_OK;
43961 }
43962 }
43963 return rc;
43964 }
43965
43966 /*
@@ -48125,11 +48017,11 @@
48017 iFrame = pWal->hdr.mxFrame;
48018 for(p=pList; p && rc==SQLITE_OK; p=p->pDirty){
48019 iFrame++;
48020 rc = walIndexAppend(pWal, iFrame, p->pgno);
48021 }
48022 while( rc==SQLITE_OK && nExtra>0 ){
48023 iFrame++;
48024 nExtra--;
48025 rc = walIndexAppend(pWal, iFrame, pLast->pgno);
48026 }
48027
@@ -48726,11 +48618,11 @@
48618 #define TRANS_WRITE 2
48619
48620 /*
48621 ** An instance of this object represents a single database file.
48622 **
48623 ** A single database file can be in use at the same time by two
48624 ** or more database connections. When two or more connections are
48625 ** sharing the same database file, each connection has it own
48626 ** private Btree object for the file and each of those Btrees points
48627 ** to this one BtShared object. BtShared.nRef is the number of
48628 ** connections currently sharing this database file.
@@ -48832,11 +48724,11 @@
48724 ** b-tree within a database file.
48725 **
48726 ** The entry is identified by its MemPage and the index in
48727 ** MemPage.aCell[] of the entry.
48728 **
48729 ** A single database file can be shared by two more database connections,
48730 ** but cursors cannot be shared. Each cursor is associated with a
48731 ** particular database connection identified BtCursor.pBtree.db.
48732 **
48733 ** Fields in this structure are accessed under the BtShared.mutex
48734 ** found at self->pBt->mutex.
@@ -48993,11 +48885,11 @@
48885 int mallocFailed; /* A memory allocation error has occurred */
48886 StrAccum errMsg; /* Accumulate the error message text here */
48887 };
48888
48889 /*
48890 ** Routines to read or write a two- and four-byte big-endian integer values.
48891 */
48892 #define get2byte(x) ((x)[0]<<8 | (x)[1])
48893 #define put2byte(p,v) ((p)[0] = (u8)((v)>>8), (p)[1] = (u8)(v))
48894 #define get4byte sqlite3Get4byte
48895 #define put4byte sqlite3Put4byte
@@ -55478,12 +55370,18 @@
55370 }
55371
55372 /* Either we found one or more cells (cntnew[0])>0) or pPage is
55373 ** a virtual root page. A virtual root page is when the real root
55374 ** page is page 1 and we are the only child of that page.
55375 **
55376 ** UPDATE: The assert() below is not necessarily true if the database
55377 ** file is corrupt. The corruption will be detected and reported later
55378 ** in this procedure so there is no need to act upon it now.
55379 */
55380 #if 0
55381 assert( cntNew[0]>0 || (pParent->pgno==1 && pParent->nCell==0) );
55382 #endif
55383
55384 TRACE(("BALANCE: old: %d %d %d ",
55385 apOld[0]->pgno,
55386 nOld>=2 ? apOld[1]->pgno : 0,
55387 nOld>=3 ? apOld[2]->pgno : 0
@@ -58194,11 +58092,13 @@
58092
58093 assert( sqlite3BtreeIsInTrans(pTo) );
58094 pFd = sqlite3PagerFile(sqlite3BtreePager(pTo));
58095 if( pFd->pMethods ){
58096 i64 nByte = sqlite3BtreeGetPageSize(pFrom)*(i64)sqlite3BtreeLastPage(pFrom);
58097 sqlite3BeginBenignMalloc();
58098 sqlite3OsFileControl(pFd, SQLITE_FCNTL_OVERWRITE, &nByte);
58099 sqlite3EndBenignMalloc();
58100 }
58101
58102 /* Set up an sqlite3_backup object. sqlite3_backup.pDestDb must be set
58103 ** to 0. This is used by the implementations of sqlite3_backup_step()
58104 ** and sqlite3_backup_finish() to detect that they are being called
@@ -58525,11 +58425,11 @@
58425 ** Release any memory held by the Mem. This may leave the Mem in an
58426 ** inconsistent state, for example with (Mem.z==0) and
58427 ** (Mem.type==SQLITE_TEXT).
58428 */
58429 SQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p){
58430 VdbeMemRelease(p);
58431 sqlite3DbFree(p->db, p->zMalloc);
58432 p->z = 0;
58433 p->zMalloc = 0;
58434 p->xDel = 0;
58435 }
@@ -58821,11 +58721,11 @@
58721 ** copies of this cell as invalid.
58722 **
58723 ** This is used for testing and debugging only - to make sure shallow
58724 ** copies are not misused.
58725 */
58726 SQLITE_PRIVATE void sqlite3VdbeMemAboutToChange(Vdbe *pVdbe, Mem *pMem){
58727 int i;
58728 Mem *pX;
58729 for(i=1, pX=&pVdbe->aMem[1]; i<=pVdbe->nMem; i++, pX++){
58730 if( pX->pScopyFrom==pMem ){
58731 pX->flags |= MEM_Invalid;
@@ -58847,11 +58747,11 @@
58747 ** pFrom->z is used, then pTo->z points to the same thing as pFrom->z
58748 ** and flags gets srcType (either MEM_Ephem or MEM_Static).
58749 */
58750 SQLITE_PRIVATE void sqlite3VdbeMemShallowCopy(Mem *pTo, const Mem *pFrom, int srcType){
58751 assert( (pFrom->flags & MEM_RowSet)==0 );
58752 VdbeMemRelease(pTo);
58753 memcpy(pTo, pFrom, MEMCELLSIZE);
58754 pTo->xDel = 0;
58755 if( (pFrom->flags&MEM_Static)==0 ){
58756 pTo->flags &= ~(MEM_Dyn|MEM_Static|MEM_Ephem);
58757 assert( srcType==MEM_Ephem || srcType==MEM_Static );
@@ -58865,11 +58765,11 @@
58765 */
58766 SQLITE_PRIVATE int sqlite3VdbeMemCopy(Mem *pTo, const Mem *pFrom){
58767 int rc = SQLITE_OK;
58768
58769 assert( (pFrom->flags & MEM_RowSet)==0 );
58770 VdbeMemRelease(pTo);
58771 memcpy(pTo, pFrom, MEMCELLSIZE);
58772 pTo->flags &= ~MEM_Dyn;
58773
58774 if( pTo->flags&(MEM_Str|MEM_Blob) ){
58775 if( 0==(pFrom->flags&MEM_Static) ){
@@ -59202,11 +59102,11 @@
59102 assert( (pVal->flags & (MEM_Ephem|MEM_Static))!=0 );
59103 if( sqlite3VdbeMemMakeWriteable(pVal)!=SQLITE_OK ){
59104 return 0;
59105 }
59106 }
59107 sqlite3VdbeMemNulTerminate(pVal); /* IMP: R-31275-44060 */
59108 }else{
59109 assert( (pVal->flags&MEM_Blob)==0 );
59110 sqlite3VdbeMemStringify(pVal, enc);
59111 assert( 0==(1&SQLITE_PTR_TO_INT(pVal->z)) );
59112 }
@@ -59583,11 +59483,12 @@
59483 return addr;
59484 }
59485
59486 /*
59487 ** Add an OP_ParseSchema opcode. This routine is broken out from
59488 ** sqlite3VdbeAddOp4() since it needs to also needs to mark all btrees
59489 ** as having been used.
59490 **
59491 ** The zWhere string must have been obtained from sqlite3_malloc().
59492 ** This routine will take ownership of the allocated memory.
59493 */
59494 SQLITE_PRIVATE void sqlite3VdbeAddParseSchemaOp(Vdbe *p, int iDb, char *zWhere){
@@ -60350,12 +60251,13 @@
60251
60252 /*
60253 ** Declare to the Vdbe that the BTree object at db->aDb[i] is used.
60254 **
60255 ** The prepared statements need to know in advance the complete set of
60256 ** attached databases that will be use. A mask of these databases
60257 ** is maintained in p->btreeMask. The p->lockMask value is the subset of
60258 ** p->btreeMask of databases that will require a lock.
60259 */
60260 SQLITE_PRIVATE void sqlite3VdbeUsesBtree(Vdbe *p, int i){
60261 assert( i>=0 && i<p->db->nDb && i<(int)sizeof(yDbMask)*8 );
60262 assert( i<(int)sizeof(p->btreeMask)*8 );
60263 p->btreeMask |= ((yDbMask)1)<<i;
@@ -60874,10 +60776,11 @@
60776 nVar = pParse->nVar;
60777 nMem = pParse->nMem;
60778 nCursor = pParse->nTab;
60779 nArg = pParse->nMaxArg;
60780 nOnce = pParse->nOnce;
60781 if( nOnce==0 ) nOnce = 1; /* Ensure at least one byte in p->aOnceFlag[] */
60782
60783 /* For each cursor required, also allocate a memory cell. Memory
60784 ** cells (nMem+1-nCursor)..nMem, inclusive, will never be used by
60785 ** the vdbe program. Instead they are used to allocate space for
60786 ** VdbeCursor/BtCursor structures. The blob of memory associated with
@@ -61225,11 +61128,11 @@
61128 int retryCount = 0;
61129 int nMainFile;
61130
61131 /* Select a master journal file name */
61132 nMainFile = sqlite3Strlen30(zMainFile);
61133 zMaster = sqlite3MPrintf(db, "%s-mjXXXXXX9XXz", zMainFile);
61134 if( zMaster==0 ) return SQLITE_NOMEM;
61135 do {
61136 u32 iRandom;
61137 if( retryCount ){
61138 if( retryCount>100 ){
@@ -63013,11 +62916,11 @@
62916 ** since any application that receives an SQLITE_MISUSE is broken by
62917 ** definition.
62918 **
62919 ** Nevertheless, some published applications that were originally written
62920 ** for version 3.6.23 or earlier do in fact depend on SQLITE_MISUSE
62921 ** returns, and those were broken by the automatic-reset change. As a
62922 ** a work-around, the SQLITE_OMIT_AUTORESET compile-time restores the
62923 ** legacy behavior of returning SQLITE_MISUSE for cases where the
62924 ** previous sqlite3_step() returned something other than a SQLITE_LOCKED
62925 ** or SQLITE_BUSY error.
62926 */
@@ -63359,17 +63262,17 @@
63262 pOut = &pVm->pResultSet[i];
63263 }else{
63264 /* If the value passed as the second argument is out of range, return
63265 ** a pointer to the following static Mem object which contains the
63266 ** value SQL NULL. Even though the Mem structure contains an element
63267 ** of type i64, on certain architectures (x86) with certain compiler
63268 ** switches (-Os), gcc may align this Mem object on a 4-byte boundary
63269 ** instead of an 8-byte one. This all works fine, except that when
63270 ** running with SQLITE_DEBUG defined the SQLite code sometimes assert()s
63271 ** that a Mem structure is located on an 8-byte boundary. To prevent
63272 ** these assert()s from failing, when building with SQLITE_DEBUG defined
63273 ** using gcc, we force nullMem to be 8-byte aligned using the magical
63274 ** __attribute__((aligned(8))) macro. */
63275 static const Mem nullMem
63276 #if defined(SQLITE_DEBUG) && defined(__GNUC__)
63277 __attribute__((aligned(8)))
63278 #endif
@@ -64298,11 +64201,11 @@
64201 ** Invoke this macro on memory cells just prior to changing the
64202 ** value of the cell. This macro verifies that shallow copies are
64203 ** not misused.
64204 */
64205 #ifdef SQLITE_DEBUG
64206 # define memAboutToChange(P,M) sqlite3VdbeMemAboutToChange(P,M)
64207 #else
64208 # define memAboutToChange(P,M)
64209 #endif
64210
64211 /*
@@ -64316,12 +64219,12 @@
64219 SQLITE_API int sqlite3_search_count = 0;
64220 #endif
64221
64222 /*
64223 ** When this global variable is positive, it gets decremented once before
64224 ** each instruction in the VDBE. When it reaches zero, the u1.isInterrupted
64225 ** field of the sqlite3 structure is set in order to simulate an interrupt.
64226 **
64227 ** This facility is used for testing purposes only. It does not function
64228 ** in an ordinary build.
64229 */
64230 #ifdef SQLITE_TEST
@@ -64442,11 +64345,11 @@
64345 */
64346 static VdbeCursor *allocateCursor(
64347 Vdbe *p, /* The virtual machine */
64348 int iCur, /* Index of the new VdbeCursor */
64349 int nField, /* Number of fields in the table or index */
64350 int iDb, /* Database the cursor belongs to, or -1 */
64351 int isBtreeCursor /* True for B-Tree. False for pseudo-table or vtab */
64352 ){
64353 /* Find the memory cell that will be used to store the blob of memory
64354 ** required for this VdbeCursor structure. It is convenient to use a
64355 ** vdbe memory cell to manage the memory allocation required for a
@@ -64813,11 +64716,11 @@
64716 ** sqlite3_interrupt() routine has been called. If it has been, then
64717 ** processing of the VDBE program is interrupted.
64718 **
64719 ** This macro added to every instruction that does a jump in order to
64720 ** implement a loop. This test used to be on every single instruction,
64721 ** but that meant we more testing than we needed. By only testing the
64722 ** flag on jump instructions, we get a (small) speed improvement.
64723 */
64724 #define CHECK_FOR_INTERRUPT \
64725 if( db->u1.isInterrupted ) goto abort_due_to_interrupt;
64726
@@ -65430,11 +65333,11 @@
65333 if( pOp->opflags & OPFLG_OUT2_PRERELEASE ){
65334 assert( pOp->p2>0 );
65335 assert( pOp->p2<=p->nMem );
65336 pOut = &aMem[pOp->p2];
65337 memAboutToChange(p, pOut);
65338 VdbeMemRelease(pOut);
65339 pOut->flags = MEM_Int;
65340 }
65341
65342 /* Sanity checking on other operands */
65343 #ifdef SQLITE_DEBUG
@@ -65738,11 +65641,11 @@
65641 assert( pOp->p3<=p->nMem );
65642 pOut->flags = MEM_Null;
65643 while( u.ab.cnt>0 ){
65644 pOut++;
65645 memAboutToChange(p, pOut);
65646 VdbeMemRelease(pOut);
65647 pOut->flags = MEM_Null;
65648 u.ab.cnt--;
65649 }
65650 break;
65651 }
@@ -65919,11 +65822,11 @@
65822 /* Invalidate all ephemeral cursor row caches */
65823 p->cacheCtr = (p->cacheCtr + 2)|1;
65824
65825 /* Make sure the results of the current row are \000 terminated
65826 ** and have an assigned type. The results are de-ephemeralized as
65827 ** a side effect.
65828 */
65829 u.ae.pMem = p->pResultSet = &aMem[pOp->p1];
65830 for(u.ae.i=0; u.ae.i<pOp->p2; u.ae.i++){
65831 assert( memIsValid(&u.ae.pMem[u.ae.i]) );
65832 Deephemeralize(&u.ae.pMem[u.ae.i]);
@@ -67160,11 +67063,11 @@
67063 ** a pointer to a Mem object.
67064 */
67065 if( u.an.aOffset[u.an.p2] ){
67066 assert( rc==SQLITE_OK );
67067 if( u.an.zRec ){
67068 VdbeMemRelease(u.an.pDest);
67069 sqlite3VdbeSerialGet((u8 *)&u.an.zRec[u.an.aOffset[u.an.p2]], u.an.aType[u.an.p2], u.an.pDest);
67070 }else{
67071 u.an.len = sqlite3VdbeSerialTypeLen(u.an.aType[u.an.p2]);
67072 sqlite3VdbeMemMove(&u.an.sMem, u.an.pDest);
67073 rc = sqlite3VdbeMemFromBtree(u.an.pCrsr, u.an.aOffset[u.an.p2], u.an.len, u.an.pC->isIndex, &u.an.sMem);
@@ -83758,11 +83661,11 @@
83661 ** Allocate the index structure.
83662 */
83663 nName = sqlite3Strlen30(zName);
83664 nCol = pList->nExpr;
83665 pIndex = sqlite3DbMallocZero(db,
83666 ROUND8(sizeof(Index)) + /* Index structure */
83667 ROUND8(sizeof(tRowcnt)*(nCol+1)) + /* Index.aiRowEst */
83668 sizeof(char *)*nCol + /* Index.azColl */
83669 sizeof(int)*nCol + /* Index.aiColumn */
83670 sizeof(u8)*nCol + /* Index.aSortOrder */
83671 nName + 1 + /* Index.zName */
@@ -83769,11 +83672,12 @@
83672 nExtra /* Collation sequence names */
83673 );
83674 if( db->mallocFailed ){
83675 goto exit_create_index;
83676 }
83677 zExtra = (char*)pIndex;
83678 pIndex->aiRowEst = (tRowcnt*)&zExtra[ROUND8(sizeof(Index))];
83679 pIndex->azColl = (char**)
83680 ((char*)pIndex->aiRowEst + ROUND8(sizeof(tRowcnt)*nCol+1));
83681 assert( EIGHT_BYTE_ALIGNMENT(pIndex->aiRowEst) );
83682 assert( EIGHT_BYTE_ALIGNMENT(pIndex->azColl) );
83683 pIndex->aiColumn = (int *)(&pIndex->azColl[nCol]);
@@ -89966,11 +89870,11 @@
89870 ** any ABORT Back out changes from the current command
89871 ** only (do not do a complete rollback) then
89872 ** cause sqlite3_exec() to return immediately
89873 ** with SQLITE_CONSTRAINT.
89874 **
89875 ** any FAIL Sqlite3_exec() returns immediately with a
89876 ** return code of SQLITE_CONSTRAINT. The
89877 ** transaction is not rolled back and any
89878 ** prior changes are retained.
89879 **
89880 ** any IGNORE The record number and data is popped from
@@ -111450,11 +111354,11 @@
111354 *tokenType = TK_SPACE;
111355 return i;
111356 }
111357 case '-': {
111358 if( z[1]=='-' ){
111359 /* IMP: R-50417-27976 -- syntax diagram for comments */
111360 for(i=2; (c=z[i])!=0 && c!='\n'; i++){}
111361 *tokenType = TK_SPACE; /* IMP: R-22934-25134 */
111362 return i;
111363 }
111364 *tokenType = TK_MINUS;
@@ -111483,11 +111387,11 @@
111387 case '/': {
111388 if( z[1]!='*' || z[2]==0 ){
111389 *tokenType = TK_SLASH;
111390 return 1;
111391 }
111392 /* IMP: R-50417-27976 -- syntax diagram for comments */
111393 for(i=3, c=z[2]; (c!='*' || z[i]!='/') && (c=z[i])!=0; i++){}
111394 if( c ) i++;
111395 *tokenType = TK_SPACE; /* IMP: R-22934-25134 */
111396 return i;
111397 }
@@ -112277,12 +112181,12 @@
112181 /* IMPLEMENTATION-OF: R-35210-63508 The sqlite3_libversion_number() function
112182 ** returns an integer equal to SQLITE_VERSION_NUMBER.
112183 */
112184 SQLITE_API int sqlite3_libversion_number(void){ return SQLITE_VERSION_NUMBER; }
112185
112186 /* IMPLEMENTATION-OF: R-20790-14025 The sqlite3_threadsafe() function returns
112187 ** zero if and only if SQLite was compiled with mutexing code omitted due to
112188 ** the SQLITE_THREADSAFE compile-time option being set to 0.
112189 */
112190 SQLITE_API int sqlite3_threadsafe(void){ return SQLITE_THREADSAFE; }
112191
112192 #if !defined(SQLITE_OMIT_TRACE) && defined(SQLITE_ENABLE_IOTRACE)
@@ -112768,19 +112672,21 @@
112672 ** Free up as much memory as we can from the given database
112673 ** connection.
112674 */
112675 SQLITE_API int sqlite3_db_release_memory(sqlite3 *db){
112676 int i;
112677 sqlite3_mutex_enter(db->mutex);
112678 sqlite3BtreeEnterAll(db);
112679 for(i=0; i<db->nDb; i++){
112680 Btree *pBt = db->aDb[i].pBt;
112681 if( pBt ){
112682 Pager *pPager = sqlite3BtreePager(pBt);
112683 sqlite3PagerShrink(pPager);
112684 }
112685 }
112686 sqlite3BtreeLeaveAll(db);
112687 sqlite3_mutex_leave(db->mutex);
112688 return SQLITE_OK;
112689 }
112690
112691 /*
112692 ** Configuration settings for an individual database connection
112693
+19 -22
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107107
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108108
** [sqlite_version()] and [sqlite_source_id()].
109109
*/
110110
#define SQLITE_VERSION "3.7.10"
111111
#define SQLITE_VERSION_NUMBER 3007010
112
-#define SQLITE_SOURCE_ID "2011-12-23 13:32:07 1f24ae716df6232de768e245ea990049deee3c22"
112
+#define SQLITE_SOURCE_ID "2012-01-05 12:38:02 1378f905d37544701776d38987fe7a312b255983"
113113
114114
/*
115115
** CAPI3REF: Run-Time Library Version Numbers
116116
** KEYWORDS: sqlite3_version, sqlite3_sourceid
117117
**
@@ -175,11 +175,11 @@
175175
176176
/*
177177
** CAPI3REF: Test To See If The Library Is Threadsafe
178178
**
179179
** ^The sqlite3_threadsafe() function returns zero if and only if
180
-** SQLite was compiled mutexing code omitted due to the
180
+** SQLite was compiled with mutexing code omitted due to the
181181
** [SQLITE_THREADSAFE] compile-time option being set to 0.
182182
**
183183
** SQLite can be compiled with or without mutexes. When
184184
** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes
185185
** are enabled and SQLite is threadsafe. When the
@@ -369,11 +369,11 @@
369369
** CAPI3REF: Result Codes
370370
** KEYWORDS: SQLITE_OK {error code} {error codes}
371371
** KEYWORDS: {result code} {result codes}
372372
**
373373
** Many SQLite functions return an integer result code from the set shown
374
-** here in order to indicates success or failure.
374
+** here in order to indicate success or failure.
375375
**
376376
** New error codes may be added in future versions of SQLite.
377377
**
378378
** See also: [SQLITE_IOERR_READ | extended result codes],
379379
** [sqlite3_vtab_on_conflict()] [SQLITE_ROLLBACK | result codes].
@@ -508,17 +508,14 @@
508508
** that when data is appended to a file, the data is appended
509509
** first then the size of the file is extended, never the other
510510
** way around. The SQLITE_IOCAP_SEQUENTIAL property means that
511511
** information is written to disk in the same order as calls
512512
** to xWrite(). The SQLITE_IOCAP_POWERSAFE_OVERWRITE property means that
513
-** after reboot following a crash or power loss, the value of
514
-** each byte in a file is a value that was actually written
515
-** into that byte at some point. In other words, a crash will
516
-** not cause unwritten bytes of the file to change nor introduce
517
-** randomness into a file nor zero out parts of the file, and any byte of
518
-** a file that are never written will not change values due to
519
-** writes to nearby bytes.
513
+** after reboot following a crash or power loss, the only bytes in a
514
+** file that were written at the application level might have changed
515
+** and that adjacent bytes, even bytes within the same sector are
516
+** guaranteed to be unchanged.
520517
*/
521518
#define SQLITE_IOCAP_ATOMIC 0x00000001
522519
#define SQLITE_IOCAP_ATOMIC512 0x00000002
523520
#define SQLITE_IOCAP_ATOMIC1K 0x00000004
524521
#define SQLITE_IOCAP_ATOMIC2K 0x00000008
@@ -750,16 +747,16 @@
750747
** opcode as doing so may disrupt the operation of the specialized VFSes
751748
** that do require it.
752749
**
753750
** ^The [SQLITE_FCNTL_WIN32_AV_RETRY] opcode is used to configure automatic
754751
** retry counts and intervals for certain disk I/O operations for the
755
-** windows [VFS] in order to work to provide robustness against
752
+** windows [VFS] in order to provide robustness in the presence of
756753
** anti-virus programs. By default, the windows VFS will retry file read,
757754
** file write, and file delete operations up to 10 times, with a delay
758755
** of 25 milliseconds before the first retry and with the delay increasing
759756
** by an additional 25 milliseconds with each subsequent retry. This
760
-** opcode allows those to values (10 retries and 25 milliseconds of delay)
757
+** opcode allows these two values (10 retries and 25 milliseconds of delay)
761758
** to be adjusted. The values are changed for all database connections
762759
** within the same process. The argument is a pointer to an array of two
763760
** integers where the first integer i the new retry count and the second
764761
** integer is the delay. If either integer is negative, then the setting
765762
** is not changed but instead the prior value of that setting is written
@@ -870,11 +867,11 @@
870867
** ^SQLite guarantees that the zFilename parameter to xOpen
871868
** is either a NULL pointer or string obtained
872869
** from xFullPathname() with an optional suffix added.
873870
** ^If a suffix is added to the zFilename parameter, it will
874871
** consist of a single "-" character followed by no more than
875
-** 10 alphanumeric and/or "-" characters.
872
+** 11 alphanumeric and/or "-" characters.
876873
** ^SQLite further guarantees that
877874
** the string will be valid and unchanged until xClose() is
878875
** called. Because of the previous sentence,
879876
** the [sqlite3_file] can safely store a pointer to the
880877
** filename if it needs to remember the filename for some reason.
@@ -2021,11 +2018,11 @@
20212018
** These routines all implement some additional formatting
20222019
** options that are useful for constructing SQL statements.
20232020
** All of the usual printf() formatting options apply. In addition, there
20242021
** is are "%q", "%Q", and "%z" options.
20252022
**
2026
-** ^(The %q option works like %s in that it substitutes a null-terminated
2023
+** ^(The %q option works like %s in that it substitutes a nul-terminated
20272024
** string from the argument list. But %q also doubles every '\'' character.
20282025
** %q is designed for use inside a string literal.)^ By doubling each '\''
20292026
** character it escapes that character and allows it to be inserted into
20302027
** the string.
20312028
**
@@ -3541,11 +3538,11 @@
35413538
** of the string. ^For clarity: the values returned by
35423539
** [sqlite3_column_bytes()] and [sqlite3_column_bytes16()] are the number of
35433540
** bytes in the string, not the number of characters.
35443541
**
35453542
** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(),
3546
-** even empty strings, are always zero terminated. ^The return
3543
+** even empty strings, are always zero-terminated. ^The return
35473544
** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.
35483545
**
35493546
** ^The object returned by [sqlite3_column_value()] is an
35503547
** [unprotected sqlite3_value] object. An unprotected sqlite3_value object
35513548
** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()].
@@ -4621,11 +4618,11 @@
46214618
SQLITE_API int sqlite3_release_memory(int);
46224619
46234620
/*
46244621
** CAPI3REF: Free Memory Used By A Database Connection
46254622
**
4626
-** ^The sqlite3_db_shrink(D) interface attempts to free as much heap
4623
+** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap
46274624
** memory as possible from database connection D. Unlike the
46284625
** [sqlite3_release_memory()] interface, this interface is effect even
46294626
** when then [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is
46304627
** omitted.
46314628
**
@@ -5404,19 +5401,19 @@
54045401
** is selected automatically at compile-time. ^(The following
54055402
** implementations are available in the SQLite core:
54065403
**
54075404
** <ul>
54085405
** <li> SQLITE_MUTEX_OS2
5409
-** <li> SQLITE_MUTEX_PTHREAD
5406
+** <li> SQLITE_MUTEX_PTHREADS
54105407
** <li> SQLITE_MUTEX_W32
54115408
** <li> SQLITE_MUTEX_NOOP
54125409
** </ul>)^
54135410
**
54145411
** ^The SQLITE_MUTEX_NOOP implementation is a set of routines
54155412
** that does no real locking and is appropriate for use in
54165413
** a single-threaded application. ^The SQLITE_MUTEX_OS2,
5417
-** SQLITE_MUTEX_PTHREAD, and SQLITE_MUTEX_W32 implementations
5414
+** SQLITE_MUTEX_PTHREADS, and SQLITE_MUTEX_W32 implementations
54185415
** are appropriate for use on OS/2, Unix, and Windows.
54195416
**
54205417
** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor
54215418
** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex
54225419
** implementation is included with the library. In this case the
@@ -5602,11 +5599,11 @@
56025599
** defined and if NDEBUG is not defined.
56035600
**
56045601
** ^These routines should return true if the mutex in their argument
56055602
** is held or not held, respectively, by the calling thread.
56065603
**
5607
-** ^The implementation is not required to provided versions of these
5604
+** ^The implementation is not required to provide versions of these
56085605
** routines that actually work. If the implementation does not provide working
56095606
** versions of these routines, it should at least provide stubs that always
56105607
** return true so that one does not get spurious assertion failures.
56115608
**
56125609
** ^If the argument to sqlite3_mutex_held() is a NULL pointer then
@@ -6084,11 +6081,11 @@
60846081
**
60856082
** [[the xInit() page cache method]]
60866083
** ^(The xInit() method is called once for each effective
60876084
** call to [sqlite3_initialize()])^
60886085
** (usually only once during the lifetime of the process). ^(The xInit()
6089
-** method is passed a copy of the sqlite3_pcache_methods.pArg value.)^
6086
+** method is passed a copy of the sqlite3_pcache_methods2.pArg value.)^
60906087
** The intent of the xInit() method is to set up global data structures
60916088
** required by the custom page cache implementation.
60926089
** ^(If the xInit() method is NULL, then the
60936090
** built-in default page cache is used instead of the application defined
60946091
** page cache.)^
@@ -6110,11 +6107,11 @@
61106107
**
61116108
** [[the xCreate() page cache methods]]
61126109
** ^SQLite invokes the xCreate() method to construct a new cache instance.
61136110
** SQLite will typically create one cache instance for each open database file,
61146111
** though this is not guaranteed. ^The
6115
-** parameter parameter, szPage, is the size in bytes of the pages that must
6112
+** first parameter, szPage, is the size in bytes of the pages that must
61166113
** be allocated by the cache. ^szPage will always a power of two. ^The
61176114
** second parameter szExtra is a number of bytes of extra storage
61186115
** associated with each page cache entry. ^The szExtra parameter will
61196116
** a number less than 250. SQLite will use the
61206117
** extra szExtra bytes on each page to store metadata about the underlying
@@ -6205,11 +6202,11 @@
62056202
**
62066203
** [[the xDestroy() page cache method]]
62076204
** ^The xDestroy() method is used to delete a cache allocated by xCreate().
62086205
** All resources associated with the specified cache should be freed. ^After
62096206
** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*]
6210
-** handle invalid, and will not use it with any other sqlite3_pcache_methods
6207
+** handle invalid, and will not use it with any other sqlite3_pcache_methods2
62116208
** functions.
62126209
**
62136210
** [[the xShrink() page cache method]]
62146211
** ^SQLite invokes the xShrink() method when it wants the page cache to
62156212
** free up as much of heap memory as possible. The page cache implementation
62166213
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.7.10"
111 #define SQLITE_VERSION_NUMBER 3007010
112 #define SQLITE_SOURCE_ID "2011-12-23 13:32:07 1f24ae716df6232de768e245ea990049deee3c22"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
@@ -175,11 +175,11 @@
175
176 /*
177 ** CAPI3REF: Test To See If The Library Is Threadsafe
178 **
179 ** ^The sqlite3_threadsafe() function returns zero if and only if
180 ** SQLite was compiled mutexing code omitted due to the
181 ** [SQLITE_THREADSAFE] compile-time option being set to 0.
182 **
183 ** SQLite can be compiled with or without mutexes. When
184 ** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes
185 ** are enabled and SQLite is threadsafe. When the
@@ -369,11 +369,11 @@
369 ** CAPI3REF: Result Codes
370 ** KEYWORDS: SQLITE_OK {error code} {error codes}
371 ** KEYWORDS: {result code} {result codes}
372 **
373 ** Many SQLite functions return an integer result code from the set shown
374 ** here in order to indicates success or failure.
375 **
376 ** New error codes may be added in future versions of SQLite.
377 **
378 ** See also: [SQLITE_IOERR_READ | extended result codes],
379 ** [sqlite3_vtab_on_conflict()] [SQLITE_ROLLBACK | result codes].
@@ -508,17 +508,14 @@
508 ** that when data is appended to a file, the data is appended
509 ** first then the size of the file is extended, never the other
510 ** way around. The SQLITE_IOCAP_SEQUENTIAL property means that
511 ** information is written to disk in the same order as calls
512 ** to xWrite(). The SQLITE_IOCAP_POWERSAFE_OVERWRITE property means that
513 ** after reboot following a crash or power loss, the value of
514 ** each byte in a file is a value that was actually written
515 ** into that byte at some point. In other words, a crash will
516 ** not cause unwritten bytes of the file to change nor introduce
517 ** randomness into a file nor zero out parts of the file, and any byte of
518 ** a file that are never written will not change values due to
519 ** writes to nearby bytes.
520 */
521 #define SQLITE_IOCAP_ATOMIC 0x00000001
522 #define SQLITE_IOCAP_ATOMIC512 0x00000002
523 #define SQLITE_IOCAP_ATOMIC1K 0x00000004
524 #define SQLITE_IOCAP_ATOMIC2K 0x00000008
@@ -750,16 +747,16 @@
750 ** opcode as doing so may disrupt the operation of the specialized VFSes
751 ** that do require it.
752 **
753 ** ^The [SQLITE_FCNTL_WIN32_AV_RETRY] opcode is used to configure automatic
754 ** retry counts and intervals for certain disk I/O operations for the
755 ** windows [VFS] in order to work to provide robustness against
756 ** anti-virus programs. By default, the windows VFS will retry file read,
757 ** file write, and file delete operations up to 10 times, with a delay
758 ** of 25 milliseconds before the first retry and with the delay increasing
759 ** by an additional 25 milliseconds with each subsequent retry. This
760 ** opcode allows those to values (10 retries and 25 milliseconds of delay)
761 ** to be adjusted. The values are changed for all database connections
762 ** within the same process. The argument is a pointer to an array of two
763 ** integers where the first integer i the new retry count and the second
764 ** integer is the delay. If either integer is negative, then the setting
765 ** is not changed but instead the prior value of that setting is written
@@ -870,11 +867,11 @@
870 ** ^SQLite guarantees that the zFilename parameter to xOpen
871 ** is either a NULL pointer or string obtained
872 ** from xFullPathname() with an optional suffix added.
873 ** ^If a suffix is added to the zFilename parameter, it will
874 ** consist of a single "-" character followed by no more than
875 ** 10 alphanumeric and/or "-" characters.
876 ** ^SQLite further guarantees that
877 ** the string will be valid and unchanged until xClose() is
878 ** called. Because of the previous sentence,
879 ** the [sqlite3_file] can safely store a pointer to the
880 ** filename if it needs to remember the filename for some reason.
@@ -2021,11 +2018,11 @@
2021 ** These routines all implement some additional formatting
2022 ** options that are useful for constructing SQL statements.
2023 ** All of the usual printf() formatting options apply. In addition, there
2024 ** is are "%q", "%Q", and "%z" options.
2025 **
2026 ** ^(The %q option works like %s in that it substitutes a null-terminated
2027 ** string from the argument list. But %q also doubles every '\'' character.
2028 ** %q is designed for use inside a string literal.)^ By doubling each '\''
2029 ** character it escapes that character and allows it to be inserted into
2030 ** the string.
2031 **
@@ -3541,11 +3538,11 @@
3541 ** of the string. ^For clarity: the values returned by
3542 ** [sqlite3_column_bytes()] and [sqlite3_column_bytes16()] are the number of
3543 ** bytes in the string, not the number of characters.
3544 **
3545 ** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(),
3546 ** even empty strings, are always zero terminated. ^The return
3547 ** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.
3548 **
3549 ** ^The object returned by [sqlite3_column_value()] is an
3550 ** [unprotected sqlite3_value] object. An unprotected sqlite3_value object
3551 ** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()].
@@ -4621,11 +4618,11 @@
4621 SQLITE_API int sqlite3_release_memory(int);
4622
4623 /*
4624 ** CAPI3REF: Free Memory Used By A Database Connection
4625 **
4626 ** ^The sqlite3_db_shrink(D) interface attempts to free as much heap
4627 ** memory as possible from database connection D. Unlike the
4628 ** [sqlite3_release_memory()] interface, this interface is effect even
4629 ** when then [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is
4630 ** omitted.
4631 **
@@ -5404,19 +5401,19 @@
5404 ** is selected automatically at compile-time. ^(The following
5405 ** implementations are available in the SQLite core:
5406 **
5407 ** <ul>
5408 ** <li> SQLITE_MUTEX_OS2
5409 ** <li> SQLITE_MUTEX_PTHREAD
5410 ** <li> SQLITE_MUTEX_W32
5411 ** <li> SQLITE_MUTEX_NOOP
5412 ** </ul>)^
5413 **
5414 ** ^The SQLITE_MUTEX_NOOP implementation is a set of routines
5415 ** that does no real locking and is appropriate for use in
5416 ** a single-threaded application. ^The SQLITE_MUTEX_OS2,
5417 ** SQLITE_MUTEX_PTHREAD, and SQLITE_MUTEX_W32 implementations
5418 ** are appropriate for use on OS/2, Unix, and Windows.
5419 **
5420 ** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor
5421 ** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex
5422 ** implementation is included with the library. In this case the
@@ -5602,11 +5599,11 @@
5602 ** defined and if NDEBUG is not defined.
5603 **
5604 ** ^These routines should return true if the mutex in their argument
5605 ** is held or not held, respectively, by the calling thread.
5606 **
5607 ** ^The implementation is not required to provided versions of these
5608 ** routines that actually work. If the implementation does not provide working
5609 ** versions of these routines, it should at least provide stubs that always
5610 ** return true so that one does not get spurious assertion failures.
5611 **
5612 ** ^If the argument to sqlite3_mutex_held() is a NULL pointer then
@@ -6084,11 +6081,11 @@
6084 **
6085 ** [[the xInit() page cache method]]
6086 ** ^(The xInit() method is called once for each effective
6087 ** call to [sqlite3_initialize()])^
6088 ** (usually only once during the lifetime of the process). ^(The xInit()
6089 ** method is passed a copy of the sqlite3_pcache_methods.pArg value.)^
6090 ** The intent of the xInit() method is to set up global data structures
6091 ** required by the custom page cache implementation.
6092 ** ^(If the xInit() method is NULL, then the
6093 ** built-in default page cache is used instead of the application defined
6094 ** page cache.)^
@@ -6110,11 +6107,11 @@
6110 **
6111 ** [[the xCreate() page cache methods]]
6112 ** ^SQLite invokes the xCreate() method to construct a new cache instance.
6113 ** SQLite will typically create one cache instance for each open database file,
6114 ** though this is not guaranteed. ^The
6115 ** parameter parameter, szPage, is the size in bytes of the pages that must
6116 ** be allocated by the cache. ^szPage will always a power of two. ^The
6117 ** second parameter szExtra is a number of bytes of extra storage
6118 ** associated with each page cache entry. ^The szExtra parameter will
6119 ** a number less than 250. SQLite will use the
6120 ** extra szExtra bytes on each page to store metadata about the underlying
@@ -6205,11 +6202,11 @@
6205 **
6206 ** [[the xDestroy() page cache method]]
6207 ** ^The xDestroy() method is used to delete a cache allocated by xCreate().
6208 ** All resources associated with the specified cache should be freed. ^After
6209 ** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*]
6210 ** handle invalid, and will not use it with any other sqlite3_pcache_methods
6211 ** functions.
6212 **
6213 ** [[the xShrink() page cache method]]
6214 ** ^SQLite invokes the xShrink() method when it wants the page cache to
6215 ** free up as much of heap memory as possible. The page cache implementation
6216
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.7.10"
111 #define SQLITE_VERSION_NUMBER 3007010
112 #define SQLITE_SOURCE_ID "2012-01-05 12:38:02 1378f905d37544701776d38987fe7a312b255983"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
@@ -175,11 +175,11 @@
175
176 /*
177 ** CAPI3REF: Test To See If The Library Is Threadsafe
178 **
179 ** ^The sqlite3_threadsafe() function returns zero if and only if
180 ** SQLite was compiled with mutexing code omitted due to the
181 ** [SQLITE_THREADSAFE] compile-time option being set to 0.
182 **
183 ** SQLite can be compiled with or without mutexes. When
184 ** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes
185 ** are enabled and SQLite is threadsafe. When the
@@ -369,11 +369,11 @@
369 ** CAPI3REF: Result Codes
370 ** KEYWORDS: SQLITE_OK {error code} {error codes}
371 ** KEYWORDS: {result code} {result codes}
372 **
373 ** Many SQLite functions return an integer result code from the set shown
374 ** here in order to indicate success or failure.
375 **
376 ** New error codes may be added in future versions of SQLite.
377 **
378 ** See also: [SQLITE_IOERR_READ | extended result codes],
379 ** [sqlite3_vtab_on_conflict()] [SQLITE_ROLLBACK | result codes].
@@ -508,17 +508,14 @@
508 ** that when data is appended to a file, the data is appended
509 ** first then the size of the file is extended, never the other
510 ** way around. The SQLITE_IOCAP_SEQUENTIAL property means that
511 ** information is written to disk in the same order as calls
512 ** to xWrite(). The SQLITE_IOCAP_POWERSAFE_OVERWRITE property means that
513 ** after reboot following a crash or power loss, the only bytes in a
514 ** file that were written at the application level might have changed
515 ** and that adjacent bytes, even bytes within the same sector are
516 ** guaranteed to be unchanged.
 
 
 
517 */
518 #define SQLITE_IOCAP_ATOMIC 0x00000001
519 #define SQLITE_IOCAP_ATOMIC512 0x00000002
520 #define SQLITE_IOCAP_ATOMIC1K 0x00000004
521 #define SQLITE_IOCAP_ATOMIC2K 0x00000008
@@ -750,16 +747,16 @@
747 ** opcode as doing so may disrupt the operation of the specialized VFSes
748 ** that do require it.
749 **
750 ** ^The [SQLITE_FCNTL_WIN32_AV_RETRY] opcode is used to configure automatic
751 ** retry counts and intervals for certain disk I/O operations for the
752 ** windows [VFS] in order to provide robustness in the presence of
753 ** anti-virus programs. By default, the windows VFS will retry file read,
754 ** file write, and file delete operations up to 10 times, with a delay
755 ** of 25 milliseconds before the first retry and with the delay increasing
756 ** by an additional 25 milliseconds with each subsequent retry. This
757 ** opcode allows these two values (10 retries and 25 milliseconds of delay)
758 ** to be adjusted. The values are changed for all database connections
759 ** within the same process. The argument is a pointer to an array of two
760 ** integers where the first integer i the new retry count and the second
761 ** integer is the delay. If either integer is negative, then the setting
762 ** is not changed but instead the prior value of that setting is written
@@ -870,11 +867,11 @@
867 ** ^SQLite guarantees that the zFilename parameter to xOpen
868 ** is either a NULL pointer or string obtained
869 ** from xFullPathname() with an optional suffix added.
870 ** ^If a suffix is added to the zFilename parameter, it will
871 ** consist of a single "-" character followed by no more than
872 ** 11 alphanumeric and/or "-" characters.
873 ** ^SQLite further guarantees that
874 ** the string will be valid and unchanged until xClose() is
875 ** called. Because of the previous sentence,
876 ** the [sqlite3_file] can safely store a pointer to the
877 ** filename if it needs to remember the filename for some reason.
@@ -2021,11 +2018,11 @@
2018 ** These routines all implement some additional formatting
2019 ** options that are useful for constructing SQL statements.
2020 ** All of the usual printf() formatting options apply. In addition, there
2021 ** is are "%q", "%Q", and "%z" options.
2022 **
2023 ** ^(The %q option works like %s in that it substitutes a nul-terminated
2024 ** string from the argument list. But %q also doubles every '\'' character.
2025 ** %q is designed for use inside a string literal.)^ By doubling each '\''
2026 ** character it escapes that character and allows it to be inserted into
2027 ** the string.
2028 **
@@ -3541,11 +3538,11 @@
3538 ** of the string. ^For clarity: the values returned by
3539 ** [sqlite3_column_bytes()] and [sqlite3_column_bytes16()] are the number of
3540 ** bytes in the string, not the number of characters.
3541 **
3542 ** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(),
3543 ** even empty strings, are always zero-terminated. ^The return
3544 ** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.
3545 **
3546 ** ^The object returned by [sqlite3_column_value()] is an
3547 ** [unprotected sqlite3_value] object. An unprotected sqlite3_value object
3548 ** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()].
@@ -4621,11 +4618,11 @@
4618 SQLITE_API int sqlite3_release_memory(int);
4619
4620 /*
4621 ** CAPI3REF: Free Memory Used By A Database Connection
4622 **
4623 ** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap
4624 ** memory as possible from database connection D. Unlike the
4625 ** [sqlite3_release_memory()] interface, this interface is effect even
4626 ** when then [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is
4627 ** omitted.
4628 **
@@ -5404,19 +5401,19 @@
5401 ** is selected automatically at compile-time. ^(The following
5402 ** implementations are available in the SQLite core:
5403 **
5404 ** <ul>
5405 ** <li> SQLITE_MUTEX_OS2
5406 ** <li> SQLITE_MUTEX_PTHREADS
5407 ** <li> SQLITE_MUTEX_W32
5408 ** <li> SQLITE_MUTEX_NOOP
5409 ** </ul>)^
5410 **
5411 ** ^The SQLITE_MUTEX_NOOP implementation is a set of routines
5412 ** that does no real locking and is appropriate for use in
5413 ** a single-threaded application. ^The SQLITE_MUTEX_OS2,
5414 ** SQLITE_MUTEX_PTHREADS, and SQLITE_MUTEX_W32 implementations
5415 ** are appropriate for use on OS/2, Unix, and Windows.
5416 **
5417 ** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor
5418 ** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex
5419 ** implementation is included with the library. In this case the
@@ -5602,11 +5599,11 @@
5599 ** defined and if NDEBUG is not defined.
5600 **
5601 ** ^These routines should return true if the mutex in their argument
5602 ** is held or not held, respectively, by the calling thread.
5603 **
5604 ** ^The implementation is not required to provide versions of these
5605 ** routines that actually work. If the implementation does not provide working
5606 ** versions of these routines, it should at least provide stubs that always
5607 ** return true so that one does not get spurious assertion failures.
5608 **
5609 ** ^If the argument to sqlite3_mutex_held() is a NULL pointer then
@@ -6084,11 +6081,11 @@
6081 **
6082 ** [[the xInit() page cache method]]
6083 ** ^(The xInit() method is called once for each effective
6084 ** call to [sqlite3_initialize()])^
6085 ** (usually only once during the lifetime of the process). ^(The xInit()
6086 ** method is passed a copy of the sqlite3_pcache_methods2.pArg value.)^
6087 ** The intent of the xInit() method is to set up global data structures
6088 ** required by the custom page cache implementation.
6089 ** ^(If the xInit() method is NULL, then the
6090 ** built-in default page cache is used instead of the application defined
6091 ** page cache.)^
@@ -6110,11 +6107,11 @@
6107 **
6108 ** [[the xCreate() page cache methods]]
6109 ** ^SQLite invokes the xCreate() method to construct a new cache instance.
6110 ** SQLite will typically create one cache instance for each open database file,
6111 ** though this is not guaranteed. ^The
6112 ** first parameter, szPage, is the size in bytes of the pages that must
6113 ** be allocated by the cache. ^szPage will always a power of two. ^The
6114 ** second parameter szExtra is a number of bytes of extra storage
6115 ** associated with each page cache entry. ^The szExtra parameter will
6116 ** a number less than 250. SQLite will use the
6117 ** extra szExtra bytes on each page to store metadata about the underlying
@@ -6205,11 +6202,11 @@
6202 **
6203 ** [[the xDestroy() page cache method]]
6204 ** ^The xDestroy() method is used to delete a cache allocated by xCreate().
6205 ** All resources associated with the specified cache should be freed. ^After
6206 ** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*]
6207 ** handle invalid, and will not use it with any other sqlite3_pcache_methods2
6208 ** functions.
6209 **
6210 ** [[the xShrink() page cache method]]
6211 ** ^SQLite invokes the xShrink() method when it wants the page cache to
6212 ** free up as much of heap memory as possible. The page cache implementation
6213

Keyboard Shortcuts

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