Fossil SCM

Improved error reporting when trying to write to a repository that is in a read-only directory.

drh 2017-12-13 20:36 trunk
Commit 500b0a2ae8bded1503aaeb17bbf2f74f32e765e493ab46c4bb4c167206d8d049
+5
--- src/main.c
+++ src/main.c
@@ -518,10 +518,15 @@
518518
** creates lots of aliases and the warning alarms people. */
519519
if( iCode==SQLITE_WARNING ) return;
520520
#endif
521521
if( iCode==SQLITE_SCHEMA ) return;
522522
if( g.dbIgnoreErrors ) return;
523
+#ifdef SQLITE_READONLY_DIRECTORY
524
+ if( iCode==SQLITE_READONLY_DIRECTORY ){
525
+ zErrmsg = "database is in a read-only directory";
526
+ }
527
+#endif
523528
fossil_warning("%s: %s", fossil_sqlite_return_code_name(iCode), zErrmsg);
524529
}
525530
526531
/*
527532
** This function attempts to find command line options known to contain
528533
--- src/main.c
+++ src/main.c
@@ -518,10 +518,15 @@
518 ** creates lots of aliases and the warning alarms people. */
519 if( iCode==SQLITE_WARNING ) return;
520 #endif
521 if( iCode==SQLITE_SCHEMA ) return;
522 if( g.dbIgnoreErrors ) return;
 
 
 
 
 
