Fossil SCM

Update to the latest pre-release of SQLite 3.18.0 that includes a fix for the harmless compiler warning on Macs.

drh 2017-03-18 14:10 trunk
Commit 9612d43f930926c42b352a7c5990a2d7fb8976fe2292083542da38f3d23fe758
2 files changed +94 -46 +5 -4
+94 -46
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -398,11 +398,11 @@
398398
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
399399
** [sqlite_version()] and [sqlite_source_id()].
400400
*/
401401
#define SQLITE_VERSION "3.18.0"
402402
#define SQLITE_VERSION_NUMBER 3018000
403
-#define SQLITE_SOURCE_ID "2017-03-16 14:28:52 6d85eb5736781b43aa674d9544c7523b849b4e634f371702f8764b33e22e1e9f"
403
+#define SQLITE_SOURCE_ID "2017-03-18 13:59:46 4e6a03d9e12b120d15946b025f97a97697cb8e8af543c238ffda220c9e3f28f4"
404404
405405
/*
406406
** CAPI3REF: Run-Time Library Version Numbers
407407
** KEYWORDS: sqlite3_version sqlite3_sourceid
408408
**
@@ -3699,13 +3699,13 @@
36993699
** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
37003700
** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^
37013701
**
37023702
** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>
37033703
** <dd>The maximum number of instructions in a virtual machine program
3704
-** used to implement an SQL statement. This limit is not currently
3705
-** enforced, though that might be added in some future release of
3706
-** SQLite.</dd>)^
3704
+** used to implement an SQL statement. If [sqlite3_prepare_v2()] or
3705
+** the equivalent tries to allocate space for more than this many opcodes
3706
+** in a single prepared statement, an SQLITE_NOMEM error is returned.</dd>)^
37073707
**
37083708
** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
37093709
** <dd>The maximum number of arguments on a function.</dd>)^
37103710
**
37113711
** [[SQLITE_LIMIT_ATTACHED]] ^(<dt>SQLITE_LIMIT_ATTACHED</dt>
@@ -3738,10 +3738,11 @@
37383738
#define SQLITE_LIMIT_ATTACHED 7
37393739
#define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8
37403740
#define SQLITE_LIMIT_VARIABLE_NUMBER 9
37413741
#define SQLITE_LIMIT_TRIGGER_DEPTH 10
37423742
#define SQLITE_LIMIT_WORKER_THREADS 11
3743
+
37433744
37443745
/*
37453746
** CAPI3REF: Compiling An SQL Statement
37463747
** KEYWORDS: {SQL statement compiler}
37473748
** METHOD: sqlite3
@@ -10866,11 +10867,11 @@
1086610867
/*
1086710868
** The maximum number of opcodes in a VDBE program.
1086810869
** Not currently enforced.
1086910870
*/
1087010871
#ifndef SQLITE_MAX_VDBE_OP
10871
-# define SQLITE_MAX_VDBE_OP 25000
10872
+# define SQLITE_MAX_VDBE_OP 250000000
1087210873
#endif
1087310874
1087410875
/*
1087510876
** The maximum number of arguments to an SQL function.
1087610877
*/
@@ -17487,10 +17488,16 @@
1748717488
"DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE),
1748817489
#endif
1748917490
#if defined(SQLITE_DEFAULT_MMAP_SIZE) && !defined(SQLITE_DEFAULT_MMAP_SIZE_xc)
1749017491
"DEFAULT_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_MMAP_SIZE),
1749117492
#endif
17493
+#if SQLITE_DEFAULT_SYNCHRONOUS
17494
+ "DEFAULT_SYNCHRONOUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_SYNCHRONOUS),
17495
+#endif
17496
+#if SQLITE_DEFAULT_WAL_SYNCHRONOUS
17497
+ "DEFAULT_WAL_SYNCHRONOUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_WAL_SYNCHRONOUS),
17498
+#endif
1749217499
#if SQLITE_DIRECT_OVERFLOW_READ
1749317500
"DIRECT_OVERFLOW_READ",
1749417501
#endif
1749517502
#if SQLITE_DISABLE_DIRSYNC
1749617503
"DISABLE_DIRSYNC",
@@ -20667,11 +20674,13 @@
2066720674
** Use the zone allocator available on apple products unless the
2066820675
** SQLITE_WITHOUT_ZONEMALLOC symbol is defined.
2066920676
*/
2067020677
#include <sys/sysctl.h>
2067120678
#include <malloc/malloc.h>
20679
+#ifdef SQLITE_MIGHT_BE_SINGLE_CORE
2067220680
#include <libkern/OSAtomic.h>
20681
+#endif /* SQLITE_MIGHT_BE_SINGLE_CORE */
2067320682
static malloc_zone_t* _sqliteZone_;
2067420683
#define SQLITE_MALLOC(x) malloc_zone_malloc(_sqliteZone_, (x))
2067520684
#define SQLITE_FREE(x) malloc_zone_free(_sqliteZone_, (x));
2067620685
#define SQLITE_REALLOC(x,y) malloc_zone_realloc(_sqliteZone_, (x), (y))
2067720686
#define SQLITE_MALLOCSIZE(x) \
@@ -20846,37 +20855,50 @@
2084620855
/*
2084720856
** Initialize this module.
2084820857
*/
2084920858
static int sqlite3MemInit(void *NotUsed){
2085020859
#if defined(__APPLE__) && !defined(SQLITE_WITHOUT_ZONEMALLOC)
20851
- int cpuCount;
20852
- size_t len;
2085320860
if( _sqliteZone_ ){
2085420861
return SQLITE_OK;
2085520862
}
20856
- len = sizeof(cpuCount);
20857
- /* One usually wants to use hw.acctivecpu for MT decisions, but not here */
20858
- sysctlbyname("hw.ncpu", &cpuCount, &len, NULL, 0);
20859
- if( cpuCount>1 ){
20860
- /* defer MT decisions to system malloc */
20861
- _sqliteZone_ = malloc_default_zone();
20862
- }else{
20863
- /* only 1 core, use our own zone to contention over global locks,
20864
- ** e.g. we have our own dedicated locks */
20865
- bool success;
20866
- malloc_zone_t* newzone = malloc_create_zone(4096, 0);
20867
- malloc_set_zone_name(newzone, "Sqlite_Heap");
20868
- do{
20869
- success = OSAtomicCompareAndSwapPtrBarrier(NULL, newzone,
20870
- (void * volatile *)&_sqliteZone_);
20871
- }while(!_sqliteZone_);
20872
- if( !success ){
20873
- /* somebody registered a zone first */
20874
- malloc_destroy_zone(newzone);
20875
- }
20876
- }
20877
-#endif
20863
+#ifndef SQLITE_MIGHT_BE_SINGLE_CORE
20864
+ /* If not compiled with the SQLITE_MIGHT_BE_SINGLE_CORE flag, assume
20865
+ ** that multiple cores are always available. This is the default case.
20866
+ */
20867
+ _sqliteZone_ = malloc_default_zone();
20868
+#else
20869
+ /* With the SQLITE_MIGHT_BE_SINGLE_CORE compile-time option, check the
20870
+ ** number of cores. Different malloc() strategies are used for single-core and
20871
+ ** multi-core machines.
20872
+ */
20873
+ {
20874
+ int cpuCount;
20875
+ size_t len;
20876
+ len = sizeof(cpuCount);
20877
+ /* One usually wants to use hw.acctivecpu for MT decisions, but not here */
20878
+ sysctlbyname("hw.ncpu", &cpuCount, &len, NULL, 0);
20879
+ if( cpuCount>1 ){
20880
+ /* defer MT decisions to system malloc */
20881
+ _sqliteZone_ = malloc_default_zone();
20882
+ }else{
20883
+ /* only 1 core, use our own zone to contention over global locks,
20884
+ ** e.g. we have our own dedicated locks */
20885
+ bool success;
20886
+ malloc_zone_t* newzone = malloc_create_zone(4096, 0);
20887
+ malloc_set_zone_name(newzone, "Sqlite_Heap");
20888
+ do{
20889
+ success = OSAtomicCompareAndSwapPtrBarrier(NULL, newzone,
20890
+ (void * volatile *)&_sqliteZone_);
20891
+ }while(!_sqliteZone_);
20892
+ if( !success ){
20893
+ /* somebody registered a zone first */
20894
+ malloc_destroy_zone(newzone);
20895
+ }
20896
+ }
20897
+ }
20898
+#endif /* SQLITE_MIGHT_BE_SINGLE_CORE */
20899
+#endif /* defined(__APPLE__) && !defined(SQLITE_WITHOUT_ZONEMALLOC) */
2087820900
UNUSED_PARAMETER(NotUsed);
2087920901
return SQLITE_OK;
2088020902
}
2088120903
2088220904
/*
@@ -61814,10 +61836,35 @@
6181461836
sqlite3BtreeLeave(p);
6181561837
return rc;
6181661838
#endif
6181761839
}
6181861840
61841
+/*
61842
+** If the user has not set the safety-level for this database connection
61843
+** using "PRAGMA synchronous", and if the safety-level is not already
61844
+** set to the value passed to this function as the second parameter,
61845
+** set it so.
61846
+*/
61847
+#if SQLITE_DEFAULT_SYNCHRONOUS!=SQLITE_DEFAULT_WAL_SYNCHRONOUS
61848
+static void setDefaultSyncFlag(BtShared *pBt, u8 safety_level){
61849
+ sqlite3 *db;
61850
+ Db *pDb;
61851
+ if( (db=pBt->db)!=0 && (pDb=db->aDb)!=0 ){
61852
+ while( pDb->pBt==0 || pDb->pBt->pBt!=pBt ){ pDb++; }
61853
+ if( pDb->bSyncSet==0
61854
+ && pDb->safety_level!=safety_level
61855
+ && pDb!=&db->aDb[1]
61856
+ ){
61857
+ pDb->safety_level = safety_level;
61858
+ sqlite3PagerSetFlags(pBt->pPager,
61859
+ pDb->safety_level | (db->flags & PAGER_FLAGS_MASK));
61860
+ }
61861
+ }
61862
+}
61863
+#else
61864
+# define setDefaultSyncFlag(pBt,safety_level)
61865
+#endif
6181961866
6182061867
/*
6182161868
** Get a reference to pPage1 of the database file. This will
6182261869
** also acquire a readlock on that file.
6182361870
**
@@ -61887,30 +61934,19 @@
6188761934
int isOpen = 0;
6188861935
rc = sqlite3PagerOpenWal(pBt->pPager, &isOpen);
6188961936
if( rc!=SQLITE_OK ){
6189061937
goto page1_init_failed;
6189161938
}else{
61892
-#if SQLITE_DEFAULT_SYNCHRONOUS!=SQLITE_DEFAULT_WAL_SYNCHRONOUS
61893
- sqlite3 *db;
61894
- Db *pDb;
61895
- if( (db=pBt->db)!=0 && (pDb=db->aDb)!=0 ){
61896
- while( pDb->pBt==0 || pDb->pBt->pBt!=pBt ){ pDb++; }
61897
- if( pDb->bSyncSet==0
61898
- && pDb->safety_level==SQLITE_DEFAULT_SYNCHRONOUS+1
61899
- ){
61900
- pDb->safety_level = SQLITE_DEFAULT_WAL_SYNCHRONOUS+1;
61901
- sqlite3PagerSetFlags(pBt->pPager,
61902
- pDb->safety_level | (db->flags & PAGER_FLAGS_MASK));
61903
- }
61904
- }
61905
-#endif
61939
+ setDefaultSyncFlag(pBt, SQLITE_DEFAULT_WAL_SYNCHRONOUS+1);
6190661940
if( isOpen==0 ){
6190761941
releasePage(pPage1);
6190861942
return SQLITE_OK;
6190961943
}
6191061944
}
6191161945
rc = SQLITE_NOTADB;
61946
+ }else{
61947
+ setDefaultSyncFlag(pBt, SQLITE_DEFAULT_SYNCHRONOUS+1);
6191261948
}
6191361949
#endif
6191461950
6191561951
/* EVIDENCE-OF: R-15465-20813 The maximum and minimum embedded payload
6191661952
** fractions and the leaf payload fraction values must be 64, 32, and 32.
@@ -71426,10 +71462,16 @@
7142671462
int nNew = (p->nOpAlloc>=512 ? p->nOpAlloc*2 : p->nOpAlloc+nOp);
7142771463
#else
7142871464
int nNew = (p->nOpAlloc ? p->nOpAlloc*2 : (int)(1024/sizeof(Op)));
7142971465
UNUSED_PARAMETER(nOp);
7143071466
#endif
71467
+
71468
+ /* Ensure that the size of a VDBE does not grow too large */
71469
+ if( nNew > p->db->aLimit[SQLITE_LIMIT_VDBE_OP] ){
71470
+ sqlite3OomFault(p->db);
71471
+ return SQLITE_NOMEM;
71472
+ }
7143171473
7143271474
assert( nOp<=(1024/sizeof(Op)) );
7143371475
assert( nNew>=(p->nOpAlloc+nOp) );
7143471476
pNew = sqlite3DbRealloc(p->db, v->aOp, nNew*sizeof(Op));
7143571477
if( pNew ){
@@ -80816,12 +80858,17 @@
8081680858
/* Content is irrelevant for
8081780859
** 1. the typeof() function,
8081880860
** 2. the length(X) function if X is a blob, and
8081980861
** 3. if the content length is zero.
8082080862
** So we might as well use bogus content rather than reading
80821
- ** content from disk. */
80822
- static u8 aZero[8]; /* This is the bogus content */
80863
+ ** content from disk.
80864
+ **
80865
+ ** Although sqlite3VdbeSerialGet() may read at most 8 bytes from the
80866
+ ** buffer passed to it, debugging function VdbeMemPrettyPrint() may
80867
+ ** read up to 16. So 16 bytes of bogus content is supplied.
80868
+ */
80869
+ static u8 aZero[16]; /* This is the bogus content */
8082380870
sqlite3VdbeSerialGet(aZero, t, pDest);
8082480871
}else{
8082580872
rc = sqlite3VdbeMemFromBtree(pC->uc.pCursor, aOffset[p2], len, pDest);
8082680873
if( rc!=SQLITE_OK ) goto abort_due_to_error;
8082780874
sqlite3VdbeSerialGet((const u8*)pDest->z, t, pDest);
@@ -114404,10 +114451,11 @@
114404114451
Index *pPrior = 0;
114405114452
int loopTop;
114406114453
int iDataCur, iIdxCur;
114407114454
int r1 = -1;
114408114455
114456
+ if( pTab->tnum<1 ) continue; /* Skip VIEWs or VIRTUAL TABLEs */
114409114457
if( pTab->pCheck==0
114410114458
&& (pTab->tabFlags & TF_HasNotNull)==0
114411114459
&& (pTab->pIndex==0 || isQuick)
114412114460
){
114413114461
continue; /* No additional checks needed for this table */
@@ -198072,11 +198120,11 @@
198072198120
int nArg, /* Number of args */
198073198121
sqlite3_value **apUnused /* Function arguments */
198074198122
){
198075198123
assert( nArg==0 );
198076198124
UNUSED_PARAM2(nArg, apUnused);
198077
- sqlite3_result_text(pCtx, "fts5: 2017-03-16 14:28:52 6d85eb5736781b43aa674d9544c7523b849b4e634f371702f8764b33e22e1e9f", -1, SQLITE_TRANSIENT);
198125
+ sqlite3_result_text(pCtx, "fts5: 2017-03-17 14:59:40 626bdca98e0cd78ae873d97e75bb7d544ca18759c9f1e67f4adf03daca7fe5bf", -1, SQLITE_TRANSIENT);
198078198126
}
198079198127
198080198128
static int fts5Init(sqlite3 *db){
198081198129
static const sqlite3_module fts5Mod = {
198082198130
/* iVersion */ 2,
198083198131
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -398,11 +398,11 @@
398 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
399 ** [sqlite_version()] and [sqlite_source_id()].
400 */
401 #define SQLITE_VERSION "3.18.0"
402 #define SQLITE_VERSION_NUMBER 3018000
403 #define SQLITE_SOURCE_ID "2017-03-16 14:28:52 6d85eb5736781b43aa674d9544c7523b849b4e634f371702f8764b33e22e1e9f"
404
405 /*
406 ** CAPI3REF: Run-Time Library Version Numbers
407 ** KEYWORDS: sqlite3_version sqlite3_sourceid
408 **
@@ -3699,13 +3699,13 @@
3699 ** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
3700 ** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^
3701 **
3702 ** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>
3703 ** <dd>The maximum number of instructions in a virtual machine program
3704 ** used to implement an SQL statement. This limit is not currently
3705 ** enforced, though that might be added in some future release of
3706 ** SQLite.</dd>)^
3707 **
3708 ** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
3709 ** <dd>The maximum number of arguments on a function.</dd>)^
3710 **
3711 ** [[SQLITE_LIMIT_ATTACHED]] ^(<dt>SQLITE_LIMIT_ATTACHED</dt>
@@ -3738,10 +3738,11 @@
3738 #define SQLITE_LIMIT_ATTACHED 7
3739 #define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8
3740 #define SQLITE_LIMIT_VARIABLE_NUMBER 9
3741 #define SQLITE_LIMIT_TRIGGER_DEPTH 10
3742 #define SQLITE_LIMIT_WORKER_THREADS 11
 
3743
3744 /*
3745 ** CAPI3REF: Compiling An SQL Statement
3746 ** KEYWORDS: {SQL statement compiler}
3747 ** METHOD: sqlite3
@@ -10866,11 +10867,11 @@
10866 /*
10867 ** The maximum number of opcodes in a VDBE program.
10868 ** Not currently enforced.
10869 */
10870 #ifndef SQLITE_MAX_VDBE_OP
10871 # define SQLITE_MAX_VDBE_OP 25000
10872 #endif
10873
10874 /*
10875 ** The maximum number of arguments to an SQL function.
10876 */
@@ -17487,10 +17488,16 @@
17487 "DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE),
17488 #endif
17489 #if defined(SQLITE_DEFAULT_MMAP_SIZE) && !defined(SQLITE_DEFAULT_MMAP_SIZE_xc)
17490 "DEFAULT_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_MMAP_SIZE),
17491 #endif
 
 
 
 
 
 
17492 #if SQLITE_DIRECT_OVERFLOW_READ
17493 "DIRECT_OVERFLOW_READ",
17494 #endif
17495 #if SQLITE_DISABLE_DIRSYNC
17496 "DISABLE_DIRSYNC",
@@ -20667,11 +20674,13 @@
20667 ** Use the zone allocator available on apple products unless the
20668 ** SQLITE_WITHOUT_ZONEMALLOC symbol is defined.
20669 */
20670 #include <sys/sysctl.h>
20671 #include <malloc/malloc.h>
 
20672 #include <libkern/OSAtomic.h>
 
20673 static malloc_zone_t* _sqliteZone_;
20674 #define SQLITE_MALLOC(x) malloc_zone_malloc(_sqliteZone_, (x))
20675 #define SQLITE_FREE(x) malloc_zone_free(_sqliteZone_, (x));
20676 #define SQLITE_REALLOC(x,y) malloc_zone_realloc(_sqliteZone_, (x), (y))
20677 #define SQLITE_MALLOCSIZE(x) \
@@ -20846,37 +20855,50 @@
20846 /*
20847 ** Initialize this module.
20848 */
20849 static int sqlite3MemInit(void *NotUsed){
20850 #if defined(__APPLE__) && !defined(SQLITE_WITHOUT_ZONEMALLOC)
20851 int cpuCount;
20852 size_t len;
20853 if( _sqliteZone_ ){
20854 return SQLITE_OK;
20855 }
20856 len = sizeof(cpuCount);
20857 /* One usually wants to use hw.acctivecpu for MT decisions, but not here */
20858 sysctlbyname("hw.ncpu", &cpuCount, &len, NULL, 0);
20859 if( cpuCount>1 ){
20860 /* defer MT decisions to system malloc */
20861 _sqliteZone_ = malloc_default_zone();
20862 }else{
20863 /* only 1 core, use our own zone to contention over global locks,
20864 ** e.g. we have our own dedicated locks */
20865 bool success;
20866 malloc_zone_t* newzone = malloc_create_zone(4096, 0);
20867 malloc_set_zone_name(newzone, "Sqlite_Heap");
20868 do{
20869 success = OSAtomicCompareAndSwapPtrBarrier(NULL, newzone,
20870 (void * volatile *)&_sqliteZone_);
20871 }while(!_sqliteZone_);
20872 if( !success ){
20873 /* somebody registered a zone first */
20874 malloc_destroy_zone(newzone);
20875 }
20876 }
20877 #endif
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20878 UNUSED_PARAMETER(NotUsed);
20879 return SQLITE_OK;
20880 }
20881
20882 /*
@@ -61814,10 +61836,35 @@
61814 sqlite3BtreeLeave(p);
61815 return rc;
61816 #endif
61817 }
61818
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61819
61820 /*
61821 ** Get a reference to pPage1 of the database file. This will
61822 ** also acquire a readlock on that file.
61823 **
@@ -61887,30 +61934,19 @@
61887 int isOpen = 0;
61888 rc = sqlite3PagerOpenWal(pBt->pPager, &isOpen);
61889 if( rc!=SQLITE_OK ){
61890 goto page1_init_failed;
61891 }else{
61892 #if SQLITE_DEFAULT_SYNCHRONOUS!=SQLITE_DEFAULT_WAL_SYNCHRONOUS
61893 sqlite3 *db;
61894 Db *pDb;
61895 if( (db=pBt->db)!=0 && (pDb=db->aDb)!=0 ){
61896 while( pDb->pBt==0 || pDb->pBt->pBt!=pBt ){ pDb++; }
61897 if( pDb->bSyncSet==0
61898 && pDb->safety_level==SQLITE_DEFAULT_SYNCHRONOUS+1
61899 ){
61900 pDb->safety_level = SQLITE_DEFAULT_WAL_SYNCHRONOUS+1;
61901 sqlite3PagerSetFlags(pBt->pPager,
61902 pDb->safety_level | (db->flags & PAGER_FLAGS_MASK));
61903 }
61904 }
61905 #endif
61906 if( isOpen==0 ){
61907 releasePage(pPage1);
61908 return SQLITE_OK;
61909 }
61910 }
61911 rc = SQLITE_NOTADB;
 
 
61912 }
61913 #endif
61914
61915 /* EVIDENCE-OF: R-15465-20813 The maximum and minimum embedded payload
61916 ** fractions and the leaf payload fraction values must be 64, 32, and 32.
@@ -71426,10 +71462,16 @@
71426 int nNew = (p->nOpAlloc>=512 ? p->nOpAlloc*2 : p->nOpAlloc+nOp);
71427 #else
71428 int nNew = (p->nOpAlloc ? p->nOpAlloc*2 : (int)(1024/sizeof(Op)));
71429 UNUSED_PARAMETER(nOp);
71430 #endif
 
 
 
 
 
 
71431
71432 assert( nOp<=(1024/sizeof(Op)) );
71433 assert( nNew>=(p->nOpAlloc+nOp) );
71434 pNew = sqlite3DbRealloc(p->db, v->aOp, nNew*sizeof(Op));
71435 if( pNew ){
@@ -80816,12 +80858,17 @@
80816 /* Content is irrelevant for
80817 ** 1. the typeof() function,
80818 ** 2. the length(X) function if X is a blob, and
80819 ** 3. if the content length is zero.
80820 ** So we might as well use bogus content rather than reading
80821 ** content from disk. */
80822 static u8 aZero[8]; /* This is the bogus content */
 
 
 
 
 
80823 sqlite3VdbeSerialGet(aZero, t, pDest);
80824 }else{
80825 rc = sqlite3VdbeMemFromBtree(pC->uc.pCursor, aOffset[p2], len, pDest);
80826 if( rc!=SQLITE_OK ) goto abort_due_to_error;
80827 sqlite3VdbeSerialGet((const u8*)pDest->z, t, pDest);
@@ -114404,10 +114451,11 @@
114404 Index *pPrior = 0;
114405 int loopTop;
114406 int iDataCur, iIdxCur;
114407 int r1 = -1;
114408
 
114409 if( pTab->pCheck==0
114410 && (pTab->tabFlags & TF_HasNotNull)==0
114411 && (pTab->pIndex==0 || isQuick)
114412 ){
114413 continue; /* No additional checks needed for this table */
@@ -198072,11 +198120,11 @@
198072 int nArg, /* Number of args */
198073 sqlite3_value **apUnused /* Function arguments */
198074 ){
198075 assert( nArg==0 );
198076 UNUSED_PARAM2(nArg, apUnused);
198077 sqlite3_result_text(pCtx, "fts5: 2017-03-16 14:28:52 6d85eb5736781b43aa674d9544c7523b849b4e634f371702f8764b33e22e1e9f", -1, SQLITE_TRANSIENT);
198078 }
198079
198080 static int fts5Init(sqlite3 *db){
198081 static const sqlite3_module fts5Mod = {
198082 /* iVersion */ 2,
198083
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -398,11 +398,11 @@
398 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
399 ** [sqlite_version()] and [sqlite_source_id()].
400 */
401 #define SQLITE_VERSION "3.18.0"
402 #define SQLITE_VERSION_NUMBER 3018000
403 #define SQLITE_SOURCE_ID "2017-03-18 13:59:46 4e6a03d9e12b120d15946b025f97a97697cb8e8af543c238ffda220c9e3f28f4"
404
405 /*
406 ** CAPI3REF: Run-Time Library Version Numbers
407 ** KEYWORDS: sqlite3_version sqlite3_sourceid
408 **
@@ -3699,13 +3699,13 @@
3699 ** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
3700 ** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^
3701 **
3702 ** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>
3703 ** <dd>The maximum number of instructions in a virtual machine program
3704 ** used to implement an SQL statement. If [sqlite3_prepare_v2()] or
3705 ** the equivalent tries to allocate space for more than this many opcodes
3706 ** in a single prepared statement, an SQLITE_NOMEM error is returned.</dd>)^
3707 **
3708 ** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
3709 ** <dd>The maximum number of arguments on a function.</dd>)^
3710 **
3711 ** [[SQLITE_LIMIT_ATTACHED]] ^(<dt>SQLITE_LIMIT_ATTACHED</dt>
@@ -3738,10 +3738,11 @@
3738 #define SQLITE_LIMIT_ATTACHED 7
3739 #define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8
3740 #define SQLITE_LIMIT_VARIABLE_NUMBER 9
3741 #define SQLITE_LIMIT_TRIGGER_DEPTH 10
3742 #define SQLITE_LIMIT_WORKER_THREADS 11
3743
3744
3745 /*
3746 ** CAPI3REF: Compiling An SQL Statement
3747 ** KEYWORDS: {SQL statement compiler}
3748 ** METHOD: sqlite3
@@ -10866,11 +10867,11 @@
10867 /*
10868 ** The maximum number of opcodes in a VDBE program.
10869 ** Not currently enforced.
10870 */
10871 #ifndef SQLITE_MAX_VDBE_OP
10872 # define SQLITE_MAX_VDBE_OP 250000000
10873 #endif
10874
10875 /*
10876 ** The maximum number of arguments to an SQL function.
10877 */
@@ -17487,10 +17488,16 @@
17488 "DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE),
17489 #endif
17490 #if defined(SQLITE_DEFAULT_MMAP_SIZE) && !defined(SQLITE_DEFAULT_MMAP_SIZE_xc)
17491 "DEFAULT_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_MMAP_SIZE),
17492 #endif
17493 #if SQLITE_DEFAULT_SYNCHRONOUS
17494 "DEFAULT_SYNCHRONOUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_SYNCHRONOUS),
17495 #endif
17496 #if SQLITE_DEFAULT_WAL_SYNCHRONOUS
17497 "DEFAULT_WAL_SYNCHRONOUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_WAL_SYNCHRONOUS),
17498 #endif
17499 #if SQLITE_DIRECT_OVERFLOW_READ
17500 "DIRECT_OVERFLOW_READ",
17501 #endif
17502 #if SQLITE_DISABLE_DIRSYNC
17503 "DISABLE_DIRSYNC",
@@ -20667,11 +20674,13 @@
20674 ** Use the zone allocator available on apple products unless the
20675 ** SQLITE_WITHOUT_ZONEMALLOC symbol is defined.
20676 */
20677 #include <sys/sysctl.h>
20678 #include <malloc/malloc.h>
20679 #ifdef SQLITE_MIGHT_BE_SINGLE_CORE
20680 #include <libkern/OSAtomic.h>
20681 #endif /* SQLITE_MIGHT_BE_SINGLE_CORE */
20682 static malloc_zone_t* _sqliteZone_;
20683 #define SQLITE_MALLOC(x) malloc_zone_malloc(_sqliteZone_, (x))
20684 #define SQLITE_FREE(x) malloc_zone_free(_sqliteZone_, (x));
20685 #define SQLITE_REALLOC(x,y) malloc_zone_realloc(_sqliteZone_, (x), (y))
20686 #define SQLITE_MALLOCSIZE(x) \
@@ -20846,37 +20855,50 @@
20855 /*
20856 ** Initialize this module.
20857 */
20858 static int sqlite3MemInit(void *NotUsed){
20859 #if defined(__APPLE__) && !defined(SQLITE_WITHOUT_ZONEMALLOC)
 
 
20860 if( _sqliteZone_ ){
20861 return SQLITE_OK;
20862 }
20863 #ifndef SQLITE_MIGHT_BE_SINGLE_CORE
20864 /* If not compiled with the SQLITE_MIGHT_BE_SINGLE_CORE flag, assume
20865 ** that multiple cores are always available. This is the default case.
20866 */
20867 _sqliteZone_ = malloc_default_zone();
20868 #else
20869 /* With the SQLITE_MIGHT_BE_SINGLE_CORE compile-time option, check the
20870 ** number of cores. Different malloc() strategies are used for single-core and
20871 ** multi-core machines.
20872 */
20873 {
20874 int cpuCount;
20875 size_t len;
20876 len = sizeof(cpuCount);
20877 /* One usually wants to use hw.acctivecpu for MT decisions, but not here */
20878 sysctlbyname("hw.ncpu", &cpuCount, &len, NULL, 0);
20879 if( cpuCount>1 ){
20880 /* defer MT decisions to system malloc */
20881 _sqliteZone_ = malloc_default_zone();
20882 }else{
20883 /* only 1 core, use our own zone to contention over global locks,
20884 ** e.g. we have our own dedicated locks */
20885 bool success;
20886 malloc_zone_t* newzone = malloc_create_zone(4096, 0);
20887 malloc_set_zone_name(newzone, "Sqlite_Heap");
20888 do{
20889 success = OSAtomicCompareAndSwapPtrBarrier(NULL, newzone,
20890 (void * volatile *)&_sqliteZone_);
20891 }while(!_sqliteZone_);
20892 if( !success ){
20893 /* somebody registered a zone first */
20894 malloc_destroy_zone(newzone);
20895 }
20896 }
20897 }
20898 #endif /* SQLITE_MIGHT_BE_SINGLE_CORE */
20899 #endif /* defined(__APPLE__) && !defined(SQLITE_WITHOUT_ZONEMALLOC) */
20900 UNUSED_PARAMETER(NotUsed);
20901 return SQLITE_OK;
20902 }
20903
20904 /*
@@ -61814,10 +61836,35 @@
61836 sqlite3BtreeLeave(p);
61837 return rc;
61838 #endif
61839 }
61840
61841 /*
61842 ** If the user has not set the safety-level for this database connection
61843 ** using "PRAGMA synchronous", and if the safety-level is not already
61844 ** set to the value passed to this function as the second parameter,
61845 ** set it so.
61846 */
61847 #if SQLITE_DEFAULT_SYNCHRONOUS!=SQLITE_DEFAULT_WAL_SYNCHRONOUS
61848 static void setDefaultSyncFlag(BtShared *pBt, u8 safety_level){
61849 sqlite3 *db;
61850 Db *pDb;
61851 if( (db=pBt->db)!=0 && (pDb=db->aDb)!=0 ){
61852 while( pDb->pBt==0 || pDb->pBt->pBt!=pBt ){ pDb++; }
61853 if( pDb->bSyncSet==0
61854 && pDb->safety_level!=safety_level
61855 && pDb!=&db->aDb[1]
61856 ){
61857 pDb->safety_level = safety_level;
61858 sqlite3PagerSetFlags(pBt->pPager,
61859 pDb->safety_level | (db->flags & PAGER_FLAGS_MASK));
61860 }
61861 }
61862 }
61863 #else
61864 # define setDefaultSyncFlag(pBt,safety_level)
61865 #endif
61866
61867 /*
61868 ** Get a reference to pPage1 of the database file. This will
61869 ** also acquire a readlock on that file.
61870 **
@@ -61887,30 +61934,19 @@
61934 int isOpen = 0;
61935 rc = sqlite3PagerOpenWal(pBt->pPager, &isOpen);
61936 if( rc!=SQLITE_OK ){
61937 goto page1_init_failed;
61938 }else{
61939 setDefaultSyncFlag(pBt, SQLITE_DEFAULT_WAL_SYNCHRONOUS+1);
 
 
 
 
 
 
 
 
 
 
 
 
 
61940 if( isOpen==0 ){
61941 releasePage(pPage1);
61942 return SQLITE_OK;
61943 }
61944 }
61945 rc = SQLITE_NOTADB;
61946 }else{
61947 setDefaultSyncFlag(pBt, SQLITE_DEFAULT_SYNCHRONOUS+1);
61948 }
61949 #endif
61950
61951 /* EVIDENCE-OF: R-15465-20813 The maximum and minimum embedded payload
61952 ** fractions and the leaf payload fraction values must be 64, 32, and 32.
@@ -71426,10 +71462,16 @@
71462 int nNew = (p->nOpAlloc>=512 ? p->nOpAlloc*2 : p->nOpAlloc+nOp);
71463 #else
71464 int nNew = (p->nOpAlloc ? p->nOpAlloc*2 : (int)(1024/sizeof(Op)));
71465 UNUSED_PARAMETER(nOp);
71466 #endif
71467
71468 /* Ensure that the size of a VDBE does not grow too large */
71469 if( nNew > p->db->aLimit[SQLITE_LIMIT_VDBE_OP] ){
71470 sqlite3OomFault(p->db);
71471 return SQLITE_NOMEM;
71472 }
71473
71474 assert( nOp<=(1024/sizeof(Op)) );
71475 assert( nNew>=(p->nOpAlloc+nOp) );
71476 pNew = sqlite3DbRealloc(p->db, v->aOp, nNew*sizeof(Op));
71477 if( pNew ){
@@ -80816,12 +80858,17 @@
80858 /* Content is irrelevant for
80859 ** 1. the typeof() function,
80860 ** 2. the length(X) function if X is a blob, and
80861 ** 3. if the content length is zero.
80862 ** So we might as well use bogus content rather than reading
80863 ** content from disk.
80864 **
80865 ** Although sqlite3VdbeSerialGet() may read at most 8 bytes from the
80866 ** buffer passed to it, debugging function VdbeMemPrettyPrint() may
80867 ** read up to 16. So 16 bytes of bogus content is supplied.
80868 */
80869 static u8 aZero[16]; /* This is the bogus content */
80870 sqlite3VdbeSerialGet(aZero, t, pDest);
80871 }else{
80872 rc = sqlite3VdbeMemFromBtree(pC->uc.pCursor, aOffset[p2], len, pDest);
80873 if( rc!=SQLITE_OK ) goto abort_due_to_error;
80874 sqlite3VdbeSerialGet((const u8*)pDest->z, t, pDest);
@@ -114404,10 +114451,11 @@
114451 Index *pPrior = 0;
114452 int loopTop;
114453 int iDataCur, iIdxCur;
114454 int r1 = -1;
114455
114456 if( pTab->tnum<1 ) continue; /* Skip VIEWs or VIRTUAL TABLEs */
114457 if( pTab->pCheck==0
114458 && (pTab->tabFlags & TF_HasNotNull)==0
114459 && (pTab->pIndex==0 || isQuick)
114460 ){
114461 continue; /* No additional checks needed for this table */
@@ -198072,11 +198120,11 @@
198120 int nArg, /* Number of args */
198121 sqlite3_value **apUnused /* Function arguments */
198122 ){
198123 assert( nArg==0 );
198124 UNUSED_PARAM2(nArg, apUnused);
198125 sqlite3_result_text(pCtx, "fts5: 2017-03-17 14:59:40 626bdca98e0cd78ae873d97e75bb7d544ca18759c9f1e67f4adf03daca7fe5bf", -1, SQLITE_TRANSIENT);
198126 }
198127
198128 static int fts5Init(sqlite3 *db){
198129 static const sqlite3_module fts5Mod = {
198130 /* iVersion */ 2,
198131
+5 -4
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -121,11 +121,11 @@
121121
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
122122
** [sqlite_version()] and [sqlite_source_id()].
123123
*/
124124
#define SQLITE_VERSION "3.18.0"
125125
#define SQLITE_VERSION_NUMBER 3018000
126
-#define SQLITE_SOURCE_ID "2017-03-16 14:28:52 6d85eb5736781b43aa674d9544c7523b849b4e634f371702f8764b33e22e1e9f"
126
+#define SQLITE_SOURCE_ID "2017-03-18 13:59:46 4e6a03d9e12b120d15946b025f97a97697cb8e8af543c238ffda220c9e3f28f4"
127127
128128
/*
129129
** CAPI3REF: Run-Time Library Version Numbers
130130
** KEYWORDS: sqlite3_version sqlite3_sourceid
131131
**
@@ -3422,13 +3422,13 @@
34223422
** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
34233423
** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^
34243424
**
34253425
** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>
34263426
** <dd>The maximum number of instructions in a virtual machine program
3427
-** used to implement an SQL statement. This limit is not currently
3428
-** enforced, though that might be added in some future release of
3429
-** SQLite.</dd>)^
3427
+** used to implement an SQL statement. If [sqlite3_prepare_v2()] or
3428
+** the equivalent tries to allocate space for more than this many opcodes
3429
+** in a single prepared statement, an SQLITE_NOMEM error is returned.</dd>)^
34303430
**
34313431
** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
34323432
** <dd>The maximum number of arguments on a function.</dd>)^
34333433
**
34343434
** [[SQLITE_LIMIT_ATTACHED]] ^(<dt>SQLITE_LIMIT_ATTACHED</dt>
@@ -3461,10 +3461,11 @@
34613461
#define SQLITE_LIMIT_ATTACHED 7
34623462
#define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8
34633463
#define SQLITE_LIMIT_VARIABLE_NUMBER 9
34643464
#define SQLITE_LIMIT_TRIGGER_DEPTH 10
34653465
#define SQLITE_LIMIT_WORKER_THREADS 11
3466
+
34663467
34673468
/*
34683469
** CAPI3REF: Compiling An SQL Statement
34693470
** KEYWORDS: {SQL statement compiler}
34703471
** METHOD: sqlite3
34713472
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -121,11 +121,11 @@
121 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
122 ** [sqlite_version()] and [sqlite_source_id()].
123 */
124 #define SQLITE_VERSION "3.18.0"
125 #define SQLITE_VERSION_NUMBER 3018000
126 #define SQLITE_SOURCE_ID "2017-03-16 14:28:52 6d85eb5736781b43aa674d9544c7523b849b4e634f371702f8764b33e22e1e9f"
127
128 /*
129 ** CAPI3REF: Run-Time Library Version Numbers
130 ** KEYWORDS: sqlite3_version sqlite3_sourceid
131 **
@@ -3422,13 +3422,13 @@
3422 ** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
3423 ** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^
3424 **
3425 ** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>
3426 ** <dd>The maximum number of instructions in a virtual machine program
3427 ** used to implement an SQL statement. This limit is not currently
3428 ** enforced, though that might be added in some future release of
3429 ** SQLite.</dd>)^
3430 **
3431 ** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
3432 ** <dd>The maximum number of arguments on a function.</dd>)^
3433 **
3434 ** [[SQLITE_LIMIT_ATTACHED]] ^(<dt>SQLITE_LIMIT_ATTACHED</dt>
@@ -3461,10 +3461,11 @@
3461 #define SQLITE_LIMIT_ATTACHED 7
3462 #define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8
3463 #define SQLITE_LIMIT_VARIABLE_NUMBER 9
3464 #define SQLITE_LIMIT_TRIGGER_DEPTH 10
3465 #define SQLITE_LIMIT_WORKER_THREADS 11
 
3466
3467 /*
3468 ** CAPI3REF: Compiling An SQL Statement
3469 ** KEYWORDS: {SQL statement compiler}
3470 ** METHOD: sqlite3
3471
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -121,11 +121,11 @@
121 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
122 ** [sqlite_version()] and [sqlite_source_id()].
123 */
124 #define SQLITE_VERSION "3.18.0"
125 #define SQLITE_VERSION_NUMBER 3018000
126 #define SQLITE_SOURCE_ID "2017-03-18 13:59:46 4e6a03d9e12b120d15946b025f97a97697cb8e8af543c238ffda220c9e3f28f4"
127
128 /*
129 ** CAPI3REF: Run-Time Library Version Numbers
130 ** KEYWORDS: sqlite3_version sqlite3_sourceid
131 **
@@ -3422,13 +3422,13 @@
3422 ** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
3423 ** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^
3424 **
3425 ** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>
3426 ** <dd>The maximum number of instructions in a virtual machine program
3427 ** used to implement an SQL statement. If [sqlite3_prepare_v2()] or
3428 ** the equivalent tries to allocate space for more than this many opcodes
3429 ** in a single prepared statement, an SQLITE_NOMEM error is returned.</dd>)^
3430 **
3431 ** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
3432 ** <dd>The maximum number of arguments on a function.</dd>)^
3433 **
3434 ** [[SQLITE_LIMIT_ATTACHED]] ^(<dt>SQLITE_LIMIT_ATTACHED</dt>
@@ -3461,10 +3461,11 @@
3461 #define SQLITE_LIMIT_ATTACHED 7
3462 #define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8
3463 #define SQLITE_LIMIT_VARIABLE_NUMBER 9
3464 #define SQLITE_LIMIT_TRIGGER_DEPTH 10
3465 #define SQLITE_LIMIT_WORKER_THREADS 11
3466
3467
3468 /*
3469 ** CAPI3REF: Compiling An SQL Statement
3470 ** KEYWORDS: {SQL statement compiler}
3471 ** METHOD: sqlite3
3472

Keyboard Shortcuts

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