Fossil SCM

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

drh 2015-07-16 18:24 trunk
Commit 82206af1101569b50af4a639c46b41135e89d2bc
2 files changed +295 -98 +1 -1
+295 -98
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -325,11 +325,11 @@
325325
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
326326
** [sqlite_version()] and [sqlite_source_id()].
327327
*/
328328
#define SQLITE_VERSION "3.8.11"
329329
#define SQLITE_VERSION_NUMBER 3008011
330
-#define SQLITE_SOURCE_ID "2015-07-08 16:22:42 5348ffc3fda5168c1e9e14aa88b0c6aedbda7c94"
330
+#define SQLITE_SOURCE_ID "2015-07-16 18:18:19 b79a4affe44bd0c8e155cae19f3f62c715684cd6"
331331
332332
/*
333333
** CAPI3REF: Run-Time Library Version Numbers
334334
** KEYWORDS: sqlite3_version, sqlite3_sourceid
335335
**
@@ -8361,11 +8361,11 @@
83618361
83628362
/*
83638363
** Make sure that the compiler intrinsics we desire are enabled when
83648364
** compiling with an appropriate version of MSVC.
83658365
*/
8366
-#if defined(_MSC_VER) && _MSC_VER>=1300
8366
+#if defined(_MSC_VER) && _MSC_VER>=1300 && !defined(_WIN32_WCE)
83678367
# include <intrin.h>
83688368
# pragma intrinsic(_byteswap_ushort)
83698369
# pragma intrinsic(_byteswap_ulong)
83708370
#endif
83718371
@@ -9189,11 +9189,13 @@
91899189
#endif
91909190
#ifndef SQLITE_MAX_MMAP_SIZE
91919191
# if defined(__linux__) \
91929192
|| defined(_WIN32) \
91939193
|| (defined(__APPLE__) && defined(__MACH__)) \
9194
- || defined(__sun)
9194
+ || defined(__sun) \
9195
+ || defined(__FreeBSD__) \
9196
+ || defined(__DragonFly__)
91959197
# define SQLITE_MAX_MMAP_SIZE 0x7fff0000 /* 2147418112 */
91969198
# else
91979199
# define SQLITE_MAX_MMAP_SIZE 0
91989200
# endif
91999201
# define SQLITE_MAX_MMAP_SIZE_xc 1 /* exclude from ctime.c */
@@ -13883,10 +13885,11 @@
1388313885
**
1388413886
*************************************************************************
1388513887
**
1388613888
** This file contains definitions of global variables and constants.
1388713889
*/
13890
+/* #include "sqliteInt.h" */
1388813891
1388913892
/* An array to map all upper-case characters into their corresponding
1389013893
** lower-case character.
1389113894
**
1389213895
** SQLite only considers US-ASCII (or EBCDIC) characters. We do not
@@ -14122,10 +14125,11 @@
1412214125
*/
1412314126
#ifndef SQLITE_OMIT_WSD
1412414127
SQLITE_PRIVATE int sqlite3PendingByte = 0x40000000;
1412514128
#endif
1412614129
14130
+/* #include "opcodes.h" */
1412714131
/*
1412814132
** Properties of opcodes. The OPFLG_INITIALIZER macro is
1412914133
** created by mkopcodeh.awk during compilation. Data is obtained
1413014134
** from the comments following the "case OP_xxxx:" statements in
1413114135
** the vdbe.c file.
@@ -14150,10 +14154,11 @@
1415014154
** SQLite was built with.
1415114155
*/
1415214156
1415314157
#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
1415414158
14159
+/* #include "sqliteInt.h" */
1415514160
1415614161
/*
1415714162
** An array of names of all compile-time options. This array should
1415814163
** be sorted A-Z.
1415914164
**
@@ -14579,10 +14584,11 @@
1457914584
*************************************************************************
1458014585
**
1458114586
** This module implements the sqlite3_status() interface and related
1458214587
** functionality.
1458314588
*/
14589
+/* #include "sqliteInt.h" */
1458414590
/************** Include vdbeInt.h in the middle of status.c ******************/
1458514591
/************** Begin file vdbeInt.h *****************************************/
1458614592
/*
1458714593
** 2003 September 6
1458814594
**
@@ -15462,10 +15468,11 @@
1546215468
** Astronomical Algorithms, 2nd Edition, 1998
1546315469
** ISBM 0-943396-61-1
1546415470
** Willmann-Bell, Inc
1546515471
** Richmond, Virginia (USA)
1546615472
*/
15473
+/* #include "sqliteInt.h" */
1546715474
/* #include <stdlib.h> */
1546815475
/* #include <assert.h> */
1546915476
#include <time.h>
1547015477
1547115478
#ifndef SQLITE_OMIT_DATETIME_FUNCS
@@ -15773,11 +15780,11 @@
1577315780
Z = (int)((p->iJD + 43200000)/86400000);
1577415781
A = (int)((Z - 1867216.25)/36524.25);
1577515782
A = Z + 1 + A - (A/4);
1577615783
B = A + 1524;
1577715784
C = (int)((B - 122.1)/365.25);
15778
- D = (36525*C)/100;
15785
+ D = (36525*(C&32767))/100;
1577915786
E = (int)((B-D)/30.6001);
1578015787
X1 = (int)(30.6001*E);
1578115788
p->D = B - D - X1;
1578215789
p->M = E<14 ? E-1 : E-13;
1578315790
p->Y = p->M>2 ? C - 4716 : C - 4715;
@@ -16574,10 +16581,11 @@
1657416581
**
1657516582
** This file contains OS interface code that is common to all
1657616583
** architectures.
1657716584
*/
1657816585
#define _SQLITE_OS_C_ 1
16586
+/* #include "sqliteInt.h" */
1657916587
#undef _SQLITE_OS_C_
1658016588
1658116589
/*
1658216590
** The default SQLite sqlite3_vfs implementations do not allocate
1658316591
** memory (actually, os_unix.c allocates a small amount of memory
@@ -16980,10 +16988,11 @@
1698016988
** is completely recoverable simply by not carrying out the resize. The
1698116989
** hash table will continue to function normally. So a malloc failure
1698216990
** during a hash table resize is a benign fault.
1698316991
*/
1698416992
16993
+/* #include "sqliteInt.h" */
1698516994
1698616995
#ifndef SQLITE_OMIT_BUILTIN_TEST
1698716996
1698816997
/*
1698916998
** Global variables.
@@ -17061,10 +17070,11 @@
1706117070
** SQLITE_ZERO_MALLOC is defined. The allocation drivers implemented
1706217071
** here always fail. SQLite will not operate with these drivers. These
1706317072
** are merely placeholders. Real drivers must be substituted using
1706417073
** sqlite3_config() before SQLite will operate.
1706517074
*/
17075
+/* #include "sqliteInt.h" */
1706617076
1706717077
/*
1706817078
** This version of the memory allocator is the default. It is
1706917079
** used when no other memory allocator is specified using compile-time
1707017080
** macros.
@@ -17147,10 +17157,11 @@
1714717157
** SQLITE_WITHOUT_MSIZE Set this symbol to disable the use of
1714817158
** _msize() on windows systems. This might
1714917159
** be necessary when compiling for Delphi,
1715017160
** for example.
1715117161
*/
17162
+/* #include "sqliteInt.h" */
1715217163
1715317164
/*
1715417165
** This version of the memory allocator is the default. It is
1715517166
** used when no other memory allocator is specified using compile-time
1715617167
** macros.
@@ -17422,10 +17433,11 @@
1742217433
** leaks and memory usage errors.
1742317434
**
1742417435
** This file contains implementations of the low-level memory allocation
1742517436
** routines specified in the sqlite3_mem_methods object.
1742617437
*/
17438
+/* #include "sqliteInt.h" */
1742717439
1742817440
/*
1742917441
** This version of the memory allocator is used only if the
1743017442
** SQLITE_MEMDEBUG macro is defined
1743117443
*/
@@ -17956,10 +17968,11 @@
1795617968
** be changed.
1795717969
**
1795817970
** This version of the memory allocation subsystem is included
1795917971
** in the build only if SQLITE_ENABLE_MEMSYS3 is defined.
1796017972
*/
17973
+/* #include "sqliteInt.h" */
1796117974
1796217975
/*
1796317976
** This version of the memory allocator is only built into the library
1796417977
** SQLITE_ENABLE_MEMSYS3 is defined. Defining this symbol does not
1796517978
** mean that the library will use a memory-pool by default, just that
@@ -18670,10 +18683,11 @@
1867018683
** N >= M*(1 + log2(n)/2) - n + 1
1867118684
**
1867218685
** The sqlite3_status() logic tracks the maximum values of n and M so
1867318686
** that an application can, at any time, verify this constraint.
1867418687
*/
18688
+/* #include "sqliteInt.h" */
1867518689
1867618690
/*
1867718691
** This version of the memory allocator is used only when
1867818692
** SQLITE_ENABLE_MEMSYS5 is defined.
1867918693
*/
@@ -19213,10 +19227,11 @@
1921319227
*************************************************************************
1921419228
** This file contains the C functions that implement mutexes.
1921519229
**
1921619230
** This file contains code that is common across all mutex implementations.
1921719231
*/
19232
+/* #include "sqliteInt.h" */
1921819233
1921919234
#if defined(SQLITE_DEBUG) && !defined(SQLITE_MUTEX_OMIT)
1922019235
/*
1922119236
** For debugging purposes, record when the mutex subsystem is initialized
1922219237
** and uninitialized so that we can assert() if there is an attempt to
@@ -19386,10 +19401,11 @@
1938619401
**
1938719402
** If compiled with SQLITE_DEBUG, then additional logic is inserted
1938819403
** that does error checking on mutexes to make sure they are being
1938919404
** called correctly.
1939019405
*/
19406
+/* #include "sqliteInt.h" */
1939119407
1939219408
#ifndef SQLITE_MUTEX_OMIT
1939319409
1939419410
#ifndef SQLITE_DEBUG
1939519411
/*
@@ -19589,10 +19605,11 @@
1958919605
** May you share freely, never taking more than you give.
1959019606
**
1959119607
*************************************************************************
1959219608
** This file contains the C functions that implement mutexes for pthreads
1959319609
*/
19610
+/* #include "sqliteInt.h" */
1959419611
1959519612
/*
1959619613
** The code in this file is only used if we are compiling threadsafe
1959719614
** under unix with pthreads.
1959819615
**
@@ -19963,10 +19980,11 @@
1996319980
** May you share freely, never taking more than you give.
1996419981
**
1996519982
*************************************************************************
1996619983
** This file contains the C functions that implement mutexes for Win32.
1996719984
*/
19985
+/* #include "sqliteInt.h" */
1996819986
1996919987
#if SQLITE_OS_WIN
1997019988
/*
1997119989
** Include code that is common to all os_*.c files
1997219990
*/
@@ -20638,10 +20656,11 @@
2063820656
**
2063920657
*************************************************************************
2064020658
**
2064120659
** Memory allocation functions used throughout sqlite.
2064220660
*/
20661
+/* #include "sqliteInt.h" */
2064320662
/* #include <stdarg.h> */
2064420663
2064520664
/*
2064620665
** Attempt to release up to n bytes of non-essential memory currently
2064720666
** held by SQLite. An example of non-essential memory is memory used to
@@ -21449,10 +21468,11 @@
2144921468
** This file contains code for a set of "printf"-like routines. These
2145021469
** routines format strings much like the printf() from the standard C
2145121470
** library, though the implementation here has enhancements to support
2145221471
** SQLite.
2145321472
*/
21473
+/* #include "sqliteInt.h" */
2145421474
2145521475
/*
2145621476
** Conversion types fall into various categories as defined by the
2145721477
** following enumeration.
2145821478
*/
@@ -22451,10 +22471,15 @@
2245122471
** stack space on small-stack systems when logging is disabled.
2245222472
**
2245322473
** sqlite3_log() must render into a static buffer. It cannot dynamically
2245422474
** allocate memory because it might be called while the memory allocator
2245522475
** mutex is held.
22476
+**
22477
+** sqlite3VXPrintf() might ask for *temporary* memory allocations for
22478
+** certain format characters (%q) or for very large precisions or widths.
22479
+** Care must be taken that any sqlite3_log() calls that occur while the
22480
+** memory mutex is held do not use these mechanisms.
2245622481
*/
2245722482
static void renderLogMsg(int iErrCode, const char *zFormat, va_list ap){
2245822483
StrAccum acc; /* String accumulator */
2245922484
char zMsg[SQLITE_PRINT_BUF_SIZE*3]; /* Complete log message */
2246022485
@@ -22526,10 +22551,11 @@
2252622551
** analysis.
2252722552
**
2252822553
** The interfaces in this file is only available when compiling
2252922554
** with SQLITE_DEBUG.
2253022555
*/
22556
+/* #include "sqliteInt.h" */
2253122557
#ifdef SQLITE_DEBUG
2253222558
2253322559
/*
2253422560
** Add a new subitem to the tree. The moreToFollow flag indicates that this
2253522561
** is not the last item in the tree.
@@ -22957,10 +22983,11 @@
2295722983
** generator (PRNG) for SQLite.
2295822984
**
2295922985
** Random numbers are used by some of the database backends in order
2296022986
** to generate random integer keys for tables or random filenames.
2296122987
*/
22988
+/* #include "sqliteInt.h" */
2296222989
2296322990
2296422991
/* All threads share a single random number generator.
2296522992
** This structure is the current state of the generator.
2296622993
*/
@@ -23103,11 +23130,13 @@
2310323130
** single threaded systems. Nothing in SQLite requires multiple threads.
2310423131
** This interface exists so that applications that want to take advantage
2310523132
** of multiple cores can do so, while also allowing applications to stay
2310623133
** single-threaded if desired.
2310723134
*/
23135
+/* #include "sqliteInt.h" */
2310823136
#if SQLITE_OS_WIN
23137
+/* # include "os_win.h" */
2310923138
#endif
2311023139
2311123140
#if SQLITE_MAX_WORKER_THREADS>0
2311223141
2311323142
/********************************* Unix Pthreads ****************************/
@@ -23377,11 +23406,13 @@
2337723406
** BOM or Byte Order Mark:
2337823407
** 0xff 0xfe little-endian utf-16 follows
2337923408
** 0xfe 0xff big-endian utf-16 follows
2338023409
**
2338123410
*/
23411
+/* #include "sqliteInt.h" */
2338223412
/* #include <assert.h> */
23413
+/* #include "vdbeInt.h" */
2338323414
2338423415
#ifndef SQLITE_AMALGAMATION
2338523416
/*
2338623417
** The following constant value is used by the SQLITE_BIGENDIAN and
2338723418
** SQLITE_LITTLEENDIAN macros.
@@ -23890,10 +23921,11 @@
2389023921
**
2389123922
** This file contains functions for allocating memory, comparing
2389223923
** strings, and stuff like that.
2389323924
**
2389423925
*/
23926
+/* #include "sqliteInt.h" */
2389523927
/* #include <stdarg.h> */
2389623928
#if HAVE_ISNAN || SQLITE_HAVE_ISNAN
2389723929
# include <math.h>
2389823930
#endif
2389923931
@@ -25286,10 +25318,11 @@
2528625318
**
2528725319
*************************************************************************
2528825320
** This is the implementation of generic hash-tables
2528925321
** used in SQLite.
2529025322
*/
25323
+/* #include "sqliteInt.h" */
2529125324
/* #include <assert.h> */
2529225325
2529325326
/* Turn bulk memory into a hash table object by initializing the
2529425327
** fields of the Hash structure.
2529525328
**
@@ -25763,10 +25796,11 @@
2576325796
** * sqlite3_vfs method implementations.
2576425797
** * Locking primitives for the proxy uber-locking-method. (MacOSX only)
2576525798
** * Definitions of sqlite3_vfs objects for all locking methods
2576625799
** plus implementations of sqlite3_os_init() and sqlite3_os_end().
2576725800
*/
25801
+/* #include "sqliteInt.h" */
2576825802
#if SQLITE_OS_UNIX /* This file is used on unix only */
2576925803
2577025804
/*
2577125805
** There are various methods for file locking used for concurrency
2577225806
** control:
@@ -33497,10 +33531,11 @@
3349733531
**
3349833532
******************************************************************************
3349933533
**
3350033534
** This file contains code that is specific to Windows.
3350133535
*/
33536
+/* #include "sqliteInt.h" */
3350233537
#if SQLITE_OS_WIN /* This file is used for Windows only */
3350333538
3350433539
/*
3350533540
** Include code that is common to all os_*.c files
3350633541
*/
@@ -33705,10 +33740,11 @@
3370533740
/************** Continuing where we left off in os_win.c *********************/
3370633741
3370733742
/*
3370833743
** Include the header file for the Windows VFS.
3370933744
*/
33745
+/* #include "os_win.h" */
3371033746
3371133747
/*
3371233748
** Compiling and using WAL mode requires several APIs that are only
3371333749
** available in Windows platforms based on the NT kernel.
3371433750
*/
@@ -39358,10 +39394,11 @@
3935839394
** sometimes grow into tens of thousands or larger. The size of the
3935939395
** Bitvec object is the number of pages in the database file at the
3936039396
** start of a transaction, and is thus usually less than a few thousand,
3936139397
** but can be as large as 2 billion for a really big database.
3936239398
*/
39399
+/* #include "sqliteInt.h" */
3936339400
3936439401
/* Size of the Bitvec structure in bytes. */
3936539402
#define BITVEC_SZ 512
3936639403
3936739404
/* Round the union size down to the nearest pointer boundary, since that's how
@@ -39747,10 +39784,11 @@
3974739784
** May you share freely, never taking more than you give.
3974839785
**
3974939786
*************************************************************************
3975039787
** This file implements that page cache.
3975139788
*/
39789
+/* #include "sqliteInt.h" */
3975239790
3975339791
/*
3975439792
** A complete page cache is an instance of this structure.
3975539793
*/
3975639794
struct PCache {
@@ -40488,10 +40526,11 @@
4048840526
**
4048940527
** Earlier versions of SQLite used only methods (1) and (2). But experiments
4049040528
** show that method (3) with N==100 provides about a 5% performance boost for
4049140529
** common workloads.
4049240530
*/
40531
+/* #include "sqliteInt.h" */
4049340532
4049440533
typedef struct PCache1 PCache1;
4049540534
typedef struct PgHdr1 PgHdr1;
4049640535
typedef struct PgFreeslot PgFreeslot;
4049740536
typedef struct PGroup PGroup;
@@ -40598,10 +40637,11 @@
4059840637
** fixed at sqlite3_initialize() time and do not require mutex protection.
4059940638
** The nFreeSlot and pFree values do require mutex protection.
4060040639
*/
4060140640
int isInit; /* True if initialized */
4060240641
int separateCache; /* Use a new PGroup for each PCache */
40642
+ int nInitPage; /* Initial bulk allocation size */
4060340643
int szSlot; /* Size of each free slot */
4060440644
int nSlot; /* The number of pcache slots */
4060540645
int nReserve; /* Try to keep nFreeSlot above this */
4060640646
void *pStart, *pEnd; /* Bounds of global page cache memory */
4060740647
/* Above requires no mutex. Use mutex below for variable that follow. */
@@ -40665,10 +40705,47 @@
4066540705
pBuf = (void*)&((char*)pBuf)[sz];
4066640706
}
4066740707
pcache1.pEnd = pBuf;
4066840708
}
4066940709
}
40710
+
40711
+/*
40712
+** Try to initialize the pCache->pFree and pCache->pBulk fields. Return
40713
+** true if pCache->pFree ends up containing one or more free pages.
40714
+*/
40715
+static int pcache1InitBulk(PCache1 *pCache){
40716
+ int szBulk;
40717
+ char *zBulk;
40718
+ if( pcache1.nInitPage==0 ) return 0;
40719
+ /* Do not bother with a bulk allocation if the cache size very small */
40720
+ if( pCache->nMax<3 ) return 0;
40721
+ sqlite3BeginBenignMalloc();
40722
+ if( pcache1.nInitPage>0 ){
40723
+ szBulk = pCache->szAlloc * pcache1.nInitPage;
40724
+ }else{
40725
+ szBulk = -1024*pcache1.nInitPage;
40726
+ }
40727
+ if( szBulk > pCache->szAlloc*pCache->nMax ){
40728
+ szBulk = pCache->szAlloc*pCache->nMax;
40729
+ }
40730
+ zBulk = pCache->pBulk = sqlite3Malloc( szBulk );
40731
+ sqlite3EndBenignMalloc();
40732
+ if( zBulk ){
40733
+ int nBulk = sqlite3MallocSize(zBulk)/pCache->szAlloc;
40734
+ int i;
40735
+ for(i=0; i<nBulk; i++){
40736
+ PgHdr1 *pX = (PgHdr1*)&zBulk[pCache->szPage];
40737
+ pX->page.pBuf = zBulk;
40738
+ pX->page.pExtra = &pX[1];
40739
+ pX->isBulkLocal = 1;
40740
+ pX->pNext = pCache->pFree;
40741
+ pCache->pFree = pX;
40742
+ zBulk += pCache->szAlloc;
40743
+ }
40744
+ }
40745
+ return pCache->pFree!=0;
40746
+}
4067040747
4067140748
/*
4067240749
** Malloc function used within this file to allocate space from the buffer
4067340750
** configured using sqlite3_config(SQLITE_CONFIG_PAGECACHE) option. If no
4067440751
** such buffer exists or there is no space left in it, this function falls
@@ -40766,11 +40843,11 @@
4076640843
static PgHdr1 *pcache1AllocPage(PCache1 *pCache){
4076740844
PgHdr1 *p = 0;
4076840845
void *pPg;
4076940846
4077040847
assert( sqlite3_mutex_held(pCache->pGroup->mutex) );
40771
- if( pCache->pFree ){
40848
+ if( pCache->pFree || (pCache->nPage==0 && pcache1InitBulk(pCache)) ){
4077240849
p = pCache->pFree;
4077340850
pCache->pFree = p->pNext;
4077440851
p->pNext = 0;
4077540852
}else{
4077640853
#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
@@ -40970,18 +41047,23 @@
4097041047
4097141048
/*
4097241049
** If there are currently more than nMaxPage pages allocated, try
4097341050
** to recycle pages to reduce the number allocated to nMaxPage.
4097441051
*/
40975
-static void pcache1EnforceMaxPage(PGroup *pGroup){
41052
+static void pcache1EnforceMaxPage(PCache1 *pCache){
41053
+ PGroup *pGroup = pCache->pGroup;
4097641054
assert( sqlite3_mutex_held(pGroup->mutex) );
4097741055
while( pGroup->nCurrentPage>pGroup->nMaxPage && pGroup->pLruTail ){
4097841056
PgHdr1 *p = pGroup->pLruTail;
4097941057
assert( p->pCache->pGroup==pGroup );
4098041058
assert( p->isPinned==0 );
4098141059
pcache1PinPage(p);
4098241060
pcache1RemoveFromHash(p, 1);
41061
+ }
41062
+ if( pCache->nPage==0 && pCache->pBulk ){
41063
+ sqlite3_free(pCache->pBulk);
41064
+ pCache->pBulk = pCache->pFree = 0;
4098341065
}
4098441066
}
4098541067
4098641068
/*
4098741069
** Discard all pages from cache pCache with a page number (key value)
@@ -41054,10 +41136,18 @@
4105441136
if( sqlite3GlobalConfig.bCoreMutex ){
4105541137
pcache1.grp.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_LRU);
4105641138
pcache1.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_PMEM);
4105741139
}
4105841140
#endif
41141
+ if( pcache1.separateCache
41142
+ && sqlite3GlobalConfig.nPage!=0
41143
+ && sqlite3GlobalConfig.pPage==0
41144
+ ){
41145
+ pcache1.nInitPage = sqlite3GlobalConfig.nPage;
41146
+ }else{
41147
+ pcache1.nInitPage = 0;
41148
+ }
4105941149
pcache1.grp.mxPinned = 10;
4106041150
pcache1.isInit = 1;
4106141151
return SQLITE_OK;
4106241152
}
4106341153
@@ -41108,40 +41198,10 @@
4110841198
pCache->nMin = 10;
4110941199
pGroup->nMinPage += pCache->nMin;
4111041200
pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage;
4111141201
}
4111241202
pcache1LeaveMutex(pGroup);
41113
- /* Try to initialize the local bulk pagecache line allocation if using
41114
- ** separate caches and if nPage!=0 */
41115
- if( pcache1.separateCache
41116
- && sqlite3GlobalConfig.nPage!=0
41117
- && sqlite3GlobalConfig.pPage==0
41118
- ){
41119
- int szBulk;
41120
- char *zBulk;
41121
- sqlite3BeginBenignMalloc();
41122
- if( sqlite3GlobalConfig.nPage>0 ){
41123
- szBulk = pCache->szAlloc * sqlite3GlobalConfig.nPage;
41124
- }else{
41125
- szBulk = -1024*sqlite3GlobalConfig.nPage;
41126
- }
41127
- zBulk = pCache->pBulk = sqlite3Malloc( szBulk );
41128
- sqlite3EndBenignMalloc();
41129
- if( zBulk ){
41130
- int nBulk = sqlite3MallocSize(zBulk)/pCache->szAlloc;
41131
- int i;
41132
- for(i=0; i<nBulk; i++){
41133
- PgHdr1 *pX = (PgHdr1*)&zBulk[szPage];
41134
- pX->page.pBuf = zBulk;
41135
- pX->page.pExtra = &pX[1];
41136
- pX->isBulkLocal = 1;
41137
- pX->pNext = pCache->pFree;
41138
- pCache->pFree = pX;
41139
- zBulk += pCache->szAlloc;
41140
- }
41141
- }
41142
- }
4114341203
if( pCache->nHash==0 ){
4114441204
pcache1Destroy((sqlite3_pcache*)pCache);
4114541205
pCache = 0;
4114641206
}
4114741207
}
@@ -41160,11 +41220,11 @@
4116041220
pcache1EnterMutex(pGroup);
4116141221
pGroup->nMaxPage += (nMax - pCache->nMax);
4116241222
pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage;
4116341223
pCache->nMax = nMax;
4116441224
pCache->n90pct = pCache->nMax*9/10;
41165
- pcache1EnforceMaxPage(pGroup);
41225
+ pcache1EnforceMaxPage(pCache);
4116641226
pcache1LeaveMutex(pGroup);
4116741227
}
4116841228
}
4116941229
4117041230
/*
@@ -41178,11 +41238,11 @@
4117841238
PGroup *pGroup = pCache->pGroup;
4117941239
int savedMaxPage;
4118041240
pcache1EnterMutex(pGroup);
4118141241
savedMaxPage = pGroup->nMaxPage;
4118241242
pGroup->nMaxPage = 0;
41183
- pcache1EnforceMaxPage(pGroup);
41243
+ pcache1EnforceMaxPage(pCache);
4118441244
pGroup->nMaxPage = savedMaxPage;
4118541245
pcache1LeaveMutex(pGroup);
4118641246
}
4118741247
}
4118841248
@@ -41515,11 +41575,11 @@
4151541575
assert( pGroup->nMaxPage >= pCache->nMax );
4151641576
pGroup->nMaxPage -= pCache->nMax;
4151741577
assert( pGroup->nMinPage >= pCache->nMin );
4151841578
pGroup->nMinPage -= pCache->nMin;
4151941579
pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage;
41520
- pcache1EnforceMaxPage(pGroup);
41580
+ pcache1EnforceMaxPage(pCache);
4152141581
pcache1LeaveMutex(pGroup);
4152241582
sqlite3_free(pCache->pBulk);
4152341583
sqlite3_free(pCache->apHash);
4152441584
sqlite3_free(pCache);
4152541585
}
@@ -41679,10 +41739,11 @@
4167941739
** primitives are constant time. The cost of DESTROY is O(N).
4168041740
**
4168141741
** There is an added cost of O(N) when switching between TEST and
4168241742
** SMALLEST primitives.
4168341743
*/
41744
+/* #include "sqliteInt.h" */
4168441745
4168541746
4168641747
/*
4168741748
** Target size for allocation chunks.
4168841749
*/
@@ -42148,10 +42209,11 @@
4214842209
** locking to prevent two processes from writing the same database
4214942210
** file simultaneously, or one process from reading the database while
4215042211
** another is writing.
4215142212
*/
4215242213
#ifndef SQLITE_OMIT_DISKIO
42214
+/* #include "sqliteInt.h" */
4215342215
/************** Include wal.h in the middle of pager.c ***********************/
4215442216
/************** Begin file wal.h *********************************************/
4215542217
/*
4215642218
** 2010 February 1
4215742219
**
@@ -42169,10 +42231,11 @@
4216942231
*/
4217042232
4217142233
#ifndef _WAL_H_
4217242234
#define _WAL_H_
4217342235
42236
+/* #include "sqliteInt.h" */
4217442237
4217542238
/* Additional values that can be added to the sync_flags argument of
4217642239
** sqlite3WalFrames():
4217742240
*/
4217842241
#define WAL_SYNC_TRANSACTIONS 0x20 /* Sync at the end of each transaction */
@@ -49783,10 +49846,11 @@
4978349846
** that correspond to frames greater than the new K value are removed
4978449847
** from the hash table at this point.
4978549848
*/
4978649849
#ifndef SQLITE_OMIT_WAL
4978749850
49851
+/* #include "wal.h" */
4978849852
4978949853
/*
4979049854
** Trace output macros
4979149855
*/
4979249856
#if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)
@@ -51000,11 +51064,11 @@
5100051064
5100151065
const int nList = *pnList; /* Size of input list */
5100251066
int nMerge = 0; /* Number of elements in list aMerge */
5100351067
ht_slot *aMerge = 0; /* List to be merged */
5100451068
int iList; /* Index into input list */
51005
- int iSub = 0; /* Index into aSub array */
51069
+ u32 iSub = 0; /* Index into aSub array */
5100651070
struct Sublist aSub[13]; /* Array of sub-lists */
5100751071
5100851072
memset(aSub, 0, sizeof(aSub));
5100951073
assert( nList<=HASHTABLE_NPAGE && nList>0 );
5101051074
assert( HASHTABLE_NPAGE==(1<<(ArraySize(aSub)-1)) );
@@ -51011,11 +51075,13 @@
5101151075
5101251076
for(iList=0; iList<nList; iList++){
5101351077
nMerge = 1;
5101451078
aMerge = &aList[iList];
5101551079
for(iSub=0; iList & (1<<iSub); iSub++){
51016
- struct Sublist *p = &aSub[iSub];
51080
+ struct Sublist *p;
51081
+ assert( iSub<ArraySize(aSub) );
51082
+ p = &aSub[iSub];
5101751083
assert( p->aList && p->nList<=(1<<iSub) );
5101851084
assert( p->aList==&aList[iList&~((2<<iSub)-1)] );
5101951085
walMerge(aContent, p->aList, p->nList, &aMerge, &nMerge, aBuffer);
5102051086
}
5102151087
aSub[iSub].aList = aMerge;
@@ -51022,11 +51088,13 @@
5102251088
aSub[iSub].nList = nMerge;
5102351089
}
5102451090
5102551091
for(iSub++; iSub<ArraySize(aSub); iSub++){
5102651092
if( nList & (1<<iSub) ){
51027
- struct Sublist *p = &aSub[iSub];
51093
+ struct Sublist *p;
51094
+ assert( iSub<ArraySize(aSub) );
51095
+ p = &aSub[iSub];
5102851096
assert( p->nList<=(1<<iSub) );
5102951097
assert( p->aList==&aList[nList&~((2<<iSub)-1)] );
5103051098
walMerge(aContent, p->aList, p->nList, &aMerge, &nMerge, aBuffer);
5103151099
}
5103251100
}
@@ -52933,10 +53001,11 @@
5293353001
** SIZE DESCRIPTION
5293453002
** 4 Page number of next trunk page
5293553003
** 4 Number of leaf pointers on this page
5293653004
** * zero or more pages numbers of leaves
5293753005
*/
53006
+/* #include "sqliteInt.h" */
5293853007
5293953008
5294053009
/* The following value is the maximum cell size assuming a maximum page
5294153010
** size give above.
5294253011
*/
@@ -53730,10 +53799,11 @@
5373053799
*************************************************************************
5373153800
** This file implements an external (disk-based) database using BTrees.
5373253801
** See the header comment on "btreeInt.h" for additional information.
5373353802
** Including a description of file format and an overview of operation.
5373453803
*/
53804
+/* #include "btreeInt.h" */
5373553805
5373653806
/*
5373753807
** The header string that appears at the beginning of every
5373853808
** SQLite database.
5373953809
*/
@@ -62675,11 +62745,11 @@
6267562745
u32 *heap = 0; /* Min-heap used for checking cell coverage */
6267662746
u32 x, prev = 0; /* Next and previous entry on the min-heap */
6267762747
const char *saved_zPfx = pCheck->zPfx;
6267862748
int saved_v1 = pCheck->v1;
6267962749
int saved_v2 = pCheck->v2;
62680
- u8 savedIsInit;
62750
+ u8 savedIsInit = 0;
6268162751
6268262752
/* Check that the page exists
6268362753
*/
6268462754
pBt = pCheck->pBt;
6268562755
usableSize = pBt->usableSize;
@@ -63311,10 +63381,12 @@
6331163381
**
6331263382
*************************************************************************
6331363383
** This file contains the implementation of the sqlite3_backup_XXX()
6331463384
** API functions and the related features.
6331563385
*/
63386
+/* #include "sqliteInt.h" */
63387
+/* #include "btreeInt.h" */
6331663388
6331763389
/*
6331863390
** Structure allocated for each backup operation.
6331963391
*/
6332063392
struct sqlite3_backup {
@@ -64109,10 +64181,12 @@
6410964181
** This file contains code use to manipulate "Mem" structure. A "Mem"
6411064182
** stores a single value in the VDBE. Mem is an opaque structure visible
6411164183
** only within the VDBE. Interface routines refer to a Mem using the
6411264184
** name sqlite_value
6411364185
*/
64186
+/* #include "sqliteInt.h" */
64187
+/* #include "vdbeInt.h" */
6411464188
6411564189
#ifdef SQLITE_DEBUG
6411664190
/*
6411764191
** Check invariants on a Mem object.
6411864192
**
@@ -65826,10 +65900,12 @@
6582665900
**
6582765901
*************************************************************************
6582865902
** This file contains code used for creating, destroying, and populating
6582965903
** a VDBE (or an "sqlite3_stmt" as it is known to the outside world.)
6583065904
*/
65905
+/* #include "sqliteInt.h" */
65906
+/* #include "vdbeInt.h" */
6583165907
6583265908
/*
6583365909
** Create a new virtual database engine.
6583465910
*/
6583565911
SQLITE_PRIVATE Vdbe *sqlite3VdbeCreate(Parse *pParse){
@@ -70074,10 +70150,12 @@
7007470150
*************************************************************************
7007570151
**
7007670152
** This file contains code use to implement APIs that are part of the
7007770153
** VDBE.
7007870154
*/
70155
+/* #include "sqliteInt.h" */
70156
+/* #include "vdbeInt.h" */
7007970157
7008070158
#ifndef SQLITE_OMIT_DEPRECATED
7008170159
/*
7008270160
** Return TRUE (non-zero) of the statement supplied as an argument needs
7008370161
** to be recompiled. A statement needs to be recompiled whenever the
@@ -70112,10 +70190,35 @@
7011270190
}else{
7011370191
return vdbeSafety(p);
7011470192
}
7011570193
}
7011670194
70195
+#ifndef SQLITE_OMIT_TRACE
70196
+/*
70197
+** Invoke the profile callback. This routine is only called if we already
70198
+** know that the profile callback is defined and needs to be invoked.
70199
+*/
70200
+static SQLITE_NOINLINE void invokeProfileCallback(sqlite3 *db, Vdbe *p){
70201
+ sqlite3_int64 iNow;
70202
+ assert( p->startTime>0 );
70203
+ assert( db->xProfile!=0 );
70204
+ assert( db->init.busy==0 );
70205
+ assert( p->zSql!=0 );
70206
+ sqlite3OsCurrentTimeInt64(db->pVfs, &iNow);
70207
+ db->xProfile(db->pProfileArg, p->zSql, (iNow - p->startTime)*1000000);
70208
+ p->startTime = 0;
70209
+}
70210
+/*
70211
+** The checkProfileCallback(DB,P) macro checks to see if a profile callback
70212
+** is needed, and it invokes the callback if it is needed.
70213
+*/
70214
+# define checkProfileCallback(DB,P) \
70215
+ if( ((P)->startTime)>0 ){ invokeProfileCallback(DB,P); }
70216
+#else
70217
+# define checkProfileCallback(DB,P) /*no-op*/
70218
+#endif
70219
+
7011770220
/*
7011870221
** The following routine destroys a virtual machine that is created by
7011970222
** the sqlite3_compile() routine. The integer returned is an SQLITE_
7012070223
** success/failure code that describes the result of executing the virtual
7012170224
** machine.
@@ -70132,10 +70235,11 @@
7013270235
}else{
7013370236
Vdbe *v = (Vdbe*)pStmt;
7013470237
sqlite3 *db = v->db;
7013570238
if( vdbeSafety(v) ) return SQLITE_MISUSE_BKPT;
7013670239
sqlite3_mutex_enter(db->mutex);
70240
+ checkProfileCallback(db, v);
7013770241
rc = sqlite3VdbeFinalize(v);
7013870242
rc = sqlite3ApiExit(db, rc);
7013970243
sqlite3LeaveMutexAndCloseZombie(db);
7014070244
}
7014170245
return rc;
@@ -70153,16 +70257,18 @@
7015370257
int rc;
7015470258
if( pStmt==0 ){
7015570259
rc = SQLITE_OK;
7015670260
}else{
7015770261
Vdbe *v = (Vdbe*)pStmt;
70158
- sqlite3_mutex_enter(v->db->mutex);
70262
+ sqlite3 *db = v->db;
70263
+ sqlite3_mutex_enter(db->mutex);
70264
+ checkProfileCallback(db, v);
7015970265
rc = sqlite3VdbeReset(v);
7016070266
sqlite3VdbeRewind(v);
70161
- assert( (rc & (v->db->errMask))==rc );
70162
- rc = sqlite3ApiExit(v->db, rc);
70163
- sqlite3_mutex_leave(v->db->mutex);
70267
+ assert( (rc & (db->errMask))==rc );
70268
+ rc = sqlite3ApiExit(db, rc);
70269
+ sqlite3_mutex_leave(db->mutex);
7016470270
}
7016570271
return rc;
7016670272
}
7016770273
7016870274
/*
@@ -70508,10 +70614,11 @@
7050870614
}
7050970615
}
7051070616
#endif
7051170617
return rc;
7051270618
}
70619
+
7051370620
7051470621
/*
7051570622
** Execute the statement pStmt, either until a row of data is ready, the
7051670623
** statement is completely executed or an error occurs.
7051770624
**
@@ -70577,12 +70684,14 @@
7057770684
assert( db->nVdbeWrite>0 || db->autoCommit==0
7057870685
|| (db->nDeferredCons==0 && db->nDeferredImmCons==0)
7057970686
);
7058070687
7058170688
#ifndef SQLITE_OMIT_TRACE
70582
- if( db->xProfile && !db->init.busy ){
70689
+ if( db->xProfile && !db->init.busy && p->zSql ){
7058370690
sqlite3OsCurrentTimeInt64(db->pVfs, &p->startTime);
70691
+ }else{
70692
+ assert( p->startTime==0 );
7058470693
}
7058570694
#endif
7058670695
7058770696
db->nVdbeActive++;
7058870697
if( p->readOnly==0 ) db->nVdbeWrite++;
@@ -70602,17 +70711,12 @@
7060270711
rc = sqlite3VdbeExec(p);
7060370712
db->nVdbeExec--;
7060470713
}
7060570714
7060670715
#ifndef SQLITE_OMIT_TRACE
70607
- /* Invoke the profile callback if there is one
70608
- */
70609
- if( rc!=SQLITE_ROW && db->xProfile && !db->init.busy && p->zSql ){
70610
- sqlite3_int64 iNow;
70611
- sqlite3OsCurrentTimeInt64(db->pVfs, &iNow);
70612
- db->xProfile(db->pProfileArg, p->zSql, (iNow - p->startTime)*1000000);
70613
- }
70716
+ /* If the statement completed successfully, invoke the profile callback */
70717
+ if( rc!=SQLITE_ROW ) checkProfileCallback(db, p);
7061470718
#endif
7061570719
7061670720
if( rc==SQLITE_DONE ){
7061770721
assert( p->rc==SQLITE_OK );
7061870722
p->rc = doWalCallbacks(db);
@@ -71685,10 +71789,12 @@
7168571789
** This file contains code used to insert the values of host parameters
7168671790
** (aka "wildcards") into the SQL text output by sqlite3_trace().
7168771791
**
7168871792
** The Vdbe parse-tree explainer is also found here.
7168971793
*/
71794
+/* #include "sqliteInt.h" */
71795
+/* #include "vdbeInt.h" */
7169071796
7169171797
#ifndef SQLITE_OMIT_TRACE
7169271798
7169371799
/*
7169471800
** zSql is a zero-terminated string of UTF-8 SQL text. Return the number of
@@ -71877,10 +71983,12 @@
7187771983
** documentation, headers files, or other derived files. The formatting
7187871984
** of the code in this file is, therefore, important. See other comments
7187971985
** in this file for details. If in doubt, do not deviate from existing
7188071986
** commenting and indentation practices when changing or adding code.
7188171987
*/
71988
+/* #include "sqliteInt.h" */
71989
+/* #include "vdbeInt.h" */
7188271990
7188371991
/*
7188471992
** Invoke this macro on memory cells just prior to changing the
7188571993
** value of the cell. This macro verifies that shallow copies are
7188671994
** not misused. A shallow copy of a string or blob just copies a
@@ -78635,10 +78743,12 @@
7863578743
*************************************************************************
7863678744
**
7863778745
** This file contains code used to implement incremental BLOB I/O.
7863878746
*/
7863978747
78748
+/* #include "sqliteInt.h" */
78749
+/* #include "vdbeInt.h" */
7864078750
7864178751
#ifndef SQLITE_OMIT_INCRBLOB
7864278752
7864378753
/*
7864478754
** Valid sqlite3_blob* handles point to Incrblob structures.
@@ -79233,10 +79343,12 @@
7923379343
** than one background thread may be created. Specifically, there may be
7923479344
** one background thread for each temporary file on disk, and one background
7923579345
** thread to merge the output of each of the others to a single PMA for
7923679346
** the main thread to read from.
7923779347
*/
79348
+/* #include "sqliteInt.h" */
79349
+/* #include "vdbeInt.h" */
7923879350
7923979351
/*
7924079352
** If SQLITE_DEBUG_SORTER_THREADS is defined, this module outputs various
7924179353
** messages to stderr that may be helpful in understanding the performance
7924279354
** characteristics of the sorter in multi-threaded mode.
@@ -81849,10 +81961,11 @@
8184981961
** 1) The in-memory representation grows too large for the allocated
8185081962
** buffer, or
8185181963
** 2) The sqlite3JournalCreate() function is called.
8185281964
*/
8185381965
#ifdef SQLITE_ENABLE_ATOMIC_WRITE
81966
+/* #include "sqliteInt.h" */
8185481967
8185581968
8185681969
/*
8185781970
** A JournalFile object is a subclass of sqlite3_file used by
8185881971
** as an open file handle for journal files.
@@ -82096,10 +82209,11 @@
8209682209
**
8209782210
** This file contains code use to implement an in-memory rollback journal.
8209882211
** The in-memory rollback journal is used to journal transactions for
8209982212
** ":memory:" databases and when the journal_mode=MEMORY pragma is used.
8210082213
*/
82214
+/* #include "sqliteInt.h" */
8210182215
8210282216
/* Forward references to internal structures */
8210382217
typedef struct MemJournal MemJournal;
8210482218
typedef struct FilePoint FilePoint;
8210582219
typedef struct FileChunk FileChunk;
@@ -82351,10 +82465,11 @@
8235182465
**
8235282466
*************************************************************************
8235382467
** This file contains routines used for walking the parser tree for
8235482468
** an SQL statement.
8235582469
*/
82470
+/* #include "sqliteInt.h" */
8235682471
/* #include <stdlib.h> */
8235782472
/* #include <string.h> */
8235882473
8235982474
8236082475
/*
@@ -82509,10 +82624,11 @@
8250982624
**
8251082625
** This file contains routines used for walking the parser tree and
8251182626
** resolve all identifiers by associating them with a particular
8251282627
** table and column.
8251382628
*/
82629
+/* #include "sqliteInt.h" */
8251482630
/* #include <stdlib.h> */
8251582631
/* #include <string.h> */
8251682632
8251782633
/*
8251882634
** Walk the expression tree pExpr and increase the aggregate function
@@ -84021,10 +84137,11 @@
8402184137
**
8402284138
*************************************************************************
8402384139
** This file contains routines used for analyzing expressions and
8402484140
** for generating VDBE code that evaluates expressions in SQLite.
8402584141
*/
84142
+/* #include "sqliteInt.h" */
8402684143
8402784144
/*
8402884145
** Return the 'affinity' of the expression pExpr if any.
8402984146
**
8403084147
** If pExpr is a column, a reference to a column via an 'AS' alias,
@@ -88183,10 +88300,11 @@
8818388300
**
8818488301
*************************************************************************
8818588302
** This file contains C code routines that used to generate VDBE code
8818688303
** that implements the ALTER TABLE command.
8818788304
*/
88305
+/* #include "sqliteInt.h" */
8818888306
8818988307
/*
8819088308
** The code in this file only exists if we are not omitting the
8819188309
** ALTER TABLE logic from the build.
8819288310
*/
@@ -89145,10 +89263,11 @@
8914589263
** sqlite_stat4.sample. The nEq, nLt, and nDLt entries of sqlite_stat3
8914689264
** all contain just a single integer which is the same as the first
8914789265
** integer in the equivalent columns in sqlite_stat4.
8914889266
*/
8914989267
#ifndef SQLITE_OMIT_ANALYZE
89268
+/* #include "sqliteInt.h" */
8915089269
8915189270
#if defined(SQLITE_ENABLE_STAT4)
8915289271
# define IsStat4 1
8915389272
# define IsStat3 0
8915489273
#elif defined(SQLITE_ENABLE_STAT3)
@@ -90910,10 +91029,11 @@
9091091029
** May you share freely, never taking more than you give.
9091191030
**
9091291031
*************************************************************************
9091391032
** This file contains code used to implement the ATTACH and DETACH commands.
9091491033
*/
91034
+/* #include "sqliteInt.h" */
9091591035
9091691036
#ifndef SQLITE_OMIT_ATTACH
9091791037
/*
9091891038
** Resolve an expression that was part of an ATTACH or DETACH statement. This
9091991039
** is slightly different from resolving a normal SQL expression, because simple
@@ -91499,10 +91619,11 @@
9149991619
** This file contains code used to implement the sqlite3_set_authorizer()
9150091620
** API. This facility is an optional feature of the library. Embedded
9150191621
** systems that do not need this facility may omit it by recompiling
9150291622
** the library with -DSQLITE_OMIT_AUTHORIZATION=1
9150391623
*/
91624
+/* #include "sqliteInt.h" */
9150491625
9150591626
/*
9150691627
** All of the code in this file may be omitted by defining a single
9150791628
** macro.
9150891629
*/
@@ -91769,10 +91890,11 @@
9176991890
** creating ID lists
9177091891
** BEGIN TRANSACTION
9177191892
** COMMIT
9177291893
** ROLLBACK
9177391894
*/
91895
+/* #include "sqliteInt.h" */
9177491896
9177591897
/*
9177691898
** This routine is called when a new SQL statement is beginning to
9177791899
** be parsed. Initialize the pParse structure as needed.
9177891900
*/
@@ -96089,10 +96211,11 @@
9608996211
**
9609096212
** This file contains functions used to access the internal hash tables
9609196213
** of user defined functions and collation sequences.
9609296214
*/
9609396215
96216
+/* #include "sqliteInt.h" */
9609496217
9609596218
/*
9609696219
** Invoke the 'collation needed' callback to request a collation sequence
9609796220
** in the encoding enc of name zName, length nName.
9609896221
*/
@@ -96566,10 +96689,11 @@
9656696689
**
9656796690
*************************************************************************
9656896691
** This file contains C code routines that are called by the parser
9656996692
** in order to generate code for DELETE FROM statements.
9657096693
*/
96694
+/* #include "sqliteInt.h" */
9657196695
9657296696
/*
9657396697
** While a SrcList can in general represent multiple tables and subqueries
9657496698
** (as in the FROM clause of a SELECT statement) in this case it contains
9657596699
** the name of a single table, as one might find in an INSERT, DELETE,
@@ -97408,12 +97532,14 @@
9740897532
*************************************************************************
9740997533
** This file contains the C-language implementations for many of the SQL
9741097534
** functions of SQLite. (Some function, and in particular the date and
9741197535
** time functions, are implemented separately.)
9741297536
*/
97537
+/* #include "sqliteInt.h" */
9741397538
/* #include <stdlib.h> */
9741497539
/* #include <assert.h> */
97540
+/* #include "vdbeInt.h" */
9741597541
9741697542
/*
9741797543
** Return the collating function associated with a function.
9741897544
*/
9741997545
static CollSeq *sqlite3GetFuncCollSeq(sqlite3_context *context){
@@ -99205,10 +99331,11 @@
9920599331
**
9920699332
*************************************************************************
9920799333
** This file contains code used by the compiler to add foreign key
9920899334
** support to compiled SQL statements.
9920999335
*/
99336
+/* #include "sqliteInt.h" */
9921099337
9921199338
#ifndef SQLITE_OMIT_FOREIGN_KEY
9921299339
#ifndef SQLITE_OMIT_TRIGGER
9921399340
9921499341
/*
@@ -100609,10 +100736,11 @@
100609100736
**
100610100737
*************************************************************************
100611100738
** This file contains C code routines that are called by the parser
100612100739
** to handle INSERT statements in SQLite.
100613100740
*/
100741
+/* #include "sqliteInt.h" */
100614100742
100615100743
/*
100616100744
** Generate code that will
100617100745
**
100618100746
** (1) acquire a lock for table pTab then
@@ -102671,10 +102799,11 @@
102671102799
** implement the programmer interface to the library. Routines in
102672102800
** other files are for internal use by SQLite and should not be
102673102801
** accessed by users of the library.
102674102802
*/
102675102803
102804
+/* #include "sqliteInt.h" */
102676102805
102677102806
/*
102678102807
** Execute SQL code. Return one of the SQLITE_ success/failure
102679102808
** codes. Also write an error message into memory obtained from
102680102809
** malloc() and make *pzErrMsg point to that message.
@@ -102839,10 +102968,11 @@
102839102968
** as extensions by SQLite should #include this file instead of
102840102969
** sqlite3.h.
102841102970
*/
102842102971
#ifndef _SQLITE3EXT_H_
102843102972
#define _SQLITE3EXT_H_
102973
+/* #include "sqlite3.h" */
102844102974
102845102975
typedef struct sqlite3_api_routines sqlite3_api_routines;
102846102976
102847102977
/*
102848102978
** The following structure holds pointers to all of the SQLite API
@@ -103345,10 +103475,11 @@
103345103475
103346103476
#endif /* _SQLITE3EXT_H_ */
103347103477
103348103478
/************** End of sqlite3ext.h ******************************************/
103349103479
/************** Continuing where we left off in loadext.c ********************/
103480
+/* #include "sqliteInt.h" */
103350103481
/* #include <string.h> */
103351103482
103352103483
#ifndef SQLITE_OMIT_LOAD_EXTENSION
103353103484
103354103485
/*
@@ -104114,10 +104245,11 @@
104114104245
** May you share freely, never taking more than you give.
104115104246
**
104116104247
*************************************************************************
104117104248
** This file contains code used to implement the PRAGMA command.
104118104249
*/
104250
+/* #include "sqliteInt.h" */
104119104251
104120104252
#if !defined(SQLITE_ENABLE_LOCKING_STYLE)
104121104253
# if defined(__APPLE__)
104122104254
# define SQLITE_ENABLE_LOCKING_STYLE 1
104123104255
# else
@@ -104220,11 +104352,11 @@
104220104352
/* ePragFlag: */ 0,
104221104353
/* iArg: */ 0 },
104222104354
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
104223104355
{ /* zName: */ "cache_size",
104224104356
/* ePragTyp: */ PragTyp_CACHE_SIZE,
104225
- /* ePragFlag: */ PragFlag_NeedSchema,
104357
+ /* ePragFlag: */ 0,
104226104358
/* iArg: */ 0 },
104227104359
#endif
104228104360
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
104229104361
{ /* zName: */ "cache_spill",
104230104362
/* ePragTyp: */ PragTyp_FLAG,
@@ -105290,10 +105422,11 @@
105290105422
** of memory.
105291105423
*/
105292105424
case PragTyp_CACHE_SIZE: {
105293105425
assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
105294105426
if( !zRight ){
105427
+ if( sqlite3ReadSchema(pParse) ) goto pragma_out;
105295105428
returnSingleInt(pParse, "cache_size", pDb->pSchema->cache_size);
105296105429
}else{
105297105430
int size = sqlite3Atoi(zRight);
105298105431
pDb->pSchema->cache_size = size;
105299105432
sqlite3BtreeSetCacheSize(pDb->pBt, pDb->pSchema->cache_size);
@@ -106565,10 +106698,11 @@
106565106698
*************************************************************************
106566106699
** This file contains the implementation of the sqlite3_prepare()
106567106700
** interface, and routines that contribute to loading the database schema
106568106701
** from disk.
106569106702
*/
106703
+/* #include "sqliteInt.h" */
106570106704
106571106705
/*
106572106706
** Fill the InitData structure with an error message that indicates
106573106707
** that the database is corrupt.
106574106708
*/
@@ -107459,10 +107593,11 @@
107459107593
**
107460107594
*************************************************************************
107461107595
** This file contains C code routines that are called by the parser
107462107596
** to handle SELECT statements in SQLite.
107463107597
*/
107598
+/* #include "sqliteInt.h" */
107464107599
107465107600
/*
107466107601
** Trace output macros
107467107602
*/
107468107603
#if SELECTTRACE_ENABLED
@@ -108528,11 +108663,10 @@
108528108663
}
108529108664
}
108530108665
return pInfo;
108531108666
}
108532108667
108533
-#ifndef SQLITE_OMIT_COMPOUND_SELECT
108534108668
/*
108535108669
** Name of the connection operator, used for error messages.
108536108670
*/
108537108671
static const char *selectOpName(int id){
108538108672
char *z;
@@ -108542,11 +108676,10 @@
108542108676
case TK_EXCEPT: z = "EXCEPT"; break;
108543108677
default: z = "UNION"; break;
108544108678
}
108545108679
return z;
108546108680
}
108547
-#endif /* SQLITE_OMIT_COMPOUND_SELECT */
108548108681
108549108682
#ifndef SQLITE_OMIT_EXPLAIN
108550108683
/*
108551108684
** Unless an "EXPLAIN QUERY PLAN" command is being processed, this function
108552108685
** is a no-op. Otherwise, it adds a single row of output to the EQP result,
@@ -109545,23 +109678,10 @@
109545109678
Parse *pParse, /* Parsing context */
109546109679
Select *p, /* The right-most of SELECTs to be coded */
109547109680
SelectDest *pDest /* What to do with query results */
109548109681
);
109549109682
109550
-/*
109551
-** Error message for when two or more terms of a compound select have different
109552
-** size result sets.
109553
-*/
109554
-SQLITE_PRIVATE void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p){
109555
- if( p->selFlags & SF_Values ){
109556
- sqlite3ErrorMsg(pParse, "all VALUES must have the same number of terms");
109557
- }else{
109558
- sqlite3ErrorMsg(pParse, "SELECTs to the left and right of %s"
109559
- " do not have the same number of result columns", selectOpName(p->op));
109560
- }
109561
-}
109562
-
109563109683
/*
109564109684
** Handle the special case of a compound-select that originates from a
109565109685
** VALUES clause. By handling this as a special case, we avoid deep
109566109686
** recursion, and thus do not need to enforce the SQLITE_LIMIT_COMPOUND_SELECT
109567109687
** on a VALUES clause.
@@ -109983,10 +110103,23 @@
109983110103
pDest->nSdst = dest.nSdst;
109984110104
sqlite3SelectDelete(db, pDelete);
109985110105
return rc;
109986110106
}
109987110107
#endif /* SQLITE_OMIT_COMPOUND_SELECT */
110108
+
110109
+/*
110110
+** Error message for when two or more terms of a compound select have different
110111
+** size result sets.
110112
+*/
110113
+SQLITE_PRIVATE void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p){
110114
+ if( p->selFlags & SF_Values ){
110115
+ sqlite3ErrorMsg(pParse, "all VALUES must have the same number of terms");
110116
+ }else{
110117
+ sqlite3ErrorMsg(pParse, "SELECTs to the left and right of %s"
110118
+ " do not have the same number of result columns", selectOpName(p->op));
110119
+ }
110120
+}
109988110121
109989110122
/*
109990110123
** Code an output subroutine for a coroutine implementation of a
109991110124
** SELECT statment.
109992110125
**
@@ -113077,10 +113210,11 @@
113077113210
** interface routine of sqlite3_exec().
113078113211
**
113079113212
** These routines are in a separate files so that they will not be linked
113080113213
** if they are not used.
113081113214
*/
113215
+/* #include "sqliteInt.h" */
113082113216
/* #include <stdlib.h> */
113083113217
/* #include <string.h> */
113084113218
113085113219
#ifndef SQLITE_OMIT_GET_TABLE
113086113220
@@ -113273,10 +113407,11 @@
113273113407
** May you share freely, never taking more than you give.
113274113408
**
113275113409
*************************************************************************
113276113410
** This file contains the implementation for TRIGGERs
113277113411
*/
113412
+/* #include "sqliteInt.h" */
113278113413
113279113414
#ifndef SQLITE_OMIT_TRIGGER
113280113415
/*
113281113416
** Delete a linked list of TriggerStep structures.
113282113417
*/
@@ -114396,10 +114531,11 @@
114396114531
**
114397114532
*************************************************************************
114398114533
** This file contains C code routines that are called by the parser
114399114534
** to handle UPDATE statements.
114400114535
*/
114536
+/* #include "sqliteInt.h" */
114401114537
114402114538
#ifndef SQLITE_OMIT_VIRTUALTABLE
114403114539
/* Forward declaration */
114404114540
static void updateVirtualTable(
114405114541
Parse *pParse, /* The parsing context */
@@ -115172,10 +115308,12 @@
115172115308
** This file contains code used to implement the VACUUM command.
115173115309
**
115174115310
** Most of the code in this file may be omitted by defining the
115175115311
** SQLITE_OMIT_VACUUM macro.
115176115312
*/
115313
+/* #include "sqliteInt.h" */
115314
+/* #include "vdbeInt.h" */
115177115315
115178115316
#if !defined(SQLITE_OMIT_VACUUM) && !defined(SQLITE_OMIT_ATTACH)
115179115317
/*
115180115318
** Finalize a prepared statement. If there was an error, store the
115181115319
** text of the error message in *pzErrMsg. Return the result code.
@@ -115544,10 +115682,11 @@
115544115682
**
115545115683
*************************************************************************
115546115684
** This file contains code used to help implement virtual tables.
115547115685
*/
115548115686
#ifndef SQLITE_OMIT_VIRTUALTABLE
115687
+/* #include "sqliteInt.h" */
115549115688
115550115689
/*
115551115690
** Before a virtual table xCreate() or xConnect() method is invoked, the
115552115691
** sqlite3.pVtabCtx member variable is set to point to an instance of
115553115692
** this struct allocated on the stack. It is used by the implementation of
@@ -116702,10 +116841,11 @@
116702116841
** This file was split off from where.c on 2015-06-06 in order to reduce the
116703116842
** size of where.c and make it easier to edit. This file contains the routines
116704116843
** that actually generate the bulk of the WHERE loop code. The original where.c
116705116844
** file retains the code that does query planning and analysis.
116706116845
*/
116846
+/* #include "sqliteInt.h" */
116707116847
/************** Include whereInt.h in the middle of wherecode.c **************/
116708116848
/************** Begin file whereInt.h ****************************************/
116709116849
/*
116710116850
** 2013-11-12
116711116851
**
@@ -118737,10 +118877,12 @@
118737118877
**
118738118878
** This file was originally part of where.c but was split out to improve
118739118879
** readability and editabiliity. This file contains utility routines for
118740118880
** analyzing Expr objects in the WHERE clause.
118741118881
*/
118882
+/* #include "sqliteInt.h" */
118883
+/* #include "whereInt.h" */
118742118884
118743118885
/* Forward declarations */
118744118886
static void exprAnalyze(SrcList*, WhereClause*, int);
118745118887
118746118888
/*
@@ -119987,10 +120129,12 @@
119987120129
** generating the code that loops through a table looking for applicable
119988120130
** rows. Indices are selected and used to speed the search when doing
119989120131
** so is applicable. Because this module is responsible for selecting
119990120132
** indices, you might also think of this module as the "query optimizer".
119991120133
*/
120134
+/* #include "sqliteInt.h" */
120135
+/* #include "whereInt.h" */
119992120136
119993120137
/* Forward declaration of methods */
119994120138
static int whereLoopResize(sqlite3*, WhereLoop*, int);
119995120139
119996120140
/* Test variable that can be set to enable WHERE tracing */
@@ -124486,10 +124630,11 @@
124486124630
*/
124487124631
/* First off, code is included that follows the "include" declaration
124488124632
** in the input grammar file. */
124489124633
/* #include <stdio.h> */
124490124634
124635
+/* #include "sqliteInt.h" */
124491124636
124492124637
/*
124493124638
** Disable all error recovery processing in the parser push-down
124494124639
** automaton.
124495124640
*/
@@ -128071,10 +128216,11 @@
128071128216
**
128072128217
** This file contains C code that splits an SQL input string up into
128073128218
** individual tokens and sends those tokens one-by-one over to the
128074128219
** parser for analysis.
128075128220
*/
128221
+/* #include "sqliteInt.h" */
128076128222
/* #include <stdlib.h> */
128077128223
128078128224
/*
128079128225
** The charMap() macro maps alphabetic characters into their
128080128226
** lower-case ASCII equivalent. On ASCII machines, this is just
@@ -128880,10 +129026,11 @@
128880129026
** This file contains C code that implements the sqlite3_complete() API.
128881129027
** This code used to be part of the tokenizer.c source file. But by
128882129028
** separating it out, the code will be automatically omitted from
128883129029
** static links that do not use it.
128884129030
*/
129031
+/* #include "sqliteInt.h" */
128885129032
#ifndef SQLITE_OMIT_COMPLETE
128886129033
128887129034
/*
128888129035
** This is defined in tokenize.c. We just have to import the definition.
128889129036
*/
@@ -129170,10 +129317,11 @@
129170129317
** Main file for the SQLite library. The routines in this file
129171129318
** implement the programmer interface to the library. Routines in
129172129319
** other files are for internal use by SQLite and should not be
129173129320
** accessed by users of the library.
129174129321
*/
129322
+/* #include "sqliteInt.h" */
129175129323
129176129324
#ifdef SQLITE_ENABLE_FTS3
129177129325
/************** Include fts3.h in the middle of main.c ***********************/
129178129326
/************** Begin file fts3.h ********************************************/
129179129327
/*
@@ -129189,10 +129337,11 @@
129189129337
******************************************************************************
129190129338
**
129191129339
** This header file is used by programs that want to link against the
129192129340
** FTS3 library. All it does is declare the sqlite3Fts3Init() interface.
129193129341
*/
129342
+/* #include "sqlite3.h" */
129194129343
129195129344
#if 0
129196129345
extern "C" {
129197129346
#endif /* __cplusplus */
129198129347
@@ -129221,10 +129370,11 @@
129221129370
******************************************************************************
129222129371
**
129223129372
** This header file is used by programs that want to link against the
129224129373
** RTREE library. All it does is declare the sqlite3RtreeInit() interface.
129225129374
*/
129375
+/* #include "sqlite3.h" */
129226129376
129227129377
#if 0
129228129378
extern "C" {
129229129379
#endif /* __cplusplus */
129230129380
@@ -129253,10 +129403,11 @@
129253129403
******************************************************************************
129254129404
**
129255129405
** This header file is used by programs that want to link against the
129256129406
** ICU extension. All it does is declare the sqlite3IcuInit() interface.
129257129407
*/
129408
+/* #include "sqlite3.h" */
129258129409
129259129410
#if 0
129260129411
extern "C" {
129261129412
#endif /* __cplusplus */
129262129413
@@ -133045,10 +133196,12 @@
133045133196
*************************************************************************
133046133197
**
133047133198
** This file contains the implementation of the sqlite3_unlock_notify()
133048133199
** API method and its associated functionality.
133049133200
*/
133201
+/* #include "sqliteInt.h" */
133202
+/* #include "btreeInt.h" */
133050133203
133051133204
/* Omit this entire file if SQLITE_ENABLE_UNLOCK_NOTIFY is not defined. */
133052133205
#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
133053133206
133054133207
/*
@@ -133688,13 +133841,15 @@
133688133841
133689133842
#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
133690133843
133691133844
/* If not building as part of the core, include sqlite3ext.h. */
133692133845
#ifndef SQLITE_CORE
133846
+/* # include "sqlite3ext.h" */
133693133847
SQLITE_EXTENSION_INIT3
133694133848
#endif
133695133849
133850
+/* #include "sqlite3.h" */
133696133851
/************** Include fts3_tokenizer.h in the middle of fts3Int.h **********/
133697133852
/************** Begin file fts3_tokenizer.h **********************************/
133698133853
/*
133699133854
** 2006 July 10
133700133855
**
@@ -133719,10 +133874,11 @@
133719133874
133720133875
/* TODO(shess) Only used for SQLITE_OK and SQLITE_DONE at this time.
133721133876
** If tokenizers are to be allowed to call sqlite3_*() functions, then
133722133877
** we will need a way to register the API consistently.
133723133878
*/
133879
+/* #include "sqlite3.h" */
133724133880
133725133881
/*
133726133882
** Structures used by the tokenizer interface. When a new tokenizer
133727133883
** implementation is registered, the caller provides a pointer to
133728133884
** an sqlite3_tokenizer_module containing pointers to the callback
@@ -134559,11 +134715,13 @@
134559134715
/* #include <stddef.h> */
134560134716
/* #include <stdio.h> */
134561134717
/* #include <string.h> */
134562134718
/* #include <stdarg.h> */
134563134719
134720
+/* #include "fts3.h" */
134564134721
#ifndef SQLITE_CORE
134722
+/* # include "sqlite3ext.h" */
134565134723
SQLITE_EXTENSION_INIT1
134566134724
#endif
134567134725
134568134726
static int fts3EvalNext(Fts3Cursor *pCsr);
134569134727
static int fts3EvalStart(Fts3Cursor *pCsr);
@@ -138606,10 +138764,11 @@
138606138764
if( p==0 ){
138607138765
p = aDoclist;
138608138766
p += sqlite3Fts3GetVarint(p, piDocid);
138609138767
}else{
138610138768
fts3PoslistCopy(0, &p);
138769
+ while( p<&aDoclist[nDoclist] && *p==0 ) p++;
138611138770
if( p>=&aDoclist[nDoclist] ){
138612138771
*pbEof = 1;
138613138772
}else{
138614138773
sqlite3_int64 iVar;
138615138774
p += sqlite3Fts3GetVarint(p, &iVar);
@@ -140012,14 +140171,14 @@
140012140171
pIter = pPhrase->doclist.pList;
140013140172
if( iDocid!=pCsr->iPrevId || pExpr->bEof ){
140014140173
int rc = SQLITE_OK;
140015140174
int bDescDoclist = pTab->bDescIdx; /* For DOCID_CMP macro */
140016140175
int bOr = 0;
140017
- u8 bEof = 0;
140018140176
u8 bTreeEof = 0;
140019140177
Fts3Expr *p; /* Used to iterate from pExpr to root */
140020140178
Fts3Expr *pNear; /* Most senior NEAR ancestor (or pExpr) */
140179
+ int bMatch;
140021140180
140022140181
/* Check if this phrase descends from an OR expression node. If not,
140023140182
** return NULL. Otherwise, the entry that corresponds to docid
140024140183
** pCsr->iPrevId may lie earlier in the doclist buffer. Or, if the
140025140184
** tree that the node is part of has been marked as EOF, but the node
@@ -140049,35 +140208,51 @@
140049140208
fts3EvalNextRow(pCsr, pNear, &rc);
140050140209
}
140051140210
}
140052140211
if( rc!=SQLITE_OK ) return rc;
140053140212
140054
- pIter = pPhrase->pOrPoslist;
140055
- iDocid = pPhrase->iOrDocid;
140056
- if( pCsr->bDesc==bDescDoclist ){
140057
- bEof = !pPhrase->doclist.nAll ||
140058
- (pIter >= (pPhrase->doclist.aAll + pPhrase->doclist.nAll));
140059
- while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)<0 ) && bEof==0 ){
140060
- sqlite3Fts3DoclistNext(
140061
- bDescDoclist, pPhrase->doclist.aAll, pPhrase->doclist.nAll,
140062
- &pIter, &iDocid, &bEof
140063
- );
140064
- }
140065
- }else{
140066
- bEof = !pPhrase->doclist.nAll || (pIter && pIter<=pPhrase->doclist.aAll);
140067
- while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)>0 ) && bEof==0 ){
140068
- int dummy;
140069
- sqlite3Fts3DoclistPrev(
140070
- bDescDoclist, pPhrase->doclist.aAll, pPhrase->doclist.nAll,
140071
- &pIter, &iDocid, &dummy, &bEof
140072
- );
140073
- }
140074
- }
140075
- pPhrase->pOrPoslist = pIter;
140076
- pPhrase->iOrDocid = iDocid;
140077
-
140078
- if( bEof || iDocid!=pCsr->iPrevId ) pIter = 0;
140213
+ bMatch = 1;
140214
+ for(p=pNear; p; p=p->pLeft){
140215
+ u8 bEof = 0;
140216
+ Fts3Expr *pTest = p;
140217
+ Fts3Phrase *pPh;
140218
+ assert( pTest->eType==FTSQUERY_NEAR || pTest->eType==FTSQUERY_PHRASE );
140219
+ if( pTest->eType==FTSQUERY_NEAR ) pTest = pTest->pRight;
140220
+ assert( pTest->eType==FTSQUERY_PHRASE );
140221
+ pPh = pTest->pPhrase;
140222
+
140223
+ pIter = pPh->pOrPoslist;
140224
+ iDocid = pPh->iOrDocid;
140225
+ if( pCsr->bDesc==bDescDoclist ){
140226
+ bEof = !pPh->doclist.nAll ||
140227
+ (pIter >= (pPh->doclist.aAll + pPh->doclist.nAll));
140228
+ while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)<0 ) && bEof==0 ){
140229
+ sqlite3Fts3DoclistNext(
140230
+ bDescDoclist, pPh->doclist.aAll, pPh->doclist.nAll,
140231
+ &pIter, &iDocid, &bEof
140232
+ );
140233
+ }
140234
+ }else{
140235
+ bEof = !pPh->doclist.nAll || (pIter && pIter<=pPh->doclist.aAll);
140236
+ while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)>0 ) && bEof==0 ){
140237
+ int dummy;
140238
+ sqlite3Fts3DoclistPrev(
140239
+ bDescDoclist, pPh->doclist.aAll, pPh->doclist.nAll,
140240
+ &pIter, &iDocid, &dummy, &bEof
140241
+ );
140242
+ }
140243
+ }
140244
+ pPh->pOrPoslist = pIter;
140245
+ pPh->iOrDocid = iDocid;
140246
+ if( bEof || iDocid!=pCsr->iPrevId ) bMatch = 0;
140247
+ }
140248
+
140249
+ if( bMatch ){
140250
+ pIter = pPhrase->pOrPoslist;
140251
+ }else{
140252
+ pIter = 0;
140253
+ }
140079140254
}
140080140255
if( pIter==0 ) return SQLITE_OK;
140081140256
140082140257
if( *pIter==0x01 ){
140083140258
pIter++;
@@ -140161,10 +140336,11 @@
140161140336
** May you share freely, never taking more than you give.
140162140337
**
140163140338
******************************************************************************
140164140339
**
140165140340
*/
140341
+/* #include "fts3Int.h" */
140166140342
#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
140167140343
140168140344
/* #include <string.h> */
140169140345
/* #include <assert.h> */
140170140346
@@ -140717,10 +140893,11 @@
140717140893
** This module contains code that implements a parser for fts3 query strings
140718140894
** (the right-hand argument to the MATCH operator). Because the supported
140719140895
** syntax is relatively simple, the whole tokenizer/parser system is
140720140896
** hand-coded.
140721140897
*/
140898
+/* #include "fts3Int.h" */
140722140899
#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
140723140900
140724140901
/*
140725140902
** By default, this module parses the legacy syntax that has been
140726140903
** traditionally used by fts3. Or, if SQLITE_ENABLE_FTS3_PARENTHESIS
@@ -142010,16 +142187,18 @@
142010142187
** (in which case SQLITE_CORE is not defined), or
142011142188
**
142012142189
** * The FTS3 module is being built into the core of
142013142190
** SQLite (in which case SQLITE_ENABLE_FTS3 is defined).
142014142191
*/
142192
+/* #include "fts3Int.h" */
142015142193
#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
142016142194
142017142195
/* #include <assert.h> */
142018142196
/* #include <stdlib.h> */
142019142197
/* #include <string.h> */
142020142198
142199
+/* #include "fts3_hash.h" */
142021142200
142022142201
/*
142023142202
** Malloc and Free functions
142024142203
*/
142025142204
static void *fts3HashMalloc(int n){
@@ -142393,17 +142572,19 @@
142393142572
** (in which case SQLITE_CORE is not defined), or
142394142573
**
142395142574
** * The FTS3 module is being built into the core of
142396142575
** SQLite (in which case SQLITE_ENABLE_FTS3 is defined).
142397142576
*/
142577
+/* #include "fts3Int.h" */
142398142578
#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
142399142579
142400142580
/* #include <assert.h> */
142401142581
/* #include <stdlib.h> */
142402142582
/* #include <stdio.h> */
142403142583
/* #include <string.h> */
142404142584
142585
+/* #include "fts3_tokenizer.h" */
142405142586
142406142587
/*
142407142588
** Class derived from sqlite3_tokenizer
142408142589
*/
142409142590
typedef struct porter_tokenizer {
@@ -143057,10 +143238,11 @@
143057143238
** (in which case SQLITE_CORE is not defined), or
143058143239
**
143059143240
** * The FTS3 module is being built into the core of
143060143241
** SQLite (in which case SQLITE_ENABLE_FTS3 is defined).
143061143242
*/
143243
+/* #include "fts3Int.h" */
143062143244
#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
143063143245
143064143246
/* #include <assert.h> */
143065143247
/* #include <string.h> */
143066143248
@@ -143552,17 +143734,19 @@
143552143734
** (in which case SQLITE_CORE is not defined), or
143553143735
**
143554143736
** * The FTS3 module is being built into the core of
143555143737
** SQLite (in which case SQLITE_ENABLE_FTS3 is defined).
143556143738
*/
143739
+/* #include "fts3Int.h" */
143557143740
#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
143558143741
143559143742
/* #include <assert.h> */
143560143743
/* #include <stdlib.h> */
143561143744
/* #include <stdio.h> */
143562143745
/* #include <string.h> */
143563143746
143747
+/* #include "fts3_tokenizer.h" */
143564143748
143565143749
typedef struct simple_tokenizer {
143566143750
sqlite3_tokenizer base;
143567143751
char delim[128]; /* flag ASCII delimiters */
143568143752
} simple_tokenizer;
@@ -143803,10 +143987,11 @@
143803143987
** end: Byte offset of the byte immediately following the end of the
143804143988
** token within the input string.
143805143989
** pos: Token offset of token within input.
143806143990
**
143807143991
*/
143992
+/* #include "fts3Int.h" */
143808143993
#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
143809143994
143810143995
/* #include <string.h> */
143811143996
/* #include <assert.h> */
143812143997
@@ -144238,10 +144423,11 @@
144238144423
** tables. It also contains code to merge FTS3 b-tree segments. Some
144239144424
** of the sub-routines used to merge segments are also used by the query
144240144425
** code in fts3.c.
144241144426
*/
144242144427
144428
+/* #include "fts3Int.h" */
144243144429
#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
144244144430
144245144431
/* #include <string.h> */
144246144432
/* #include <assert.h> */
144247144433
/* #include <stdlib.h> */
@@ -149898,10 +150084,11 @@
149898150084
** May you share freely, never taking more than you give.
149899150085
**
149900150086
******************************************************************************
149901150087
*/
149902150088
150089
+/* #include "fts3Int.h" */
149903150090
#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
149904150091
149905150092
/* #include <string.h> */
149906150093
/* #include <assert.h> */
149907150094
@@ -151610,17 +151797,19 @@
151610151797
** Implementation of the "unicode" full-text-search tokenizer.
151611151798
*/
151612151799
151613151800
#ifndef SQLITE_DISABLE_FTS3_UNICODE
151614151801
151802
+/* #include "fts3Int.h" */
151615151803
#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
151616151804
151617151805
/* #include <assert.h> */
151618151806
/* #include <stdlib.h> */
151619151807
/* #include <stdio.h> */
151620151808
/* #include <string.h> */
151621151809
151810
+/* #include "fts3_tokenizer.h" */
151622151811
151623151812
/*
151624151813
** The following two macros - READ_UTF8 and WRITE_UTF8 - have been copied
151625151814
** from the sqlite3 source file utf.c. If this file is compiled as part
151626151815
** of the amalgamation, they are not required.
@@ -152412,12 +152601,14 @@
152412152601
*/
152413152602
152414152603
#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_RTREE)
152415152604
152416152605
#ifndef SQLITE_CORE
152606
+/* #include "sqlite3ext.h" */
152417152607
SQLITE_EXTENSION_INIT1
152418152608
#else
152609
+/* #include "sqlite3.h" */
152419152610
#endif
152420152611
152421152612
/* #include <string.h> */
152422152613
/* #include <assert.h> */
152423152614
/* #include <stdio.h> */
@@ -155909,12 +156100,14 @@
155909156100
#include <unicode/ucol.h>
155910156101
155911156102
/* #include <assert.h> */
155912156103
155913156104
#ifndef SQLITE_CORE
156105
+/* #include "sqlite3ext.h" */
155914156106
SQLITE_EXTENSION_INIT1
155915156107
#else
156108
+/* #include "sqlite3.h" */
155916156109
#endif
155917156110
155918156111
/*
155919156112
** Maximum length (in bytes) of the pattern in a LIKE or GLOB
155920156113
** operator.
@@ -156386,15 +156579,17 @@
156386156579
** May you share freely, never taking more than you give.
156387156580
**
156388156581
*************************************************************************
156389156582
** This file implements a tokenizer for fts3 based on the ICU library.
156390156583
*/
156584
+/* #include "fts3Int.h" */
156391156585
#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
156392156586
#ifdef SQLITE_ENABLE_ICU
156393156587
156394156588
/* #include <assert.h> */
156395156589
/* #include <string.h> */
156590
+/* #include "fts3_tokenizer.h" */
156396156591
156397156592
#include <unicode/ubrk.h>
156398156593
/* #include <unicode/ucol.h> */
156399156594
/* #include <unicode/ustring.h> */
156400156595
#include <unicode/utf16.h>
@@ -156723,10 +156918,11 @@
156723156918
/* #include <assert.h> */
156724156919
/* #include <string.h> */
156725156920
/* #include <stdio.h> */
156726156921
/* #include <unistd.h> */
156727156922
156923
+/* #include "sqlite3.h" */
156728156924
156729156925
#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_OTA)
156730156926
/************** Include sqlite3ota.h in the middle of sqlite3ota.c ***********/
156731156927
/************** Begin file sqlite3ota.h **************************************/
156732156928
/*
@@ -156976,10 +157172,11 @@
156976157172
*/
156977157173
156978157174
#ifndef _SQLITE3OTA_H
156979157175
#define _SQLITE3OTA_H
156980157176
157177
+/* #include "sqlite3.h" ** Required for error code definitions ** */
156981157178
156982157179
typedef struct sqlite3ota sqlite3ota;
156983157180
156984157181
/*
156985157182
** Open an OTA handle.
@@ -157144,11 +157341,10 @@
157144157341
** are undefined.
157145157342
*/
157146157343
SQLITE_API void SQLITE_STDCALL sqlite3ota_destroy_vfs(const char *zName);
157147157344
157148157345
#endif /* _SQLITE3OTA_H */
157149
-
157150157346
157151157347
/************** End of sqlite3ota.h ******************************************/
157152157348
/************** Continuing where we left off in sqlite3ota.c *****************/
157153157349
157154157350
/* Maximum number of prepared UPDATE statements held by this module */
@@ -160741,10 +160937,11 @@
160741160937
** information from an SQLite database in order to implement the
160742160938
** "sqlite3_analyzer" utility. See the ../tool/spaceanal.tcl script
160743160939
** for an example implementation.
160744160940
*/
160745160941
160942
+/* #include "sqliteInt.h" ** Requires access to internal data structures ** */
160746160943
#if (defined(SQLITE_ENABLE_DBSTAT_VTAB) || defined(SQLITE_TEST)) \
160747160944
&& !defined(SQLITE_OMIT_VIRTUALTABLE)
160748160945
160749160946
/*
160750160947
** Page paths:
160751160948
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -325,11 +325,11 @@
325 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
326 ** [sqlite_version()] and [sqlite_source_id()].
327 */
328 #define SQLITE_VERSION "3.8.11"
329 #define SQLITE_VERSION_NUMBER 3008011
330 #define SQLITE_SOURCE_ID "2015-07-08 16:22:42 5348ffc3fda5168c1e9e14aa88b0c6aedbda7c94"
331
332 /*
333 ** CAPI3REF: Run-Time Library Version Numbers
334 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
335 **
@@ -8361,11 +8361,11 @@
8361
8362 /*
8363 ** Make sure that the compiler intrinsics we desire are enabled when
8364 ** compiling with an appropriate version of MSVC.
8365 */
8366 #if defined(_MSC_VER) && _MSC_VER>=1300
8367 # include <intrin.h>
8368 # pragma intrinsic(_byteswap_ushort)
8369 # pragma intrinsic(_byteswap_ulong)
8370 #endif
8371
@@ -9189,11 +9189,13 @@
9189 #endif
9190 #ifndef SQLITE_MAX_MMAP_SIZE
9191 # if defined(__linux__) \
9192 || defined(_WIN32) \
9193 || (defined(__APPLE__) && defined(__MACH__)) \
9194 || defined(__sun)
 
 
9195 # define SQLITE_MAX_MMAP_SIZE 0x7fff0000 /* 2147418112 */
9196 # else
9197 # define SQLITE_MAX_MMAP_SIZE 0
9198 # endif
9199 # define SQLITE_MAX_MMAP_SIZE_xc 1 /* exclude from ctime.c */
@@ -13883,10 +13885,11 @@
13883 **
13884 *************************************************************************
13885 **
13886 ** This file contains definitions of global variables and constants.
13887 */
 
13888
13889 /* An array to map all upper-case characters into their corresponding
13890 ** lower-case character.
13891 **
13892 ** SQLite only considers US-ASCII (or EBCDIC) characters. We do not
@@ -14122,10 +14125,11 @@
14122 */
14123 #ifndef SQLITE_OMIT_WSD
14124 SQLITE_PRIVATE int sqlite3PendingByte = 0x40000000;
14125 #endif
14126
 
14127 /*
14128 ** Properties of opcodes. The OPFLG_INITIALIZER macro is
14129 ** created by mkopcodeh.awk during compilation. Data is obtained
14130 ** from the comments following the "case OP_xxxx:" statements in
14131 ** the vdbe.c file.
@@ -14150,10 +14154,11 @@
14150 ** SQLite was built with.
14151 */
14152
14153 #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
14154
 
14155
14156 /*
14157 ** An array of names of all compile-time options. This array should
14158 ** be sorted A-Z.
14159 **
@@ -14579,10 +14584,11 @@
14579 *************************************************************************
14580 **
14581 ** This module implements the sqlite3_status() interface and related
14582 ** functionality.
14583 */
 
14584 /************** Include vdbeInt.h in the middle of status.c ******************/
14585 /************** Begin file vdbeInt.h *****************************************/
14586 /*
14587 ** 2003 September 6
14588 **
@@ -15462,10 +15468,11 @@
15462 ** Astronomical Algorithms, 2nd Edition, 1998
15463 ** ISBM 0-943396-61-1
15464 ** Willmann-Bell, Inc
15465 ** Richmond, Virginia (USA)
15466 */
 
15467 /* #include <stdlib.h> */
15468 /* #include <assert.h> */
15469 #include <time.h>
15470
15471 #ifndef SQLITE_OMIT_DATETIME_FUNCS
@@ -15773,11 +15780,11 @@
15773 Z = (int)((p->iJD + 43200000)/86400000);
15774 A = (int)((Z - 1867216.25)/36524.25);
15775 A = Z + 1 + A - (A/4);
15776 B = A + 1524;
15777 C = (int)((B - 122.1)/365.25);
15778 D = (36525*C)/100;
15779 E = (int)((B-D)/30.6001);
15780 X1 = (int)(30.6001*E);
15781 p->D = B - D - X1;
15782 p->M = E<14 ? E-1 : E-13;
15783 p->Y = p->M>2 ? C - 4716 : C - 4715;
@@ -16574,10 +16581,11 @@
16574 **
16575 ** This file contains OS interface code that is common to all
16576 ** architectures.
16577 */
16578 #define _SQLITE_OS_C_ 1
 
16579 #undef _SQLITE_OS_C_
16580
16581 /*
16582 ** The default SQLite sqlite3_vfs implementations do not allocate
16583 ** memory (actually, os_unix.c allocates a small amount of memory
@@ -16980,10 +16988,11 @@
16980 ** is completely recoverable simply by not carrying out the resize. The
16981 ** hash table will continue to function normally. So a malloc failure
16982 ** during a hash table resize is a benign fault.
16983 */
16984
 
16985
16986 #ifndef SQLITE_OMIT_BUILTIN_TEST
16987
16988 /*
16989 ** Global variables.
@@ -17061,10 +17070,11 @@
17061 ** SQLITE_ZERO_MALLOC is defined. The allocation drivers implemented
17062 ** here always fail. SQLite will not operate with these drivers. These
17063 ** are merely placeholders. Real drivers must be substituted using
17064 ** sqlite3_config() before SQLite will operate.
17065 */
 
17066
17067 /*
17068 ** This version of the memory allocator is the default. It is
17069 ** used when no other memory allocator is specified using compile-time
17070 ** macros.
@@ -17147,10 +17157,11 @@
17147 ** SQLITE_WITHOUT_MSIZE Set this symbol to disable the use of
17148 ** _msize() on windows systems. This might
17149 ** be necessary when compiling for Delphi,
17150 ** for example.
17151 */
 
17152
17153 /*
17154 ** This version of the memory allocator is the default. It is
17155 ** used when no other memory allocator is specified using compile-time
17156 ** macros.
@@ -17422,10 +17433,11 @@
17422 ** leaks and memory usage errors.
17423 **
17424 ** This file contains implementations of the low-level memory allocation
17425 ** routines specified in the sqlite3_mem_methods object.
17426 */
 
17427
17428 /*
17429 ** This version of the memory allocator is used only if the
17430 ** SQLITE_MEMDEBUG macro is defined
17431 */
@@ -17956,10 +17968,11 @@
17956 ** be changed.
17957 **
17958 ** This version of the memory allocation subsystem is included
17959 ** in the build only if SQLITE_ENABLE_MEMSYS3 is defined.
17960 */
 
17961
17962 /*
17963 ** This version of the memory allocator is only built into the library
17964 ** SQLITE_ENABLE_MEMSYS3 is defined. Defining this symbol does not
17965 ** mean that the library will use a memory-pool by default, just that
@@ -18670,10 +18683,11 @@
18670 ** N >= M*(1 + log2(n)/2) - n + 1
18671 **
18672 ** The sqlite3_status() logic tracks the maximum values of n and M so
18673 ** that an application can, at any time, verify this constraint.
18674 */
 
18675
18676 /*
18677 ** This version of the memory allocator is used only when
18678 ** SQLITE_ENABLE_MEMSYS5 is defined.
18679 */
@@ -19213,10 +19227,11 @@
19213 *************************************************************************
19214 ** This file contains the C functions that implement mutexes.
19215 **
19216 ** This file contains code that is common across all mutex implementations.
19217 */
 
19218
19219 #if defined(SQLITE_DEBUG) && !defined(SQLITE_MUTEX_OMIT)
19220 /*
19221 ** For debugging purposes, record when the mutex subsystem is initialized
19222 ** and uninitialized so that we can assert() if there is an attempt to
@@ -19386,10 +19401,11 @@
19386 **
19387 ** If compiled with SQLITE_DEBUG, then additional logic is inserted
19388 ** that does error checking on mutexes to make sure they are being
19389 ** called correctly.
19390 */
 
19391
19392 #ifndef SQLITE_MUTEX_OMIT
19393
19394 #ifndef SQLITE_DEBUG
19395 /*
@@ -19589,10 +19605,11 @@
19589 ** May you share freely, never taking more than you give.
19590 **
19591 *************************************************************************
19592 ** This file contains the C functions that implement mutexes for pthreads
19593 */
 
19594
19595 /*
19596 ** The code in this file is only used if we are compiling threadsafe
19597 ** under unix with pthreads.
19598 **
@@ -19963,10 +19980,11 @@
19963 ** May you share freely, never taking more than you give.
19964 **
19965 *************************************************************************
19966 ** This file contains the C functions that implement mutexes for Win32.
19967 */
 
19968
19969 #if SQLITE_OS_WIN
19970 /*
19971 ** Include code that is common to all os_*.c files
19972 */
@@ -20638,10 +20656,11 @@
20638 **
20639 *************************************************************************
20640 **
20641 ** Memory allocation functions used throughout sqlite.
20642 */
 
20643 /* #include <stdarg.h> */
20644
20645 /*
20646 ** Attempt to release up to n bytes of non-essential memory currently
20647 ** held by SQLite. An example of non-essential memory is memory used to
@@ -21449,10 +21468,11 @@
21449 ** This file contains code for a set of "printf"-like routines. These
21450 ** routines format strings much like the printf() from the standard C
21451 ** library, though the implementation here has enhancements to support
21452 ** SQLite.
21453 */
 
21454
21455 /*
21456 ** Conversion types fall into various categories as defined by the
21457 ** following enumeration.
21458 */
@@ -22451,10 +22471,15 @@
22451 ** stack space on small-stack systems when logging is disabled.
22452 **
22453 ** sqlite3_log() must render into a static buffer. It cannot dynamically
22454 ** allocate memory because it might be called while the memory allocator
22455 ** mutex is held.
 
 
 
 
 
22456 */
22457 static void renderLogMsg(int iErrCode, const char *zFormat, va_list ap){
22458 StrAccum acc; /* String accumulator */
22459 char zMsg[SQLITE_PRINT_BUF_SIZE*3]; /* Complete log message */
22460
@@ -22526,10 +22551,11 @@
22526 ** analysis.
22527 **
22528 ** The interfaces in this file is only available when compiling
22529 ** with SQLITE_DEBUG.
22530 */
 
22531 #ifdef SQLITE_DEBUG
22532
22533 /*
22534 ** Add a new subitem to the tree. The moreToFollow flag indicates that this
22535 ** is not the last item in the tree.
@@ -22957,10 +22983,11 @@
22957 ** generator (PRNG) for SQLite.
22958 **
22959 ** Random numbers are used by some of the database backends in order
22960 ** to generate random integer keys for tables or random filenames.
22961 */
 
22962
22963
22964 /* All threads share a single random number generator.
22965 ** This structure is the current state of the generator.
22966 */
@@ -23103,11 +23130,13 @@
23103 ** single threaded systems. Nothing in SQLite requires multiple threads.
23104 ** This interface exists so that applications that want to take advantage
23105 ** of multiple cores can do so, while also allowing applications to stay
23106 ** single-threaded if desired.
23107 */
 
23108 #if SQLITE_OS_WIN
 
23109 #endif
23110
23111 #if SQLITE_MAX_WORKER_THREADS>0
23112
23113 /********************************* Unix Pthreads ****************************/
@@ -23377,11 +23406,13 @@
23377 ** BOM or Byte Order Mark:
23378 ** 0xff 0xfe little-endian utf-16 follows
23379 ** 0xfe 0xff big-endian utf-16 follows
23380 **
23381 */
 
23382 /* #include <assert.h> */
 
23383
23384 #ifndef SQLITE_AMALGAMATION
23385 /*
23386 ** The following constant value is used by the SQLITE_BIGENDIAN and
23387 ** SQLITE_LITTLEENDIAN macros.
@@ -23890,10 +23921,11 @@
23890 **
23891 ** This file contains functions for allocating memory, comparing
23892 ** strings, and stuff like that.
23893 **
23894 */
 
23895 /* #include <stdarg.h> */
23896 #if HAVE_ISNAN || SQLITE_HAVE_ISNAN
23897 # include <math.h>
23898 #endif
23899
@@ -25286,10 +25318,11 @@
25286 **
25287 *************************************************************************
25288 ** This is the implementation of generic hash-tables
25289 ** used in SQLite.
25290 */
 
25291 /* #include <assert.h> */
25292
25293 /* Turn bulk memory into a hash table object by initializing the
25294 ** fields of the Hash structure.
25295 **
@@ -25763,10 +25796,11 @@
25763 ** * sqlite3_vfs method implementations.
25764 ** * Locking primitives for the proxy uber-locking-method. (MacOSX only)
25765 ** * Definitions of sqlite3_vfs objects for all locking methods
25766 ** plus implementations of sqlite3_os_init() and sqlite3_os_end().
25767 */
 
25768 #if SQLITE_OS_UNIX /* This file is used on unix only */
25769
25770 /*
25771 ** There are various methods for file locking used for concurrency
25772 ** control:
@@ -33497,10 +33531,11 @@
33497 **
33498 ******************************************************************************
33499 **
33500 ** This file contains code that is specific to Windows.
33501 */
 
33502 #if SQLITE_OS_WIN /* This file is used for Windows only */
33503
33504 /*
33505 ** Include code that is common to all os_*.c files
33506 */
@@ -33705,10 +33740,11 @@
33705 /************** Continuing where we left off in os_win.c *********************/
33706
33707 /*
33708 ** Include the header file for the Windows VFS.
33709 */
 
33710
33711 /*
33712 ** Compiling and using WAL mode requires several APIs that are only
33713 ** available in Windows platforms based on the NT kernel.
33714 */
@@ -39358,10 +39394,11 @@
39358 ** sometimes grow into tens of thousands or larger. The size of the
39359 ** Bitvec object is the number of pages in the database file at the
39360 ** start of a transaction, and is thus usually less than a few thousand,
39361 ** but can be as large as 2 billion for a really big database.
39362 */
 
39363
39364 /* Size of the Bitvec structure in bytes. */
39365 #define BITVEC_SZ 512
39366
39367 /* Round the union size down to the nearest pointer boundary, since that's how
@@ -39747,10 +39784,11 @@
39747 ** May you share freely, never taking more than you give.
39748 **
39749 *************************************************************************
39750 ** This file implements that page cache.
39751 */
 
39752
39753 /*
39754 ** A complete page cache is an instance of this structure.
39755 */
39756 struct PCache {
@@ -40488,10 +40526,11 @@
40488 **
40489 ** Earlier versions of SQLite used only methods (1) and (2). But experiments
40490 ** show that method (3) with N==100 provides about a 5% performance boost for
40491 ** common workloads.
40492 */
 
40493
40494 typedef struct PCache1 PCache1;
40495 typedef struct PgHdr1 PgHdr1;
40496 typedef struct PgFreeslot PgFreeslot;
40497 typedef struct PGroup PGroup;
@@ -40598,10 +40637,11 @@
40598 ** fixed at sqlite3_initialize() time and do not require mutex protection.
40599 ** The nFreeSlot and pFree values do require mutex protection.
40600 */
40601 int isInit; /* True if initialized */
40602 int separateCache; /* Use a new PGroup for each PCache */
 
40603 int szSlot; /* Size of each free slot */
40604 int nSlot; /* The number of pcache slots */
40605 int nReserve; /* Try to keep nFreeSlot above this */
40606 void *pStart, *pEnd; /* Bounds of global page cache memory */
40607 /* Above requires no mutex. Use mutex below for variable that follow. */
@@ -40665,10 +40705,47 @@
40665 pBuf = (void*)&((char*)pBuf)[sz];
40666 }
40667 pcache1.pEnd = pBuf;
40668 }
40669 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40670
40671 /*
40672 ** Malloc function used within this file to allocate space from the buffer
40673 ** configured using sqlite3_config(SQLITE_CONFIG_PAGECACHE) option. If no
40674 ** such buffer exists or there is no space left in it, this function falls
@@ -40766,11 +40843,11 @@
40766 static PgHdr1 *pcache1AllocPage(PCache1 *pCache){
40767 PgHdr1 *p = 0;
40768 void *pPg;
40769
40770 assert( sqlite3_mutex_held(pCache->pGroup->mutex) );
40771 if( pCache->pFree ){
40772 p = pCache->pFree;
40773 pCache->pFree = p->pNext;
40774 p->pNext = 0;
40775 }else{
40776 #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
@@ -40970,18 +41047,23 @@
40970
40971 /*
40972 ** If there are currently more than nMaxPage pages allocated, try
40973 ** to recycle pages to reduce the number allocated to nMaxPage.
40974 */
40975 static void pcache1EnforceMaxPage(PGroup *pGroup){
 
40976 assert( sqlite3_mutex_held(pGroup->mutex) );
40977 while( pGroup->nCurrentPage>pGroup->nMaxPage && pGroup->pLruTail ){
40978 PgHdr1 *p = pGroup->pLruTail;
40979 assert( p->pCache->pGroup==pGroup );
40980 assert( p->isPinned==0 );
40981 pcache1PinPage(p);
40982 pcache1RemoveFromHash(p, 1);
 
 
 
 
40983 }
40984 }
40985
40986 /*
40987 ** Discard all pages from cache pCache with a page number (key value)
@@ -41054,10 +41136,18 @@
41054 if( sqlite3GlobalConfig.bCoreMutex ){
41055 pcache1.grp.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_LRU);
41056 pcache1.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_PMEM);
41057 }
41058 #endif
 
 
 
 
 
 
 
 
41059 pcache1.grp.mxPinned = 10;
41060 pcache1.isInit = 1;
41061 return SQLITE_OK;
41062 }
41063
@@ -41108,40 +41198,10 @@
41108 pCache->nMin = 10;
41109 pGroup->nMinPage += pCache->nMin;
41110 pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage;
41111 }
41112 pcache1LeaveMutex(pGroup);
41113 /* Try to initialize the local bulk pagecache line allocation if using
41114 ** separate caches and if nPage!=0 */
41115 if( pcache1.separateCache
41116 && sqlite3GlobalConfig.nPage!=0
41117 && sqlite3GlobalConfig.pPage==0
41118 ){
41119 int szBulk;
41120 char *zBulk;
41121 sqlite3BeginBenignMalloc();
41122 if( sqlite3GlobalConfig.nPage>0 ){
41123 szBulk = pCache->szAlloc * sqlite3GlobalConfig.nPage;
41124 }else{
41125 szBulk = -1024*sqlite3GlobalConfig.nPage;
41126 }
41127 zBulk = pCache->pBulk = sqlite3Malloc( szBulk );
41128 sqlite3EndBenignMalloc();
41129 if( zBulk ){
41130 int nBulk = sqlite3MallocSize(zBulk)/pCache->szAlloc;
41131 int i;
41132 for(i=0; i<nBulk; i++){
41133 PgHdr1 *pX = (PgHdr1*)&zBulk[szPage];
41134 pX->page.pBuf = zBulk;
41135 pX->page.pExtra = &pX[1];
41136 pX->isBulkLocal = 1;
41137 pX->pNext = pCache->pFree;
41138 pCache->pFree = pX;
41139 zBulk += pCache->szAlloc;
41140 }
41141 }
41142 }
41143 if( pCache->nHash==0 ){
41144 pcache1Destroy((sqlite3_pcache*)pCache);
41145 pCache = 0;
41146 }
41147 }
@@ -41160,11 +41220,11 @@
41160 pcache1EnterMutex(pGroup);
41161 pGroup->nMaxPage += (nMax - pCache->nMax);
41162 pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage;
41163 pCache->nMax = nMax;
41164 pCache->n90pct = pCache->nMax*9/10;
41165 pcache1EnforceMaxPage(pGroup);
41166 pcache1LeaveMutex(pGroup);
41167 }
41168 }
41169
41170 /*
@@ -41178,11 +41238,11 @@
41178 PGroup *pGroup = pCache->pGroup;
41179 int savedMaxPage;
41180 pcache1EnterMutex(pGroup);
41181 savedMaxPage = pGroup->nMaxPage;
41182 pGroup->nMaxPage = 0;
41183 pcache1EnforceMaxPage(pGroup);
41184 pGroup->nMaxPage = savedMaxPage;
41185 pcache1LeaveMutex(pGroup);
41186 }
41187 }
41188
@@ -41515,11 +41575,11 @@
41515 assert( pGroup->nMaxPage >= pCache->nMax );
41516 pGroup->nMaxPage -= pCache->nMax;
41517 assert( pGroup->nMinPage >= pCache->nMin );
41518 pGroup->nMinPage -= pCache->nMin;
41519 pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage;
41520 pcache1EnforceMaxPage(pGroup);
41521 pcache1LeaveMutex(pGroup);
41522 sqlite3_free(pCache->pBulk);
41523 sqlite3_free(pCache->apHash);
41524 sqlite3_free(pCache);
41525 }
@@ -41679,10 +41739,11 @@
41679 ** primitives are constant time. The cost of DESTROY is O(N).
41680 **
41681 ** There is an added cost of O(N) when switching between TEST and
41682 ** SMALLEST primitives.
41683 */
 
41684
41685
41686 /*
41687 ** Target size for allocation chunks.
41688 */
@@ -42148,10 +42209,11 @@
42148 ** locking to prevent two processes from writing the same database
42149 ** file simultaneously, or one process from reading the database while
42150 ** another is writing.
42151 */
42152 #ifndef SQLITE_OMIT_DISKIO
 
42153 /************** Include wal.h in the middle of pager.c ***********************/
42154 /************** Begin file wal.h *********************************************/
42155 /*
42156 ** 2010 February 1
42157 **
@@ -42169,10 +42231,11 @@
42169 */
42170
42171 #ifndef _WAL_H_
42172 #define _WAL_H_
42173
 
42174
42175 /* Additional values that can be added to the sync_flags argument of
42176 ** sqlite3WalFrames():
42177 */
42178 #define WAL_SYNC_TRANSACTIONS 0x20 /* Sync at the end of each transaction */
@@ -49783,10 +49846,11 @@
49783 ** that correspond to frames greater than the new K value are removed
49784 ** from the hash table at this point.
49785 */
49786 #ifndef SQLITE_OMIT_WAL
49787
 
49788
49789 /*
49790 ** Trace output macros
49791 */
49792 #if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)
@@ -51000,11 +51064,11 @@
51000
51001 const int nList = *pnList; /* Size of input list */
51002 int nMerge = 0; /* Number of elements in list aMerge */
51003 ht_slot *aMerge = 0; /* List to be merged */
51004 int iList; /* Index into input list */
51005 int iSub = 0; /* Index into aSub array */
51006 struct Sublist aSub[13]; /* Array of sub-lists */
51007
51008 memset(aSub, 0, sizeof(aSub));
51009 assert( nList<=HASHTABLE_NPAGE && nList>0 );
51010 assert( HASHTABLE_NPAGE==(1<<(ArraySize(aSub)-1)) );
@@ -51011,11 +51075,13 @@
51011
51012 for(iList=0; iList<nList; iList++){
51013 nMerge = 1;
51014 aMerge = &aList[iList];
51015 for(iSub=0; iList & (1<<iSub); iSub++){
51016 struct Sublist *p = &aSub[iSub];
 
 
51017 assert( p->aList && p->nList<=(1<<iSub) );
51018 assert( p->aList==&aList[iList&~((2<<iSub)-1)] );
51019 walMerge(aContent, p->aList, p->nList, &aMerge, &nMerge, aBuffer);
51020 }
51021 aSub[iSub].aList = aMerge;
@@ -51022,11 +51088,13 @@
51022 aSub[iSub].nList = nMerge;
51023 }
51024
51025 for(iSub++; iSub<ArraySize(aSub); iSub++){
51026 if( nList & (1<<iSub) ){
51027 struct Sublist *p = &aSub[iSub];
 
 
51028 assert( p->nList<=(1<<iSub) );
51029 assert( p->aList==&aList[nList&~((2<<iSub)-1)] );
51030 walMerge(aContent, p->aList, p->nList, &aMerge, &nMerge, aBuffer);
51031 }
51032 }
@@ -52933,10 +53001,11 @@
52933 ** SIZE DESCRIPTION
52934 ** 4 Page number of next trunk page
52935 ** 4 Number of leaf pointers on this page
52936 ** * zero or more pages numbers of leaves
52937 */
 
52938
52939
52940 /* The following value is the maximum cell size assuming a maximum page
52941 ** size give above.
52942 */
@@ -53730,10 +53799,11 @@
53730 *************************************************************************
53731 ** This file implements an external (disk-based) database using BTrees.
53732 ** See the header comment on "btreeInt.h" for additional information.
53733 ** Including a description of file format and an overview of operation.
53734 */
 
53735
53736 /*
53737 ** The header string that appears at the beginning of every
53738 ** SQLite database.
53739 */
@@ -62675,11 +62745,11 @@
62675 u32 *heap = 0; /* Min-heap used for checking cell coverage */
62676 u32 x, prev = 0; /* Next and previous entry on the min-heap */
62677 const char *saved_zPfx = pCheck->zPfx;
62678 int saved_v1 = pCheck->v1;
62679 int saved_v2 = pCheck->v2;
62680 u8 savedIsInit;
62681
62682 /* Check that the page exists
62683 */
62684 pBt = pCheck->pBt;
62685 usableSize = pBt->usableSize;
@@ -63311,10 +63381,12 @@
63311 **
63312 *************************************************************************
63313 ** This file contains the implementation of the sqlite3_backup_XXX()
63314 ** API functions and the related features.
63315 */
 
 
63316
63317 /*
63318 ** Structure allocated for each backup operation.
63319 */
63320 struct sqlite3_backup {
@@ -64109,10 +64181,12 @@
64109 ** This file contains code use to manipulate "Mem" structure. A "Mem"
64110 ** stores a single value in the VDBE. Mem is an opaque structure visible
64111 ** only within the VDBE. Interface routines refer to a Mem using the
64112 ** name sqlite_value
64113 */
 
 
64114
64115 #ifdef SQLITE_DEBUG
64116 /*
64117 ** Check invariants on a Mem object.
64118 **
@@ -65826,10 +65900,12 @@
65826 **
65827 *************************************************************************
65828 ** This file contains code used for creating, destroying, and populating
65829 ** a VDBE (or an "sqlite3_stmt" as it is known to the outside world.)
65830 */
 
 
65831
65832 /*
65833 ** Create a new virtual database engine.
65834 */
65835 SQLITE_PRIVATE Vdbe *sqlite3VdbeCreate(Parse *pParse){
@@ -70074,10 +70150,12 @@
70074 *************************************************************************
70075 **
70076 ** This file contains code use to implement APIs that are part of the
70077 ** VDBE.
70078 */
 
 
70079
70080 #ifndef SQLITE_OMIT_DEPRECATED
70081 /*
70082 ** Return TRUE (non-zero) of the statement supplied as an argument needs
70083 ** to be recompiled. A statement needs to be recompiled whenever the
@@ -70112,10 +70190,35 @@
70112 }else{
70113 return vdbeSafety(p);
70114 }
70115 }
70116
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70117 /*
70118 ** The following routine destroys a virtual machine that is created by
70119 ** the sqlite3_compile() routine. The integer returned is an SQLITE_
70120 ** success/failure code that describes the result of executing the virtual
70121 ** machine.
@@ -70132,10 +70235,11 @@
70132 }else{
70133 Vdbe *v = (Vdbe*)pStmt;
70134 sqlite3 *db = v->db;
70135 if( vdbeSafety(v) ) return SQLITE_MISUSE_BKPT;
70136 sqlite3_mutex_enter(db->mutex);
 
70137 rc = sqlite3VdbeFinalize(v);
70138 rc = sqlite3ApiExit(db, rc);
70139 sqlite3LeaveMutexAndCloseZombie(db);
70140 }
70141 return rc;
@@ -70153,16 +70257,18 @@
70153 int rc;
70154 if( pStmt==0 ){
70155 rc = SQLITE_OK;
70156 }else{
70157 Vdbe *v = (Vdbe*)pStmt;
70158 sqlite3_mutex_enter(v->db->mutex);
 
 
70159 rc = sqlite3VdbeReset(v);
70160 sqlite3VdbeRewind(v);
70161 assert( (rc & (v->db->errMask))==rc );
70162 rc = sqlite3ApiExit(v->db, rc);
70163 sqlite3_mutex_leave(v->db->mutex);
70164 }
70165 return rc;
70166 }
70167
70168 /*
@@ -70508,10 +70614,11 @@
70508 }
70509 }
70510 #endif
70511 return rc;
70512 }
 
70513
70514 /*
70515 ** Execute the statement pStmt, either until a row of data is ready, the
70516 ** statement is completely executed or an error occurs.
70517 **
@@ -70577,12 +70684,14 @@
70577 assert( db->nVdbeWrite>0 || db->autoCommit==0
70578 || (db->nDeferredCons==0 && db->nDeferredImmCons==0)
70579 );
70580
70581 #ifndef SQLITE_OMIT_TRACE
70582 if( db->xProfile && !db->init.busy ){
70583 sqlite3OsCurrentTimeInt64(db->pVfs, &p->startTime);
 
 
70584 }
70585 #endif
70586
70587 db->nVdbeActive++;
70588 if( p->readOnly==0 ) db->nVdbeWrite++;
@@ -70602,17 +70711,12 @@
70602 rc = sqlite3VdbeExec(p);
70603 db->nVdbeExec--;
70604 }
70605
70606 #ifndef SQLITE_OMIT_TRACE
70607 /* Invoke the profile callback if there is one
70608 */
70609 if( rc!=SQLITE_ROW && db->xProfile && !db->init.busy && p->zSql ){
70610 sqlite3_int64 iNow;
70611 sqlite3OsCurrentTimeInt64(db->pVfs, &iNow);
70612 db->xProfile(db->pProfileArg, p->zSql, (iNow - p->startTime)*1000000);
70613 }
70614 #endif
70615
70616 if( rc==SQLITE_DONE ){
70617 assert( p->rc==SQLITE_OK );
70618 p->rc = doWalCallbacks(db);
@@ -71685,10 +71789,12 @@
71685 ** This file contains code used to insert the values of host parameters
71686 ** (aka "wildcards") into the SQL text output by sqlite3_trace().
71687 **
71688 ** The Vdbe parse-tree explainer is also found here.
71689 */
 
 
71690
71691 #ifndef SQLITE_OMIT_TRACE
71692
71693 /*
71694 ** zSql is a zero-terminated string of UTF-8 SQL text. Return the number of
@@ -71877,10 +71983,12 @@
71877 ** documentation, headers files, or other derived files. The formatting
71878 ** of the code in this file is, therefore, important. See other comments
71879 ** in this file for details. If in doubt, do not deviate from existing
71880 ** commenting and indentation practices when changing or adding code.
71881 */
 
 
71882
71883 /*
71884 ** Invoke this macro on memory cells just prior to changing the
71885 ** value of the cell. This macro verifies that shallow copies are
71886 ** not misused. A shallow copy of a string or blob just copies a
@@ -78635,10 +78743,12 @@
78635 *************************************************************************
78636 **
78637 ** This file contains code used to implement incremental BLOB I/O.
78638 */
78639
 
 
78640
78641 #ifndef SQLITE_OMIT_INCRBLOB
78642
78643 /*
78644 ** Valid sqlite3_blob* handles point to Incrblob structures.
@@ -79233,10 +79343,12 @@
79233 ** than one background thread may be created. Specifically, there may be
79234 ** one background thread for each temporary file on disk, and one background
79235 ** thread to merge the output of each of the others to a single PMA for
79236 ** the main thread to read from.
79237 */
 
 
79238
79239 /*
79240 ** If SQLITE_DEBUG_SORTER_THREADS is defined, this module outputs various
79241 ** messages to stderr that may be helpful in understanding the performance
79242 ** characteristics of the sorter in multi-threaded mode.
@@ -81849,10 +81961,11 @@
81849 ** 1) The in-memory representation grows too large for the allocated
81850 ** buffer, or
81851 ** 2) The sqlite3JournalCreate() function is called.
81852 */
81853 #ifdef SQLITE_ENABLE_ATOMIC_WRITE
 
81854
81855
81856 /*
81857 ** A JournalFile object is a subclass of sqlite3_file used by
81858 ** as an open file handle for journal files.
@@ -82096,10 +82209,11 @@
82096 **
82097 ** This file contains code use to implement an in-memory rollback journal.
82098 ** The in-memory rollback journal is used to journal transactions for
82099 ** ":memory:" databases and when the journal_mode=MEMORY pragma is used.
82100 */
 
82101
82102 /* Forward references to internal structures */
82103 typedef struct MemJournal MemJournal;
82104 typedef struct FilePoint FilePoint;
82105 typedef struct FileChunk FileChunk;
@@ -82351,10 +82465,11 @@
82351 **
82352 *************************************************************************
82353 ** This file contains routines used for walking the parser tree for
82354 ** an SQL statement.
82355 */
 
82356 /* #include <stdlib.h> */
82357 /* #include <string.h> */
82358
82359
82360 /*
@@ -82509,10 +82624,11 @@
82509 **
82510 ** This file contains routines used for walking the parser tree and
82511 ** resolve all identifiers by associating them with a particular
82512 ** table and column.
82513 */
 
82514 /* #include <stdlib.h> */
82515 /* #include <string.h> */
82516
82517 /*
82518 ** Walk the expression tree pExpr and increase the aggregate function
@@ -84021,10 +84137,11 @@
84021 **
84022 *************************************************************************
84023 ** This file contains routines used for analyzing expressions and
84024 ** for generating VDBE code that evaluates expressions in SQLite.
84025 */
 
84026
84027 /*
84028 ** Return the 'affinity' of the expression pExpr if any.
84029 **
84030 ** If pExpr is a column, a reference to a column via an 'AS' alias,
@@ -88183,10 +88300,11 @@
88183 **
88184 *************************************************************************
88185 ** This file contains C code routines that used to generate VDBE code
88186 ** that implements the ALTER TABLE command.
88187 */
 
88188
88189 /*
88190 ** The code in this file only exists if we are not omitting the
88191 ** ALTER TABLE logic from the build.
88192 */
@@ -89145,10 +89263,11 @@
89145 ** sqlite_stat4.sample. The nEq, nLt, and nDLt entries of sqlite_stat3
89146 ** all contain just a single integer which is the same as the first
89147 ** integer in the equivalent columns in sqlite_stat4.
89148 */
89149 #ifndef SQLITE_OMIT_ANALYZE
 
89150
89151 #if defined(SQLITE_ENABLE_STAT4)
89152 # define IsStat4 1
89153 # define IsStat3 0
89154 #elif defined(SQLITE_ENABLE_STAT3)
@@ -90910,10 +91029,11 @@
90910 ** May you share freely, never taking more than you give.
90911 **
90912 *************************************************************************
90913 ** This file contains code used to implement the ATTACH and DETACH commands.
90914 */
 
90915
90916 #ifndef SQLITE_OMIT_ATTACH
90917 /*
90918 ** Resolve an expression that was part of an ATTACH or DETACH statement. This
90919 ** is slightly different from resolving a normal SQL expression, because simple
@@ -91499,10 +91619,11 @@
91499 ** This file contains code used to implement the sqlite3_set_authorizer()
91500 ** API. This facility is an optional feature of the library. Embedded
91501 ** systems that do not need this facility may omit it by recompiling
91502 ** the library with -DSQLITE_OMIT_AUTHORIZATION=1
91503 */
 
91504
91505 /*
91506 ** All of the code in this file may be omitted by defining a single
91507 ** macro.
91508 */
@@ -91769,10 +91890,11 @@
91769 ** creating ID lists
91770 ** BEGIN TRANSACTION
91771 ** COMMIT
91772 ** ROLLBACK
91773 */
 
91774
91775 /*
91776 ** This routine is called when a new SQL statement is beginning to
91777 ** be parsed. Initialize the pParse structure as needed.
91778 */
@@ -96089,10 +96211,11 @@
96089 **
96090 ** This file contains functions used to access the internal hash tables
96091 ** of user defined functions and collation sequences.
96092 */
96093
 
96094
96095 /*
96096 ** Invoke the 'collation needed' callback to request a collation sequence
96097 ** in the encoding enc of name zName, length nName.
96098 */
@@ -96566,10 +96689,11 @@
96566 **
96567 *************************************************************************
96568 ** This file contains C code routines that are called by the parser
96569 ** in order to generate code for DELETE FROM statements.
96570 */
 
96571
96572 /*
96573 ** While a SrcList can in general represent multiple tables and subqueries
96574 ** (as in the FROM clause of a SELECT statement) in this case it contains
96575 ** the name of a single table, as one might find in an INSERT, DELETE,
@@ -97408,12 +97532,14 @@
97408 *************************************************************************
97409 ** This file contains the C-language implementations for many of the SQL
97410 ** functions of SQLite. (Some function, and in particular the date and
97411 ** time functions, are implemented separately.)
97412 */
 
97413 /* #include <stdlib.h> */
97414 /* #include <assert.h> */
 
97415
97416 /*
97417 ** Return the collating function associated with a function.
97418 */
97419 static CollSeq *sqlite3GetFuncCollSeq(sqlite3_context *context){
@@ -99205,10 +99331,11 @@
99205 **
99206 *************************************************************************
99207 ** This file contains code used by the compiler to add foreign key
99208 ** support to compiled SQL statements.
99209 */
 
99210
99211 #ifndef SQLITE_OMIT_FOREIGN_KEY
99212 #ifndef SQLITE_OMIT_TRIGGER
99213
99214 /*
@@ -100609,10 +100736,11 @@
100609 **
100610 *************************************************************************
100611 ** This file contains C code routines that are called by the parser
100612 ** to handle INSERT statements in SQLite.
100613 */
 
100614
100615 /*
100616 ** Generate code that will
100617 **
100618 ** (1) acquire a lock for table pTab then
@@ -102671,10 +102799,11 @@
102671 ** implement the programmer interface to the library. Routines in
102672 ** other files are for internal use by SQLite and should not be
102673 ** accessed by users of the library.
102674 */
102675
 
102676
102677 /*
102678 ** Execute SQL code. Return one of the SQLITE_ success/failure
102679 ** codes. Also write an error message into memory obtained from
102680 ** malloc() and make *pzErrMsg point to that message.
@@ -102839,10 +102968,11 @@
102839 ** as extensions by SQLite should #include this file instead of
102840 ** sqlite3.h.
102841 */
102842 #ifndef _SQLITE3EXT_H_
102843 #define _SQLITE3EXT_H_
 
102844
102845 typedef struct sqlite3_api_routines sqlite3_api_routines;
102846
102847 /*
102848 ** The following structure holds pointers to all of the SQLite API
@@ -103345,10 +103475,11 @@
103345
103346 #endif /* _SQLITE3EXT_H_ */
103347
103348 /************** End of sqlite3ext.h ******************************************/
103349 /************** Continuing where we left off in loadext.c ********************/
 
103350 /* #include <string.h> */
103351
103352 #ifndef SQLITE_OMIT_LOAD_EXTENSION
103353
103354 /*
@@ -104114,10 +104245,11 @@
104114 ** May you share freely, never taking more than you give.
104115 **
104116 *************************************************************************
104117 ** This file contains code used to implement the PRAGMA command.
104118 */
 
104119
104120 #if !defined(SQLITE_ENABLE_LOCKING_STYLE)
104121 # if defined(__APPLE__)
104122 # define SQLITE_ENABLE_LOCKING_STYLE 1
104123 # else
@@ -104220,11 +104352,11 @@
104220 /* ePragFlag: */ 0,
104221 /* iArg: */ 0 },
104222 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
104223 { /* zName: */ "cache_size",
104224 /* ePragTyp: */ PragTyp_CACHE_SIZE,
104225 /* ePragFlag: */ PragFlag_NeedSchema,
104226 /* iArg: */ 0 },
104227 #endif
104228 #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
104229 { /* zName: */ "cache_spill",
104230 /* ePragTyp: */ PragTyp_FLAG,
@@ -105290,10 +105422,11 @@
105290 ** of memory.
105291 */
105292 case PragTyp_CACHE_SIZE: {
105293 assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
105294 if( !zRight ){
 
105295 returnSingleInt(pParse, "cache_size", pDb->pSchema->cache_size);
105296 }else{
105297 int size = sqlite3Atoi(zRight);
105298 pDb->pSchema->cache_size = size;
105299 sqlite3BtreeSetCacheSize(pDb->pBt, pDb->pSchema->cache_size);
@@ -106565,10 +106698,11 @@
106565 *************************************************************************
106566 ** This file contains the implementation of the sqlite3_prepare()
106567 ** interface, and routines that contribute to loading the database schema
106568 ** from disk.
106569 */
 
106570
106571 /*
106572 ** Fill the InitData structure with an error message that indicates
106573 ** that the database is corrupt.
106574 */
@@ -107459,10 +107593,11 @@
107459 **
107460 *************************************************************************
107461 ** This file contains C code routines that are called by the parser
107462 ** to handle SELECT statements in SQLite.
107463 */
 
107464
107465 /*
107466 ** Trace output macros
107467 */
107468 #if SELECTTRACE_ENABLED
@@ -108528,11 +108663,10 @@
108528 }
108529 }
108530 return pInfo;
108531 }
108532
108533 #ifndef SQLITE_OMIT_COMPOUND_SELECT
108534 /*
108535 ** Name of the connection operator, used for error messages.
108536 */
108537 static const char *selectOpName(int id){
108538 char *z;
@@ -108542,11 +108676,10 @@
108542 case TK_EXCEPT: z = "EXCEPT"; break;
108543 default: z = "UNION"; break;
108544 }
108545 return z;
108546 }
108547 #endif /* SQLITE_OMIT_COMPOUND_SELECT */
108548
108549 #ifndef SQLITE_OMIT_EXPLAIN
108550 /*
108551 ** Unless an "EXPLAIN QUERY PLAN" command is being processed, this function
108552 ** is a no-op. Otherwise, it adds a single row of output to the EQP result,
@@ -109545,23 +109678,10 @@
109545 Parse *pParse, /* Parsing context */
109546 Select *p, /* The right-most of SELECTs to be coded */
109547 SelectDest *pDest /* What to do with query results */
109548 );
109549
109550 /*
109551 ** Error message for when two or more terms of a compound select have different
109552 ** size result sets.
109553 */
109554 SQLITE_PRIVATE void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p){
109555 if( p->selFlags & SF_Values ){
109556 sqlite3ErrorMsg(pParse, "all VALUES must have the same number of terms");
109557 }else{
109558 sqlite3ErrorMsg(pParse, "SELECTs to the left and right of %s"
109559 " do not have the same number of result columns", selectOpName(p->op));
109560 }
109561 }
109562
109563 /*
109564 ** Handle the special case of a compound-select that originates from a
109565 ** VALUES clause. By handling this as a special case, we avoid deep
109566 ** recursion, and thus do not need to enforce the SQLITE_LIMIT_COMPOUND_SELECT
109567 ** on a VALUES clause.
@@ -109983,10 +110103,23 @@
109983 pDest->nSdst = dest.nSdst;
109984 sqlite3SelectDelete(db, pDelete);
109985 return rc;
109986 }
109987 #endif /* SQLITE_OMIT_COMPOUND_SELECT */
 
 
 
 
 
 
 
 
 
 
 
 
 
109988
109989 /*
109990 ** Code an output subroutine for a coroutine implementation of a
109991 ** SELECT statment.
109992 **
@@ -113077,10 +113210,11 @@
113077 ** interface routine of sqlite3_exec().
113078 **
113079 ** These routines are in a separate files so that they will not be linked
113080 ** if they are not used.
113081 */
 
113082 /* #include <stdlib.h> */
113083 /* #include <string.h> */
113084
113085 #ifndef SQLITE_OMIT_GET_TABLE
113086
@@ -113273,10 +113407,11 @@
113273 ** May you share freely, never taking more than you give.
113274 **
113275 *************************************************************************
113276 ** This file contains the implementation for TRIGGERs
113277 */
 
113278
113279 #ifndef SQLITE_OMIT_TRIGGER
113280 /*
113281 ** Delete a linked list of TriggerStep structures.
113282 */
@@ -114396,10 +114531,11 @@
114396 **
114397 *************************************************************************
114398 ** This file contains C code routines that are called by the parser
114399 ** to handle UPDATE statements.
114400 */
 
114401
114402 #ifndef SQLITE_OMIT_VIRTUALTABLE
114403 /* Forward declaration */
114404 static void updateVirtualTable(
114405 Parse *pParse, /* The parsing context */
@@ -115172,10 +115308,12 @@
115172 ** This file contains code used to implement the VACUUM command.
115173 **
115174 ** Most of the code in this file may be omitted by defining the
115175 ** SQLITE_OMIT_VACUUM macro.
115176 */
 
 
115177
115178 #if !defined(SQLITE_OMIT_VACUUM) && !defined(SQLITE_OMIT_ATTACH)
115179 /*
115180 ** Finalize a prepared statement. If there was an error, store the
115181 ** text of the error message in *pzErrMsg. Return the result code.
@@ -115544,10 +115682,11 @@
115544 **
115545 *************************************************************************
115546 ** This file contains code used to help implement virtual tables.
115547 */
115548 #ifndef SQLITE_OMIT_VIRTUALTABLE
 
115549
115550 /*
115551 ** Before a virtual table xCreate() or xConnect() method is invoked, the
115552 ** sqlite3.pVtabCtx member variable is set to point to an instance of
115553 ** this struct allocated on the stack. It is used by the implementation of
@@ -116702,10 +116841,11 @@
116702 ** This file was split off from where.c on 2015-06-06 in order to reduce the
116703 ** size of where.c and make it easier to edit. This file contains the routines
116704 ** that actually generate the bulk of the WHERE loop code. The original where.c
116705 ** file retains the code that does query planning and analysis.
116706 */
 
116707 /************** Include whereInt.h in the middle of wherecode.c **************/
116708 /************** Begin file whereInt.h ****************************************/
116709 /*
116710 ** 2013-11-12
116711 **
@@ -118737,10 +118877,12 @@
118737 **
118738 ** This file was originally part of where.c but was split out to improve
118739 ** readability and editabiliity. This file contains utility routines for
118740 ** analyzing Expr objects in the WHERE clause.
118741 */
 
 
118742
118743 /* Forward declarations */
118744 static void exprAnalyze(SrcList*, WhereClause*, int);
118745
118746 /*
@@ -119987,10 +120129,12 @@
119987 ** generating the code that loops through a table looking for applicable
119988 ** rows. Indices are selected and used to speed the search when doing
119989 ** so is applicable. Because this module is responsible for selecting
119990 ** indices, you might also think of this module as the "query optimizer".
119991 */
 
 
119992
119993 /* Forward declaration of methods */
119994 static int whereLoopResize(sqlite3*, WhereLoop*, int);
119995
119996 /* Test variable that can be set to enable WHERE tracing */
@@ -124486,10 +124630,11 @@
124486 */
124487 /* First off, code is included that follows the "include" declaration
124488 ** in the input grammar file. */
124489 /* #include <stdio.h> */
124490
 
124491
124492 /*
124493 ** Disable all error recovery processing in the parser push-down
124494 ** automaton.
124495 */
@@ -128071,10 +128216,11 @@
128071 **
128072 ** This file contains C code that splits an SQL input string up into
128073 ** individual tokens and sends those tokens one-by-one over to the
128074 ** parser for analysis.
128075 */
 
128076 /* #include <stdlib.h> */
128077
128078 /*
128079 ** The charMap() macro maps alphabetic characters into their
128080 ** lower-case ASCII equivalent. On ASCII machines, this is just
@@ -128880,10 +129026,11 @@
128880 ** This file contains C code that implements the sqlite3_complete() API.
128881 ** This code used to be part of the tokenizer.c source file. But by
128882 ** separating it out, the code will be automatically omitted from
128883 ** static links that do not use it.
128884 */
 
128885 #ifndef SQLITE_OMIT_COMPLETE
128886
128887 /*
128888 ** This is defined in tokenize.c. We just have to import the definition.
128889 */
@@ -129170,10 +129317,11 @@
129170 ** Main file for the SQLite library. The routines in this file
129171 ** implement the programmer interface to the library. Routines in
129172 ** other files are for internal use by SQLite and should not be
129173 ** accessed by users of the library.
129174 */
 
129175
129176 #ifdef SQLITE_ENABLE_FTS3
129177 /************** Include fts3.h in the middle of main.c ***********************/
129178 /************** Begin file fts3.h ********************************************/
129179 /*
@@ -129189,10 +129337,11 @@
129189 ******************************************************************************
129190 **
129191 ** This header file is used by programs that want to link against the
129192 ** FTS3 library. All it does is declare the sqlite3Fts3Init() interface.
129193 */
 
129194
129195 #if 0
129196 extern "C" {
129197 #endif /* __cplusplus */
129198
@@ -129221,10 +129370,11 @@
129221 ******************************************************************************
129222 **
129223 ** This header file is used by programs that want to link against the
129224 ** RTREE library. All it does is declare the sqlite3RtreeInit() interface.
129225 */
 
129226
129227 #if 0
129228 extern "C" {
129229 #endif /* __cplusplus */
129230
@@ -129253,10 +129403,11 @@
129253 ******************************************************************************
129254 **
129255 ** This header file is used by programs that want to link against the
129256 ** ICU extension. All it does is declare the sqlite3IcuInit() interface.
129257 */
 
129258
129259 #if 0
129260 extern "C" {
129261 #endif /* __cplusplus */
129262
@@ -133045,10 +133196,12 @@
133045 *************************************************************************
133046 **
133047 ** This file contains the implementation of the sqlite3_unlock_notify()
133048 ** API method and its associated functionality.
133049 */
 
 
133050
133051 /* Omit this entire file if SQLITE_ENABLE_UNLOCK_NOTIFY is not defined. */
133052 #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
133053
133054 /*
@@ -133688,13 +133841,15 @@
133688
133689 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
133690
133691 /* If not building as part of the core, include sqlite3ext.h. */
133692 #ifndef SQLITE_CORE
 
133693 SQLITE_EXTENSION_INIT3
133694 #endif
133695
 
133696 /************** Include fts3_tokenizer.h in the middle of fts3Int.h **********/
133697 /************** Begin file fts3_tokenizer.h **********************************/
133698 /*
133699 ** 2006 July 10
133700 **
@@ -133719,10 +133874,11 @@
133719
133720 /* TODO(shess) Only used for SQLITE_OK and SQLITE_DONE at this time.
133721 ** If tokenizers are to be allowed to call sqlite3_*() functions, then
133722 ** we will need a way to register the API consistently.
133723 */
 
133724
133725 /*
133726 ** Structures used by the tokenizer interface. When a new tokenizer
133727 ** implementation is registered, the caller provides a pointer to
133728 ** an sqlite3_tokenizer_module containing pointers to the callback
@@ -134559,11 +134715,13 @@
134559 /* #include <stddef.h> */
134560 /* #include <stdio.h> */
134561 /* #include <string.h> */
134562 /* #include <stdarg.h> */
134563
 
134564 #ifndef SQLITE_CORE
 
134565 SQLITE_EXTENSION_INIT1
134566 #endif
134567
134568 static int fts3EvalNext(Fts3Cursor *pCsr);
134569 static int fts3EvalStart(Fts3Cursor *pCsr);
@@ -138606,10 +138764,11 @@
138606 if( p==0 ){
138607 p = aDoclist;
138608 p += sqlite3Fts3GetVarint(p, piDocid);
138609 }else{
138610 fts3PoslistCopy(0, &p);
 
138611 if( p>=&aDoclist[nDoclist] ){
138612 *pbEof = 1;
138613 }else{
138614 sqlite3_int64 iVar;
138615 p += sqlite3Fts3GetVarint(p, &iVar);
@@ -140012,14 +140171,14 @@
140012 pIter = pPhrase->doclist.pList;
140013 if( iDocid!=pCsr->iPrevId || pExpr->bEof ){
140014 int rc = SQLITE_OK;
140015 int bDescDoclist = pTab->bDescIdx; /* For DOCID_CMP macro */
140016 int bOr = 0;
140017 u8 bEof = 0;
140018 u8 bTreeEof = 0;
140019 Fts3Expr *p; /* Used to iterate from pExpr to root */
140020 Fts3Expr *pNear; /* Most senior NEAR ancestor (or pExpr) */
 
140021
140022 /* Check if this phrase descends from an OR expression node. If not,
140023 ** return NULL. Otherwise, the entry that corresponds to docid
140024 ** pCsr->iPrevId may lie earlier in the doclist buffer. Or, if the
140025 ** tree that the node is part of has been marked as EOF, but the node
@@ -140049,35 +140208,51 @@
140049 fts3EvalNextRow(pCsr, pNear, &rc);
140050 }
140051 }
140052 if( rc!=SQLITE_OK ) return rc;
140053
140054 pIter = pPhrase->pOrPoslist;
140055 iDocid = pPhrase->iOrDocid;
140056 if( pCsr->bDesc==bDescDoclist ){
140057 bEof = !pPhrase->doclist.nAll ||
140058 (pIter >= (pPhrase->doclist.aAll + pPhrase->doclist.nAll));
140059 while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)<0 ) && bEof==0 ){
140060 sqlite3Fts3DoclistNext(
140061 bDescDoclist, pPhrase->doclist.aAll, pPhrase->doclist.nAll,
140062 &pIter, &iDocid, &bEof
140063 );
140064 }
140065 }else{
140066 bEof = !pPhrase->doclist.nAll || (pIter && pIter<=pPhrase->doclist.aAll);
140067 while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)>0 ) && bEof==0 ){
140068 int dummy;
140069 sqlite3Fts3DoclistPrev(
140070 bDescDoclist, pPhrase->doclist.aAll, pPhrase->doclist.nAll,
140071 &pIter, &iDocid, &dummy, &bEof
140072 );
140073 }
140074 }
140075 pPhrase->pOrPoslist = pIter;
140076 pPhrase->iOrDocid = iDocid;
140077
140078 if( bEof || iDocid!=pCsr->iPrevId ) pIter = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140079 }
140080 if( pIter==0 ) return SQLITE_OK;
140081
140082 if( *pIter==0x01 ){
140083 pIter++;
@@ -140161,10 +140336,11 @@
140161 ** May you share freely, never taking more than you give.
140162 **
140163 ******************************************************************************
140164 **
140165 */
 
140166 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
140167
140168 /* #include <string.h> */
140169 /* #include <assert.h> */
140170
@@ -140717,10 +140893,11 @@
140717 ** This module contains code that implements a parser for fts3 query strings
140718 ** (the right-hand argument to the MATCH operator). Because the supported
140719 ** syntax is relatively simple, the whole tokenizer/parser system is
140720 ** hand-coded.
140721 */
 
140722 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
140723
140724 /*
140725 ** By default, this module parses the legacy syntax that has been
140726 ** traditionally used by fts3. Or, if SQLITE_ENABLE_FTS3_PARENTHESIS
@@ -142010,16 +142187,18 @@
142010 ** (in which case SQLITE_CORE is not defined), or
142011 **
142012 ** * The FTS3 module is being built into the core of
142013 ** SQLite (in which case SQLITE_ENABLE_FTS3 is defined).
142014 */
 
142015 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
142016
142017 /* #include <assert.h> */
142018 /* #include <stdlib.h> */
142019 /* #include <string.h> */
142020
 
142021
142022 /*
142023 ** Malloc and Free functions
142024 */
142025 static void *fts3HashMalloc(int n){
@@ -142393,17 +142572,19 @@
142393 ** (in which case SQLITE_CORE is not defined), or
142394 **
142395 ** * The FTS3 module is being built into the core of
142396 ** SQLite (in which case SQLITE_ENABLE_FTS3 is defined).
142397 */
 
142398 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
142399
142400 /* #include <assert.h> */
142401 /* #include <stdlib.h> */
142402 /* #include <stdio.h> */
142403 /* #include <string.h> */
142404
 
142405
142406 /*
142407 ** Class derived from sqlite3_tokenizer
142408 */
142409 typedef struct porter_tokenizer {
@@ -143057,10 +143238,11 @@
143057 ** (in which case SQLITE_CORE is not defined), or
143058 **
143059 ** * The FTS3 module is being built into the core of
143060 ** SQLite (in which case SQLITE_ENABLE_FTS3 is defined).
143061 */
 
143062 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
143063
143064 /* #include <assert.h> */
143065 /* #include <string.h> */
143066
@@ -143552,17 +143734,19 @@
143552 ** (in which case SQLITE_CORE is not defined), or
143553 **
143554 ** * The FTS3 module is being built into the core of
143555 ** SQLite (in which case SQLITE_ENABLE_FTS3 is defined).
143556 */
 
143557 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
143558
143559 /* #include <assert.h> */
143560 /* #include <stdlib.h> */
143561 /* #include <stdio.h> */
143562 /* #include <string.h> */
143563
 
143564
143565 typedef struct simple_tokenizer {
143566 sqlite3_tokenizer base;
143567 char delim[128]; /* flag ASCII delimiters */
143568 } simple_tokenizer;
@@ -143803,10 +143987,11 @@
143803 ** end: Byte offset of the byte immediately following the end of the
143804 ** token within the input string.
143805 ** pos: Token offset of token within input.
143806 **
143807 */
 
143808 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
143809
143810 /* #include <string.h> */
143811 /* #include <assert.h> */
143812
@@ -144238,10 +144423,11 @@
144238 ** tables. It also contains code to merge FTS3 b-tree segments. Some
144239 ** of the sub-routines used to merge segments are also used by the query
144240 ** code in fts3.c.
144241 */
144242
 
144243 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
144244
144245 /* #include <string.h> */
144246 /* #include <assert.h> */
144247 /* #include <stdlib.h> */
@@ -149898,10 +150084,11 @@
149898 ** May you share freely, never taking more than you give.
149899 **
149900 ******************************************************************************
149901 */
149902
 
149903 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
149904
149905 /* #include <string.h> */
149906 /* #include <assert.h> */
149907
@@ -151610,17 +151797,19 @@
151610 ** Implementation of the "unicode" full-text-search tokenizer.
151611 */
151612
151613 #ifndef SQLITE_DISABLE_FTS3_UNICODE
151614
 
151615 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
151616
151617 /* #include <assert.h> */
151618 /* #include <stdlib.h> */
151619 /* #include <stdio.h> */
151620 /* #include <string.h> */
151621
 
151622
151623 /*
151624 ** The following two macros - READ_UTF8 and WRITE_UTF8 - have been copied
151625 ** from the sqlite3 source file utf.c. If this file is compiled as part
151626 ** of the amalgamation, they are not required.
@@ -152412,12 +152601,14 @@
152412 */
152413
152414 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_RTREE)
152415
152416 #ifndef SQLITE_CORE
 
152417 SQLITE_EXTENSION_INIT1
152418 #else
 
152419 #endif
152420
152421 /* #include <string.h> */
152422 /* #include <assert.h> */
152423 /* #include <stdio.h> */
@@ -155909,12 +156100,14 @@
155909 #include <unicode/ucol.h>
155910
155911 /* #include <assert.h> */
155912
155913 #ifndef SQLITE_CORE
 
155914 SQLITE_EXTENSION_INIT1
155915 #else
 
155916 #endif
155917
155918 /*
155919 ** Maximum length (in bytes) of the pattern in a LIKE or GLOB
155920 ** operator.
@@ -156386,15 +156579,17 @@
156386 ** May you share freely, never taking more than you give.
156387 **
156388 *************************************************************************
156389 ** This file implements a tokenizer for fts3 based on the ICU library.
156390 */
 
156391 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
156392 #ifdef SQLITE_ENABLE_ICU
156393
156394 /* #include <assert.h> */
156395 /* #include <string.h> */
 
156396
156397 #include <unicode/ubrk.h>
156398 /* #include <unicode/ucol.h> */
156399 /* #include <unicode/ustring.h> */
156400 #include <unicode/utf16.h>
@@ -156723,10 +156918,11 @@
156723 /* #include <assert.h> */
156724 /* #include <string.h> */
156725 /* #include <stdio.h> */
156726 /* #include <unistd.h> */
156727
 
156728
156729 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_OTA)
156730 /************** Include sqlite3ota.h in the middle of sqlite3ota.c ***********/
156731 /************** Begin file sqlite3ota.h **************************************/
156732 /*
@@ -156976,10 +157172,11 @@
156976 */
156977
156978 #ifndef _SQLITE3OTA_H
156979 #define _SQLITE3OTA_H
156980
 
156981
156982 typedef struct sqlite3ota sqlite3ota;
156983
156984 /*
156985 ** Open an OTA handle.
@@ -157144,11 +157341,10 @@
157144 ** are undefined.
157145 */
157146 SQLITE_API void SQLITE_STDCALL sqlite3ota_destroy_vfs(const char *zName);
157147
157148 #endif /* _SQLITE3OTA_H */
157149
157150
157151 /************** End of sqlite3ota.h ******************************************/
157152 /************** Continuing where we left off in sqlite3ota.c *****************/
157153
157154 /* Maximum number of prepared UPDATE statements held by this module */
@@ -160741,10 +160937,11 @@
160741 ** information from an SQLite database in order to implement the
160742 ** "sqlite3_analyzer" utility. See the ../tool/spaceanal.tcl script
160743 ** for an example implementation.
160744 */
160745
 
160746 #if (defined(SQLITE_ENABLE_DBSTAT_VTAB) || defined(SQLITE_TEST)) \
160747 && !defined(SQLITE_OMIT_VIRTUALTABLE)
160748
160749 /*
160750 ** Page paths:
160751
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -325,11 +325,11 @@
325 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
326 ** [sqlite_version()] and [sqlite_source_id()].
327 */
328 #define SQLITE_VERSION "3.8.11"
329 #define SQLITE_VERSION_NUMBER 3008011
330 #define SQLITE_SOURCE_ID "2015-07-16 18:18:19 b79a4affe44bd0c8e155cae19f3f62c715684cd6"
331
332 /*
333 ** CAPI3REF: Run-Time Library Version Numbers
334 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
335 **
@@ -8361,11 +8361,11 @@
8361
8362 /*
8363 ** Make sure that the compiler intrinsics we desire are enabled when
8364 ** compiling with an appropriate version of MSVC.
8365 */
8366 #if defined(_MSC_VER) && _MSC_VER>=1300 && !defined(_WIN32_WCE)
8367 # include <intrin.h>
8368 # pragma intrinsic(_byteswap_ushort)
8369 # pragma intrinsic(_byteswap_ulong)
8370 #endif
8371
@@ -9189,11 +9189,13 @@
9189 #endif
9190 #ifndef SQLITE_MAX_MMAP_SIZE
9191 # if defined(__linux__) \
9192 || defined(_WIN32) \
9193 || (defined(__APPLE__) && defined(__MACH__)) \
9194 || defined(__sun) \
9195 || defined(__FreeBSD__) \
9196 || defined(__DragonFly__)
9197 # define SQLITE_MAX_MMAP_SIZE 0x7fff0000 /* 2147418112 */
9198 # else
9199 # define SQLITE_MAX_MMAP_SIZE 0
9200 # endif
9201 # define SQLITE_MAX_MMAP_SIZE_xc 1 /* exclude from ctime.c */
@@ -13883,10 +13885,11 @@
13885 **
13886 *************************************************************************
13887 **
13888 ** This file contains definitions of global variables and constants.
13889 */
13890 /* #include "sqliteInt.h" */
13891
13892 /* An array to map all upper-case characters into their corresponding
13893 ** lower-case character.
13894 **
13895 ** SQLite only considers US-ASCII (or EBCDIC) characters. We do not
@@ -14122,10 +14125,11 @@
14125 */
14126 #ifndef SQLITE_OMIT_WSD
14127 SQLITE_PRIVATE int sqlite3PendingByte = 0x40000000;
14128 #endif
14129
14130 /* #include "opcodes.h" */
14131 /*
14132 ** Properties of opcodes. The OPFLG_INITIALIZER macro is
14133 ** created by mkopcodeh.awk during compilation. Data is obtained
14134 ** from the comments following the "case OP_xxxx:" statements in
14135 ** the vdbe.c file.
@@ -14150,10 +14154,11 @@
14154 ** SQLite was built with.
14155 */
14156
14157 #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
14158
14159 /* #include "sqliteInt.h" */
14160
14161 /*
14162 ** An array of names of all compile-time options. This array should
14163 ** be sorted A-Z.
14164 **
@@ -14579,10 +14584,11 @@
14584 *************************************************************************
14585 **
14586 ** This module implements the sqlite3_status() interface and related
14587 ** functionality.
14588 */
14589 /* #include "sqliteInt.h" */
14590 /************** Include vdbeInt.h in the middle of status.c ******************/
14591 /************** Begin file vdbeInt.h *****************************************/
14592 /*
14593 ** 2003 September 6
14594 **
@@ -15462,10 +15468,11 @@
15468 ** Astronomical Algorithms, 2nd Edition, 1998
15469 ** ISBM 0-943396-61-1
15470 ** Willmann-Bell, Inc
15471 ** Richmond, Virginia (USA)
15472 */
15473 /* #include "sqliteInt.h" */
15474 /* #include <stdlib.h> */
15475 /* #include <assert.h> */
15476 #include <time.h>
15477
15478 #ifndef SQLITE_OMIT_DATETIME_FUNCS
@@ -15773,11 +15780,11 @@
15780 Z = (int)((p->iJD + 43200000)/86400000);
15781 A = (int)((Z - 1867216.25)/36524.25);
15782 A = Z + 1 + A - (A/4);
15783 B = A + 1524;
15784 C = (int)((B - 122.1)/365.25);
15785 D = (36525*(C&32767))/100;
15786 E = (int)((B-D)/30.6001);
15787 X1 = (int)(30.6001*E);
15788 p->D = B - D - X1;
15789 p->M = E<14 ? E-1 : E-13;
15790 p->Y = p->M>2 ? C - 4716 : C - 4715;
@@ -16574,10 +16581,11 @@
16581 **
16582 ** This file contains OS interface code that is common to all
16583 ** architectures.
16584 */
16585 #define _SQLITE_OS_C_ 1
16586 /* #include "sqliteInt.h" */
16587 #undef _SQLITE_OS_C_
16588
16589 /*
16590 ** The default SQLite sqlite3_vfs implementations do not allocate
16591 ** memory (actually, os_unix.c allocates a small amount of memory
@@ -16980,10 +16988,11 @@
16988 ** is completely recoverable simply by not carrying out the resize. The
16989 ** hash table will continue to function normally. So a malloc failure
16990 ** during a hash table resize is a benign fault.
16991 */
16992
16993 /* #include "sqliteInt.h" */
16994
16995 #ifndef SQLITE_OMIT_BUILTIN_TEST
16996
16997 /*
16998 ** Global variables.
@@ -17061,10 +17070,11 @@
17070 ** SQLITE_ZERO_MALLOC is defined. The allocation drivers implemented
17071 ** here always fail. SQLite will not operate with these drivers. These
17072 ** are merely placeholders. Real drivers must be substituted using
17073 ** sqlite3_config() before SQLite will operate.
17074 */
17075 /* #include "sqliteInt.h" */
17076
17077 /*
17078 ** This version of the memory allocator is the default. It is
17079 ** used when no other memory allocator is specified using compile-time
17080 ** macros.
@@ -17147,10 +17157,11 @@
17157 ** SQLITE_WITHOUT_MSIZE Set this symbol to disable the use of
17158 ** _msize() on windows systems. This might
17159 ** be necessary when compiling for Delphi,
17160 ** for example.
17161 */
17162 /* #include "sqliteInt.h" */
17163
17164 /*
17165 ** This version of the memory allocator is the default. It is
17166 ** used when no other memory allocator is specified using compile-time
17167 ** macros.
@@ -17422,10 +17433,11 @@
17433 ** leaks and memory usage errors.
17434 **
17435 ** This file contains implementations of the low-level memory allocation
17436 ** routines specified in the sqlite3_mem_methods object.
17437 */
17438 /* #include "sqliteInt.h" */
17439
17440 /*
17441 ** This version of the memory allocator is used only if the
17442 ** SQLITE_MEMDEBUG macro is defined
17443 */
@@ -17956,10 +17968,11 @@
17968 ** be changed.
17969 **
17970 ** This version of the memory allocation subsystem is included
17971 ** in the build only if SQLITE_ENABLE_MEMSYS3 is defined.
17972 */
17973 /* #include "sqliteInt.h" */
17974
17975 /*
17976 ** This version of the memory allocator is only built into the library
17977 ** SQLITE_ENABLE_MEMSYS3 is defined. Defining this symbol does not
17978 ** mean that the library will use a memory-pool by default, just that
@@ -18670,10 +18683,11 @@
18683 ** N >= M*(1 + log2(n)/2) - n + 1
18684 **
18685 ** The sqlite3_status() logic tracks the maximum values of n and M so
18686 ** that an application can, at any time, verify this constraint.
18687 */
18688 /* #include "sqliteInt.h" */
18689
18690 /*
18691 ** This version of the memory allocator is used only when
18692 ** SQLITE_ENABLE_MEMSYS5 is defined.
18693 */
@@ -19213,10 +19227,11 @@
19227 *************************************************************************
19228 ** This file contains the C functions that implement mutexes.
19229 **
19230 ** This file contains code that is common across all mutex implementations.
19231 */
19232 /* #include "sqliteInt.h" */
19233
19234 #if defined(SQLITE_DEBUG) && !defined(SQLITE_MUTEX_OMIT)
19235 /*
19236 ** For debugging purposes, record when the mutex subsystem is initialized
19237 ** and uninitialized so that we can assert() if there is an attempt to
@@ -19386,10 +19401,11 @@
19401 **
19402 ** If compiled with SQLITE_DEBUG, then additional logic is inserted
19403 ** that does error checking on mutexes to make sure they are being
19404 ** called correctly.
19405 */
19406 /* #include "sqliteInt.h" */
19407
19408 #ifndef SQLITE_MUTEX_OMIT
19409
19410 #ifndef SQLITE_DEBUG
19411 /*
@@ -19589,10 +19605,11 @@
19605 ** May you share freely, never taking more than you give.
19606 **
19607 *************************************************************************
19608 ** This file contains the C functions that implement mutexes for pthreads
19609 */
19610 /* #include "sqliteInt.h" */
19611
19612 /*
19613 ** The code in this file is only used if we are compiling threadsafe
19614 ** under unix with pthreads.
19615 **
@@ -19963,10 +19980,11 @@
19980 ** May you share freely, never taking more than you give.
19981 **
19982 *************************************************************************
19983 ** This file contains the C functions that implement mutexes for Win32.
19984 */
19985 /* #include "sqliteInt.h" */
19986
19987 #if SQLITE_OS_WIN
19988 /*
19989 ** Include code that is common to all os_*.c files
19990 */
@@ -20638,10 +20656,11 @@
20656 **
20657 *************************************************************************
20658 **
20659 ** Memory allocation functions used throughout sqlite.
20660 */
20661 /* #include "sqliteInt.h" */
20662 /* #include <stdarg.h> */
20663
20664 /*
20665 ** Attempt to release up to n bytes of non-essential memory currently
20666 ** held by SQLite. An example of non-essential memory is memory used to
@@ -21449,10 +21468,11 @@
21468 ** This file contains code for a set of "printf"-like routines. These
21469 ** routines format strings much like the printf() from the standard C
21470 ** library, though the implementation here has enhancements to support
21471 ** SQLite.
21472 */
21473 /* #include "sqliteInt.h" */
21474
21475 /*
21476 ** Conversion types fall into various categories as defined by the
21477 ** following enumeration.
21478 */
@@ -22451,10 +22471,15 @@
22471 ** stack space on small-stack systems when logging is disabled.
22472 **
22473 ** sqlite3_log() must render into a static buffer. It cannot dynamically
22474 ** allocate memory because it might be called while the memory allocator
22475 ** mutex is held.
22476 **
22477 ** sqlite3VXPrintf() might ask for *temporary* memory allocations for
22478 ** certain format characters (%q) or for very large precisions or widths.
22479 ** Care must be taken that any sqlite3_log() calls that occur while the
22480 ** memory mutex is held do not use these mechanisms.
22481 */
22482 static void renderLogMsg(int iErrCode, const char *zFormat, va_list ap){
22483 StrAccum acc; /* String accumulator */
22484 char zMsg[SQLITE_PRINT_BUF_SIZE*3]; /* Complete log message */
22485
@@ -22526,10 +22551,11 @@
22551 ** analysis.
22552 **
22553 ** The interfaces in this file is only available when compiling
22554 ** with SQLITE_DEBUG.
22555 */
22556 /* #include "sqliteInt.h" */
22557 #ifdef SQLITE_DEBUG
22558
22559 /*
22560 ** Add a new subitem to the tree. The moreToFollow flag indicates that this
22561 ** is not the last item in the tree.
@@ -22957,10 +22983,11 @@
22983 ** generator (PRNG) for SQLite.
22984 **
22985 ** Random numbers are used by some of the database backends in order
22986 ** to generate random integer keys for tables or random filenames.
22987 */
22988 /* #include "sqliteInt.h" */
22989
22990
22991 /* All threads share a single random number generator.
22992 ** This structure is the current state of the generator.
22993 */
@@ -23103,11 +23130,13 @@
23130 ** single threaded systems. Nothing in SQLite requires multiple threads.
23131 ** This interface exists so that applications that want to take advantage
23132 ** of multiple cores can do so, while also allowing applications to stay
23133 ** single-threaded if desired.
23134 */
23135 /* #include "sqliteInt.h" */
23136 #if SQLITE_OS_WIN
23137 /* # include "os_win.h" */
23138 #endif
23139
23140 #if SQLITE_MAX_WORKER_THREADS>0
23141
23142 /********************************* Unix Pthreads ****************************/
@@ -23377,11 +23406,13 @@
23406 ** BOM or Byte Order Mark:
23407 ** 0xff 0xfe little-endian utf-16 follows
23408 ** 0xfe 0xff big-endian utf-16 follows
23409 **
23410 */
23411 /* #include "sqliteInt.h" */
23412 /* #include <assert.h> */
23413 /* #include "vdbeInt.h" */
23414
23415 #ifndef SQLITE_AMALGAMATION
23416 /*
23417 ** The following constant value is used by the SQLITE_BIGENDIAN and
23418 ** SQLITE_LITTLEENDIAN macros.
@@ -23890,10 +23921,11 @@
23921 **
23922 ** This file contains functions for allocating memory, comparing
23923 ** strings, and stuff like that.
23924 **
23925 */
23926 /* #include "sqliteInt.h" */
23927 /* #include <stdarg.h> */
23928 #if HAVE_ISNAN || SQLITE_HAVE_ISNAN
23929 # include <math.h>
23930 #endif
23931
@@ -25286,10 +25318,11 @@
25318 **
25319 *************************************************************************
25320 ** This is the implementation of generic hash-tables
25321 ** used in SQLite.
25322 */
25323 /* #include "sqliteInt.h" */
25324 /* #include <assert.h> */
25325
25326 /* Turn bulk memory into a hash table object by initializing the
25327 ** fields of the Hash structure.
25328 **
@@ -25763,10 +25796,11 @@
25796 ** * sqlite3_vfs method implementations.
25797 ** * Locking primitives for the proxy uber-locking-method. (MacOSX only)
25798 ** * Definitions of sqlite3_vfs objects for all locking methods
25799 ** plus implementations of sqlite3_os_init() and sqlite3_os_end().
25800 */
25801 /* #include "sqliteInt.h" */
25802 #if SQLITE_OS_UNIX /* This file is used on unix only */
25803
25804 /*
25805 ** There are various methods for file locking used for concurrency
25806 ** control:
@@ -33497,10 +33531,11 @@
33531 **
33532 ******************************************************************************
33533 **
33534 ** This file contains code that is specific to Windows.
33535 */
33536 /* #include "sqliteInt.h" */
33537 #if SQLITE_OS_WIN /* This file is used for Windows only */
33538
33539 /*
33540 ** Include code that is common to all os_*.c files
33541 */
@@ -33705,10 +33740,11 @@
33740 /************** Continuing where we left off in os_win.c *********************/
33741
33742 /*
33743 ** Include the header file for the Windows VFS.
33744 */
33745 /* #include "os_win.h" */
33746
33747 /*
33748 ** Compiling and using WAL mode requires several APIs that are only
33749 ** available in Windows platforms based on the NT kernel.
33750 */
@@ -39358,10 +39394,11 @@
39394 ** sometimes grow into tens of thousands or larger. The size of the
39395 ** Bitvec object is the number of pages in the database file at the
39396 ** start of a transaction, and is thus usually less than a few thousand,
39397 ** but can be as large as 2 billion for a really big database.
39398 */
39399 /* #include "sqliteInt.h" */
39400
39401 /* Size of the Bitvec structure in bytes. */
39402 #define BITVEC_SZ 512
39403
39404 /* Round the union size down to the nearest pointer boundary, since that's how
@@ -39747,10 +39784,11 @@
39784 ** May you share freely, never taking more than you give.
39785 **
39786 *************************************************************************
39787 ** This file implements that page cache.
39788 */
39789 /* #include "sqliteInt.h" */
39790
39791 /*
39792 ** A complete page cache is an instance of this structure.
39793 */
39794 struct PCache {
@@ -40488,10 +40526,11 @@
40526 **
40527 ** Earlier versions of SQLite used only methods (1) and (2). But experiments
40528 ** show that method (3) with N==100 provides about a 5% performance boost for
40529 ** common workloads.
40530 */
40531 /* #include "sqliteInt.h" */
40532
40533 typedef struct PCache1 PCache1;
40534 typedef struct PgHdr1 PgHdr1;
40535 typedef struct PgFreeslot PgFreeslot;
40536 typedef struct PGroup PGroup;
@@ -40598,10 +40637,11 @@
40637 ** fixed at sqlite3_initialize() time and do not require mutex protection.
40638 ** The nFreeSlot and pFree values do require mutex protection.
40639 */
40640 int isInit; /* True if initialized */
40641 int separateCache; /* Use a new PGroup for each PCache */
40642 int nInitPage; /* Initial bulk allocation size */
40643 int szSlot; /* Size of each free slot */
40644 int nSlot; /* The number of pcache slots */
40645 int nReserve; /* Try to keep nFreeSlot above this */
40646 void *pStart, *pEnd; /* Bounds of global page cache memory */
40647 /* Above requires no mutex. Use mutex below for variable that follow. */
@@ -40665,10 +40705,47 @@
40705 pBuf = (void*)&((char*)pBuf)[sz];
40706 }
40707 pcache1.pEnd = pBuf;
40708 }
40709 }
40710
40711 /*
40712 ** Try to initialize the pCache->pFree and pCache->pBulk fields. Return
40713 ** true if pCache->pFree ends up containing one or more free pages.
40714 */
40715 static int pcache1InitBulk(PCache1 *pCache){
40716 int szBulk;
40717 char *zBulk;
40718 if( pcache1.nInitPage==0 ) return 0;
40719 /* Do not bother with a bulk allocation if the cache size very small */
40720 if( pCache->nMax<3 ) return 0;
40721 sqlite3BeginBenignMalloc();
40722 if( pcache1.nInitPage>0 ){
40723 szBulk = pCache->szAlloc * pcache1.nInitPage;
40724 }else{
40725 szBulk = -1024*pcache1.nInitPage;
40726 }
40727 if( szBulk > pCache->szAlloc*pCache->nMax ){
40728 szBulk = pCache->szAlloc*pCache->nMax;
40729 }
40730 zBulk = pCache->pBulk = sqlite3Malloc( szBulk );
40731 sqlite3EndBenignMalloc();
40732 if( zBulk ){
40733 int nBulk = sqlite3MallocSize(zBulk)/pCache->szAlloc;
40734 int i;
40735 for(i=0; i<nBulk; i++){
40736 PgHdr1 *pX = (PgHdr1*)&zBulk[pCache->szPage];
40737 pX->page.pBuf = zBulk;
40738 pX->page.pExtra = &pX[1];
40739 pX->isBulkLocal = 1;
40740 pX->pNext = pCache->pFree;
40741 pCache->pFree = pX;
40742 zBulk += pCache->szAlloc;
40743 }
40744 }
40745 return pCache->pFree!=0;
40746 }
40747
40748 /*
40749 ** Malloc function used within this file to allocate space from the buffer
40750 ** configured using sqlite3_config(SQLITE_CONFIG_PAGECACHE) option. If no
40751 ** such buffer exists or there is no space left in it, this function falls
@@ -40766,11 +40843,11 @@
40843 static PgHdr1 *pcache1AllocPage(PCache1 *pCache){
40844 PgHdr1 *p = 0;
40845 void *pPg;
40846
40847 assert( sqlite3_mutex_held(pCache->pGroup->mutex) );
40848 if( pCache->pFree || (pCache->nPage==0 && pcache1InitBulk(pCache)) ){
40849 p = pCache->pFree;
40850 pCache->pFree = p->pNext;
40851 p->pNext = 0;
40852 }else{
40853 #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
@@ -40970,18 +41047,23 @@
41047
41048 /*
41049 ** If there are currently more than nMaxPage pages allocated, try
41050 ** to recycle pages to reduce the number allocated to nMaxPage.
41051 */
41052 static void pcache1EnforceMaxPage(PCache1 *pCache){
41053 PGroup *pGroup = pCache->pGroup;
41054 assert( sqlite3_mutex_held(pGroup->mutex) );
41055 while( pGroup->nCurrentPage>pGroup->nMaxPage && pGroup->pLruTail ){
41056 PgHdr1 *p = pGroup->pLruTail;
41057 assert( p->pCache->pGroup==pGroup );
41058 assert( p->isPinned==0 );
41059 pcache1PinPage(p);
41060 pcache1RemoveFromHash(p, 1);
41061 }
41062 if( pCache->nPage==0 && pCache->pBulk ){
41063 sqlite3_free(pCache->pBulk);
41064 pCache->pBulk = pCache->pFree = 0;
41065 }
41066 }
41067
41068 /*
41069 ** Discard all pages from cache pCache with a page number (key value)
@@ -41054,10 +41136,18 @@
41136 if( sqlite3GlobalConfig.bCoreMutex ){
41137 pcache1.grp.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_LRU);
41138 pcache1.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_PMEM);
41139 }
41140 #endif
41141 if( pcache1.separateCache
41142 && sqlite3GlobalConfig.nPage!=0
41143 && sqlite3GlobalConfig.pPage==0
41144 ){
41145 pcache1.nInitPage = sqlite3GlobalConfig.nPage;
41146 }else{
41147 pcache1.nInitPage = 0;
41148 }
41149 pcache1.grp.mxPinned = 10;
41150 pcache1.isInit = 1;
41151 return SQLITE_OK;
41152 }
41153
@@ -41108,40 +41198,10 @@
41198 pCache->nMin = 10;
41199 pGroup->nMinPage += pCache->nMin;
41200 pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage;
41201 }
41202 pcache1LeaveMutex(pGroup);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41203 if( pCache->nHash==0 ){
41204 pcache1Destroy((sqlite3_pcache*)pCache);
41205 pCache = 0;
41206 }
41207 }
@@ -41160,11 +41220,11 @@
41220 pcache1EnterMutex(pGroup);
41221 pGroup->nMaxPage += (nMax - pCache->nMax);
41222 pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage;
41223 pCache->nMax = nMax;
41224 pCache->n90pct = pCache->nMax*9/10;
41225 pcache1EnforceMaxPage(pCache);
41226 pcache1LeaveMutex(pGroup);
41227 }
41228 }
41229
41230 /*
@@ -41178,11 +41238,11 @@
41238 PGroup *pGroup = pCache->pGroup;
41239 int savedMaxPage;
41240 pcache1EnterMutex(pGroup);
41241 savedMaxPage = pGroup->nMaxPage;
41242 pGroup->nMaxPage = 0;
41243 pcache1EnforceMaxPage(pCache);
41244 pGroup->nMaxPage = savedMaxPage;
41245 pcache1LeaveMutex(pGroup);
41246 }
41247 }
41248
@@ -41515,11 +41575,11 @@
41575 assert( pGroup->nMaxPage >= pCache->nMax );
41576 pGroup->nMaxPage -= pCache->nMax;
41577 assert( pGroup->nMinPage >= pCache->nMin );
41578 pGroup->nMinPage -= pCache->nMin;
41579 pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage;
41580 pcache1EnforceMaxPage(pCache);
41581 pcache1LeaveMutex(pGroup);
41582 sqlite3_free(pCache->pBulk);
41583 sqlite3_free(pCache->apHash);
41584 sqlite3_free(pCache);
41585 }
@@ -41679,10 +41739,11 @@
41739 ** primitives are constant time. The cost of DESTROY is O(N).
41740 **
41741 ** There is an added cost of O(N) when switching between TEST and
41742 ** SMALLEST primitives.
41743 */
41744 /* #include "sqliteInt.h" */
41745
41746
41747 /*
41748 ** Target size for allocation chunks.
41749 */
@@ -42148,10 +42209,11 @@
42209 ** locking to prevent two processes from writing the same database
42210 ** file simultaneously, or one process from reading the database while
42211 ** another is writing.
42212 */
42213 #ifndef SQLITE_OMIT_DISKIO
42214 /* #include "sqliteInt.h" */
42215 /************** Include wal.h in the middle of pager.c ***********************/
42216 /************** Begin file wal.h *********************************************/
42217 /*
42218 ** 2010 February 1
42219 **
@@ -42169,10 +42231,11 @@
42231 */
42232
42233 #ifndef _WAL_H_
42234 #define _WAL_H_
42235
42236 /* #include "sqliteInt.h" */
42237
42238 /* Additional values that can be added to the sync_flags argument of
42239 ** sqlite3WalFrames():
42240 */
42241 #define WAL_SYNC_TRANSACTIONS 0x20 /* Sync at the end of each transaction */
@@ -49783,10 +49846,11 @@
49846 ** that correspond to frames greater than the new K value are removed
49847 ** from the hash table at this point.
49848 */
49849 #ifndef SQLITE_OMIT_WAL
49850
49851 /* #include "wal.h" */
49852
49853 /*
49854 ** Trace output macros
49855 */
49856 #if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)
@@ -51000,11 +51064,11 @@
51064
51065 const int nList = *pnList; /* Size of input list */
51066 int nMerge = 0; /* Number of elements in list aMerge */
51067 ht_slot *aMerge = 0; /* List to be merged */
51068 int iList; /* Index into input list */
51069 u32 iSub = 0; /* Index into aSub array */
51070 struct Sublist aSub[13]; /* Array of sub-lists */
51071
51072 memset(aSub, 0, sizeof(aSub));
51073 assert( nList<=HASHTABLE_NPAGE && nList>0 );
51074 assert( HASHTABLE_NPAGE==(1<<(ArraySize(aSub)-1)) );
@@ -51011,11 +51075,13 @@
51075
51076 for(iList=0; iList<nList; iList++){
51077 nMerge = 1;
51078 aMerge = &aList[iList];
51079 for(iSub=0; iList & (1<<iSub); iSub++){
51080 struct Sublist *p;
51081 assert( iSub<ArraySize(aSub) );
51082 p = &aSub[iSub];
51083 assert( p->aList && p->nList<=(1<<iSub) );
51084 assert( p->aList==&aList[iList&~((2<<iSub)-1)] );
51085 walMerge(aContent, p->aList, p->nList, &aMerge, &nMerge, aBuffer);
51086 }
51087 aSub[iSub].aList = aMerge;
@@ -51022,11 +51088,13 @@
51088 aSub[iSub].nList = nMerge;
51089 }
51090
51091 for(iSub++; iSub<ArraySize(aSub); iSub++){
51092 if( nList & (1<<iSub) ){
51093 struct Sublist *p;
51094 assert( iSub<ArraySize(aSub) );
51095 p = &aSub[iSub];
51096 assert( p->nList<=(1<<iSub) );
51097 assert( p->aList==&aList[nList&~((2<<iSub)-1)] );
51098 walMerge(aContent, p->aList, p->nList, &aMerge, &nMerge, aBuffer);
51099 }
51100 }
@@ -52933,10 +53001,11 @@
53001 ** SIZE DESCRIPTION
53002 ** 4 Page number of next trunk page
53003 ** 4 Number of leaf pointers on this page
53004 ** * zero or more pages numbers of leaves
53005 */
53006 /* #include "sqliteInt.h" */
53007
53008
53009 /* The following value is the maximum cell size assuming a maximum page
53010 ** size give above.
53011 */
@@ -53730,10 +53799,11 @@
53799 *************************************************************************
53800 ** This file implements an external (disk-based) database using BTrees.
53801 ** See the header comment on "btreeInt.h" for additional information.
53802 ** Including a description of file format and an overview of operation.
53803 */
53804 /* #include "btreeInt.h" */
53805
53806 /*
53807 ** The header string that appears at the beginning of every
53808 ** SQLite database.
53809 */
@@ -62675,11 +62745,11 @@
62745 u32 *heap = 0; /* Min-heap used for checking cell coverage */
62746 u32 x, prev = 0; /* Next and previous entry on the min-heap */
62747 const char *saved_zPfx = pCheck->zPfx;
62748 int saved_v1 = pCheck->v1;
62749 int saved_v2 = pCheck->v2;
62750 u8 savedIsInit = 0;
62751
62752 /* Check that the page exists
62753 */
62754 pBt = pCheck->pBt;
62755 usableSize = pBt->usableSize;
@@ -63311,10 +63381,12 @@
63381 **
63382 *************************************************************************
63383 ** This file contains the implementation of the sqlite3_backup_XXX()
63384 ** API functions and the related features.
63385 */
63386 /* #include "sqliteInt.h" */
63387 /* #include "btreeInt.h" */
63388
63389 /*
63390 ** Structure allocated for each backup operation.
63391 */
63392 struct sqlite3_backup {
@@ -64109,10 +64181,12 @@
64181 ** This file contains code use to manipulate "Mem" structure. A "Mem"
64182 ** stores a single value in the VDBE. Mem is an opaque structure visible
64183 ** only within the VDBE. Interface routines refer to a Mem using the
64184 ** name sqlite_value
64185 */
64186 /* #include "sqliteInt.h" */
64187 /* #include "vdbeInt.h" */
64188
64189 #ifdef SQLITE_DEBUG
64190 /*
64191 ** Check invariants on a Mem object.
64192 **
@@ -65826,10 +65900,12 @@
65900 **
65901 *************************************************************************
65902 ** This file contains code used for creating, destroying, and populating
65903 ** a VDBE (or an "sqlite3_stmt" as it is known to the outside world.)
65904 */
65905 /* #include "sqliteInt.h" */
65906 /* #include "vdbeInt.h" */
65907
65908 /*
65909 ** Create a new virtual database engine.
65910 */
65911 SQLITE_PRIVATE Vdbe *sqlite3VdbeCreate(Parse *pParse){
@@ -70074,10 +70150,12 @@
70150 *************************************************************************
70151 **
70152 ** This file contains code use to implement APIs that are part of the
70153 ** VDBE.
70154 */
70155 /* #include "sqliteInt.h" */
70156 /* #include "vdbeInt.h" */
70157
70158 #ifndef SQLITE_OMIT_DEPRECATED
70159 /*
70160 ** Return TRUE (non-zero) of the statement supplied as an argument needs
70161 ** to be recompiled. A statement needs to be recompiled whenever the
@@ -70112,10 +70190,35 @@
70190 }else{
70191 return vdbeSafety(p);
70192 }
70193 }
70194
70195 #ifndef SQLITE_OMIT_TRACE
70196 /*
70197 ** Invoke the profile callback. This routine is only called if we already
70198 ** know that the profile callback is defined and needs to be invoked.
70199 */
70200 static SQLITE_NOINLINE void invokeProfileCallback(sqlite3 *db, Vdbe *p){
70201 sqlite3_int64 iNow;
70202 assert( p->startTime>0 );
70203 assert( db->xProfile!=0 );
70204 assert( db->init.busy==0 );
70205 assert( p->zSql!=0 );
70206 sqlite3OsCurrentTimeInt64(db->pVfs, &iNow);
70207 db->xProfile(db->pProfileArg, p->zSql, (iNow - p->startTime)*1000000);
70208 p->startTime = 0;
70209 }
70210 /*
70211 ** The checkProfileCallback(DB,P) macro checks to see if a profile callback
70212 ** is needed, and it invokes the callback if it is needed.
70213 */
70214 # define checkProfileCallback(DB,P) \
70215 if( ((P)->startTime)>0 ){ invokeProfileCallback(DB,P); }
70216 #else
70217 # define checkProfileCallback(DB,P) /*no-op*/
70218 #endif
70219
70220 /*
70221 ** The following routine destroys a virtual machine that is created by
70222 ** the sqlite3_compile() routine. The integer returned is an SQLITE_
70223 ** success/failure code that describes the result of executing the virtual
70224 ** machine.
@@ -70132,10 +70235,11 @@
70235 }else{
70236 Vdbe *v = (Vdbe*)pStmt;
70237 sqlite3 *db = v->db;
70238 if( vdbeSafety(v) ) return SQLITE_MISUSE_BKPT;
70239 sqlite3_mutex_enter(db->mutex);
70240 checkProfileCallback(db, v);
70241 rc = sqlite3VdbeFinalize(v);
70242 rc = sqlite3ApiExit(db, rc);
70243 sqlite3LeaveMutexAndCloseZombie(db);
70244 }
70245 return rc;
@@ -70153,16 +70257,18 @@
70257 int rc;
70258 if( pStmt==0 ){
70259 rc = SQLITE_OK;
70260 }else{
70261 Vdbe *v = (Vdbe*)pStmt;
70262 sqlite3 *db = v->db;
70263 sqlite3_mutex_enter(db->mutex);
70264 checkProfileCallback(db, v);
70265 rc = sqlite3VdbeReset(v);
70266 sqlite3VdbeRewind(v);
70267 assert( (rc & (db->errMask))==rc );
70268 rc = sqlite3ApiExit(db, rc);
70269 sqlite3_mutex_leave(db->mutex);
70270 }
70271 return rc;
70272 }
70273
70274 /*
@@ -70508,10 +70614,11 @@
70614 }
70615 }
70616 #endif
70617 return rc;
70618 }
70619
70620
70621 /*
70622 ** Execute the statement pStmt, either until a row of data is ready, the
70623 ** statement is completely executed or an error occurs.
70624 **
@@ -70577,12 +70684,14 @@
70684 assert( db->nVdbeWrite>0 || db->autoCommit==0
70685 || (db->nDeferredCons==0 && db->nDeferredImmCons==0)
70686 );
70687
70688 #ifndef SQLITE_OMIT_TRACE
70689 if( db->xProfile && !db->init.busy && p->zSql ){
70690 sqlite3OsCurrentTimeInt64(db->pVfs, &p->startTime);
70691 }else{
70692 assert( p->startTime==0 );
70693 }
70694 #endif
70695
70696 db->nVdbeActive++;
70697 if( p->readOnly==0 ) db->nVdbeWrite++;
@@ -70602,17 +70711,12 @@
70711 rc = sqlite3VdbeExec(p);
70712 db->nVdbeExec--;
70713 }
70714
70715 #ifndef SQLITE_OMIT_TRACE
70716 /* If the statement completed successfully, invoke the profile callback */
70717 if( rc!=SQLITE_ROW ) checkProfileCallback(db, p);
 
 
 
 
 
70718 #endif
70719
70720 if( rc==SQLITE_DONE ){
70721 assert( p->rc==SQLITE_OK );
70722 p->rc = doWalCallbacks(db);
@@ -71685,10 +71789,12 @@
71789 ** This file contains code used to insert the values of host parameters
71790 ** (aka "wildcards") into the SQL text output by sqlite3_trace().
71791 **
71792 ** The Vdbe parse-tree explainer is also found here.
71793 */
71794 /* #include "sqliteInt.h" */
71795 /* #include "vdbeInt.h" */
71796
71797 #ifndef SQLITE_OMIT_TRACE
71798
71799 /*
71800 ** zSql is a zero-terminated string of UTF-8 SQL text. Return the number of
@@ -71877,10 +71983,12 @@
71983 ** documentation, headers files, or other derived files. The formatting
71984 ** of the code in this file is, therefore, important. See other comments
71985 ** in this file for details. If in doubt, do not deviate from existing
71986 ** commenting and indentation practices when changing or adding code.
71987 */
71988 /* #include "sqliteInt.h" */
71989 /* #include "vdbeInt.h" */
71990
71991 /*
71992 ** Invoke this macro on memory cells just prior to changing the
71993 ** value of the cell. This macro verifies that shallow copies are
71994 ** not misused. A shallow copy of a string or blob just copies a
@@ -78635,10 +78743,12 @@
78743 *************************************************************************
78744 **
78745 ** This file contains code used to implement incremental BLOB I/O.
78746 */
78747
78748 /* #include "sqliteInt.h" */
78749 /* #include "vdbeInt.h" */
78750
78751 #ifndef SQLITE_OMIT_INCRBLOB
78752
78753 /*
78754 ** Valid sqlite3_blob* handles point to Incrblob structures.
@@ -79233,10 +79343,12 @@
79343 ** than one background thread may be created. Specifically, there may be
79344 ** one background thread for each temporary file on disk, and one background
79345 ** thread to merge the output of each of the others to a single PMA for
79346 ** the main thread to read from.
79347 */
79348 /* #include "sqliteInt.h" */
79349 /* #include "vdbeInt.h" */
79350
79351 /*
79352 ** If SQLITE_DEBUG_SORTER_THREADS is defined, this module outputs various
79353 ** messages to stderr that may be helpful in understanding the performance
79354 ** characteristics of the sorter in multi-threaded mode.
@@ -81849,10 +81961,11 @@
81961 ** 1) The in-memory representation grows too large for the allocated
81962 ** buffer, or
81963 ** 2) The sqlite3JournalCreate() function is called.
81964 */
81965 #ifdef SQLITE_ENABLE_ATOMIC_WRITE
81966 /* #include "sqliteInt.h" */
81967
81968
81969 /*
81970 ** A JournalFile object is a subclass of sqlite3_file used by
81971 ** as an open file handle for journal files.
@@ -82096,10 +82209,11 @@
82209 **
82210 ** This file contains code use to implement an in-memory rollback journal.
82211 ** The in-memory rollback journal is used to journal transactions for
82212 ** ":memory:" databases and when the journal_mode=MEMORY pragma is used.
82213 */
82214 /* #include "sqliteInt.h" */
82215
82216 /* Forward references to internal structures */
82217 typedef struct MemJournal MemJournal;
82218 typedef struct FilePoint FilePoint;
82219 typedef struct FileChunk FileChunk;
@@ -82351,10 +82465,11 @@
82465 **
82466 *************************************************************************
82467 ** This file contains routines used for walking the parser tree for
82468 ** an SQL statement.
82469 */
82470 /* #include "sqliteInt.h" */
82471 /* #include <stdlib.h> */
82472 /* #include <string.h> */
82473
82474
82475 /*
@@ -82509,10 +82624,11 @@
82624 **
82625 ** This file contains routines used for walking the parser tree and
82626 ** resolve all identifiers by associating them with a particular
82627 ** table and column.
82628 */
82629 /* #include "sqliteInt.h" */
82630 /* #include <stdlib.h> */
82631 /* #include <string.h> */
82632
82633 /*
82634 ** Walk the expression tree pExpr and increase the aggregate function
@@ -84021,10 +84137,11 @@
84137 **
84138 *************************************************************************
84139 ** This file contains routines used for analyzing expressions and
84140 ** for generating VDBE code that evaluates expressions in SQLite.
84141 */
84142 /* #include "sqliteInt.h" */
84143
84144 /*
84145 ** Return the 'affinity' of the expression pExpr if any.
84146 **
84147 ** If pExpr is a column, a reference to a column via an 'AS' alias,
@@ -88183,10 +88300,11 @@
88300 **
88301 *************************************************************************
88302 ** This file contains C code routines that used to generate VDBE code
88303 ** that implements the ALTER TABLE command.
88304 */
88305 /* #include "sqliteInt.h" */
88306
88307 /*
88308 ** The code in this file only exists if we are not omitting the
88309 ** ALTER TABLE logic from the build.
88310 */
@@ -89145,10 +89263,11 @@
89263 ** sqlite_stat4.sample. The nEq, nLt, and nDLt entries of sqlite_stat3
89264 ** all contain just a single integer which is the same as the first
89265 ** integer in the equivalent columns in sqlite_stat4.
89266 */
89267 #ifndef SQLITE_OMIT_ANALYZE
89268 /* #include "sqliteInt.h" */
89269
89270 #if defined(SQLITE_ENABLE_STAT4)
89271 # define IsStat4 1
89272 # define IsStat3 0
89273 #elif defined(SQLITE_ENABLE_STAT3)
@@ -90910,10 +91029,11 @@
91029 ** May you share freely, never taking more than you give.
91030 **
91031 *************************************************************************
91032 ** This file contains code used to implement the ATTACH and DETACH commands.
91033 */
91034 /* #include "sqliteInt.h" */
91035
91036 #ifndef SQLITE_OMIT_ATTACH
91037 /*
91038 ** Resolve an expression that was part of an ATTACH or DETACH statement. This
91039 ** is slightly different from resolving a normal SQL expression, because simple
@@ -91499,10 +91619,11 @@
91619 ** This file contains code used to implement the sqlite3_set_authorizer()
91620 ** API. This facility is an optional feature of the library. Embedded
91621 ** systems that do not need this facility may omit it by recompiling
91622 ** the library with -DSQLITE_OMIT_AUTHORIZATION=1
91623 */
91624 /* #include "sqliteInt.h" */
91625
91626 /*
91627 ** All of the code in this file may be omitted by defining a single
91628 ** macro.
91629 */
@@ -91769,10 +91890,11 @@
91890 ** creating ID lists
91891 ** BEGIN TRANSACTION
91892 ** COMMIT
91893 ** ROLLBACK
91894 */
91895 /* #include "sqliteInt.h" */
91896
91897 /*
91898 ** This routine is called when a new SQL statement is beginning to
91899 ** be parsed. Initialize the pParse structure as needed.
91900 */
@@ -96089,10 +96211,11 @@
96211 **
96212 ** This file contains functions used to access the internal hash tables
96213 ** of user defined functions and collation sequences.
96214 */
96215
96216 /* #include "sqliteInt.h" */
96217
96218 /*
96219 ** Invoke the 'collation needed' callback to request a collation sequence
96220 ** in the encoding enc of name zName, length nName.
96221 */
@@ -96566,10 +96689,11 @@
96689 **
96690 *************************************************************************
96691 ** This file contains C code routines that are called by the parser
96692 ** in order to generate code for DELETE FROM statements.
96693 */
96694 /* #include "sqliteInt.h" */
96695
96696 /*
96697 ** While a SrcList can in general represent multiple tables and subqueries
96698 ** (as in the FROM clause of a SELECT statement) in this case it contains
96699 ** the name of a single table, as one might find in an INSERT, DELETE,
@@ -97408,12 +97532,14 @@
97532 *************************************************************************
97533 ** This file contains the C-language implementations for many of the SQL
97534 ** functions of SQLite. (Some function, and in particular the date and
97535 ** time functions, are implemented separately.)
97536 */
97537 /* #include "sqliteInt.h" */
97538 /* #include <stdlib.h> */
97539 /* #include <assert.h> */
97540 /* #include "vdbeInt.h" */
97541
97542 /*
97543 ** Return the collating function associated with a function.
97544 */
97545 static CollSeq *sqlite3GetFuncCollSeq(sqlite3_context *context){
@@ -99205,10 +99331,11 @@
99331 **
99332 *************************************************************************
99333 ** This file contains code used by the compiler to add foreign key
99334 ** support to compiled SQL statements.
99335 */
99336 /* #include "sqliteInt.h" */
99337
99338 #ifndef SQLITE_OMIT_FOREIGN_KEY
99339 #ifndef SQLITE_OMIT_TRIGGER
99340
99341 /*
@@ -100609,10 +100736,11 @@
100736 **
100737 *************************************************************************
100738 ** This file contains C code routines that are called by the parser
100739 ** to handle INSERT statements in SQLite.
100740 */
100741 /* #include "sqliteInt.h" */
100742
100743 /*
100744 ** Generate code that will
100745 **
100746 ** (1) acquire a lock for table pTab then
@@ -102671,10 +102799,11 @@
102799 ** implement the programmer interface to the library. Routines in
102800 ** other files are for internal use by SQLite and should not be
102801 ** accessed by users of the library.
102802 */
102803
102804 /* #include "sqliteInt.h" */
102805
102806 /*
102807 ** Execute SQL code. Return one of the SQLITE_ success/failure
102808 ** codes. Also write an error message into memory obtained from
102809 ** malloc() and make *pzErrMsg point to that message.
@@ -102839,10 +102968,11 @@
102968 ** as extensions by SQLite should #include this file instead of
102969 ** sqlite3.h.
102970 */
102971 #ifndef _SQLITE3EXT_H_
102972 #define _SQLITE3EXT_H_
102973 /* #include "sqlite3.h" */
102974
102975 typedef struct sqlite3_api_routines sqlite3_api_routines;
102976
102977 /*
102978 ** The following structure holds pointers to all of the SQLite API
@@ -103345,10 +103475,11 @@
103475
103476 #endif /* _SQLITE3EXT_H_ */
103477
103478 /************** End of sqlite3ext.h ******************************************/
103479 /************** Continuing where we left off in loadext.c ********************/
103480 /* #include "sqliteInt.h" */
103481 /* #include <string.h> */
103482
103483 #ifndef SQLITE_OMIT_LOAD_EXTENSION
103484
103485 /*
@@ -104114,10 +104245,11 @@
104245 ** May you share freely, never taking more than you give.
104246 **
104247 *************************************************************************
104248 ** This file contains code used to implement the PRAGMA command.
104249 */
104250 /* #include "sqliteInt.h" */
104251
104252 #if !defined(SQLITE_ENABLE_LOCKING_STYLE)
104253 # if defined(__APPLE__)
104254 # define SQLITE_ENABLE_LOCKING_STYLE 1
104255 # else
@@ -104220,11 +104352,11 @@
104352 /* ePragFlag: */ 0,
104353 /* iArg: */ 0 },
104354 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
104355 { /* zName: */ "cache_size",
104356 /* ePragTyp: */ PragTyp_CACHE_SIZE,
104357 /* ePragFlag: */ 0,
104358 /* iArg: */ 0 },
104359 #endif
104360 #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
104361 { /* zName: */ "cache_spill",
104362 /* ePragTyp: */ PragTyp_FLAG,
@@ -105290,10 +105422,11 @@
105422 ** of memory.
105423 */
105424 case PragTyp_CACHE_SIZE: {
105425 assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
105426 if( !zRight ){
105427 if( sqlite3ReadSchema(pParse) ) goto pragma_out;
105428 returnSingleInt(pParse, "cache_size", pDb->pSchema->cache_size);
105429 }else{
105430 int size = sqlite3Atoi(zRight);
105431 pDb->pSchema->cache_size = size;
105432 sqlite3BtreeSetCacheSize(pDb->pBt, pDb->pSchema->cache_size);
@@ -106565,10 +106698,11 @@
106698 *************************************************************************
106699 ** This file contains the implementation of the sqlite3_prepare()
106700 ** interface, and routines that contribute to loading the database schema
106701 ** from disk.
106702 */
106703 /* #include "sqliteInt.h" */
106704
106705 /*
106706 ** Fill the InitData structure with an error message that indicates
106707 ** that the database is corrupt.
106708 */
@@ -107459,10 +107593,11 @@
107593 **
107594 *************************************************************************
107595 ** This file contains C code routines that are called by the parser
107596 ** to handle SELECT statements in SQLite.
107597 */
107598 /* #include "sqliteInt.h" */
107599
107600 /*
107601 ** Trace output macros
107602 */
107603 #if SELECTTRACE_ENABLED
@@ -108528,11 +108663,10 @@
108663 }
108664 }
108665 return pInfo;
108666 }
108667
 
108668 /*
108669 ** Name of the connection operator, used for error messages.
108670 */
108671 static const char *selectOpName(int id){
108672 char *z;
@@ -108542,11 +108676,10 @@
108676 case TK_EXCEPT: z = "EXCEPT"; break;
108677 default: z = "UNION"; break;
108678 }
108679 return z;
108680 }
 
108681
108682 #ifndef SQLITE_OMIT_EXPLAIN
108683 /*
108684 ** Unless an "EXPLAIN QUERY PLAN" command is being processed, this function
108685 ** is a no-op. Otherwise, it adds a single row of output to the EQP result,
@@ -109545,23 +109678,10 @@
109678 Parse *pParse, /* Parsing context */
109679 Select *p, /* The right-most of SELECTs to be coded */
109680 SelectDest *pDest /* What to do with query results */
109681 );
109682
 
 
 
 
 
 
 
 
 
 
 
 
 
109683 /*
109684 ** Handle the special case of a compound-select that originates from a
109685 ** VALUES clause. By handling this as a special case, we avoid deep
109686 ** recursion, and thus do not need to enforce the SQLITE_LIMIT_COMPOUND_SELECT
109687 ** on a VALUES clause.
@@ -109983,10 +110103,23 @@
110103 pDest->nSdst = dest.nSdst;
110104 sqlite3SelectDelete(db, pDelete);
110105 return rc;
110106 }
110107 #endif /* SQLITE_OMIT_COMPOUND_SELECT */
110108
110109 /*
110110 ** Error message for when two or more terms of a compound select have different
110111 ** size result sets.
110112 */
110113 SQLITE_PRIVATE void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p){
110114 if( p->selFlags & SF_Values ){
110115 sqlite3ErrorMsg(pParse, "all VALUES must have the same number of terms");
110116 }else{
110117 sqlite3ErrorMsg(pParse, "SELECTs to the left and right of %s"
110118 " do not have the same number of result columns", selectOpName(p->op));
110119 }
110120 }
110121
110122 /*
110123 ** Code an output subroutine for a coroutine implementation of a
110124 ** SELECT statment.
110125 **
@@ -113077,10 +113210,11 @@
113210 ** interface routine of sqlite3_exec().
113211 **
113212 ** These routines are in a separate files so that they will not be linked
113213 ** if they are not used.
113214 */
113215 /* #include "sqliteInt.h" */
113216 /* #include <stdlib.h> */
113217 /* #include <string.h> */
113218
113219 #ifndef SQLITE_OMIT_GET_TABLE
113220
@@ -113273,10 +113407,11 @@
113407 ** May you share freely, never taking more than you give.
113408 **
113409 *************************************************************************
113410 ** This file contains the implementation for TRIGGERs
113411 */
113412 /* #include "sqliteInt.h" */
113413
113414 #ifndef SQLITE_OMIT_TRIGGER
113415 /*
113416 ** Delete a linked list of TriggerStep structures.
113417 */
@@ -114396,10 +114531,11 @@
114531 **
114532 *************************************************************************
114533 ** This file contains C code routines that are called by the parser
114534 ** to handle UPDATE statements.
114535 */
114536 /* #include "sqliteInt.h" */
114537
114538 #ifndef SQLITE_OMIT_VIRTUALTABLE
114539 /* Forward declaration */
114540 static void updateVirtualTable(
114541 Parse *pParse, /* The parsing context */
@@ -115172,10 +115308,12 @@
115308 ** This file contains code used to implement the VACUUM command.
115309 **
115310 ** Most of the code in this file may be omitted by defining the
115311 ** SQLITE_OMIT_VACUUM macro.
115312 */
115313 /* #include "sqliteInt.h" */
115314 /* #include "vdbeInt.h" */
115315
115316 #if !defined(SQLITE_OMIT_VACUUM) && !defined(SQLITE_OMIT_ATTACH)
115317 /*
115318 ** Finalize a prepared statement. If there was an error, store the
115319 ** text of the error message in *pzErrMsg. Return the result code.
@@ -115544,10 +115682,11 @@
115682 **
115683 *************************************************************************
115684 ** This file contains code used to help implement virtual tables.
115685 */
115686 #ifndef SQLITE_OMIT_VIRTUALTABLE
115687 /* #include "sqliteInt.h" */
115688
115689 /*
115690 ** Before a virtual table xCreate() or xConnect() method is invoked, the
115691 ** sqlite3.pVtabCtx member variable is set to point to an instance of
115692 ** this struct allocated on the stack. It is used by the implementation of
@@ -116702,10 +116841,11 @@
116841 ** This file was split off from where.c on 2015-06-06 in order to reduce the
116842 ** size of where.c and make it easier to edit. This file contains the routines
116843 ** that actually generate the bulk of the WHERE loop code. The original where.c
116844 ** file retains the code that does query planning and analysis.
116845 */
116846 /* #include "sqliteInt.h" */
116847 /************** Include whereInt.h in the middle of wherecode.c **************/
116848 /************** Begin file whereInt.h ****************************************/
116849 /*
116850 ** 2013-11-12
116851 **
@@ -118737,10 +118877,12 @@
118877 **
118878 ** This file was originally part of where.c but was split out to improve
118879 ** readability and editabiliity. This file contains utility routines for
118880 ** analyzing Expr objects in the WHERE clause.
118881 */
118882 /* #include "sqliteInt.h" */
118883 /* #include "whereInt.h" */
118884
118885 /* Forward declarations */
118886 static void exprAnalyze(SrcList*, WhereClause*, int);
118887
118888 /*
@@ -119987,10 +120129,12 @@
120129 ** generating the code that loops through a table looking for applicable
120130 ** rows. Indices are selected and used to speed the search when doing
120131 ** so is applicable. Because this module is responsible for selecting
120132 ** indices, you might also think of this module as the "query optimizer".
120133 */
120134 /* #include "sqliteInt.h" */
120135 /* #include "whereInt.h" */
120136
120137 /* Forward declaration of methods */
120138 static int whereLoopResize(sqlite3*, WhereLoop*, int);
120139
120140 /* Test variable that can be set to enable WHERE tracing */
@@ -124486,10 +124630,11 @@
124630 */
124631 /* First off, code is included that follows the "include" declaration
124632 ** in the input grammar file. */
124633 /* #include <stdio.h> */
124634
124635 /* #include "sqliteInt.h" */
124636
124637 /*
124638 ** Disable all error recovery processing in the parser push-down
124639 ** automaton.
124640 */
@@ -128071,10 +128216,11 @@
128216 **
128217 ** This file contains C code that splits an SQL input string up into
128218 ** individual tokens and sends those tokens one-by-one over to the
128219 ** parser for analysis.
128220 */
128221 /* #include "sqliteInt.h" */
128222 /* #include <stdlib.h> */
128223
128224 /*
128225 ** The charMap() macro maps alphabetic characters into their
128226 ** lower-case ASCII equivalent. On ASCII machines, this is just
@@ -128880,10 +129026,11 @@
129026 ** This file contains C code that implements the sqlite3_complete() API.
129027 ** This code used to be part of the tokenizer.c source file. But by
129028 ** separating it out, the code will be automatically omitted from
129029 ** static links that do not use it.
129030 */
129031 /* #include "sqliteInt.h" */
129032 #ifndef SQLITE_OMIT_COMPLETE
129033
129034 /*
129035 ** This is defined in tokenize.c. We just have to import the definition.
129036 */
@@ -129170,10 +129317,11 @@
129317 ** Main file for the SQLite library. The routines in this file
129318 ** implement the programmer interface to the library. Routines in
129319 ** other files are for internal use by SQLite and should not be
129320 ** accessed by users of the library.
129321 */
129322 /* #include "sqliteInt.h" */
129323
129324 #ifdef SQLITE_ENABLE_FTS3
129325 /************** Include fts3.h in the middle of main.c ***********************/
129326 /************** Begin file fts3.h ********************************************/
129327 /*
@@ -129189,10 +129337,11 @@
129337 ******************************************************************************
129338 **
129339 ** This header file is used by programs that want to link against the
129340 ** FTS3 library. All it does is declare the sqlite3Fts3Init() interface.
129341 */
129342 /* #include "sqlite3.h" */
129343
129344 #if 0
129345 extern "C" {
129346 #endif /* __cplusplus */
129347
@@ -129221,10 +129370,11 @@
129370 ******************************************************************************
129371 **
129372 ** This header file is used by programs that want to link against the
129373 ** RTREE library. All it does is declare the sqlite3RtreeInit() interface.
129374 */
129375 /* #include "sqlite3.h" */
129376
129377 #if 0
129378 extern "C" {
129379 #endif /* __cplusplus */
129380
@@ -129253,10 +129403,11 @@
129403 ******************************************************************************
129404 **
129405 ** This header file is used by programs that want to link against the
129406 ** ICU extension. All it does is declare the sqlite3IcuInit() interface.
129407 */
129408 /* #include "sqlite3.h" */
129409
129410 #if 0
129411 extern "C" {
129412 #endif /* __cplusplus */
129413
@@ -133045,10 +133196,12 @@
133196 *************************************************************************
133197 **
133198 ** This file contains the implementation of the sqlite3_unlock_notify()
133199 ** API method and its associated functionality.
133200 */
133201 /* #include "sqliteInt.h" */
133202 /* #include "btreeInt.h" */
133203
133204 /* Omit this entire file if SQLITE_ENABLE_UNLOCK_NOTIFY is not defined. */
133205 #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
133206
133207 /*
@@ -133688,13 +133841,15 @@
133841
133842 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
133843
133844 /* If not building as part of the core, include sqlite3ext.h. */
133845 #ifndef SQLITE_CORE
133846 /* # include "sqlite3ext.h" */
133847 SQLITE_EXTENSION_INIT3
133848 #endif
133849
133850 /* #include "sqlite3.h" */
133851 /************** Include fts3_tokenizer.h in the middle of fts3Int.h **********/
133852 /************** Begin file fts3_tokenizer.h **********************************/
133853 /*
133854 ** 2006 July 10
133855 **
@@ -133719,10 +133874,11 @@
133874
133875 /* TODO(shess) Only used for SQLITE_OK and SQLITE_DONE at this time.
133876 ** If tokenizers are to be allowed to call sqlite3_*() functions, then
133877 ** we will need a way to register the API consistently.
133878 */
133879 /* #include "sqlite3.h" */
133880
133881 /*
133882 ** Structures used by the tokenizer interface. When a new tokenizer
133883 ** implementation is registered, the caller provides a pointer to
133884 ** an sqlite3_tokenizer_module containing pointers to the callback
@@ -134559,11 +134715,13 @@
134715 /* #include <stddef.h> */
134716 /* #include <stdio.h> */
134717 /* #include <string.h> */
134718 /* #include <stdarg.h> */
134719
134720 /* #include "fts3.h" */
134721 #ifndef SQLITE_CORE
134722 /* # include "sqlite3ext.h" */
134723 SQLITE_EXTENSION_INIT1
134724 #endif
134725
134726 static int fts3EvalNext(Fts3Cursor *pCsr);
134727 static int fts3EvalStart(Fts3Cursor *pCsr);
@@ -138606,10 +138764,11 @@
138764 if( p==0 ){
138765 p = aDoclist;
138766 p += sqlite3Fts3GetVarint(p, piDocid);
138767 }else{
138768 fts3PoslistCopy(0, &p);
138769 while( p<&aDoclist[nDoclist] && *p==0 ) p++;
138770 if( p>=&aDoclist[nDoclist] ){
138771 *pbEof = 1;
138772 }else{
138773 sqlite3_int64 iVar;
138774 p += sqlite3Fts3GetVarint(p, &iVar);
@@ -140012,14 +140171,14 @@
140171 pIter = pPhrase->doclist.pList;
140172 if( iDocid!=pCsr->iPrevId || pExpr->bEof ){
140173 int rc = SQLITE_OK;
140174 int bDescDoclist = pTab->bDescIdx; /* For DOCID_CMP macro */
140175 int bOr = 0;
 
140176 u8 bTreeEof = 0;
140177 Fts3Expr *p; /* Used to iterate from pExpr to root */
140178 Fts3Expr *pNear; /* Most senior NEAR ancestor (or pExpr) */
140179 int bMatch;
140180
140181 /* Check if this phrase descends from an OR expression node. If not,
140182 ** return NULL. Otherwise, the entry that corresponds to docid
140183 ** pCsr->iPrevId may lie earlier in the doclist buffer. Or, if the
140184 ** tree that the node is part of has been marked as EOF, but the node
@@ -140049,35 +140208,51 @@
140208 fts3EvalNextRow(pCsr, pNear, &rc);
140209 }
140210 }
140211 if( rc!=SQLITE_OK ) return rc;
140212
140213 bMatch = 1;
140214 for(p=pNear; p; p=p->pLeft){
140215 u8 bEof = 0;
140216 Fts3Expr *pTest = p;
140217 Fts3Phrase *pPh;
140218 assert( pTest->eType==FTSQUERY_NEAR || pTest->eType==FTSQUERY_PHRASE );
140219 if( pTest->eType==FTSQUERY_NEAR ) pTest = pTest->pRight;
140220 assert( pTest->eType==FTSQUERY_PHRASE );
140221 pPh = pTest->pPhrase;
140222
140223 pIter = pPh->pOrPoslist;
140224 iDocid = pPh->iOrDocid;
140225 if( pCsr->bDesc==bDescDoclist ){
140226 bEof = !pPh->doclist.nAll ||
140227 (pIter >= (pPh->doclist.aAll + pPh->doclist.nAll));
140228 while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)<0 ) && bEof==0 ){
140229 sqlite3Fts3DoclistNext(
140230 bDescDoclist, pPh->doclist.aAll, pPh->doclist.nAll,
140231 &pIter, &iDocid, &bEof
140232 );
140233 }
140234 }else{
140235 bEof = !pPh->doclist.nAll || (pIter && pIter<=pPh->doclist.aAll);
140236 while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)>0 ) && bEof==0 ){
140237 int dummy;
140238 sqlite3Fts3DoclistPrev(
140239 bDescDoclist, pPh->doclist.aAll, pPh->doclist.nAll,
140240 &pIter, &iDocid, &dummy, &bEof
140241 );
140242 }
140243 }
140244 pPh->pOrPoslist = pIter;
140245 pPh->iOrDocid = iDocid;
140246 if( bEof || iDocid!=pCsr->iPrevId ) bMatch = 0;
140247 }
140248
140249 if( bMatch ){
140250 pIter = pPhrase->pOrPoslist;
140251 }else{
140252 pIter = 0;
140253 }
140254 }
140255 if( pIter==0 ) return SQLITE_OK;
140256
140257 if( *pIter==0x01 ){
140258 pIter++;
@@ -140161,10 +140336,11 @@
140336 ** May you share freely, never taking more than you give.
140337 **
140338 ******************************************************************************
140339 **
140340 */
140341 /* #include "fts3Int.h" */
140342 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
140343
140344 /* #include <string.h> */
140345 /* #include <assert.h> */
140346
@@ -140717,10 +140893,11 @@
140893 ** This module contains code that implements a parser for fts3 query strings
140894 ** (the right-hand argument to the MATCH operator). Because the supported
140895 ** syntax is relatively simple, the whole tokenizer/parser system is
140896 ** hand-coded.
140897 */
140898 /* #include "fts3Int.h" */
140899 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
140900
140901 /*
140902 ** By default, this module parses the legacy syntax that has been
140903 ** traditionally used by fts3. Or, if SQLITE_ENABLE_FTS3_PARENTHESIS
@@ -142010,16 +142187,18 @@
142187 ** (in which case SQLITE_CORE is not defined), or
142188 **
142189 ** * The FTS3 module is being built into the core of
142190 ** SQLite (in which case SQLITE_ENABLE_FTS3 is defined).
142191 */
142192 /* #include "fts3Int.h" */
142193 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
142194
142195 /* #include <assert.h> */
142196 /* #include <stdlib.h> */
142197 /* #include <string.h> */
142198
142199 /* #include "fts3_hash.h" */
142200
142201 /*
142202 ** Malloc and Free functions
142203 */
142204 static void *fts3HashMalloc(int n){
@@ -142393,17 +142572,19 @@
142572 ** (in which case SQLITE_CORE is not defined), or
142573 **
142574 ** * The FTS3 module is being built into the core of
142575 ** SQLite (in which case SQLITE_ENABLE_FTS3 is defined).
142576 */
142577 /* #include "fts3Int.h" */
142578 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
142579
142580 /* #include <assert.h> */
142581 /* #include <stdlib.h> */
142582 /* #include <stdio.h> */
142583 /* #include <string.h> */
142584
142585 /* #include "fts3_tokenizer.h" */
142586
142587 /*
142588 ** Class derived from sqlite3_tokenizer
142589 */
142590 typedef struct porter_tokenizer {
@@ -143057,10 +143238,11 @@
143238 ** (in which case SQLITE_CORE is not defined), or
143239 **
143240 ** * The FTS3 module is being built into the core of
143241 ** SQLite (in which case SQLITE_ENABLE_FTS3 is defined).
143242 */
143243 /* #include "fts3Int.h" */
143244 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
143245
143246 /* #include <assert.h> */
143247 /* #include <string.h> */
143248
@@ -143552,17 +143734,19 @@
143734 ** (in which case SQLITE_CORE is not defined), or
143735 **
143736 ** * The FTS3 module is being built into the core of
143737 ** SQLite (in which case SQLITE_ENABLE_FTS3 is defined).
143738 */
143739 /* #include "fts3Int.h" */
143740 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
143741
143742 /* #include <assert.h> */
143743 /* #include <stdlib.h> */
143744 /* #include <stdio.h> */
143745 /* #include <string.h> */
143746
143747 /* #include "fts3_tokenizer.h" */
143748
143749 typedef struct simple_tokenizer {
143750 sqlite3_tokenizer base;
143751 char delim[128]; /* flag ASCII delimiters */
143752 } simple_tokenizer;
@@ -143803,10 +143987,11 @@
143987 ** end: Byte offset of the byte immediately following the end of the
143988 ** token within the input string.
143989 ** pos: Token offset of token within input.
143990 **
143991 */
143992 /* #include "fts3Int.h" */
143993 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
143994
143995 /* #include <string.h> */
143996 /* #include <assert.h> */
143997
@@ -144238,10 +144423,11 @@
144423 ** tables. It also contains code to merge FTS3 b-tree segments. Some
144424 ** of the sub-routines used to merge segments are also used by the query
144425 ** code in fts3.c.
144426 */
144427
144428 /* #include "fts3Int.h" */
144429 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
144430
144431 /* #include <string.h> */
144432 /* #include <assert.h> */
144433 /* #include <stdlib.h> */
@@ -149898,10 +150084,11 @@
150084 ** May you share freely, never taking more than you give.
150085 **
150086 ******************************************************************************
150087 */
150088
150089 /* #include "fts3Int.h" */
150090 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
150091
150092 /* #include <string.h> */
150093 /* #include <assert.h> */
150094
@@ -151610,17 +151797,19 @@
151797 ** Implementation of the "unicode" full-text-search tokenizer.
151798 */
151799
151800 #ifndef SQLITE_DISABLE_FTS3_UNICODE
151801
151802 /* #include "fts3Int.h" */
151803 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
151804
151805 /* #include <assert.h> */
151806 /* #include <stdlib.h> */
151807 /* #include <stdio.h> */
151808 /* #include <string.h> */
151809
151810 /* #include "fts3_tokenizer.h" */
151811
151812 /*
151813 ** The following two macros - READ_UTF8 and WRITE_UTF8 - have been copied
151814 ** from the sqlite3 source file utf.c. If this file is compiled as part
151815 ** of the amalgamation, they are not required.
@@ -152412,12 +152601,14 @@
152601 */
152602
152603 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_RTREE)
152604
152605 #ifndef SQLITE_CORE
152606 /* #include "sqlite3ext.h" */
152607 SQLITE_EXTENSION_INIT1
152608 #else
152609 /* #include "sqlite3.h" */
152610 #endif
152611
152612 /* #include <string.h> */
152613 /* #include <assert.h> */
152614 /* #include <stdio.h> */
@@ -155909,12 +156100,14 @@
156100 #include <unicode/ucol.h>
156101
156102 /* #include <assert.h> */
156103
156104 #ifndef SQLITE_CORE
156105 /* #include "sqlite3ext.h" */
156106 SQLITE_EXTENSION_INIT1
156107 #else
156108 /* #include "sqlite3.h" */
156109 #endif
156110
156111 /*
156112 ** Maximum length (in bytes) of the pattern in a LIKE or GLOB
156113 ** operator.
@@ -156386,15 +156579,17 @@
156579 ** May you share freely, never taking more than you give.
156580 **
156581 *************************************************************************
156582 ** This file implements a tokenizer for fts3 based on the ICU library.
156583 */
156584 /* #include "fts3Int.h" */
156585 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
156586 #ifdef SQLITE_ENABLE_ICU
156587
156588 /* #include <assert.h> */
156589 /* #include <string.h> */
156590 /* #include "fts3_tokenizer.h" */
156591
156592 #include <unicode/ubrk.h>
156593 /* #include <unicode/ucol.h> */
156594 /* #include <unicode/ustring.h> */
156595 #include <unicode/utf16.h>
@@ -156723,10 +156918,11 @@
156918 /* #include <assert.h> */
156919 /* #include <string.h> */
156920 /* #include <stdio.h> */
156921 /* #include <unistd.h> */
156922
156923 /* #include "sqlite3.h" */
156924
156925 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_OTA)
156926 /************** Include sqlite3ota.h in the middle of sqlite3ota.c ***********/
156927 /************** Begin file sqlite3ota.h **************************************/
156928 /*
@@ -156976,10 +157172,11 @@
157172 */
157173
157174 #ifndef _SQLITE3OTA_H
157175 #define _SQLITE3OTA_H
157176
157177 /* #include "sqlite3.h" ** Required for error code definitions ** */
157178
157179 typedef struct sqlite3ota sqlite3ota;
157180
157181 /*
157182 ** Open an OTA handle.
@@ -157144,11 +157341,10 @@
157341 ** are undefined.
157342 */
157343 SQLITE_API void SQLITE_STDCALL sqlite3ota_destroy_vfs(const char *zName);
157344
157345 #endif /* _SQLITE3OTA_H */
 
157346
157347 /************** End of sqlite3ota.h ******************************************/
157348 /************** Continuing where we left off in sqlite3ota.c *****************/
157349
157350 /* Maximum number of prepared UPDATE statements held by this module */
@@ -160741,10 +160937,11 @@
160937 ** information from an SQLite database in order to implement the
160938 ** "sqlite3_analyzer" utility. See the ../tool/spaceanal.tcl script
160939 ** for an example implementation.
160940 */
160941
160942 /* #include "sqliteInt.h" ** Requires access to internal data structures ** */
160943 #if (defined(SQLITE_ENABLE_DBSTAT_VTAB) || defined(SQLITE_TEST)) \
160944 && !defined(SQLITE_OMIT_VIRTUALTABLE)
160945
160946 /*
160947 ** Page paths:
160948
+1 -1
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -111,11 +111,11 @@
111111
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
112112
** [sqlite_version()] and [sqlite_source_id()].
113113
*/
114114
#define SQLITE_VERSION "3.8.11"
115115
#define SQLITE_VERSION_NUMBER 3008011
116
-#define SQLITE_SOURCE_ID "2015-07-08 16:22:42 5348ffc3fda5168c1e9e14aa88b0c6aedbda7c94"
116
+#define SQLITE_SOURCE_ID "2015-07-16 18:18:19 b79a4affe44bd0c8e155cae19f3f62c715684cd6"
117117
118118
/*
119119
** CAPI3REF: Run-Time Library Version Numbers
120120
** KEYWORDS: sqlite3_version, sqlite3_sourceid
121121
**
122122
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -111,11 +111,11 @@
111 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
112 ** [sqlite_version()] and [sqlite_source_id()].
113 */
114 #define SQLITE_VERSION "3.8.11"
115 #define SQLITE_VERSION_NUMBER 3008011
116 #define SQLITE_SOURCE_ID "2015-07-08 16:22:42 5348ffc3fda5168c1e9e14aa88b0c6aedbda7c94"
117
118 /*
119 ** CAPI3REF: Run-Time Library Version Numbers
120 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
121 **
122
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -111,11 +111,11 @@
111 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
112 ** [sqlite_version()] and [sqlite_source_id()].
113 */
114 #define SQLITE_VERSION "3.8.11"
115 #define SQLITE_VERSION_NUMBER 3008011
116 #define SQLITE_SOURCE_ID "2015-07-16 18:18:19 b79a4affe44bd0c8e155cae19f3f62c715684cd6"
117
118 /*
119 ** CAPI3REF: Run-Time Library Version Numbers
120 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
121 **
122

Keyboard Shortcuts

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