523 fossil_warning("%s: %s", fossil_sqlite_return_code_name(iCode), zErrmsg);
524 }
525
526 /*
527 ** This function attempts to find command line options known to contain
528
--- src/main.c
+++ src/main.c
@@ -518,10 +518,15 @@
518 ** creates lots of aliases and the warning alarms people. */
519 if( iCode==SQLITE_WARNING ) return;
520 #endif
521 if( iCode==SQLITE_SCHEMA ) return;
522 if( g.dbIgnoreErrors ) return;
523 #ifdef SQLITE_READONLY_DIRECTORY
524 if( iCode==SQLITE_READONLY_DIRECTORY ){
525 zErrmsg = "database is in a read-only directory";
526 }
527 #endif
528 fossil_warning("%s: %s", fossil_sqlite_return_code_name(iCode), zErrmsg);
529 }
530
531 /*
532 ** This function attempts to find command line options known to contain
533
+88 -50
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1147,11 +1147,11 @@
11471147
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
11481148
** [sqlite_version()] and [sqlite_source_id()].
11491149
*/
11501150
#define SQLITE_VERSION "3.22.0"
11511151
#define SQLITE_VERSION_NUMBER 3022000
1152
-#define SQLITE_SOURCE_ID "2017-12-06 20:50:08 6a55bd67720451cdf316155cf348103bfce1056a78bcddf0029b45ff0fdbcc71"
1152
+#define SQLITE_SOURCE_ID "2017-12-13 20:35:34 1c0aa919ee429cd194820ec9c54084563f39e63fd399b23f859fc6703b429b15"
11531153
11541154
/*
11551155
** CAPI3REF: Run-Time Library Version Numbers
11561156
** KEYWORDS: sqlite3_version sqlite3_sourceid
11571157
**
@@ -1492,10 +1492,12 @@
14921492
** on a per database connection basis using the
14931493
** [sqlite3_extended_result_codes()] API. Or, the extended code for
14941494
** the most recent error can be obtained using
14951495
** [sqlite3_extended_errcode()].
14961496
*/
1497
+#define SQLITE_ERROR_MISSING_COLLSEQ (SQLITE_ERROR | (1<<8))
1498
+#define SQLITE_ERROR_RETRY (SQLITE_ERROR | (2<<8))
14971499
#define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8))
14981500
#define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8))
14991501
#define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8))
15001502
#define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8))
15011503
#define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8))
@@ -1537,10 +1539,11 @@
15371539
#define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
15381540
#define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
15391541
#define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3<<8))
15401542
#define SQLITE_READONLY_DBMOVED (SQLITE_READONLY | (4<<8))
15411543
#define SQLITE_READONLY_CANTINIT (SQLITE_READONLY | (5<<8))
1544
+#define SQLITE_READONLY_DIRECTORY (SQLITE_READONLY | (6<<8))
15421545
#define SQLITE_ABORT_ROLLBACK (SQLITE_ABORT | (2<<8))
15431546
#define SQLITE_CONSTRAINT_CHECK (SQLITE_CONSTRAINT | (1<<8))
15441547
#define SQLITE_CONSTRAINT_COMMITHOOK (SQLITE_CONSTRAINT | (2<<8))
15451548
#define SQLITE_CONSTRAINT_FOREIGNKEY (SQLITE_CONSTRAINT | (3<<8))
15461549
#define SQLITE_CONSTRAINT_FUNCTION (SQLITE_CONSTRAINT | (4<<8))
@@ -15955,10 +15958,11 @@
1595515958
unsigned uniqNotNull:1; /* True if UNIQUE and NOT NULL for all columns */
1595615959
unsigned isResized:1; /* True if resizeIndexObject() has been called */
1595715960
unsigned isCovering:1; /* True if this is a covering index */
1595815961
unsigned noSkipScan:1; /* Do not try to use skip-scan if true */
1595915962
unsigned hasStat1:1; /* aiRowLogEst values come from sqlite_stat1 */
15963
+ unsigned bNoQuery:1; /* Do not use this index to optimize queries */
1596015964
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
1596115965
int nSample; /* Number of elements in aSample[] */
1596215966
int nSampleCol; /* Size of IndexSample.anEq[] and so on */
1596315967
tRowcnt *aAvgEq; /* Average nEq values for keys not in aSample */
1596415968
IndexSample *aSample; /* Samples of the left-most key */
@@ -16767,11 +16771,11 @@
1676716771
int nErr; /* Number of errors seen */
1676816772
int nTab; /* Number of previously allocated VDBE cursors */
1676916773
int nMem; /* Number of memory cells used so far */
1677016774
int nOpAlloc; /* Number of slots allocated for Vdbe.aOp[] */
1677116775
int szOpAlloc; /* Bytes of memory space allocated for Vdbe.aOp[] */
16772
- int iSelfTab; /* Table for associated with an index on expr, or negative
16776
+ int iSelfTab; /* Table associated with an index on expr, or negative
1677316777
** of the base register during check-constraint eval */
1677416778
int iCacheLevel; /* ColCache valid when aColCache[].iLevel<=iCacheLevel */
1677516779
int iCacheCnt; /* Counter used to generate aColCache[].lru values */
1677616780
int nLabel; /* Number of labels used */
1677716781
int *aLabel; /* Space to hold the labels */
@@ -19494,11 +19498,11 @@
1949419498
** The conversion algorithms are implemented based on descriptions
1949519499
** in the following text:
1949619500
**
1949719501
** Jean Meeus
1949819502
** Astronomical Algorithms, 2nd Edition, 1998
19499
-** ISBM 0-943396-61-1
19503
+** ISBN 0-943396-61-1
1950019504
** Willmann-Bell, Inc
1950119505
** Richmond, Virginia (USA)
1950219506
*/
1950319507
/* #include "sqliteInt.h" */
1950419508
/* #include <stdlib.h> */
@@ -31066,11 +31070,11 @@
3106631070
#if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0
3106731071
{ "munmap", (sqlite3_syscall_ptr)munmap, 0 },
3106831072
#else
3106931073
{ "munmap", (sqlite3_syscall_ptr)0, 0 },
3107031074
#endif
31071
-#define osMunmap ((void*(*)(void*,size_t))aSyscall[23].pCurrent)
31075
+#define osMunmap ((int(*)(void*,size_t))aSyscall[23].pCurrent)
3107231076
3107331077
#if HAVE_MREMAP && (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0)
3107431078
{ "mremap", (sqlite3_syscall_ptr)mremap, 0 },
3107531079
#else
3107631080
{ "mremap", (sqlite3_syscall_ptr)0, 0 },
@@ -34748,11 +34752,11 @@
3474834752
struct flock f; /* The posix advisory locking structure */
3474934753
int rc = SQLITE_OK; /* Result code form fcntl() */
3475034754
3475134755
/* Access to the unixShmNode object is serialized by the caller */
3475234756
pShmNode = pFile->pInode->pShmNode;
34753
- assert( sqlite3_mutex_held(pShmNode->mutex) || pShmNode->nRef==0 );
34757
+ assert( pShmNode->nRef==0 || sqlite3_mutex_held(pShmNode->mutex) );
3475434758
3475534759
/* Shared locks never span more than one byte */
3475634760
assert( n==1 || lockType!=F_RDLCK );
3475734761
3475834762
/* Locks are within range */
@@ -36382,11 +36386,11 @@
3638236386
3638336387
/* If creating a master or main-file journal, this function will open
3638436388
** a file-descriptor on the directory too. The first time unixSync()
3638536389
** is called the directory file descriptor will be fsync()ed and close()d.
3638636390
*/
36387
- int syncDir = (isCreate && (
36391
+ int isNewJrnl = (isCreate && (
3638836392
eType==SQLITE_OPEN_MASTER_JOURNAL
3638936393
|| eType==SQLITE_OPEN_MAIN_JOURNAL
3639036394
|| eType==SQLITE_OPEN_WAL
3639136395
));
3639236396
@@ -36452,11 +36456,11 @@
3645236456
** sqlite3_uri_parameter(). */
3645336457
assert( (flags & SQLITE_OPEN_URI) || zName[strlen(zName)+1]==0 );
3645436458
3645536459
}else if( !zName ){
3645636460
/* If zName is NULL, the upper layer is requesting a temp file. */
36457
- assert(isDelete && !syncDir);
36461
+ assert(isDelete && !isNewJrnl);
3645836462
rc = unixGetTempname(pVfs->mxPathname, zTmpname);
3645936463
if( rc!=SQLITE_OK ){
3646036464
return rc;
3646136465
}
3646236466
zName = zTmpname;
@@ -36498,10 +36502,13 @@
3649836502
isReadonly = 1;
3649936503
fd = robust_open(zName, openFlags, openMode);
3650036504
}
3650136505
if( fd<0 ){
3650236506
rc = unixLogError(SQLITE_CANTOPEN_BKPT, "open", zName);
36507
+ /* If unable to create a journal, change the error code to
36508
+ ** indicate that the directory permissions are wrong. */
36509
+ if( isNewJrnl && osAccess(zName, F_OK) ) rc = SQLITE_READONLY_DIRECTORY;
3650336510
goto open_finished;
3650436511
}
3650536512
3650636513
/* If this process is running as root and if creating a new rollback
3650736514
** journal or WAL file, set the ownership of the journal or WAL to be
@@ -36557,11 +36564,11 @@
3655736564
/* Set up appropriate ctrlFlags */
3655836565
if( isDelete ) ctrlFlags |= UNIXFILE_DELETE;
3655936566
if( isReadonly ) ctrlFlags |= UNIXFILE_RDONLY;
3656036567
noLock = eType!=SQLITE_OPEN_MAIN_DB;
3656136568
if( noLock ) ctrlFlags |= UNIXFILE_NOLOCK;
36562
- if( syncDir ) ctrlFlags |= UNIXFILE_DIRSYNC;
36569
+ if( isNewJrnl ) ctrlFlags |= UNIXFILE_DIRSYNC;
3656336570
if( flags & SQLITE_OPEN_URI ) ctrlFlags |= UNIXFILE_URI;
3656436571
3656536572
#if SQLITE_ENABLE_LOCKING_STYLE
3656636573
#if SQLITE_PREFER_PROXY_LOCKING
3656736574
isAutoProxy = 1;
@@ -42257,11 +42264,11 @@
4225742264
int nByte /* Number of bytes to lock or unlock */
4225842265
){
4225942266
int rc = 0; /* Result code form Lock/UnlockFileEx() */
4226042267
4226142268
/* Access to the winShmNode object is serialized by the caller */
42262
- assert( sqlite3_mutex_held(pFile->mutex) || pFile->nRef==0 );
42269
+ assert( pFile->nRef==0 || sqlite3_mutex_held(pFile->mutex) );
4226342270
4226442271
OSTRACE(("SHM-LOCK file=%p, lock=%d, offset=%d, size=%d\n",
4226542272
pFile->hFile.h, lockType, ofst, nByte));
4226642273
4226742274
/* Release/Acquire the system-level lock */
@@ -105647,10 +105654,22 @@
105647105654
pKey->aColl[i] = zColl==sqlite3StrBINARY ? 0 :
105648105655
sqlite3LocateCollSeq(pParse, zColl);
105649105656
pKey->aSortOrder[i] = pIdx->aSortOrder[i];
105650105657
}
105651105658
if( pParse->nErr ){
105659
+ assert( pParse->rc==SQLITE_ERROR_MISSING_COLLSEQ );
105660
+ if( pIdx->bNoQuery==0 ){
105661
+ /* Deactivate the index because it contains an unknown collating
105662
+ ** sequence. The only way to reactive the index is to reload the
105663
+ ** schema. Adding the missing collating sequence later does not
105664
+ ** reactive the index. The application had the chance to register
105665
+ ** the missing index using the collation-needed callback. For
105666
+ ** simplicity, SQLite will not give the application a second chance.
105667
+ */
105668
+ pIdx->bNoQuery = 1;
105669
+ pParse->rc = SQLITE_ERROR_RETRY;
105670
+ }
105652105671
sqlite3KeyInfoUnref(pKey);
105653105672
pKey = 0;
105654105673
}
105655105674
}
105656105675
return pKey;
@@ -105832,10 +105851,11 @@
105832105851
p = 0;
105833105852
}
105834105853
assert( !p || p->xCmp );
105835105854
if( p==0 ){
105836105855
sqlite3ErrorMsg(pParse, "no such collation sequence: %s", zName);
105856
+ pParse->rc = SQLITE_ERROR_MISSING_COLLSEQ;
105837105857
}
105838105858
return p;
105839105859
}
105840105860
105841105861
/*
@@ -106498,15 +106518,15 @@
106498106518
** deleted from is a view
106499106519
*/
106500106520
#ifndef SQLITE_OMIT_TRIGGER
106501106521
pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);
106502106522
isView = pTab->pSelect!=0;
106503
- bComplex = pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0);
106504106523
#else
106505106524
# define pTrigger 0
106506106525
# define isView 0
106507106526
#endif
106527
+ bComplex = pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0);
106508106528
#ifdef SQLITE_OMIT_VIEW
106509106529
# undef isView
106510106530
# define isView 0
106511106531
#endif
106512106532
@@ -118067,12 +118087,10 @@
118067118087
}
118068118088
118069118089
end_prepare:
118070118090
118071118091
sqlite3ParserReset(&sParse);
118072
- rc = sqlite3ApiExit(db, rc);
118073
- assert( (rc&db->errMask)==rc );
118074118092
return rc;
118075118093
}
118076118094
static int sqlite3LockAndPrepare(
118077118095
sqlite3 *db, /* Database handle. */
118078118096
const char *zSql, /* UTF-8 encoded SQL statement. */
@@ -118081,10 +118099,11 @@
118081118099
Vdbe *pOld, /* VM being reprepared */
118082118100
sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
118083118101
const char **pzTail /* OUT: End of parsed string */
118084118102
){
118085118103
int rc;
118104
+ int cnt = 0;
118086118105
118087118106
#ifdef SQLITE_ENABLE_API_ARMOR
118088118107
if( ppStmt==0 ) return SQLITE_MISUSE_BKPT;
118089118108
#endif
118090118109
*ppStmt = 0;
@@ -118091,19 +118110,22 @@
118091118110
if( !sqlite3SafetyCheckOk(db)||zSql==0 ){
118092118111
return SQLITE_MISUSE_BKPT;
118093118112
}
118094118113
sqlite3_mutex_enter(db->mutex);
118095118114
sqlite3BtreeEnterAll(db);
118096
- rc = sqlite3Prepare(db, zSql, nBytes, prepFlags, pOld, ppStmt, pzTail);
118097
- if( rc==SQLITE_SCHEMA ){
118098
- sqlite3ResetOneSchema(db, -1);
118099
- sqlite3_finalize(*ppStmt);
118100
- rc = sqlite3Prepare(db, zSql, nBytes, prepFlags, pOld, ppStmt, pzTail);
118101
- }
118102
- sqlite3BtreeLeaveAll(db);
118103
- sqlite3_mutex_leave(db->mutex);
118104
- assert( rc==SQLITE_OK || *ppStmt==0 );
118115
+ do{
118116
+ /* Make multiple attempts to compile the SQL, until it either succeeds
118117
+ ** or encounters a permanent error. A schema problem after one schema
118118
+ ** reset is considered a permanent error. */
118119
+ rc = sqlite3Prepare(db, zSql, nBytes, prepFlags, pOld, ppStmt, pzTail);
118120
+ assert( rc==SQLITE_OK || *ppStmt==0 );
118121
+ }while( rc==SQLITE_ERROR_RETRY
118122
+ || (rc==SQLITE_SCHEMA && (sqlite3ResetOneSchema(db,-1), cnt++)==0) );
118123
+ sqlite3BtreeLeaveAll(db);
118124
+ rc = sqlite3ApiExit(db, rc);
118125
+ assert( (rc&db->errMask)==rc );
118126
+ sqlite3_mutex_leave(db->mutex);
118105118127
return rc;
118106118128
}
118107118129
118108118130
/*
118109118131
** Rerun the compilation of a statement after a schema change.
@@ -121628,11 +121650,11 @@
121628121650
** (8) If the subquery uses LIMIT then the outer query may not be a join.
121629121651
**
121630121652
** (9) If the subquery uses LIMIT then the outer query may not be aggregate.
121631121653
**
121632121654
** (**) Restriction (10) was removed from the code on 2005-02-05 but we
121633
-** accidentally carried the comment forward until 2014-09-15. Original
121655
+** accidently carried the comment forward until 2014-09-15. Original
121634121656
** constraint: "If the subquery is aggregate then the outer query
121635121657
** may not use LIMIT."
121636121658
**
121637121659
** (11) The subquery and the outer query may not both have ORDER BY clauses.
121638121660
**
@@ -130436,10 +130458,11 @@
130436130458
}else{
130437130459
endEq = 1;
130438130460
}
130439130461
}else if( bStopAtNull ){
130440130462
sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);
130463
+ sqlite3ExprCacheRemove(pParse, regBase+nEq, 1);
130441130464
endEq = 0;
130442130465
nConstraint++;
130443130466
}
130444130467
sqlite3DbFree(db, zStartAff);
130445130468
sqlite3DbFree(db, zEndAff);
@@ -135364,10 +135387,11 @@
135364135387
if( pProbe->pPartIdxWhere!=0
135365135388
&& !whereUsablePartialIndex(pSrc->iCursor, pWC, pProbe->pPartIdxWhere) ){
135366135389
testcase( pNew->iTab!=pSrc->iCursor ); /* See ticket [98d973b8f5] */
135367135390
continue; /* Partial index inappropriate for this query */
135368135391
}
135392
+ if( pProbe->bNoQuery ) continue;
135369135393
rSize = pProbe->aiRowLogEst[0];
135370135394
pNew->u.btree.nEq = 0;
135371135395
pNew->u.btree.nBtm = 0;
135372135396
pNew->u.btree.nTop = 0;
135373135397
pNew->nSkip = 0;
@@ -142677,11 +142701,11 @@
142677142701
#endif /* __cplusplus */
142678142702
142679142703
/************** End of rtree.h ***********************************************/
142680142704
/************** Continuing where we left off in main.c ***********************/
142681142705
#endif
142682
-#ifdef SQLITE_ENABLE_ICU
142706
+#if defined(SQLITE_ENABLE_ICU) || defined(SQLITE_ENABLE_ICU_COLLATIONS)
142683142707
/************** Include sqliteicu.h in the middle of main.c ******************/
142684142708
/************** Begin file sqliteicu.h ***************************************/
142685142709
/*
142686142710
** 2008 May 26
142687142711
**
@@ -145736,11 +145760,11 @@
145736145760
if( !db->mallocFailed && rc==SQLITE_OK ){
145737145761
rc = sqlite3Fts3Init(db);
145738145762
}
145739145763
#endif
145740145764
145741
-#ifdef SQLITE_ENABLE_ICU
145765
+#if defined(SQLITE_ENABLE_ICU) || defined(SQLITE_ENABLE_ICU_COLLATIONS)
145742145766
if( !db->mallocFailed && rc==SQLITE_OK ){
145743145767
rc = sqlite3IcuInit(db);
145744145768
}
145745145769
#endif
145746145770
@@ -170615,11 +170639,13 @@
170615170639
**
170616170640
** * An implementation of the LIKE operator that uses ICU to
170617170641
** provide case-independent matching.
170618170642
*/
170619170643
170620
-#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_ICU)
170644
+#if !defined(SQLITE_CORE) \
170645
+ || defined(SQLITE_ENABLE_ICU) \
170646
+ || defined(SQLITE_ENABLE_ICU_COLLATIONS)
170621170647
170622170648
/* Include ICU headers */
170623170649
#include <unicode/utypes.h>
170624170650
#include <unicode/uregex.h>
170625170651
#include <unicode/ustring.h>
@@ -170632,10 +170658,30 @@
170632170658
SQLITE_EXTENSION_INIT1
170633170659
#else
170634170660
/* #include "sqlite3.h" */
170635170661
#endif
170636170662
170663
+/*
170664
+** This function is called when an ICU function called from within
170665
+** the implementation of an SQL scalar function returns an error.
170666
+**
170667
+** The scalar function context passed as the first argument is
170668
+** loaded with an error message based on the following two args.
170669
+*/
170670
+static void icuFunctionError(
170671
+ sqlite3_context *pCtx, /* SQLite scalar function context */
170672
+ const char *zName, /* Name of ICU function that failed */
170673
+ UErrorCode e /* Error code returned by ICU function */
170674
+){
170675
+ char zBuf[128];
170676
+ sqlite3_snprintf(128, zBuf, "ICU error: %s(): %s", zName, u_errorName(e));
170677
+ zBuf[127] = '\0';
170678
+ sqlite3_result_error(pCtx, zBuf, -1);
170679
+}
170680
+
170681
+#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_ICU)
170682
+
170637170683
/*
170638170684
** Maximum length (in bytes) of the pattern in a LIKE or GLOB
170639170685
** operator.
170640170686
*/
170641170687
#ifndef SQLITE_MAX_LIKE_PATTERN_LENGTH
@@ -170811,28 +170857,10 @@
170811170857
if( zA && zB ){
170812170858
sqlite3_result_int(context, icuLikeCompare(zA, zB, uEsc));
170813170859
}
170814170860
}
170815170861
170816
-/*
170817
-** This function is called when an ICU function called from within
170818
-** the implementation of an SQL scalar function returns an error.
170819
-**
170820
-** The scalar function context passed as the first argument is
170821
-** loaded with an error message based on the following two args.
170822
-*/
170823
-static void icuFunctionError(
170824
- sqlite3_context *pCtx, /* SQLite scalar function context */
170825
- const char *zName, /* Name of ICU function that failed */
170826
- UErrorCode e /* Error code returned by ICU function */
170827
-){
170828
- char zBuf[128];
170829
- sqlite3_snprintf(128, zBuf, "ICU error: %s(): %s", zName, u_errorName(e));
170830
- zBuf[127] = '\0';
170831
- sqlite3_result_error(pCtx, zBuf, -1);
170832
-}
170833
-
170834170862
/*
170835170863
** Function to delete compiled regexp objects. Registered as
170836170864
** a destructor function with sqlite3_set_auxdata().
170837170865
*/
170838170866
static void icuRegexpDelete(void *p){
@@ -170994,10 +171022,12 @@
170994171022
return;
170995171023
}
170996171024
assert( 0 ); /* Unreachable */
170997171025
}
170998171026
171027
+#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_ICU) */
171028
+
170999171029
/*
171000171030
** Collation sequence destructor function. The pCtx argument points to
171001171031
** a UCollator structure previously allocated using ucol_open().
171002171032
*/
171003171033
static void icuCollationDel(void *pCtx){
@@ -171088,10 +171118,11 @@
171088171118
unsigned short enc; /* Optimal text encoding */
171089171119
unsigned char iContext; /* sqlite3_user_data() context */
171090171120
void (*xFunc)(sqlite3_context*,int,sqlite3_value**);
171091171121
} scalars[] = {
171092171122
{"icu_load_collation", 2, SQLITE_UTF8, 1, icuLoadCollation},
171123
+#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_ICU)
171093171124
{"regexp", 2, SQLITE_ANY|SQLITE_DETERMINISTIC, 0, icuRegexpFunc},
171094171125
{"lower", 1, SQLITE_UTF16|SQLITE_DETERMINISTIC, 0, icuCaseFunc16},
171095171126
{"lower", 2, SQLITE_UTF16|SQLITE_DETERMINISTIC, 0, icuCaseFunc16},
171096171127
{"upper", 1, SQLITE_UTF16|SQLITE_DETERMINISTIC, 1, icuCaseFunc16},
171097171128
{"upper", 2, SQLITE_UTF16|SQLITE_DETERMINISTIC, 1, icuCaseFunc16},
@@ -171099,14 +171130,14 @@
171099171130
{"lower", 2, SQLITE_UTF8|SQLITE_DETERMINISTIC, 0, icuCaseFunc16},
171100171131
{"upper", 1, SQLITE_UTF8|SQLITE_DETERMINISTIC, 1, icuCaseFunc16},
171101171132
{"upper", 2, SQLITE_UTF8|SQLITE_DETERMINISTIC, 1, icuCaseFunc16},
171102171133
{"like", 2, SQLITE_UTF8|SQLITE_DETERMINISTIC, 0, icuLikeFunc},
171103171134
{"like", 3, SQLITE_UTF8|SQLITE_DETERMINISTIC, 0, icuLikeFunc},
171135
+#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_ICU) */
171104171136
};
171105171137
int rc = SQLITE_OK;
171106171138
int i;
171107
-
171108171139
171109171140
for(i=0; rc==SQLITE_OK && i<(int)(sizeof(scalars)/sizeof(scalars[0])); i++){
171110171141
const struct IcuScalar *p = &scalars[i];
171111171142
rc = sqlite3_create_function(
171112171143
db, p->zName, p->nArg, p->enc,
@@ -184999,11 +185030,11 @@
184999185030
0 /* xRollbackTo */
185000185031
};
185001185032
#endif /* SQLITE_OMIT_VIRTUALTABLE */
185002185033
185003185034
/****************************************************************************
185004
-** The following routines are the only publicly visible identifiers in this
185035
+** The following routines are the only publically visible identifiers in this
185005185036
** file. Call the following routines in order to register the various SQL
185006185037
** functions and the virtual table implemented by this file.
185007185038
****************************************************************************/
185008185039
185009185040
SQLITE_PRIVATE int sqlite3Json1Init(sqlite3 *db){
@@ -198157,11 +198188,17 @@
198157198188
Fts5DoclistIter i1;
198158198189
Fts5DoclistIter i2;
198159198190
Fts5Buffer out = {0, 0, 0};
198160198191
Fts5Buffer tmp = {0, 0, 0};
198161198192
198162
- if( sqlite3Fts5BufferSize(&p->rc, &out, p1->n + p2->n) ) return;
198193
+ /* The maximum size of the output is equal to the sum of the two
198194
+ ** input sizes + 1 varint (9 bytes). The extra varint is because if the
198195
+ ** first rowid in one input is a large negative number, and the first in
198196
+ ** the other a non-negative number, the delta for the non-negative
198197
+ ** number will be larger on disk than the literal integer value
198198
+ ** was. */
198199
+ if( sqlite3Fts5BufferSize(&p->rc, &out, p1->n + p2->n + 9) ) return;
198163198200
fts5DoclistIterInit(p1, &i1);
198164198201
fts5DoclistIterInit(p2, &i2);
198165198202
198166198203
while( 1 ){
198167198204
if( i1.iRowid<i2.iRowid ){
@@ -198251,10 +198288,11 @@
198251198288
}
198252198289
else if( i2.aPoslist ){
198253198290
fts5MergeAppendDocid(&out, iLastRowid, i2.iRowid);
198254198291
fts5BufferSafeAppendBlob(&out, i2.aPoslist, i2.aEof - i2.aPoslist);
198255198292
}
198293
+ assert( out.n<=(p1->n+p2->n+9) );
198256198294
198257198295
fts5BufferSet(&p->rc, p1, out.n, out.p);
198258198296
fts5BufferFree(&tmp);
198259198297
fts5BufferFree(&out);
198260198298
}
@@ -202372,11 +202410,11 @@
202372202410
int nArg, /* Number of args */
202373202411
sqlite3_value **apUnused /* Function arguments */
202374202412
){
202375202413
assert( nArg==0 );
202376202414
UNUSED_PARAM2(nArg, apUnused);
202377
- sqlite3_result_text(pCtx, "fts5: 2017-12-01 18:40:18 5771b1d611b3562ea6c040f3f893073c4d0ee58c35b37ae211520d9aee8ed547", -1, SQLITE_TRANSIENT);
202415
+ sqlite3_result_text(pCtx, "fts5: 2017-12-13 15:32:33 30bf38d589adf0b2eb613e184ffb03ed7e625736cb04fd5c341328f72bc5ef4d", -1, SQLITE_TRANSIENT);
202378202416
}
202379202417
202380202418
static int fts5Init(sqlite3 *db){
202381202419
static const sqlite3_module fts5Mod = {
202382202420
/* iVersion */ 2,
@@ -205632,11 +205670,11 @@
205632205670
205633205671
int bEof; /* True if this cursor is at EOF */
205634205672
Fts5IndexIter *pIter; /* Term/rowid iterator object */
205635205673
205636205674
int nLeTerm; /* Size of zLeTerm in bytes */
205637
- char *zLeTerm; /* (term <= $zLeTerm) parameter, or NULL */
205675
+ char *zLeTerm; /* (term <= $zLeTerm) paramater, or NULL */
205638205676
205639205677
/* These are used by 'col' tables only */
205640205678
Fts5Config *pConfig; /* Fts5 table configuration */
205641205679
int iCol;
205642205680
i64 *aCnt;
@@ -206640,12 +206678,12 @@
206640206678
}
206641206679
#endif /* SQLITE_CORE */
206642206680
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
206643206681
206644206682
/************** End of stmt.c ************************************************/
206645
-#if __LINE__!=206645
206683
+#if __LINE__!=206683
206646206684
#undef SQLITE_SOURCE_ID
206647
-#define SQLITE_SOURCE_ID "2017-12-06 20:50:08 6a55bd67720451cdf316155cf348103bfce1056a78bcddf0029b45ff0fdbalt2"
206685
+#define SQLITE_SOURCE_ID "2017-12-13 20:35:34 1c0aa919ee429cd194820ec9c54084563f39e63fd399b23f859fc6703b42alt2"
206648206686
#endif
206649206687
/* Return the source-id for this library */
206650206688
SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
206651206689
/************************** End of sqlite3.c ******************************/
206652206690
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1147,11 +1147,11 @@
1147 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1148 ** [sqlite_version()] and [sqlite_source_id()].
1149 */
1150 #define SQLITE_VERSION "3.22.0"
1151 #define SQLITE_VERSION_NUMBER 3022000
1152 #define SQLITE_SOURCE_ID "2017-12-06 20:50:08 6a55bd67720451cdf316155cf348103bfce1056a78bcddf0029b45ff0fdbcc71"
1153
1154 /*
1155 ** CAPI3REF: Run-Time Library Version Numbers
1156 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1157 **
@@ -1492,10 +1492,12 @@
1492 ** on a per database connection basis using the
1493 ** [sqlite3_extended_result_codes()] API. Or, the extended code for
1494 ** the most recent error can be obtained using
1495 ** [sqlite3_extended_errcode()].
1496 */
 
 
1497 #define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8))
1498 #define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8))
1499 #define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8))
1500 #define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8))
1501 #define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8))
@@ -1537,10 +1539,11 @@
1537 #define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
1538 #define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
1539 #define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3<<8))
1540 #define SQLITE_READONLY_DBMOVED (SQLITE_READONLY | (4<<8))
1541 #define SQLITE_READONLY_CANTINIT (SQLITE_READONLY | (5<<8))
 
1542 #define SQLITE_ABORT_ROLLBACK (SQLITE_ABORT | (2<<8))
1543 #define SQLITE_CONSTRAINT_CHECK (SQLITE_CONSTRAINT | (1<<8))
1544 #define SQLITE_CONSTRAINT_COMMITHOOK (SQLITE_CONSTRAINT | (2<<8))
1545 #define SQLITE_CONSTRAINT_FOREIGNKEY (SQLITE_CONSTRAINT | (3<<8))
1546 #define SQLITE_CONSTRAINT_FUNCTION (SQLITE_CONSTRAINT | (4<<8))
@@ -15955,10 +15958,11 @@
15955 unsigned uniqNotNull:1; /* True if UNIQUE and NOT NULL for all columns */
15956 unsigned isResized:1; /* True if resizeIndexObject() has been called */
15957 unsigned isCovering:1; /* True if this is a covering index */
15958 unsigned noSkipScan:1; /* Do not try to use skip-scan if true */
15959 unsigned hasStat1:1; /* aiRowLogEst values come from sqlite_stat1 */
 
15960 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
15961 int nSample; /* Number of elements in aSample[] */
15962 int nSampleCol; /* Size of IndexSample.anEq[] and so on */
15963 tRowcnt *aAvgEq; /* Average nEq values for keys not in aSample */
15964 IndexSample *aSample; /* Samples of the left-most key */
@@ -16767,11 +16771,11 @@
16767 int nErr; /* Number of errors seen */
16768 int nTab; /* Number of previously allocated VDBE cursors */
16769 int nMem; /* Number of memory cells used so far */
16770 int nOpAlloc; /* Number of slots allocated for Vdbe.aOp[] */
16771 int szOpAlloc; /* Bytes of memory space allocated for Vdbe.aOp[] */
16772 int iSelfTab; /* Table for associated with an index on expr, or negative
16773 ** of the base register during check-constraint eval */
16774 int iCacheLevel; /* ColCache valid when aColCache[].iLevel<=iCacheLevel */
16775 int iCacheCnt; /* Counter used to generate aColCache[].lru values */
16776 int nLabel; /* Number of labels used */
16777 int *aLabel; /* Space to hold the labels */
@@ -19494,11 +19498,11 @@
19494 ** The conversion algorithms are implemented based on descriptions
19495 ** in the following text:
19496 **
19497 ** Jean Meeus
19498 ** Astronomical Algorithms, 2nd Edition, 1998
19499 ** ISBM 0-943396-61-1
19500 ** Willmann-Bell, Inc
19501 ** Richmond, Virginia (USA)
19502 */
19503 /* #include "sqliteInt.h" */
19504 /* #include <stdlib.h> */
@@ -31066,11 +31070,11 @@
31066 #if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0
31067 { "munmap", (sqlite3_syscall_ptr)munmap, 0 },
31068 #else
31069 { "munmap", (sqlite3_syscall_ptr)0, 0 },
31070 #endif
31071 #define osMunmap ((void*(*)(void*,size_t))aSyscall[23].pCurrent)
31072
31073 #if HAVE_MREMAP && (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0)
31074 { "mremap", (sqlite3_syscall_ptr)mremap, 0 },
31075 #else
31076 { "mremap", (sqlite3_syscall_ptr)0, 0 },
@@ -34748,11 +34752,11 @@
34748 struct flock f; /* The posix advisory locking structure */
34749 int rc = SQLITE_OK; /* Result code form fcntl() */
34750
34751 /* Access to the unixShmNode object is serialized by the caller */
34752 pShmNode = pFile->pInode->pShmNode;
34753 assert( sqlite3_mutex_held(pShmNode->mutex) || pShmNode->nRef==0 );
34754
34755 /* Shared locks never span more than one byte */
34756 assert( n==1 || lockType!=F_RDLCK );
34757
34758 /* Locks are within range */
@@ -36382,11 +36386,11 @@
36382
36383 /* If creating a master or main-file journal, this function will open
36384 ** a file-descriptor on the directory too. The first time unixSync()
36385 ** is called the directory file descriptor will be fsync()ed and close()d.
36386 */
36387 int syncDir = (isCreate && (
36388 eType==SQLITE_OPEN_MASTER_JOURNAL
36389 || eType==SQLITE_OPEN_MAIN_JOURNAL
36390 || eType==SQLITE_OPEN_WAL
36391 ));
36392
@@ -36452,11 +36456,11 @@
36452 ** sqlite3_uri_parameter(). */
36453 assert( (flags & SQLITE_OPEN_URI) || zName[strlen(zName)+1]==0 );
36454
36455 }else if( !zName ){
36456 /* If zName is NULL, the upper layer is requesting a temp file. */
36457 assert(isDelete && !syncDir);
36458 rc = unixGetTempname(pVfs->mxPathname, zTmpname);
36459 if( rc!=SQLITE_OK ){
36460 return rc;
36461 }
36462 zName = zTmpname;
@@ -36498,10 +36502,13 @@
36498 isReadonly = 1;
36499 fd = robust_open(zName, openFlags, openMode);
36500 }
36501 if( fd<0 ){
36502 rc = unixLogError(SQLITE_CANTOPEN_BKPT, "open", zName);
 
 
 
36503 goto open_finished;
36504 }
36505
36506 /* If this process is running as root and if creating a new rollback
36507 ** journal or WAL file, set the ownership of the journal or WAL to be
@@ -36557,11 +36564,11 @@
36557 /* Set up appropriate ctrlFlags */
36558 if( isDelete ) ctrlFlags |= UNIXFILE_DELETE;
36559 if( isReadonly ) ctrlFlags |= UNIXFILE_RDONLY;
36560 noLock = eType!=SQLITE_OPEN_MAIN_DB;
36561 if( noLock ) ctrlFlags |= UNIXFILE_NOLOCK;
36562 if( syncDir ) ctrlFlags |= UNIXFILE_DIRSYNC;
36563 if( flags & SQLITE_OPEN_URI ) ctrlFlags |= UNIXFILE_URI;
36564
36565 #if SQLITE_ENABLE_LOCKING_STYLE
36566 #if SQLITE_PREFER_PROXY_LOCKING
36567 isAutoProxy = 1;
@@ -42257,11 +42264,11 @@
42257 int nByte /* Number of bytes to lock or unlock */
42258 ){
42259 int rc = 0; /* Result code form Lock/UnlockFileEx() */
42260
42261 /* Access to the winShmNode object is serialized by the caller */
42262 assert( sqlite3_mutex_held(pFile->mutex) || pFile->nRef==0 );
42263
42264 OSTRACE(("SHM-LOCK file=%p, lock=%d, offset=%d, size=%d\n",
42265 pFile->hFile.h, lockType, ofst, nByte));
42266
42267 /* Release/Acquire the system-level lock */
@@ -105647,10 +105654,22 @@
105647 pKey->aColl[i] = zColl==sqlite3StrBINARY ? 0 :
105648 sqlite3LocateCollSeq(pParse, zColl);
105649 pKey->aSortOrder[i] = pIdx->aSortOrder[i];
105650 }
105651 if( pParse->nErr ){
 
 
 
 
 
 
 
 
 
 
 
 
105652 sqlite3KeyInfoUnref(pKey);
105653 pKey = 0;
105654 }
105655 }
105656 return pKey;
@@ -105832,10 +105851,11 @@
105832 p = 0;
105833 }
105834 assert( !p || p->xCmp );
105835 if( p==0 ){
105836 sqlite3ErrorMsg(pParse, "no such collation sequence: %s", zName);
 
105837 }
105838 return p;
105839 }
105840
105841 /*
@@ -106498,15 +106518,15 @@
106498 ** deleted from is a view
106499 */
106500 #ifndef SQLITE_OMIT_TRIGGER
106501 pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);
106502 isView = pTab->pSelect!=0;
106503 bComplex = pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0);
106504 #else
106505 # define pTrigger 0
106506 # define isView 0
106507 #endif
 
106508 #ifdef SQLITE_OMIT_VIEW
106509 # undef isView
106510 # define isView 0
106511 #endif
106512
@@ -118067,12 +118087,10 @@
118067 }
118068
118069 end_prepare:
118070
118071 sqlite3ParserReset(&sParse);
118072 rc = sqlite3ApiExit(db, rc);
118073 assert( (rc&db->errMask)==rc );
118074 return rc;
118075 }
118076 static int sqlite3LockAndPrepare(
118077 sqlite3 *db, /* Database handle. */
118078 const char *zSql, /* UTF-8 encoded SQL statement. */
@@ -118081,10 +118099,11 @@
118081 Vdbe *pOld, /* VM being reprepared */
118082 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
118083 const char **pzTail /* OUT: End of parsed string */
118084 ){
118085 int rc;
 
118086
118087 #ifdef SQLITE_ENABLE_API_ARMOR
118088 if( ppStmt==0 ) return SQLITE_MISUSE_BKPT;
118089 #endif
118090 *ppStmt = 0;
@@ -118091,19 +118110,22 @@
118091 if( !sqlite3SafetyCheckOk(db)||zSql==0 ){
118092 return SQLITE_MISUSE_BKPT;
118093 }
118094 sqlite3_mutex_enter(db->mutex);
118095 sqlite3BtreeEnterAll(db);
118096 rc = sqlite3Prepare(db, zSql, nBytes, prepFlags, pOld, ppStmt, pzTail);
118097 if( rc==SQLITE_SCHEMA ){
118098 sqlite3ResetOneSchema(db, -1);
118099 sqlite3_finalize(*ppStmt);
118100 rc = sqlite3Prepare(db, zSql, nBytes, prepFlags, pOld, ppStmt, pzTail);
118101 }
118102 sqlite3BtreeLeaveAll(db);
118103 sqlite3_mutex_leave(db->mutex);
118104 assert( rc==SQLITE_OK || *ppStmt==0 );
 
 
 
118105 return rc;
118106 }
118107
118108 /*
118109 ** Rerun the compilation of a statement after a schema change.
@@ -121628,11 +121650,11 @@
121628 ** (8) If the subquery uses LIMIT then the outer query may not be a join.
121629 **
121630 ** (9) If the subquery uses LIMIT then the outer query may not be aggregate.
121631 **
121632 ** (**) Restriction (10) was removed from the code on 2005-02-05 but we
121633 ** accidentally carried the comment forward until 2014-09-15. Original
121634 ** constraint: "If the subquery is aggregate then the outer query
121635 ** may not use LIMIT."
121636 **
121637 ** (11) The subquery and the outer query may not both have ORDER BY clauses.
121638 **
@@ -130436,10 +130458,11 @@
130436 }else{
130437 endEq = 1;
130438 }
130439 }else if( bStopAtNull ){
130440 sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);
 
130441 endEq = 0;
130442 nConstraint++;
130443 }
130444 sqlite3DbFree(db, zStartAff);
130445 sqlite3DbFree(db, zEndAff);
@@ -135364,10 +135387,11 @@
135364 if( pProbe->pPartIdxWhere!=0
135365 && !whereUsablePartialIndex(pSrc->iCursor, pWC, pProbe->pPartIdxWhere) ){
135366 testcase( pNew->iTab!=pSrc->iCursor ); /* See ticket [98d973b8f5] */
135367 continue; /* Partial index inappropriate for this query */
135368 }
 
135369 rSize = pProbe->aiRowLogEst[0];
135370 pNew->u.btree.nEq = 0;
135371 pNew->u.btree.nBtm = 0;
135372 pNew->u.btree.nTop = 0;
135373 pNew->nSkip = 0;
@@ -142677,11 +142701,11 @@
142677 #endif /* __cplusplus */
142678
142679 /************** End of rtree.h ***********************************************/
142680 /************** Continuing where we left off in main.c ***********************/
142681 #endif
142682 #ifdef SQLITE_ENABLE_ICU
142683 /************** Include sqliteicu.h in the middle of main.c ******************/
142684 /************** Begin file sqliteicu.h ***************************************/
142685 /*
142686 ** 2008 May 26
142687 **
@@ -145736,11 +145760,11 @@
145736 if( !db->mallocFailed && rc==SQLITE_OK ){
145737 rc = sqlite3Fts3Init(db);
145738 }
145739 #endif
145740
145741 #ifdef SQLITE_ENABLE_ICU
145742 if( !db->mallocFailed && rc==SQLITE_OK ){
145743 rc = sqlite3IcuInit(db);
145744 }
145745 #endif
145746
@@ -170615,11 +170639,13 @@
170615 **
170616 ** * An implementation of the LIKE operator that uses ICU to
170617 ** provide case-independent matching.
170618 */
170619
170620 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_ICU)
 
 
170621
170622 /* Include ICU headers */
170623 #include <unicode/utypes.h>
170624 #include <unicode/uregex.h>
170625 #include <unicode/ustring.h>
@@ -170632,10 +170658,30 @@
170632 SQLITE_EXTENSION_INIT1
170633 #else
170634 /* #include "sqlite3.h" */
170635 #endif
170636
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170637 /*
170638 ** Maximum length (in bytes) of the pattern in a LIKE or GLOB
170639 ** operator.
170640 */
170641 #ifndef SQLITE_MAX_LIKE_PATTERN_LENGTH
@@ -170811,28 +170857,10 @@
170811 if( zA && zB ){
170812 sqlite3_result_int(context, icuLikeCompare(zA, zB, uEsc));
170813 }
170814 }
170815
170816 /*
170817 ** This function is called when an ICU function called from within
170818 ** the implementation of an SQL scalar function returns an error.
170819 **
170820 ** The scalar function context passed as the first argument is
170821 ** loaded with an error message based on the following two args.
170822 */
170823 static void icuFunctionError(
170824 sqlite3_context *pCtx, /* SQLite scalar function context */
170825 const char *zName, /* Name of ICU function that failed */
170826 UErrorCode e /* Error code returned by ICU function */
170827 ){
170828 char zBuf[128];
170829 sqlite3_snprintf(128, zBuf, "ICU error: %s(): %s", zName, u_errorName(e));
170830 zBuf[127] = '\0';
170831 sqlite3_result_error(pCtx, zBuf, -1);
170832 }
170833
170834 /*
170835 ** Function to delete compiled regexp objects. Registered as
170836 ** a destructor function with sqlite3_set_auxdata().
170837 */
170838 static void icuRegexpDelete(void *p){
@@ -170994,10 +171022,12 @@
170994 return;
170995 }
170996 assert( 0 ); /* Unreachable */
170997 }
170998
 
 
170999 /*
171000 ** Collation sequence destructor function. The pCtx argument points to
171001 ** a UCollator structure previously allocated using ucol_open().
171002 */
171003 static void icuCollationDel(void *pCtx){
@@ -171088,10 +171118,11 @@
171088 unsigned short enc; /* Optimal text encoding */
171089 unsigned char iContext; /* sqlite3_user_data() context */
171090 void (*xFunc)(sqlite3_context*,int,sqlite3_value**);
171091 } scalars[] = {
171092 {"icu_load_collation", 2, SQLITE_UTF8, 1, icuLoadCollation},
 
171093 {"regexp", 2, SQLITE_ANY|SQLITE_DETERMINISTIC, 0, icuRegexpFunc},
171094 {"lower", 1, SQLITE_UTF16|SQLITE_DETERMINISTIC, 0, icuCaseFunc16},
171095 {"lower", 2, SQLITE_UTF16|SQLITE_DETERMINISTIC, 0, icuCaseFunc16},
171096 {"upper", 1, SQLITE_UTF16|SQLITE_DETERMINISTIC, 1, icuCaseFunc16},
171097 {"upper", 2, SQLITE_UTF16|SQLITE_DETERMINISTIC, 1, icuCaseFunc16},
@@ -171099,14 +171130,14 @@
171099 {"lower", 2, SQLITE_UTF8|SQLITE_DETERMINISTIC, 0, icuCaseFunc16},
171100 {"upper", 1, SQLITE_UTF8|SQLITE_DETERMINISTIC, 1, icuCaseFunc16},
171101 {"upper", 2, SQLITE_UTF8|SQLITE_DETERMINISTIC, 1, icuCaseFunc16},
171102 {"like", 2, SQLITE_UTF8|SQLITE_DETERMINISTIC, 0, icuLikeFunc},
171103 {"like", 3, SQLITE_UTF8|SQLITE_DETERMINISTIC, 0, icuLikeFunc},
 
171104 };
171105 int rc = SQLITE_OK;
171106 int i;
171107
171108
171109 for(i=0; rc==SQLITE_OK && i<(int)(sizeof(scalars)/sizeof(scalars[0])); i++){
171110 const struct IcuScalar *p = &scalars[i];
171111 rc = sqlite3_create_function(
171112 db, p->zName, p->nArg, p->enc,
@@ -184999,11 +185030,11 @@
184999 0 /* xRollbackTo */
185000 };
185001 #endif /* SQLITE_OMIT_VIRTUALTABLE */
185002
185003 /****************************************************************************
185004 ** The following routines are the only publicly visible identifiers in this
185005 ** file. Call the following routines in order to register the various SQL
185006 ** functions and the virtual table implemented by this file.
185007 ****************************************************************************/
185008
185009 SQLITE_PRIVATE int sqlite3Json1Init(sqlite3 *db){
@@ -198157,11 +198188,17 @@
198157 Fts5DoclistIter i1;
198158 Fts5DoclistIter i2;
198159 Fts5Buffer out = {0, 0, 0};
198160 Fts5Buffer tmp = {0, 0, 0};
198161
198162 if( sqlite3Fts5BufferSize(&p->rc, &out, p1->n + p2->n) ) return;
 
 
 
 
 
 
198163 fts5DoclistIterInit(p1, &i1);
198164 fts5DoclistIterInit(p2, &i2);
198165
198166 while( 1 ){
198167 if( i1.iRowid<i2.iRowid ){
@@ -198251,10 +198288,11 @@
198251 }
198252 else if( i2.aPoslist ){
198253 fts5MergeAppendDocid(&out, iLastRowid, i2.iRowid);
198254 fts5BufferSafeAppendBlob(&out, i2.aPoslist, i2.aEof - i2.aPoslist);
198255 }
 
198256
198257 fts5BufferSet(&p->rc, p1, out.n, out.p);
198258 fts5BufferFree(&tmp);
198259 fts5BufferFree(&out);
198260 }
@@ -202372,11 +202410,11 @@
202372 int nArg, /* Number of args */
202373 sqlite3_value **apUnused /* Function arguments */
202374 ){
202375 assert( nArg==0 );
202376 UNUSED_PARAM2(nArg, apUnused);
202377 sqlite3_result_text(pCtx, "fts5: 2017-12-01 18:40:18 5771b1d611b3562ea6c040f3f893073c4d0ee58c35b37ae211520d9aee8ed547", -1, SQLITE_TRANSIENT);
202378 }
202379
202380 static int fts5Init(sqlite3 *db){
202381 static const sqlite3_module fts5Mod = {
202382 /* iVersion */ 2,
@@ -205632,11 +205670,11 @@
205632
205633 int bEof; /* True if this cursor is at EOF */
205634 Fts5IndexIter *pIter; /* Term/rowid iterator object */
205635
205636 int nLeTerm; /* Size of zLeTerm in bytes */
205637 char *zLeTerm; /* (term <= $zLeTerm) parameter, or NULL */
205638
205639 /* These are used by 'col' tables only */
205640 Fts5Config *pConfig; /* Fts5 table configuration */
205641 int iCol;
205642 i64 *aCnt;
@@ -206640,12 +206678,12 @@
206640 }
206641 #endif /* SQLITE_CORE */
206642 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
206643
206644 /************** End of stmt.c ************************************************/
206645 #if __LINE__!=206645
206646 #undef SQLITE_SOURCE_ID
206647 #define SQLITE_SOURCE_ID "2017-12-06 20:50:08 6a55bd67720451cdf316155cf348103bfce1056a78bcddf0029b45ff0fdbalt2"
206648 #endif
206649 /* Return the source-id for this library */
206650 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
206651 /************************** End of sqlite3.c ******************************/
206652
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1147,11 +1147,11 @@
1147 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1148 ** [sqlite_version()] and [sqlite_source_id()].
1149 */
1150 #define SQLITE_VERSION "3.22.0"
1151 #define SQLITE_VERSION_NUMBER 3022000
1152 #define SQLITE_SOURCE_ID "2017-12-13 20:35:34 1c0aa919ee429cd194820ec9c54084563f39e63fd399b23f859fc6703b429b15"
1153
1154 /*
1155 ** CAPI3REF: Run-Time Library Version Numbers
1156 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1157 **
@@ -1492,10 +1492,12 @@
1492 ** on a per database connection basis using the
1493 ** [sqlite3_extended_result_codes()] API. Or, the extended code for
1494 ** the most recent error can be obtained using
1495 ** [sqlite3_extended_errcode()].
1496 */
1497 #define SQLITE_ERROR_MISSING_COLLSEQ (SQLITE_ERROR | (1<<8))
1498 #define SQLITE_ERROR_RETRY (SQLITE_ERROR | (2<<8))
1499 #define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8))
1500 #define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8))
1501 #define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8))
1502 #define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8))
1503 #define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8))
@@ -1537,10 +1539,11 @@
1539 #define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
1540 #define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
1541 #define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3<<8))
1542 #define SQLITE_READONLY_DBMOVED (SQLITE_READONLY | (4<<8))
1543 #define SQLITE_READONLY_CANTINIT (SQLITE_READONLY | (5<<8))
1544 #define SQLITE_READONLY_DIRECTORY (SQLITE_READONLY | (6<<8))
1545 #define SQLITE_ABORT_ROLLBACK (SQLITE_ABORT | (2<<8))
1546 #define SQLITE_CONSTRAINT_CHECK (SQLITE_CONSTRAINT | (1<<8))
1547 #define SQLITE_CONSTRAINT_COMMITHOOK (SQLITE_CONSTRAINT | (2<<8))
1548 #define SQLITE_CONSTRAINT_FOREIGNKEY (SQLITE_CONSTRAINT | (3<<8))
1549 #define SQLITE_CONSTRAINT_FUNCTION (SQLITE_CONSTRAINT | (4<<8))
@@ -15955,10 +15958,11 @@
15958 unsigned uniqNotNull:1; /* True if UNIQUE and NOT NULL for all columns */
15959 unsigned isResized:1; /* True if resizeIndexObject() has been called */
15960 unsigned isCovering:1; /* True if this is a covering index */
15961 unsigned noSkipScan:1; /* Do not try to use skip-scan if true */
15962 unsigned hasStat1:1; /* aiRowLogEst values come from sqlite_stat1 */
15963 unsigned bNoQuery:1; /* Do not use this index to optimize queries */
15964 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
15965 int nSample; /* Number of elements in aSample[] */
15966 int nSampleCol; /* Size of IndexSample.anEq[] and so on */
15967 tRowcnt *aAvgEq; /* Average nEq values for keys not in aSample */
15968 IndexSample *aSample; /* Samples of the left-most key */
@@ -16767,11 +16771,11 @@
16771 int nErr; /* Number of errors seen */
16772 int nTab; /* Number of previously allocated VDBE cursors */
16773 int nMem; /* Number of memory cells used so far */
16774 int nOpAlloc; /* Number of slots allocated for Vdbe.aOp[] */
16775 int szOpAlloc; /* Bytes of memory space allocated for Vdbe.aOp[] */
16776 int iSelfTab; /* Table associated with an index on expr, or negative
16777 ** of the base register during check-constraint eval */
16778 int iCacheLevel; /* ColCache valid when aColCache[].iLevel<=iCacheLevel */
16779 int iCacheCnt; /* Counter used to generate aColCache[].lru values */
16780 int nLabel; /* Number of labels used */
16781 int *aLabel; /* Space to hold the labels */
@@ -19494,11 +19498,11 @@
19498 ** The conversion algorithms are implemented based on descriptions
19499 ** in the following text:
19500 **
19501 ** Jean Meeus
19502 ** Astronomical Algorithms, 2nd Edition, 1998
19503 ** ISBN 0-943396-61-1
19504 ** Willmann-Bell, Inc
19505 ** Richmond, Virginia (USA)
19506 */
19507 /* #include "sqliteInt.h" */
19508 /* #include <stdlib.h> */
@@ -31066,11 +31070,11 @@
31070 #if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0
31071 { "munmap", (sqlite3_syscall_ptr)munmap, 0 },
31072 #else
31073 { "munmap", (sqlite3_syscall_ptr)0, 0 },
31074 #endif
31075 #define osMunmap ((int(*)(void*,size_t))aSyscall[23].pCurrent)
31076
31077 #if HAVE_MREMAP && (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0)
31078 { "mremap", (sqlite3_syscall_ptr)mremap, 0 },
31079 #else
31080 { "mremap", (sqlite3_syscall_ptr)0, 0 },
@@ -34748,11 +34752,11 @@
34752 struct flock f; /* The posix advisory locking structure */
34753 int rc = SQLITE_OK; /* Result code form fcntl() */
34754
34755 /* Access to the unixShmNode object is serialized by the caller */
34756 pShmNode = pFile->pInode->pShmNode;
34757 assert( pShmNode->nRef==0 || sqlite3_mutex_held(pShmNode->mutex) );
34758
34759 /* Shared locks never span more than one byte */
34760 assert( n==1 || lockType!=F_RDLCK );
34761
34762 /* Locks are within range */
@@ -36382,11 +36386,11 @@
36386
36387 /* If creating a master or main-file journal, this function will open
36388 ** a file-descriptor on the directory too. The first time unixSync()
36389 ** is called the directory file descriptor will be fsync()ed and close()d.
36390 */
36391 int isNewJrnl = (isCreate && (
36392 eType==SQLITE_OPEN_MASTER_JOURNAL
36393 || eType==SQLITE_OPEN_MAIN_JOURNAL
36394 || eType==SQLITE_OPEN_WAL
36395 ));
36396
@@ -36452,11 +36456,11 @@
36456 ** sqlite3_uri_parameter(). */
36457 assert( (flags & SQLITE_OPEN_URI) || zName[strlen(zName)+1]==0 );
36458
36459 }else if( !zName ){
36460 /* If zName is NULL, the upper layer is requesting a temp file. */
36461 assert(isDelete && !isNewJrnl);
36462 rc = unixGetTempname(pVfs->mxPathname, zTmpname);
36463 if( rc!=SQLITE_OK ){
36464 return rc;
36465 }
36466 zName = zTmpname;
@@ -36498,10 +36502,13 @@
36502 isReadonly = 1;
36503 fd = robust_open(zName, openFlags, openMode);
36504 }
36505 if( fd<0 ){
36506 rc = unixLogError(SQLITE_CANTOPEN_BKPT, "open", zName);
36507 /* If unable to create a journal, change the error code to
36508 ** indicate that the directory permissions are wrong. */
36509 if( isNewJrnl && osAccess(zName, F_OK) ) rc = SQLITE_READONLY_DIRECTORY;
36510 goto open_finished;
36511 }
36512
36513 /* If this process is running as root and if creating a new rollback
36514 ** journal or WAL file, set the ownership of the journal or WAL to be
@@ -36557,11 +36564,11 @@
36564 /* Set up appropriate ctrlFlags */
36565 if( isDelete ) ctrlFlags |= UNIXFILE_DELETE;
36566 if( isReadonly ) ctrlFlags |= UNIXFILE_RDONLY;
36567 noLock = eType!=SQLITE_OPEN_MAIN_DB;
36568 if( noLock ) ctrlFlags |= UNIXFILE_NOLOCK;
36569 if( isNewJrnl ) ctrlFlags |= UNIXFILE_DIRSYNC;
36570 if( flags & SQLITE_OPEN_URI ) ctrlFlags |= UNIXFILE_URI;
36571
36572 #if SQLITE_ENABLE_LOCKING_STYLE
36573 #if SQLITE_PREFER_PROXY_LOCKING
36574 isAutoProxy = 1;
@@ -42257,11 +42264,11 @@
42264 int nByte /* Number of bytes to lock or unlock */
42265 ){
42266 int rc = 0; /* Result code form Lock/UnlockFileEx() */
42267
42268 /* Access to the winShmNode object is serialized by the caller */
42269 assert( pFile->nRef==0 || sqlite3_mutex_held(pFile->mutex) );
42270
42271 OSTRACE(("SHM-LOCK file=%p, lock=%d, offset=%d, size=%d\n",
42272 pFile->hFile.h, lockType, ofst, nByte));
42273
42274 /* Release/Acquire the system-level lock */
@@ -105647,10 +105654,22 @@
105654 pKey->aColl[i] = zColl==sqlite3StrBINARY ? 0 :
105655 sqlite3LocateCollSeq(pParse, zColl);
105656 pKey->aSortOrder[i] = pIdx->aSortOrder[i];
105657 }
105658 if( pParse->nErr ){
105659 assert( pParse->rc==SQLITE_ERROR_MISSING_COLLSEQ );
105660 if( pIdx->bNoQuery==0 ){
105661 /* Deactivate the index because it contains an unknown collating
105662 ** sequence. The only way to reactive the index is to reload the
105663 ** schema. Adding the missing collating sequence later does not
105664 ** reactive the index. The application had the chance to register
105665 ** the missing index using the collation-needed callback. For
105666 ** simplicity, SQLite will not give the application a second chance.
105667 */
105668 pIdx->bNoQuery = 1;
105669 pParse->rc = SQLITE_ERROR_RETRY;
105670 }
105671 sqlite3KeyInfoUnref(pKey);
105672 pKey = 0;
105673 }
105674 }
105675 return pKey;
@@ -105832,10 +105851,11 @@
105851 p = 0;
105852 }
105853 assert( !p || p->xCmp );
105854 if( p==0 ){
105855 sqlite3ErrorMsg(pParse, "no such collation sequence: %s", zName);
105856 pParse->rc = SQLITE_ERROR_MISSING_COLLSEQ;
105857 }
105858 return p;
105859 }
105860
105861 /*
@@ -106498,15 +106518,15 @@
106518 ** deleted from is a view
106519 */
106520 #ifndef SQLITE_OMIT_TRIGGER
106521 pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);
106522 isView = pTab->pSelect!=0;
 
106523 #else
106524 # define pTrigger 0
106525 # define isView 0
106526 #endif
106527 bComplex = pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0);
106528 #ifdef SQLITE_OMIT_VIEW
106529 # undef isView
106530 # define isView 0
106531 #endif
106532
@@ -118067,12 +118087,10 @@
118087 }
118088
118089 end_prepare:
118090
118091 sqlite3ParserReset(&sParse);
 
 
118092 return rc;
118093 }
118094 static int sqlite3LockAndPrepare(
118095 sqlite3 *db, /* Database handle. */
118096 const char *zSql, /* UTF-8 encoded SQL statement. */
@@ -118081,10 +118099,11 @@
118099 Vdbe *pOld, /* VM being reprepared */
118100 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
118101 const char **pzTail /* OUT: End of parsed string */
118102 ){
118103 int rc;
118104 int cnt = 0;
118105
118106 #ifdef SQLITE_ENABLE_API_ARMOR
118107 if( ppStmt==0 ) return SQLITE_MISUSE_BKPT;
118108 #endif
118109 *ppStmt = 0;
@@ -118091,19 +118110,22 @@
118110 if( !sqlite3SafetyCheckOk(db)||zSql==0 ){
118111 return SQLITE_MISUSE_BKPT;
118112 }
118113 sqlite3_mutex_enter(db->mutex);
118114 sqlite3BtreeEnterAll(db);
118115 do{
118116 /* Make multiple attempts to compile the SQL, until it either succeeds
118117 ** or encounters a permanent error. A schema problem after one schema
118118 ** reset is considered a permanent error. */
118119 rc = sqlite3Prepare(db, zSql, nBytes, prepFlags, pOld, ppStmt, pzTail);
118120 assert( rc==SQLITE_OK || *ppStmt==0 );
118121 }while( rc==SQLITE_ERROR_RETRY
118122 || (rc==SQLITE_SCHEMA && (sqlite3ResetOneSchema(db,-1), cnt++)==0) );
118123 sqlite3BtreeLeaveAll(db);
118124 rc = sqlite3ApiExit(db, rc);
118125 assert( (rc&db->errMask)==rc );
118126 sqlite3_mutex_leave(db->mutex);
118127 return rc;
118128 }
118129
118130 /*
118131 ** Rerun the compilation of a statement after a schema change.
@@ -121628,11 +121650,11 @@
121650 ** (8) If the subquery uses LIMIT then the outer query may not be a join.
121651 **
121652 ** (9) If the subquery uses LIMIT then the outer query may not be aggregate.
121653 **
121654 ** (**) Restriction (10) was removed from the code on 2005-02-05 but we
121655 ** accidently carried the comment forward until 2014-09-15. Original
121656 ** constraint: "If the subquery is aggregate then the outer query
121657 ** may not use LIMIT."
121658 **
121659 ** (11) The subquery and the outer query may not both have ORDER BY clauses.
121660 **
@@ -130436,10 +130458,11 @@
130458 }else{
130459 endEq = 1;
130460 }
130461 }else if( bStopAtNull ){
130462 sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);
130463 sqlite3ExprCacheRemove(pParse, regBase+nEq, 1);
130464 endEq = 0;
130465 nConstraint++;
130466 }
130467 sqlite3DbFree(db, zStartAff);
130468 sqlite3DbFree(db, zEndAff);
@@ -135364,10 +135387,11 @@
135387 if( pProbe->pPartIdxWhere!=0
135388 && !whereUsablePartialIndex(pSrc->iCursor, pWC, pProbe->pPartIdxWhere) ){
135389 testcase( pNew->iTab!=pSrc->iCursor ); /* See ticket [98d973b8f5] */
135390 continue; /* Partial index inappropriate for this query */
135391 }
135392 if( pProbe->bNoQuery ) continue;
135393 rSize = pProbe->aiRowLogEst[0];
135394 pNew->u.btree.nEq = 0;
135395 pNew->u.btree.nBtm = 0;
135396 pNew->u.btree.nTop = 0;
135397 pNew->nSkip = 0;
@@ -142677,11 +142701,11 @@
142701 #endif /* __cplusplus */
142702
142703 /************** End of rtree.h ***********************************************/
142704 /************** Continuing where we left off in main.c ***********************/
142705 #endif
142706 #if defined(SQLITE_ENABLE_ICU) || defined(SQLITE_ENABLE_ICU_COLLATIONS)
142707 /************** Include sqliteicu.h in the middle of main.c ******************/
142708 /************** Begin file sqliteicu.h ***************************************/
142709 /*
142710 ** 2008 May 26
142711 **
@@ -145736,11 +145760,11 @@
145760 if( !db->mallocFailed && rc==SQLITE_OK ){
145761 rc = sqlite3Fts3Init(db);
145762 }
145763 #endif
145764
145765 #if defined(SQLITE_ENABLE_ICU) || defined(SQLITE_ENABLE_ICU_COLLATIONS)
145766 if( !db->mallocFailed && rc==SQLITE_OK ){
145767 rc = sqlite3IcuInit(db);
145768 }
145769 #endif
145770
@@ -170615,11 +170639,13 @@
170639 **
170640 ** * An implementation of the LIKE operator that uses ICU to
170641 ** provide case-independent matching.
170642 */
170643
170644 #if !defined(SQLITE_CORE) \
170645 || defined(SQLITE_ENABLE_ICU) \
170646 || defined(SQLITE_ENABLE_ICU_COLLATIONS)
170647
170648 /* Include ICU headers */
170649 #include <unicode/utypes.h>
170650 #include <unicode/uregex.h>
170651 #include <unicode/ustring.h>
@@ -170632,10 +170658,30 @@
170658 SQLITE_EXTENSION_INIT1
170659 #else
170660 /* #include "sqlite3.h" */
170661 #endif
170662
170663 /*
170664 ** This function is called when an ICU function called from within
170665 ** the implementation of an SQL scalar function returns an error.
170666 **
170667 ** The scalar function context passed as the first argument is
170668 ** loaded with an error message based on the following two args.
170669 */
170670 static void icuFunctionError(
170671 sqlite3_context *pCtx, /* SQLite scalar function context */
170672 const char *zName, /* Name of ICU function that failed */
170673 UErrorCode e /* Error code returned by ICU function */
170674 ){
170675 char zBuf[128];
170676 sqlite3_snprintf(128, zBuf, "ICU error: %s(): %s", zName, u_errorName(e));
170677 zBuf[127] = '\0';
170678 sqlite3_result_error(pCtx, zBuf, -1);
170679 }
170680
170681 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_ICU)
170682
170683 /*
170684 ** Maximum length (in bytes) of the pattern in a LIKE or GLOB
170685 ** operator.
170686 */
170687 #ifndef SQLITE_MAX_LIKE_PATTERN_LENGTH
@@ -170811,28 +170857,10 @@
170857 if( zA && zB ){
170858 sqlite3_result_int(context, icuLikeCompare(zA, zB, uEsc));
170859 }
170860 }
170861
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170862 /*
170863 ** Function to delete compiled regexp objects. Registered as
170864 ** a destructor function with sqlite3_set_auxdata().
170865 */
170866 static void icuRegexpDelete(void *p){
@@ -170994,10 +171022,12 @@
171022 return;
171023 }
171024 assert( 0 ); /* Unreachable */
171025 }
171026
171027 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_ICU) */
171028
171029 /*
171030 ** Collation sequence destructor function. The pCtx argument points to
171031 ** a UCollator structure previously allocated using ucol_open().
171032 */
171033 static void icuCollationDel(void *pCtx){
@@ -171088,10 +171118,11 @@
171118 unsigned short enc; /* Optimal text encoding */
171119 unsigned char iContext; /* sqlite3_user_data() context */
171120 void (*xFunc)(sqlite3_context*,int,sqlite3_value**);
171121 } scalars[] = {
171122 {"icu_load_collation", 2, SQLITE_UTF8, 1, icuLoadCollation},
171123 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_ICU)
171124 {"regexp", 2, SQLITE_ANY|SQLITE_DETERMINISTIC, 0, icuRegexpFunc},
171125 {"lower", 1, SQLITE_UTF16|SQLITE_DETERMINISTIC, 0, icuCaseFunc16},
171126 {"lower", 2, SQLITE_UTF16|SQLITE_DETERMINISTIC, 0, icuCaseFunc16},
171127 {"upper", 1, SQLITE_UTF16|SQLITE_DETERMINISTIC, 1, icuCaseFunc16},
171128 {"upper", 2, SQLITE_UTF16|SQLITE_DETERMINISTIC, 1, icuCaseFunc16},
@@ -171099,14 +171130,14 @@
171130 {"lower", 2, SQLITE_UTF8|SQLITE_DETERMINISTIC, 0, icuCaseFunc16},
171131 {"upper", 1, SQLITE_UTF8|SQLITE_DETERMINISTIC, 1, icuCaseFunc16},
171132 {"upper", 2, SQLITE_UTF8|SQLITE_DETERMINISTIC, 1, icuCaseFunc16},
171133 {"like", 2, SQLITE_UTF8|SQLITE_DETERMINISTIC, 0, icuLikeFunc},
171134 {"like", 3, SQLITE_UTF8|SQLITE_DETERMINISTIC, 0, icuLikeFunc},
171135 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_ICU) */
171136 };
171137 int rc = SQLITE_OK;
171138 int i;
 
171139
171140 for(i=0; rc==SQLITE_OK && i<(int)(sizeof(scalars)/sizeof(scalars[0])); i++){
171141 const struct IcuScalar *p = &scalars[i];
171142 rc = sqlite3_create_function(
171143 db, p->zName, p->nArg, p->enc,
@@ -184999,11 +185030,11 @@
185030 0 /* xRollbackTo */
185031 };
185032 #endif /* SQLITE_OMIT_VIRTUALTABLE */
185033
185034 /****************************************************************************
185035 ** The following routines are the only publically visible identifiers in this
185036 ** file. Call the following routines in order to register the various SQL
185037 ** functions and the virtual table implemented by this file.
185038 ****************************************************************************/
185039
185040 SQLITE_PRIVATE int sqlite3Json1Init(sqlite3 *db){
@@ -198157,11 +198188,17 @@
198188 Fts5DoclistIter i1;
198189 Fts5DoclistIter i2;
198190 Fts5Buffer out = {0, 0, 0};
198191 Fts5Buffer tmp = {0, 0, 0};
198192
198193 /* The maximum size of the output is equal to the sum of the two
198194 ** input sizes + 1 varint (9 bytes). The extra varint is because if the
198195 ** first rowid in one input is a large negative number, and the first in
198196 ** the other a non-negative number, the delta for the non-negative
198197 ** number will be larger on disk than the literal integer value
198198 ** was. */
198199 if( sqlite3Fts5BufferSize(&p->rc, &out, p1->n + p2->n + 9) ) return;
198200 fts5DoclistIterInit(p1, &i1);
198201 fts5DoclistIterInit(p2, &i2);
198202
198203 while( 1 ){
198204 if( i1.iRowid<i2.iRowid ){
@@ -198251,10 +198288,11 @@
198288 }
198289 else if( i2.aPoslist ){
198290 fts5MergeAppendDocid(&out, iLastRowid, i2.iRowid);
198291 fts5BufferSafeAppendBlob(&out, i2.aPoslist, i2.aEof - i2.aPoslist);
198292 }
198293 assert( out.n<=(p1->n+p2->n+9) );
198294
198295 fts5BufferSet(&p->rc, p1, out.n, out.p);
198296 fts5BufferFree(&tmp);
198297 fts5BufferFree(&out);
198298 }
@@ -202372,11 +202410,11 @@
202410 int nArg, /* Number of args */
202411 sqlite3_value **apUnused /* Function arguments */
202412 ){
202413 assert( nArg==0 );
202414 UNUSED_PARAM2(nArg, apUnused);
202415 sqlite3_result_text(pCtx, "fts5: 2017-12-13 15:32:33 30bf38d589adf0b2eb613e184ffb03ed7e625736cb04fd5c341328f72bc5ef4d", -1, SQLITE_TRANSIENT);
202416 }
202417
202418 static int fts5Init(sqlite3 *db){
202419 static const sqlite3_module fts5Mod = {
202420 /* iVersion */ 2,
@@ -205632,11 +205670,11 @@
205670
205671 int bEof; /* True if this cursor is at EOF */
205672 Fts5IndexIter *pIter; /* Term/rowid iterator object */
205673
205674 int nLeTerm; /* Size of zLeTerm in bytes */
205675 char *zLeTerm; /* (term <= $zLeTerm) paramater, or NULL */
205676
205677 /* These are used by 'col' tables only */
205678 Fts5Config *pConfig; /* Fts5 table configuration */
205679 int iCol;
205680 i64 *aCnt;
@@ -206640,12 +206678,12 @@
206678 }
206679 #endif /* SQLITE_CORE */
206680 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
206681
206682 /************** End of stmt.c ************************************************/
206683 #if __LINE__!=206683
206684 #undef SQLITE_SOURCE_ID
206685 #define SQLITE_SOURCE_ID "2017-12-13 20:35:34 1c0aa919ee429cd194820ec9c54084563f39e63fd399b23f859fc6703b42alt2"
206686 #endif
206687 /* Return the source-id for this library */
206688 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
206689 /************************** End of sqlite3.c ******************************/
206690
+4 -1
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -123,11 +123,11 @@
123123
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124124
** [sqlite_version()] and [sqlite_source_id()].
125125
*/
126126
#define SQLITE_VERSION "3.22.0"
127127
#define SQLITE_VERSION_NUMBER 3022000
128
-#define SQLITE_SOURCE_ID "2017-12-06 20:50:08 6a55bd67720451cdf316155cf348103bfce1056a78bcddf0029b45ff0fdbcc71"
128
+#define SQLITE_SOURCE_ID "2017-12-13 20:35:34 1c0aa919ee429cd194820ec9c54084563f39e63fd399b23f859fc6703b429b15"
129129
130130
/*
131131
** CAPI3REF: Run-Time Library Version Numbers
132132
** KEYWORDS: sqlite3_version sqlite3_sourceid
133133
**
@@ -468,10 +468,12 @@
468468
** on a per database connection basis using the
469469
** [sqlite3_extended_result_codes()] API. Or, the extended code for
470470
** the most recent error can be obtained using
471471
** [sqlite3_extended_errcode()].
472472
*/
473
+#define SQLITE_ERROR_MISSING_COLLSEQ (SQLITE_ERROR | (1<<8))
474
+#define SQLITE_ERROR_RETRY (SQLITE_ERROR | (2<<8))
473475
#define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8))
474476
#define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8))
475477
#define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8))
476478
#define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8))
477479
#define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8))
@@ -513,10 +515,11 @@
513515
#define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
514516
#define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
515517
#define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3<<8))
516518
#define SQLITE_READONLY_DBMOVED (SQLITE_READONLY | (4<<8))
517519
#define SQLITE_READONLY_CANTINIT (SQLITE_READONLY | (5<<8))
520
+#define SQLITE_READONLY_DIRECTORY (SQLITE_READONLY | (6<<8))
518521
#define SQLITE_ABORT_ROLLBACK (SQLITE_ABORT | (2<<8))
519522
#define SQLITE_CONSTRAINT_CHECK (SQLITE_CONSTRAINT | (1<<8))
520523
#define SQLITE_CONSTRAINT_COMMITHOOK (SQLITE_CONSTRAINT | (2<<8))
521524
#define SQLITE_CONSTRAINT_FOREIGNKEY (SQLITE_CONSTRAINT | (3<<8))
522525
#define SQLITE_CONSTRAINT_FUNCTION (SQLITE_CONSTRAINT | (4<<8))
523526
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -123,11 +123,11 @@
123 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124 ** [sqlite_version()] and [sqlite_source_id()].
125 */
126 #define SQLITE_VERSION "3.22.0"
127 #define SQLITE_VERSION_NUMBER 3022000
128 #define SQLITE_SOURCE_ID "2017-12-06 20:50:08 6a55bd67720451cdf316155cf348103bfce1056a78bcddf0029b45ff0fdbcc71"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
@@ -468,10 +468,12 @@
468 ** on a per database connection basis using the
469 ** [sqlite3_extended_result_codes()] API. Or, the extended code for
470 ** the most recent error can be obtained using
471 ** [sqlite3_extended_errcode()].
472 */
 
 
473 #define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8))
474 #define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8))
475 #define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8))
476 #define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8))
477 #define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8))
@@ -513,10 +515,11 @@
513 #define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
514 #define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
515 #define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3<<8))
516 #define SQLITE_READONLY_DBMOVED (SQLITE_READONLY | (4<<8))
517 #define SQLITE_READONLY_CANTINIT (SQLITE_READONLY | (5<<8))
 
518 #define SQLITE_ABORT_ROLLBACK (SQLITE_ABORT | (2<<8))
519 #define SQLITE_CONSTRAINT_CHECK (SQLITE_CONSTRAINT | (1<<8))
520 #define SQLITE_CONSTRAINT_COMMITHOOK (SQLITE_CONSTRAINT | (2<<8))
521 #define SQLITE_CONSTRAINT_FOREIGNKEY (SQLITE_CONSTRAINT | (3<<8))
522 #define SQLITE_CONSTRAINT_FUNCTION (SQLITE_CONSTRAINT | (4<<8))
523
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -123,11 +123,11 @@
123 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124 ** [sqlite_version()] and [sqlite_source_id()].
125 */
126 #define SQLITE_VERSION "3.22.0"
127 #define SQLITE_VERSION_NUMBER 3022000
128 #define SQLITE_SOURCE_ID "2017-12-13 20:35:34 1c0aa919ee429cd194820ec9c54084563f39e63fd399b23f859fc6703b429b15"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
@@ -468,10 +468,12 @@
468 ** on a per database connection basis using the
469 ** [sqlite3_extended_result_codes()] API. Or, the extended code for
470 ** the most recent error can be obtained using
471 ** [sqlite3_extended_errcode()].
472 */
473 #define SQLITE_ERROR_MISSING_COLLSEQ (SQLITE_ERROR | (1<<8))
474 #define SQLITE_ERROR_RETRY (SQLITE_ERROR | (2<<8))
475 #define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8))
476 #define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8))
477 #define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8))
478 #define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8))
479 #define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8))
@@ -513,10 +515,11 @@
515 #define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
516 #define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
517 #define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3<<8))
518 #define SQLITE_READONLY_DBMOVED (SQLITE_READONLY | (4<<8))
519 #define SQLITE_READONLY_CANTINIT (SQLITE_READONLY | (5<<8))
520 #define SQLITE_READONLY_DIRECTORY (SQLITE_READONLY | (6<<8))
521 #define SQLITE_ABORT_ROLLBACK (SQLITE_ABORT | (2<<8))
522 #define SQLITE_CONSTRAINT_CHECK (SQLITE_CONSTRAINT | (1<<8))
523 #define SQLITE_CONSTRAINT_COMMITHOOK (SQLITE_CONSTRAINT | (2<<8))
524 #define SQLITE_CONSTRAINT_FOREIGNKEY (SQLITE_CONSTRAINT | (3<<8))
525 #define SQLITE_CONSTRAINT_FUNCTION (SQLITE_CONSTRAINT | (4<<8))
526

Keyboard Shortcuts

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