Fossil SCM

Update the built-in SQLite to the first 3.25.0 release candidate.

drh 2018-09-10 22:21 trunk
Commit ed84acb6d28398fced4e09ad419f5dbd23cb954373b360fbeee8b1adc66c762f
3 files changed +1 -1 +117 -55 +1 -1
+1 -1
--- src/shell.c
+++ src/shell.c
@@ -2224,11 +2224,11 @@
22242224
WIN32_FIND_DATAW fd;
22252225
LPWSTR zUnicodeName;
22262226
extern LPWSTR sqlite3_win32_utf8_to_unicode(const char*);
22272227
zUnicodeName = sqlite3_win32_utf8_to_unicode(zPath);
22282228
if( zUnicodeName ){
2229
- memset(&fd, 0, sizeof(WIN32_FIND_DATA));
2229
+ memset(&fd, 0, sizeof(WIN32_FIND_DATAW));
22302230
hFindFile = FindFirstFileW(zUnicodeName, &fd);
22312231
if( hFindFile!=NULL ){
22322232
pStatBuf->st_ctime = (time_t)fileTimeToUnixTime(&fd.ftCreationTime);
22332233
pStatBuf->st_atime = (time_t)fileTimeToUnixTime(&fd.ftLastAccessTime);
22342234
pStatBuf->st_mtime = (time_t)fileTimeToUnixTime(&fd.ftLastWriteTime);
22352235
--- src/shell.c
+++ src/shell.c
@@ -2224,11 +2224,11 @@
2224 WIN32_FIND_DATAW fd;
2225 LPWSTR zUnicodeName;
2226 extern LPWSTR sqlite3_win32_utf8_to_unicode(const char*);
2227 zUnicodeName = sqlite3_win32_utf8_to_unicode(zPath);
2228 if( zUnicodeName ){
2229 memset(&fd, 0, sizeof(WIN32_FIND_DATA));
2230 hFindFile = FindFirstFileW(zUnicodeName, &fd);
2231 if( hFindFile!=NULL ){
2232 pStatBuf->st_ctime = (time_t)fileTimeToUnixTime(&fd.ftCreationTime);
2233 pStatBuf->st_atime = (time_t)fileTimeToUnixTime(&fd.ftLastAccessTime);
2234 pStatBuf->st_mtime = (time_t)fileTimeToUnixTime(&fd.ftLastWriteTime);
2235
--- src/shell.c
+++ src/shell.c
@@ -2224,11 +2224,11 @@
2224 WIN32_FIND_DATAW fd;
2225 LPWSTR zUnicodeName;
2226 extern LPWSTR sqlite3_win32_utf8_to_unicode(const char*);
2227 zUnicodeName = sqlite3_win32_utf8_to_unicode(zPath);
2228 if( zUnicodeName ){
2229 memset(&fd, 0, sizeof(WIN32_FIND_DATAW));
2230 hFindFile = FindFirstFileW(zUnicodeName, &fd);
2231 if( hFindFile!=NULL ){
2232 pStatBuf->st_ctime = (time_t)fileTimeToUnixTime(&fd.ftCreationTime);
2233 pStatBuf->st_atime = (time_t)fileTimeToUnixTime(&fd.ftLastAccessTime);
2234 pStatBuf->st_mtime = (time_t)fileTimeToUnixTime(&fd.ftLastWriteTime);
2235
+117 -55
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1156,11 +1156,11 @@
11561156
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
11571157
** [sqlite_version()] and [sqlite_source_id()].
11581158
*/
11591159
#define SQLITE_VERSION "3.25.0"
11601160
#define SQLITE_VERSION_NUMBER 3025000
1161
-#define SQLITE_SOURCE_ID "2018-09-06 18:56:36 91aab32e71fcb924e24c02d5f0901f7a474760fc993a7e7436e667512cf5d3c3"
1161
+#define SQLITE_SOURCE_ID "2018-09-10 19:34:06 74c381b573817d0212153278b5ee5d2238a27a727dcf7ee769365c47bb9fc40d"
11621162
11631163
/*
11641164
** CAPI3REF: Run-Time Library Version Numbers
11651165
** KEYWORDS: sqlite3_version sqlite3_sourceid
11661166
**
@@ -18653,11 +18653,11 @@
1865318653
SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(Parse*,SrcList*,Expr*,ExprList*,ExprList*,u16,int);
1865418654
SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo*);
1865518655
SQLITE_PRIVATE LogEst sqlite3WhereOutputRowCount(WhereInfo*);
1865618656
SQLITE_PRIVATE int sqlite3WhereIsDistinct(WhereInfo*);
1865718657
SQLITE_PRIVATE int sqlite3WhereIsOrdered(WhereInfo*);
18658
-SQLITE_PRIVATE int sqlite3WhereOrderedInnerLoop(WhereInfo*);
18658
+SQLITE_PRIVATE int sqlite3WhereOrderByLimitOptLabel(WhereInfo*);
1865918659
SQLITE_PRIVATE int sqlite3WhereIsSorted(WhereInfo*);
1866018660
SQLITE_PRIVATE int sqlite3WhereContinueLabel(WhereInfo*);
1866118661
SQLITE_PRIVATE int sqlite3WhereBreakLabel(WhereInfo*);
1866218662
SQLITE_PRIVATE int sqlite3WhereOkOnePass(WhereInfo*, int*);
1866318663
#define ONEPASS_OFF 0 /* Use of ONEPASS not allowed */
@@ -35271,11 +35271,11 @@
3527135271
assert( unixFileMutexNotheld(pFile) );
3527235272
unixEnterMutex();
3527335273
if( pFile->pInode ){
3527435274
unixInodeInfo *pInode = pFile->pInode;
3527535275
sqlite3_mutex_enter(pInode->pLockMutex);
35276
- if( pFile->pInode->nLock ){
35276
+ if( pInode->nLock ){
3527735277
/* If there are outstanding locks, do not actually close the file just
3527835278
** yet because that would clear those locks. Instead, add the file
3527935279
** descriptor to pInode->aPending. It will be automatically closed when
3528035280
** the last lock is cleared.
3528135281
*/
@@ -88405,10 +88405,11 @@
8840588405
{
8840688406
zMaster = MASTER_NAME;
8840788407
initData.db = db;
8840888408
initData.iDb = pOp->p1;
8840988409
initData.pzErrMsg = &p->zErrMsg;
88410
+ initData.mInitFlags = 0;
8841088411
zSql = sqlite3MPrintf(db,
8841188412
"SELECT name, rootpage, sql FROM '%q'.%s WHERE %s ORDER BY rowid",
8841288413
db->aDb[iDb].zDbSName, zMaster, pOp->p4.z);
8841388414
if( zSql==0 ){
8841488415
rc = SQLITE_NOMEM_BKPT;
@@ -102148,33 +102149,34 @@
102148102149
** successful. Otherwise, return an SQLite error code and leave an error
102149102150
** message in the Parse object.
102150102151
*/
102151102152
static int renameResolveTrigger(Parse *pParse, const char *zDb){
102152102153
sqlite3 *db = pParse->db;
102154
+ Trigger *pNew = pParse->pNewTrigger;
102153102155
TriggerStep *pStep;
102154102156
NameContext sNC;
102155102157
int rc = SQLITE_OK;
102156102158
102157102159
memset(&sNC, 0, sizeof(sNC));
102158102160
sNC.pParse = pParse;
102159
- pParse->pTriggerTab = sqlite3FindTable(db, pParse->pNewTrigger->table, zDb);
102160
- pParse->eTriggerOp = pParse->pNewTrigger->op;
102161
+ assert( pNew->pTabSchema );
102162
+ pParse->pTriggerTab = sqlite3FindTable(db, pNew->table,
102163
+ db->aDb[sqlite3SchemaToIndex(db, pNew->pTabSchema)].zDbSName
102164
+ );
102165
+ pParse->eTriggerOp = pNew->op;
102161102166
102162102167
/* Resolve symbols in WHEN clause */
102163
- if( pParse->pNewTrigger->pWhen ){
102164
- rc = sqlite3ResolveExprNames(&sNC, pParse->pNewTrigger->pWhen);
102168
+ if( pNew->pWhen ){
102169
+ rc = sqlite3ResolveExprNames(&sNC, pNew->pWhen);
102165102170
}
102166102171
102167
- for(pStep=pParse->pNewTrigger->step_list;
102168
- rc==SQLITE_OK && pStep;
102169
- pStep=pStep->pNext
102170
- ){
102172
+ for(pStep=pNew->step_list; rc==SQLITE_OK && pStep; pStep=pStep->pNext){
102171102173
if( pStep->pSelect ){
102172102174
sqlite3SelectPrep(pParse, pStep->pSelect, &sNC);
102173102175
if( pParse->nErr ) rc = pParse->rc;
102174102176
}
102175
- if( rc==SQLITE_OK && pStep->zTarget ){
102177
+ if( rc==SQLITE_OK && pStep->zTarget ){
102176102178
Table *pTarget = sqlite3LocateTable(pParse, 0, pStep->zTarget, zDb);
102177102179
if( pTarget==0 ){
102178102180
rc = SQLITE_ERROR;
102179102181
}else{
102180102182
SrcList sSrc;
@@ -102534,14 +102536,16 @@
102534102536
if( sParse.nErr ) rc = sParse.rc;
102535102537
sqlite3WalkSelect(&sWalker, pTab->pSelect);
102536102538
}else{
102537102539
/* Modify any FK definitions to point to the new table. */
102538102540
#ifndef SQLITE_OMIT_FOREIGN_KEY
102539
- FKey *pFKey;
102540
- for(pFKey=pTab->pFKey; pFKey; pFKey=pFKey->pNextFrom){
102541
- if( sqlite3_stricmp(pFKey->zTo, zOld)==0 ){
102542
- renameTokenFind(&sParse, &sCtx, (void*)pFKey->zTo);
102541
+ if( db->flags & SQLITE_ForeignKeys ){
102542
+ FKey *pFKey;
102543
+ for(pFKey=pTab->pFKey; pFKey; pFKey=pFKey->pNextFrom){
102544
+ if( sqlite3_stricmp(pFKey->zTo, zOld)==0 ){
102545
+ renameTokenFind(&sParse, &sCtx, (void*)pFKey->zTo);
102546
+ }
102543102547
}
102544102548
}
102545102549
#endif
102546102550
102547102551
/* If this is the table being altered, fix any table refs in CHECK
@@ -109502,12 +109506,14 @@
109502109506
if( p==0 ){
109503109507
goto append_from_error;
109504109508
}
109505109509
assert( p->nSrc>0 );
109506109510
pItem = &p->a[p->nSrc-1];
109511
+ assert( (pTable==0)==(pDatabase==0) );
109512
+ assert( pItem->zName==0 || pDatabase!=0 );
109507109513
if( IN_RENAME_OBJECT && pItem->zName ){
109508
- Token *pToken = (pDatabase && pDatabase->z) ? pDatabase : pTable;
109514
+ Token *pToken = (ALWAYS(pDatabase) && pDatabase->z) ? pDatabase : pTable;
109509109515
sqlite3RenameTokenMap(pParse, pItem->zName, pToken);
109510109516
}
109511109517
assert( pAlias!=0 );
109512109518
if( pAlias->n ){
109513109519
pItem->zAlias = sqlite3NameFromToken(db, pAlias);
@@ -117881,10 +117887,16 @@
117881117887
void (*str_appendchar)(sqlite3_str*, int N, char C);
117882117888
void (*str_reset)(sqlite3_str*);
117883117889
int (*str_errcode)(sqlite3_str*);
117884117890
int (*str_length)(sqlite3_str*);
117885117891
char *(*str_value)(sqlite3_str*);
117892
+ int (*create_window_function)(sqlite3*,const char*,int,int,void*,
117893
+ void (*xStep)(sqlite3_context*,int,sqlite3_value**),
117894
+ void (*xFinal)(sqlite3_context*),
117895
+ void (*xValue)(sqlite3_context*),
117896
+ void (*xInv)(sqlite3_context*,int,sqlite3_value**),
117897
+ void(*xDestroy)(void*));
117886117898
};
117887117899
117888117900
/*
117889117901
** This is the function signature used for all extension entry points. It
117890117902
** is also defined in the file "loadext.c".
@@ -118166,10 +118178,12 @@
118166118178
#define sqlite3_str_appendchar sqlite3_api->str_appendchar
118167118179
#define sqlite3_str_reset sqlite3_api->str_reset
118168118180
#define sqlite3_str_errcode sqlite3_api->str_errcode
118169118181
#define sqlite3_str_length sqlite3_api->str_length
118170118182
#define sqlite3_str_value sqlite3_api->str_value
118183
+/* Version 3.25.0 and later */
118184
+#define sqlite3_create_window_function sqlite3_api->create_window_function
118171118185
#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
118172118186
118173118187
#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
118174118188
/* This case when the file really is being compiled as a loadable
118175118189
** extension */
@@ -118619,11 +118633,13 @@
118619118633
sqlite3_str_appendall,
118620118634
sqlite3_str_appendchar,
118621118635
sqlite3_str_reset,
118622118636
sqlite3_str_errcode,
118623118637
sqlite3_str_length,
118624
- sqlite3_str_value
118638
+ sqlite3_str_value,
118639
+ /* Version 3.25.0 and later */
118640
+ sqlite3_create_window_function
118625118641
};
118626118642
118627118643
/*
118628118644
** Attempt to load an SQLite extension library contained in the file
118629118645
** zFile. The entry point is zProc. zProc may be 0 in which case a
@@ -123117,12 +123133,12 @@
123117123133
int iECursor; /* Cursor number for the sorter */
123118123134
int regReturn; /* Register holding block-output return address */
123119123135
int labelBkOut; /* Start label for the block-output subroutine */
123120123136
int addrSortIndex; /* Address of the OP_SorterOpen or OP_OpenEphemeral */
123121123137
int labelDone; /* Jump here when done, ex: LIMIT reached */
123138
+ int labelOBLopt; /* Jump here when sorter is full */
123122123139
u8 sortFlags; /* Zero or more SORTFLAG_* bits */
123123
- u8 bOrderedInnerLoop; /* ORDER BY correctly sorts the inner loop */
123124123140
#ifdef SQLITE_ENABLE_SORTER_REFERENCES
123125123141
u8 nDefer; /* Number of valid entries in aDefer[] */
123126123142
struct DeferredCsr {
123127123143
Table *pTab; /* Table definition */
123128123144
int iCsr; /* Cursor number for table */
@@ -123742,14 +123758,14 @@
123742123758
** are already LIMIT+OFFSET items in the sorter, delete the largest
123743123759
** entry before inserting the new one. This way there are never more
123744123760
** than LIMIT+OFFSET items in the sorter.
123745123761
**
123746123762
** If the new record does not need to be inserted into the sorter,
123747
- ** jump to the next iteration of the loop. Or, if the
123748
- ** pSort->bOrderedInnerLoop flag is set to indicate that the inner
123749
- ** loop delivers items in sorted order, jump to the next iteration
123750
- ** of the outer loop.
123763
+ ** jump to the next iteration of the loop. If the pSort->labelOBLopt
123764
+ ** value is not zero, then it is a label of where to jump. Otherwise,
123765
+ ** just bypass the row insert logic. See the header comment on the
123766
+ ** sqlite3WhereOrderByLimitOptLabel() function for additional info.
123751123767
*/
123752123768
int iCsr = pSort->iECursor;
123753123769
sqlite3VdbeAddOp2(v, OP_IfNotZero, iLimit, sqlite3VdbeCurrentAddr(v)+4);
123754123770
VdbeCoverage(v);
123755123771
sqlite3VdbeAddOp2(v, OP_Last, iCsr, 0);
@@ -123767,13 +123783,12 @@
123767123783
op = OP_IdxInsert;
123768123784
}
123769123785
sqlite3VdbeAddOp4Int(v, op, pSort->iECursor, regRecord,
123770123786
regBase+nOBSat, nBase-nOBSat);
123771123787
if( iSkip ){
123772
- assert( pSort->bOrderedInnerLoop==0 || pSort->bOrderedInnerLoop==1 );
123773123788
sqlite3VdbeChangeP2(v, iSkip,
123774
- sqlite3VdbeCurrentAddr(v) + pSort->bOrderedInnerLoop);
123789
+ pSort->labelOBLopt ? pSort->labelOBLopt : sqlite3VdbeCurrentAddr(v));
123775123790
}
123776123791
}
123777123792
123778123793
/*
123779123794
** Add code to implement the OFFSET
@@ -129109,11 +129124,11 @@
129109129124
if( sDistinct.isTnct && sqlite3WhereIsDistinct(pWInfo) ){
129110129125
sDistinct.eTnctType = sqlite3WhereIsDistinct(pWInfo);
129111129126
}
129112129127
if( sSort.pOrderBy ){
129113129128
sSort.nOBSat = sqlite3WhereIsOrdered(pWInfo);
129114
- sSort.bOrderedInnerLoop = sqlite3WhereOrderedInnerLoop(pWInfo);
129129
+ sSort.labelOBLopt = sqlite3WhereOrderByLimitOptLabel(pWInfo);
129115129130
if( sSort.nOBSat==sSort.pOrderBy->nExpr ){
129116129131
sSort.pOrderBy = 0;
129117129132
}
129118129133
}
129119129134
@@ -135312,11 +135327,11 @@
135312135327
** an access of the index rather than the original table.
135313135328
*/
135314135329
static int codeCursorHintFixExpr(Walker *pWalker, Expr *pExpr){
135315135330
int rc = WRC_Continue;
135316135331
struct CCurHint *pHint = pWalker->u.pCCurHint;
135317
- if( pExpr->op==TK_COLUMN && !ExprHasProperty(pExpr, EP_FixedCol) ){
135332
+ if( pExpr->op==TK_COLUMN ){
135318135333
if( pExpr->iTable!=pHint->iTabCur ){
135319135334
Vdbe *v = pWalker->pParse->pVdbe;
135320135335
int reg = ++pWalker->pParse->nMem; /* Register for column value */
135321135336
sqlite3ExprCodeGetColumnOfTable(
135322135337
v, pExpr->pTab, pExpr->iTable, pExpr->iColumn, reg
@@ -136899,27 +136914,10 @@
136899136914
}else if( op==TK_STRING ){
136900136915
z = (u8*)pRight->u.zToken;
136901136916
}
136902136917
if( z ){
136903136918
136904
- /* If the RHS begins with a digit or a minus sign, then the LHS must
136905
- ** be an ordinary column (not a virtual table column) with TEXT affinity.
136906
- ** Otherwise the LHS might be numeric and "lhs >= rhs" would be false
136907
- ** even though "lhs LIKE rhs" is true. But if the RHS does not start
136908
- ** with a digit or '-', then "lhs LIKE rhs" will always be false if
136909
- ** the LHS is numeric and so the optimization still works.
136910
- */
136911
- if( sqlite3Isdigit(z[0]) || z[0]=='-' ){
136912
- if( pLeft->op!=TK_COLUMN
136913
- || sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT
136914
- || IsVirtual(pLeft->pTab) /* Value might be numeric */
136915
- ){
136916
- sqlite3ValueFree(pVal);
136917
- return 0;
136918
- }
136919
- }
136920
-
136921136919
/* Count the number of prefix characters prior to the first wildcard */
136922136920
cnt = 0;
136923136921
while( (c=z[cnt])!=0 && c!=wc[0] && c!=wc[1] && c!=wc[2] ){
136924136922
cnt++;
136925136923
if( c==wc[3] && z[cnt]!=0 ) cnt++;
@@ -136948,10 +136946,36 @@
136948136946
for(iFrom=iTo=0; iFrom<cnt; iFrom++){
136949136947
if( zNew[iFrom]==wc[3] ) iFrom++;
136950136948
zNew[iTo++] = zNew[iFrom];
136951136949
}
136952136950
zNew[iTo] = 0;
136951
+
136952
+ /* If the RHS begins with a digit or a minus sign, then the LHS must be
136953
+ ** an ordinary column (not a virtual table column) with TEXT affinity.
136954
+ ** Otherwise the LHS might be numeric and "lhs >= rhs" would be false
136955
+ ** even though "lhs LIKE rhs" is true. But if the RHS does not start
136956
+ ** with a digit or '-', then "lhs LIKE rhs" will always be false if
136957
+ ** the LHS is numeric and so the optimization still works.
136958
+ **
136959
+ ** 2018-09-10 ticket c94369cae9b561b1f996d0054bfab11389f9d033
136960
+ ** The RHS pattern must not be '/%' because the termination condition
136961
+ ** will then become "x<'0'" and if the affinity is numeric, will then
136962
+ ** be converted into "x<0", which is incorrect.
136963
+ */
136964
+ if( sqlite3Isdigit(zNew[0])
136965
+ || zNew[0]=='-'
136966
+ || (zNew[0]+1=='0' && iTo==1)
136967
+ ){
136968
+ if( pLeft->op!=TK_COLUMN
136969
+ || sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT
136970
+ || IsVirtual(pLeft->pTab) /* Value might be numeric */
136971
+ ){
136972
+ sqlite3ExprDelete(db, pPrefix);
136973
+ sqlite3ValueFree(pVal);
136974
+ return 0;
136975
+ }
136976
+ }
136953136977
}
136954136978
*ppPrefix = pPrefix;
136955136979
136956136980
/* If the RHS pattern is a bound parameter, make arrangements to
136957136981
** reprepare the statement when that parameter is rebound */
@@ -138321,19 +138345,42 @@
138321138345
SQLITE_PRIVATE int sqlite3WhereIsOrdered(WhereInfo *pWInfo){
138322138346
return pWInfo->nOBSat;
138323138347
}
138324138348
138325138349
/*
138326
-** Return TRUE if the innermost loop of the WHERE clause implementation
138327
-** returns rows in ORDER BY order for complete run of the inner loop.
138350
+** In the ORDER BY LIMIT optimization, if the inner-most loop is known
138351
+** to emit rows in increasing order, and if the last row emitted by the
138352
+** inner-most loop did not fit within the sorter, then we can skip all
138353
+** subsequent rows for the current iteration of the inner loop (because they
138354
+** will not fit in the sorter either) and continue with the second inner
138355
+** loop - the loop immediately outside the inner-most.
138328138356
**
138329
-** Across multiple iterations of outer loops, the output rows need not be
138330
-** sorted. As long as rows are sorted for just the innermost loop, this
138331
-** routine can return TRUE.
138357
+** When a row does not fit in the sorter (because the sorter already
138358
+** holds LIMIT+OFFSET rows that are smaller), then a jump is made to the
138359
+** label returned by this function.
138360
+**
138361
+** If the ORDER BY LIMIT optimization applies, the jump destination should
138362
+** be the continuation for the second-inner-most loop. If the ORDER BY
138363
+** LIMIT optimization does not apply, then the jump destination should
138364
+** be the continuation for the inner-most loop.
138365
+**
138366
+** It is always safe for this routine to return the continuation of the
138367
+** inner-most loop, in the sense that a correct answer will result.
138368
+** Returning the continuation the second inner loop is an optimization
138369
+** that might make the code run a little faster, but should not change
138370
+** the final answer.
138332138371
*/
138333
-SQLITE_PRIVATE int sqlite3WhereOrderedInnerLoop(WhereInfo *pWInfo){
138334
- return pWInfo->bOrderedInnerLoop;
138372
+SQLITE_PRIVATE int sqlite3WhereOrderByLimitOptLabel(WhereInfo *pWInfo){
138373
+ WhereLevel *pInner;
138374
+ if( !pWInfo->bOrderedInnerLoop ){
138375
+ /* The ORDER BY LIMIT optimization does not apply. Jump to the
138376
+ ** continuation of the inner-most loop. */
138377
+ return pWInfo->iContinue;
138378
+ }
138379
+ pInner = &pWInfo->a[pWInfo->nLevel-1];
138380
+ assert( pInner->addrNxt!=0 );
138381
+ return pInner->addrNxt;
138335138382
}
138336138383
138337138384
/*
138338138385
** Return the VDBE address or label to jump to in order to continue
138339138386
** immediately with the next row of a WHERE clause.
@@ -139197,10 +139244,24 @@
139197139244
testcase( pTerm->eOperator & WO_IS );
139198139245
testcase( pTerm->eOperator & WO_ISNULL );
139199139246
testcase( pTerm->eOperator & WO_ALL );
139200139247
if( (pTerm->eOperator & ~(WO_EQUIV))==0 ) continue;
139201139248
if( pTerm->wtFlags & TERM_VNULL ) continue;
139249
+ if( (pSrc->fg.jointype & JT_LEFT)!=0
139250
+ && !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
139251
+ && (pTerm->eOperator & (WO_IS|WO_ISNULL))
139252
+ ){
139253
+ /* An "IS" term in the WHERE clause where the virtual table is the rhs
139254
+ ** of a LEFT JOIN. Do not pass this term to the virtual table
139255
+ ** implementation, as this can lead to incorrect results from SQL such
139256
+ ** as:
139257
+ **
139258
+ ** "LEFT JOIN vtab WHERE vtab.col IS NULL" */
139259
+ testcase( pTerm->eOperator & WO_ISNULL );
139260
+ testcase( pTerm->eOperator & WO_IS );
139261
+ continue;
139262
+ }
139202139263
assert( pTerm->u.leftColumn>=(-1) );
139203139264
pIdxCons[j].iColumn = pTerm->u.leftColumn;
139204139265
pIdxCons[j].iTermOffset = i;
139205139266
op = pTerm->eOperator & WO_ALL;
139206139267
if( op==WO_IN ) op = WO_EQ;
@@ -142502,10 +142563,11 @@
142502142563
WHERE_DISTINCTBY, nLoop-1, pFrom->aLoop[nLoop-1], &notUsed);
142503142564
if( rc==pWInfo->pResultSet->nExpr ){
142504142565
pWInfo->eDistinct = WHERE_DISTINCT_ORDERED;
142505142566
}
142506142567
}
142568
+ pWInfo->bOrderedInnerLoop = 0;
142507142569
if( pWInfo->pOrderBy ){
142508142570
if( pWInfo->wctrlFlags & WHERE_DISTINCTBY ){
142509142571
if( pFrom->isOrdered==pWInfo->pOrderBy->nExpr ){
142510142572
pWInfo->eDistinct = WHERE_DISTINCT_ORDERED;
142511142573
}
@@ -161029,11 +161091,11 @@
161029161091
*/
161030161092
static int fts3SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){
161031161093
int rc = SQLITE_OK;
161032161094
UNUSED_PARAMETER(iSavepoint);
161033161095
assert( ((Fts3Table *)pVtab)->inTransaction );
161034
- assert( ((Fts3Table *)pVtab)->mxSavepoint < iSavepoint );
161096
+ assert( ((Fts3Table *)pVtab)->mxSavepoint <= iSavepoint );
161035161097
TESTONLY( ((Fts3Table *)pVtab)->mxSavepoint = iSavepoint );
161036161098
if( ((Fts3Table *)pVtab)->bIgnoreSavepoint==0 ){
161037161099
rc = fts3SyncMethod(pVtab);
161038161100
}
161039161101
return rc;
@@ -214325,11 +214387,11 @@
214325214387
int nArg, /* Number of args */
214326214388
sqlite3_value **apUnused /* Function arguments */
214327214389
){
214328214390
assert( nArg==0 );
214329214391
UNUSED_PARAM2(nArg, apUnused);
214330
- sqlite3_result_text(pCtx, "fts5: 2018-09-06 18:56:36 91aab32e71fcb924e24c02d5f0901f7a474760fc993a7e7436e667512cf5d3c3", -1, SQLITE_TRANSIENT);
214392
+ sqlite3_result_text(pCtx, "fts5: 2018-09-10 16:38:25 564fa75195c5179d0bc86431aaff06136fc65ec63aa9839cd1114b1fbfac928b", -1, SQLITE_TRANSIENT);
214331214393
}
214332214394
214333214395
static int fts5Init(sqlite3 *db){
214334214396
static const sqlite3_module fts5Mod = {
214335214397
/* iVersion */ 2,
@@ -219035,12 +219097,12 @@
219035219097
}
219036219098
#endif /* SQLITE_CORE */
219037219099
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
219038219100
219039219101
/************** End of stmt.c ************************************************/
219040
-#if __LINE__!=219040
219102
+#if __LINE__!=219102
219041219103
#undef SQLITE_SOURCE_ID
219042
-#define SQLITE_SOURCE_ID "2018-09-06 18:56:36 91aab32e71fcb924e24c02d5f0901f7a474760fc993a7e7436e667512cf5alt2"
219104
+#define SQLITE_SOURCE_ID "2018-09-10 19:34:06 74c381b573817d0212153278b5ee5d2238a27a727dcf7ee769365c47bb9falt2"
219043219105
#endif
219044219106
/* Return the source-id for this library */
219045219107
SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
219046219108
/************************** End of sqlite3.c ******************************/
219047219109
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1156,11 +1156,11 @@
1156 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1157 ** [sqlite_version()] and [sqlite_source_id()].
1158 */
1159 #define SQLITE_VERSION "3.25.0"
1160 #define SQLITE_VERSION_NUMBER 3025000
1161 #define SQLITE_SOURCE_ID "2018-09-06 18:56:36 91aab32e71fcb924e24c02d5f0901f7a474760fc993a7e7436e667512cf5d3c3"
1162
1163 /*
1164 ** CAPI3REF: Run-Time Library Version Numbers
1165 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1166 **
@@ -18653,11 +18653,11 @@
18653 SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(Parse*,SrcList*,Expr*,ExprList*,ExprList*,u16,int);
18654 SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo*);
18655 SQLITE_PRIVATE LogEst sqlite3WhereOutputRowCount(WhereInfo*);
18656 SQLITE_PRIVATE int sqlite3WhereIsDistinct(WhereInfo*);
18657 SQLITE_PRIVATE int sqlite3WhereIsOrdered(WhereInfo*);
18658 SQLITE_PRIVATE int sqlite3WhereOrderedInnerLoop(WhereInfo*);
18659 SQLITE_PRIVATE int sqlite3WhereIsSorted(WhereInfo*);
18660 SQLITE_PRIVATE int sqlite3WhereContinueLabel(WhereInfo*);
18661 SQLITE_PRIVATE int sqlite3WhereBreakLabel(WhereInfo*);
18662 SQLITE_PRIVATE int sqlite3WhereOkOnePass(WhereInfo*, int*);
18663 #define ONEPASS_OFF 0 /* Use of ONEPASS not allowed */
@@ -35271,11 +35271,11 @@
35271 assert( unixFileMutexNotheld(pFile) );
35272 unixEnterMutex();
35273 if( pFile->pInode ){
35274 unixInodeInfo *pInode = pFile->pInode;
35275 sqlite3_mutex_enter(pInode->pLockMutex);
35276 if( pFile->pInode->nLock ){
35277 /* If there are outstanding locks, do not actually close the file just
35278 ** yet because that would clear those locks. Instead, add the file
35279 ** descriptor to pInode->aPending. It will be automatically closed when
35280 ** the last lock is cleared.
35281 */
@@ -88405,10 +88405,11 @@
88405 {
88406 zMaster = MASTER_NAME;
88407 initData.db = db;
88408 initData.iDb = pOp->p1;
88409 initData.pzErrMsg = &p->zErrMsg;
 
88410 zSql = sqlite3MPrintf(db,
88411 "SELECT name, rootpage, sql FROM '%q'.%s WHERE %s ORDER BY rowid",
88412 db->aDb[iDb].zDbSName, zMaster, pOp->p4.z);
88413 if( zSql==0 ){
88414 rc = SQLITE_NOMEM_BKPT;
@@ -102148,33 +102149,34 @@
102148 ** successful. Otherwise, return an SQLite error code and leave an error
102149 ** message in the Parse object.
102150 */
102151 static int renameResolveTrigger(Parse *pParse, const char *zDb){
102152 sqlite3 *db = pParse->db;
 
102153 TriggerStep *pStep;
102154 NameContext sNC;
102155 int rc = SQLITE_OK;
102156
102157 memset(&sNC, 0, sizeof(sNC));
102158 sNC.pParse = pParse;
102159 pParse->pTriggerTab = sqlite3FindTable(db, pParse->pNewTrigger->table, zDb);
102160 pParse->eTriggerOp = pParse->pNewTrigger->op;
 
 
 
102161
102162 /* Resolve symbols in WHEN clause */
102163 if( pParse->pNewTrigger->pWhen ){
102164 rc = sqlite3ResolveExprNames(&sNC, pParse->pNewTrigger->pWhen);
102165 }
102166
102167 for(pStep=pParse->pNewTrigger->step_list;
102168 rc==SQLITE_OK && pStep;
102169 pStep=pStep->pNext
102170 ){
102171 if( pStep->pSelect ){
102172 sqlite3SelectPrep(pParse, pStep->pSelect, &sNC);
102173 if( pParse->nErr ) rc = pParse->rc;
102174 }
102175 if( rc==SQLITE_OK && pStep->zTarget ){
102176 Table *pTarget = sqlite3LocateTable(pParse, 0, pStep->zTarget, zDb);
102177 if( pTarget==0 ){
102178 rc = SQLITE_ERROR;
102179 }else{
102180 SrcList sSrc;
@@ -102534,14 +102536,16 @@
102534 if( sParse.nErr ) rc = sParse.rc;
102535 sqlite3WalkSelect(&sWalker, pTab->pSelect);
102536 }else{
102537 /* Modify any FK definitions to point to the new table. */
102538 #ifndef SQLITE_OMIT_FOREIGN_KEY
102539 FKey *pFKey;
102540 for(pFKey=pTab->pFKey; pFKey; pFKey=pFKey->pNextFrom){
102541 if( sqlite3_stricmp(pFKey->zTo, zOld)==0 ){
102542 renameTokenFind(&sParse, &sCtx, (void*)pFKey->zTo);
 
 
102543 }
102544 }
102545 #endif
102546
102547 /* If this is the table being altered, fix any table refs in CHECK
@@ -109502,12 +109506,14 @@
109502 if( p==0 ){
109503 goto append_from_error;
109504 }
109505 assert( p->nSrc>0 );
109506 pItem = &p->a[p->nSrc-1];
 
 
109507 if( IN_RENAME_OBJECT && pItem->zName ){
109508 Token *pToken = (pDatabase && pDatabase->z) ? pDatabase : pTable;
109509 sqlite3RenameTokenMap(pParse, pItem->zName, pToken);
109510 }
109511 assert( pAlias!=0 );
109512 if( pAlias->n ){
109513 pItem->zAlias = sqlite3NameFromToken(db, pAlias);
@@ -117881,10 +117887,16 @@
117881 void (*str_appendchar)(sqlite3_str*, int N, char C);
117882 void (*str_reset)(sqlite3_str*);
117883 int (*str_errcode)(sqlite3_str*);
117884 int (*str_length)(sqlite3_str*);
117885 char *(*str_value)(sqlite3_str*);
 
 
 
 
 
 
117886 };
117887
117888 /*
117889 ** This is the function signature used for all extension entry points. It
117890 ** is also defined in the file "loadext.c".
@@ -118166,10 +118178,12 @@
118166 #define sqlite3_str_appendchar sqlite3_api->str_appendchar
118167 #define sqlite3_str_reset sqlite3_api->str_reset
118168 #define sqlite3_str_errcode sqlite3_api->str_errcode
118169 #define sqlite3_str_length sqlite3_api->str_length
118170 #define sqlite3_str_value sqlite3_api->str_value
 
 
118171 #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
118172
118173 #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
118174 /* This case when the file really is being compiled as a loadable
118175 ** extension */
@@ -118619,11 +118633,13 @@
118619 sqlite3_str_appendall,
118620 sqlite3_str_appendchar,
118621 sqlite3_str_reset,
118622 sqlite3_str_errcode,
118623 sqlite3_str_length,
118624 sqlite3_str_value
 
 
118625 };
118626
118627 /*
118628 ** Attempt to load an SQLite extension library contained in the file
118629 ** zFile. The entry point is zProc. zProc may be 0 in which case a
@@ -123117,12 +123133,12 @@
123117 int iECursor; /* Cursor number for the sorter */
123118 int regReturn; /* Register holding block-output return address */
123119 int labelBkOut; /* Start label for the block-output subroutine */
123120 int addrSortIndex; /* Address of the OP_SorterOpen or OP_OpenEphemeral */
123121 int labelDone; /* Jump here when done, ex: LIMIT reached */
 
123122 u8 sortFlags; /* Zero or more SORTFLAG_* bits */
123123 u8 bOrderedInnerLoop; /* ORDER BY correctly sorts the inner loop */
123124 #ifdef SQLITE_ENABLE_SORTER_REFERENCES
123125 u8 nDefer; /* Number of valid entries in aDefer[] */
123126 struct DeferredCsr {
123127 Table *pTab; /* Table definition */
123128 int iCsr; /* Cursor number for table */
@@ -123742,14 +123758,14 @@
123742 ** are already LIMIT+OFFSET items in the sorter, delete the largest
123743 ** entry before inserting the new one. This way there are never more
123744 ** than LIMIT+OFFSET items in the sorter.
123745 **
123746 ** If the new record does not need to be inserted into the sorter,
123747 ** jump to the next iteration of the loop. Or, if the
123748 ** pSort->bOrderedInnerLoop flag is set to indicate that the inner
123749 ** loop delivers items in sorted order, jump to the next iteration
123750 ** of the outer loop.
123751 */
123752 int iCsr = pSort->iECursor;
123753 sqlite3VdbeAddOp2(v, OP_IfNotZero, iLimit, sqlite3VdbeCurrentAddr(v)+4);
123754 VdbeCoverage(v);
123755 sqlite3VdbeAddOp2(v, OP_Last, iCsr, 0);
@@ -123767,13 +123783,12 @@
123767 op = OP_IdxInsert;
123768 }
123769 sqlite3VdbeAddOp4Int(v, op, pSort->iECursor, regRecord,
123770 regBase+nOBSat, nBase-nOBSat);
123771 if( iSkip ){
123772 assert( pSort->bOrderedInnerLoop==0 || pSort->bOrderedInnerLoop==1 );
123773 sqlite3VdbeChangeP2(v, iSkip,
123774 sqlite3VdbeCurrentAddr(v) + pSort->bOrderedInnerLoop);
123775 }
123776 }
123777
123778 /*
123779 ** Add code to implement the OFFSET
@@ -129109,11 +129124,11 @@
129109 if( sDistinct.isTnct && sqlite3WhereIsDistinct(pWInfo) ){
129110 sDistinct.eTnctType = sqlite3WhereIsDistinct(pWInfo);
129111 }
129112 if( sSort.pOrderBy ){
129113 sSort.nOBSat = sqlite3WhereIsOrdered(pWInfo);
129114 sSort.bOrderedInnerLoop = sqlite3WhereOrderedInnerLoop(pWInfo);
129115 if( sSort.nOBSat==sSort.pOrderBy->nExpr ){
129116 sSort.pOrderBy = 0;
129117 }
129118 }
129119
@@ -135312,11 +135327,11 @@
135312 ** an access of the index rather than the original table.
135313 */
135314 static int codeCursorHintFixExpr(Walker *pWalker, Expr *pExpr){
135315 int rc = WRC_Continue;
135316 struct CCurHint *pHint = pWalker->u.pCCurHint;
135317 if( pExpr->op==TK_COLUMN && !ExprHasProperty(pExpr, EP_FixedCol) ){
135318 if( pExpr->iTable!=pHint->iTabCur ){
135319 Vdbe *v = pWalker->pParse->pVdbe;
135320 int reg = ++pWalker->pParse->nMem; /* Register for column value */
135321 sqlite3ExprCodeGetColumnOfTable(
135322 v, pExpr->pTab, pExpr->iTable, pExpr->iColumn, reg
@@ -136899,27 +136914,10 @@
136899 }else if( op==TK_STRING ){
136900 z = (u8*)pRight->u.zToken;
136901 }
136902 if( z ){
136903
136904 /* If the RHS begins with a digit or a minus sign, then the LHS must
136905 ** be an ordinary column (not a virtual table column) with TEXT affinity.
136906 ** Otherwise the LHS might be numeric and "lhs >= rhs" would be false
136907 ** even though "lhs LIKE rhs" is true. But if the RHS does not start
136908 ** with a digit or '-', then "lhs LIKE rhs" will always be false if
136909 ** the LHS is numeric and so the optimization still works.
136910 */
136911 if( sqlite3Isdigit(z[0]) || z[0]=='-' ){
136912 if( pLeft->op!=TK_COLUMN
136913 || sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT
136914 || IsVirtual(pLeft->pTab) /* Value might be numeric */
136915 ){
136916 sqlite3ValueFree(pVal);
136917 return 0;
136918 }
136919 }
136920
136921 /* Count the number of prefix characters prior to the first wildcard */
136922 cnt = 0;
136923 while( (c=z[cnt])!=0 && c!=wc[0] && c!=wc[1] && c!=wc[2] ){
136924 cnt++;
136925 if( c==wc[3] && z[cnt]!=0 ) cnt++;
@@ -136948,10 +136946,36 @@
136948 for(iFrom=iTo=0; iFrom<cnt; iFrom++){
136949 if( zNew[iFrom]==wc[3] ) iFrom++;
136950 zNew[iTo++] = zNew[iFrom];
136951 }
136952 zNew[iTo] = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136953 }
136954 *ppPrefix = pPrefix;
136955
136956 /* If the RHS pattern is a bound parameter, make arrangements to
136957 ** reprepare the statement when that parameter is rebound */
@@ -138321,19 +138345,42 @@
138321 SQLITE_PRIVATE int sqlite3WhereIsOrdered(WhereInfo *pWInfo){
138322 return pWInfo->nOBSat;
138323 }
138324
138325 /*
138326 ** Return TRUE if the innermost loop of the WHERE clause implementation
138327 ** returns rows in ORDER BY order for complete run of the inner loop.
 
 
 
 
138328 **
138329 ** Across multiple iterations of outer loops, the output rows need not be
138330 ** sorted. As long as rows are sorted for just the innermost loop, this
138331 ** routine can return TRUE.
 
 
 
 
 
 
 
 
 
 
 
138332 */
138333 SQLITE_PRIVATE int sqlite3WhereOrderedInnerLoop(WhereInfo *pWInfo){
138334 return pWInfo->bOrderedInnerLoop;
 
 
 
 
 
 
 
 
138335 }
138336
138337 /*
138338 ** Return the VDBE address or label to jump to in order to continue
138339 ** immediately with the next row of a WHERE clause.
@@ -139197,10 +139244,24 @@
139197 testcase( pTerm->eOperator & WO_IS );
139198 testcase( pTerm->eOperator & WO_ISNULL );
139199 testcase( pTerm->eOperator & WO_ALL );
139200 if( (pTerm->eOperator & ~(WO_EQUIV))==0 ) continue;
139201 if( pTerm->wtFlags & TERM_VNULL ) continue;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139202 assert( pTerm->u.leftColumn>=(-1) );
139203 pIdxCons[j].iColumn = pTerm->u.leftColumn;
139204 pIdxCons[j].iTermOffset = i;
139205 op = pTerm->eOperator & WO_ALL;
139206 if( op==WO_IN ) op = WO_EQ;
@@ -142502,10 +142563,11 @@
142502 WHERE_DISTINCTBY, nLoop-1, pFrom->aLoop[nLoop-1], &notUsed);
142503 if( rc==pWInfo->pResultSet->nExpr ){
142504 pWInfo->eDistinct = WHERE_DISTINCT_ORDERED;
142505 }
142506 }
 
142507 if( pWInfo->pOrderBy ){
142508 if( pWInfo->wctrlFlags & WHERE_DISTINCTBY ){
142509 if( pFrom->isOrdered==pWInfo->pOrderBy->nExpr ){
142510 pWInfo->eDistinct = WHERE_DISTINCT_ORDERED;
142511 }
@@ -161029,11 +161091,11 @@
161029 */
161030 static int fts3SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){
161031 int rc = SQLITE_OK;
161032 UNUSED_PARAMETER(iSavepoint);
161033 assert( ((Fts3Table *)pVtab)->inTransaction );
161034 assert( ((Fts3Table *)pVtab)->mxSavepoint < iSavepoint );
161035 TESTONLY( ((Fts3Table *)pVtab)->mxSavepoint = iSavepoint );
161036 if( ((Fts3Table *)pVtab)->bIgnoreSavepoint==0 ){
161037 rc = fts3SyncMethod(pVtab);
161038 }
161039 return rc;
@@ -214325,11 +214387,11 @@
214325 int nArg, /* Number of args */
214326 sqlite3_value **apUnused /* Function arguments */
214327 ){
214328 assert( nArg==0 );
214329 UNUSED_PARAM2(nArg, apUnused);
214330 sqlite3_result_text(pCtx, "fts5: 2018-09-06 18:56:36 91aab32e71fcb924e24c02d5f0901f7a474760fc993a7e7436e667512cf5d3c3", -1, SQLITE_TRANSIENT);
214331 }
214332
214333 static int fts5Init(sqlite3 *db){
214334 static const sqlite3_module fts5Mod = {
214335 /* iVersion */ 2,
@@ -219035,12 +219097,12 @@
219035 }
219036 #endif /* SQLITE_CORE */
219037 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
219038
219039 /************** End of stmt.c ************************************************/
219040 #if __LINE__!=219040
219041 #undef SQLITE_SOURCE_ID
219042 #define SQLITE_SOURCE_ID "2018-09-06 18:56:36 91aab32e71fcb924e24c02d5f0901f7a474760fc993a7e7436e667512cf5alt2"
219043 #endif
219044 /* Return the source-id for this library */
219045 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
219046 /************************** End of sqlite3.c ******************************/
219047
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1156,11 +1156,11 @@
1156 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1157 ** [sqlite_version()] and [sqlite_source_id()].
1158 */
1159 #define SQLITE_VERSION "3.25.0"
1160 #define SQLITE_VERSION_NUMBER 3025000
1161 #define SQLITE_SOURCE_ID "2018-09-10 19:34:06 74c381b573817d0212153278b5ee5d2238a27a727dcf7ee769365c47bb9fc40d"
1162
1163 /*
1164 ** CAPI3REF: Run-Time Library Version Numbers
1165 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1166 **
@@ -18653,11 +18653,11 @@
18653 SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(Parse*,SrcList*,Expr*,ExprList*,ExprList*,u16,int);
18654 SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo*);
18655 SQLITE_PRIVATE LogEst sqlite3WhereOutputRowCount(WhereInfo*);
18656 SQLITE_PRIVATE int sqlite3WhereIsDistinct(WhereInfo*);
18657 SQLITE_PRIVATE int sqlite3WhereIsOrdered(WhereInfo*);
18658 SQLITE_PRIVATE int sqlite3WhereOrderByLimitOptLabel(WhereInfo*);
18659 SQLITE_PRIVATE int sqlite3WhereIsSorted(WhereInfo*);
18660 SQLITE_PRIVATE int sqlite3WhereContinueLabel(WhereInfo*);
18661 SQLITE_PRIVATE int sqlite3WhereBreakLabel(WhereInfo*);
18662 SQLITE_PRIVATE int sqlite3WhereOkOnePass(WhereInfo*, int*);
18663 #define ONEPASS_OFF 0 /* Use of ONEPASS not allowed */
@@ -35271,11 +35271,11 @@
35271 assert( unixFileMutexNotheld(pFile) );
35272 unixEnterMutex();
35273 if( pFile->pInode ){
35274 unixInodeInfo *pInode = pFile->pInode;
35275 sqlite3_mutex_enter(pInode->pLockMutex);
35276 if( pInode->nLock ){
35277 /* If there are outstanding locks, do not actually close the file just
35278 ** yet because that would clear those locks. Instead, add the file
35279 ** descriptor to pInode->aPending. It will be automatically closed when
35280 ** the last lock is cleared.
35281 */
@@ -88405,10 +88405,11 @@
88405 {
88406 zMaster = MASTER_NAME;
88407 initData.db = db;
88408 initData.iDb = pOp->p1;
88409 initData.pzErrMsg = &p->zErrMsg;
88410 initData.mInitFlags = 0;
88411 zSql = sqlite3MPrintf(db,
88412 "SELECT name, rootpage, sql FROM '%q'.%s WHERE %s ORDER BY rowid",
88413 db->aDb[iDb].zDbSName, zMaster, pOp->p4.z);
88414 if( zSql==0 ){
88415 rc = SQLITE_NOMEM_BKPT;
@@ -102148,33 +102149,34 @@
102149 ** successful. Otherwise, return an SQLite error code and leave an error
102150 ** message in the Parse object.
102151 */
102152 static int renameResolveTrigger(Parse *pParse, const char *zDb){
102153 sqlite3 *db = pParse->db;
102154 Trigger *pNew = pParse->pNewTrigger;
102155 TriggerStep *pStep;
102156 NameContext sNC;
102157 int rc = SQLITE_OK;
102158
102159 memset(&sNC, 0, sizeof(sNC));
102160 sNC.pParse = pParse;
102161 assert( pNew->pTabSchema );
102162 pParse->pTriggerTab = sqlite3FindTable(db, pNew->table,
102163 db->aDb[sqlite3SchemaToIndex(db, pNew->pTabSchema)].zDbSName
102164 );
102165 pParse->eTriggerOp = pNew->op;
102166
102167 /* Resolve symbols in WHEN clause */
102168 if( pNew->pWhen ){
102169 rc = sqlite3ResolveExprNames(&sNC, pNew->pWhen);
102170 }
102171
102172 for(pStep=pNew->step_list; rc==SQLITE_OK && pStep; pStep=pStep->pNext){
 
 
 
102173 if( pStep->pSelect ){
102174 sqlite3SelectPrep(pParse, pStep->pSelect, &sNC);
102175 if( pParse->nErr ) rc = pParse->rc;
102176 }
102177 if( rc==SQLITE_OK && pStep->zTarget ){
102178 Table *pTarget = sqlite3LocateTable(pParse, 0, pStep->zTarget, zDb);
102179 if( pTarget==0 ){
102180 rc = SQLITE_ERROR;
102181 }else{
102182 SrcList sSrc;
@@ -102534,14 +102536,16 @@
102536 if( sParse.nErr ) rc = sParse.rc;
102537 sqlite3WalkSelect(&sWalker, pTab->pSelect);
102538 }else{
102539 /* Modify any FK definitions to point to the new table. */
102540 #ifndef SQLITE_OMIT_FOREIGN_KEY
102541 if( db->flags & SQLITE_ForeignKeys ){
102542 FKey *pFKey;
102543 for(pFKey=pTab->pFKey; pFKey; pFKey=pFKey->pNextFrom){
102544 if( sqlite3_stricmp(pFKey->zTo, zOld)==0 ){
102545 renameTokenFind(&sParse, &sCtx, (void*)pFKey->zTo);
102546 }
102547 }
102548 }
102549 #endif
102550
102551 /* If this is the table being altered, fix any table refs in CHECK
@@ -109502,12 +109506,14 @@
109506 if( p==0 ){
109507 goto append_from_error;
109508 }
109509 assert( p->nSrc>0 );
109510 pItem = &p->a[p->nSrc-1];
109511 assert( (pTable==0)==(pDatabase==0) );
109512 assert( pItem->zName==0 || pDatabase!=0 );
109513 if( IN_RENAME_OBJECT && pItem->zName ){
109514 Token *pToken = (ALWAYS(pDatabase) && pDatabase->z) ? pDatabase : pTable;
109515 sqlite3RenameTokenMap(pParse, pItem->zName, pToken);
109516 }
109517 assert( pAlias!=0 );
109518 if( pAlias->n ){
109519 pItem->zAlias = sqlite3NameFromToken(db, pAlias);
@@ -117881,10 +117887,16 @@
117887 void (*str_appendchar)(sqlite3_str*, int N, char C);
117888 void (*str_reset)(sqlite3_str*);
117889 int (*str_errcode)(sqlite3_str*);
117890 int (*str_length)(sqlite3_str*);
117891 char *(*str_value)(sqlite3_str*);
117892 int (*create_window_function)(sqlite3*,const char*,int,int,void*,
117893 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
117894 void (*xFinal)(sqlite3_context*),
117895 void (*xValue)(sqlite3_context*),
117896 void (*xInv)(sqlite3_context*,int,sqlite3_value**),
117897 void(*xDestroy)(void*));
117898 };
117899
117900 /*
117901 ** This is the function signature used for all extension entry points. It
117902 ** is also defined in the file "loadext.c".
@@ -118166,10 +118178,12 @@
118178 #define sqlite3_str_appendchar sqlite3_api->str_appendchar
118179 #define sqlite3_str_reset sqlite3_api->str_reset
118180 #define sqlite3_str_errcode sqlite3_api->str_errcode
118181 #define sqlite3_str_length sqlite3_api->str_length
118182 #define sqlite3_str_value sqlite3_api->str_value
118183 /* Version 3.25.0 and later */
118184 #define sqlite3_create_window_function sqlite3_api->create_window_function
118185 #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
118186
118187 #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
118188 /* This case when the file really is being compiled as a loadable
118189 ** extension */
@@ -118619,11 +118633,13 @@
118633 sqlite3_str_appendall,
118634 sqlite3_str_appendchar,
118635 sqlite3_str_reset,
118636 sqlite3_str_errcode,
118637 sqlite3_str_length,
118638 sqlite3_str_value,
118639 /* Version 3.25.0 and later */
118640 sqlite3_create_window_function
118641 };
118642
118643 /*
118644 ** Attempt to load an SQLite extension library contained in the file
118645 ** zFile. The entry point is zProc. zProc may be 0 in which case a
@@ -123117,12 +123133,12 @@
123133 int iECursor; /* Cursor number for the sorter */
123134 int regReturn; /* Register holding block-output return address */
123135 int labelBkOut; /* Start label for the block-output subroutine */
123136 int addrSortIndex; /* Address of the OP_SorterOpen or OP_OpenEphemeral */
123137 int labelDone; /* Jump here when done, ex: LIMIT reached */
123138 int labelOBLopt; /* Jump here when sorter is full */
123139 u8 sortFlags; /* Zero or more SORTFLAG_* bits */
 
123140 #ifdef SQLITE_ENABLE_SORTER_REFERENCES
123141 u8 nDefer; /* Number of valid entries in aDefer[] */
123142 struct DeferredCsr {
123143 Table *pTab; /* Table definition */
123144 int iCsr; /* Cursor number for table */
@@ -123742,14 +123758,14 @@
123758 ** are already LIMIT+OFFSET items in the sorter, delete the largest
123759 ** entry before inserting the new one. This way there are never more
123760 ** than LIMIT+OFFSET items in the sorter.
123761 **
123762 ** If the new record does not need to be inserted into the sorter,
123763 ** jump to the next iteration of the loop. If the pSort->labelOBLopt
123764 ** value is not zero, then it is a label of where to jump. Otherwise,
123765 ** just bypass the row insert logic. See the header comment on the
123766 ** sqlite3WhereOrderByLimitOptLabel() function for additional info.
123767 */
123768 int iCsr = pSort->iECursor;
123769 sqlite3VdbeAddOp2(v, OP_IfNotZero, iLimit, sqlite3VdbeCurrentAddr(v)+4);
123770 VdbeCoverage(v);
123771 sqlite3VdbeAddOp2(v, OP_Last, iCsr, 0);
@@ -123767,13 +123783,12 @@
123783 op = OP_IdxInsert;
123784 }
123785 sqlite3VdbeAddOp4Int(v, op, pSort->iECursor, regRecord,
123786 regBase+nOBSat, nBase-nOBSat);
123787 if( iSkip ){
 
123788 sqlite3VdbeChangeP2(v, iSkip,
123789 pSort->labelOBLopt ? pSort->labelOBLopt : sqlite3VdbeCurrentAddr(v));
123790 }
123791 }
123792
123793 /*
123794 ** Add code to implement the OFFSET
@@ -129109,11 +129124,11 @@
129124 if( sDistinct.isTnct && sqlite3WhereIsDistinct(pWInfo) ){
129125 sDistinct.eTnctType = sqlite3WhereIsDistinct(pWInfo);
129126 }
129127 if( sSort.pOrderBy ){
129128 sSort.nOBSat = sqlite3WhereIsOrdered(pWInfo);
129129 sSort.labelOBLopt = sqlite3WhereOrderByLimitOptLabel(pWInfo);
129130 if( sSort.nOBSat==sSort.pOrderBy->nExpr ){
129131 sSort.pOrderBy = 0;
129132 }
129133 }
129134
@@ -135312,11 +135327,11 @@
135327 ** an access of the index rather than the original table.
135328 */
135329 static int codeCursorHintFixExpr(Walker *pWalker, Expr *pExpr){
135330 int rc = WRC_Continue;
135331 struct CCurHint *pHint = pWalker->u.pCCurHint;
135332 if( pExpr->op==TK_COLUMN ){
135333 if( pExpr->iTable!=pHint->iTabCur ){
135334 Vdbe *v = pWalker->pParse->pVdbe;
135335 int reg = ++pWalker->pParse->nMem; /* Register for column value */
135336 sqlite3ExprCodeGetColumnOfTable(
135337 v, pExpr->pTab, pExpr->iTable, pExpr->iColumn, reg
@@ -136899,27 +136914,10 @@
136914 }else if( op==TK_STRING ){
136915 z = (u8*)pRight->u.zToken;
136916 }
136917 if( z ){
136918
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136919 /* Count the number of prefix characters prior to the first wildcard */
136920 cnt = 0;
136921 while( (c=z[cnt])!=0 && c!=wc[0] && c!=wc[1] && c!=wc[2] ){
136922 cnt++;
136923 if( c==wc[3] && z[cnt]!=0 ) cnt++;
@@ -136948,10 +136946,36 @@
136946 for(iFrom=iTo=0; iFrom<cnt; iFrom++){
136947 if( zNew[iFrom]==wc[3] ) iFrom++;
136948 zNew[iTo++] = zNew[iFrom];
136949 }
136950 zNew[iTo] = 0;
136951
136952 /* If the RHS begins with a digit or a minus sign, then the LHS must be
136953 ** an ordinary column (not a virtual table column) with TEXT affinity.
136954 ** Otherwise the LHS might be numeric and "lhs >= rhs" would be false
136955 ** even though "lhs LIKE rhs" is true. But if the RHS does not start
136956 ** with a digit or '-', then "lhs LIKE rhs" will always be false if
136957 ** the LHS is numeric and so the optimization still works.
136958 **
136959 ** 2018-09-10 ticket c94369cae9b561b1f996d0054bfab11389f9d033
136960 ** The RHS pattern must not be '/%' because the termination condition
136961 ** will then become "x<'0'" and if the affinity is numeric, will then
136962 ** be converted into "x<0", which is incorrect.
136963 */
136964 if( sqlite3Isdigit(zNew[0])
136965 || zNew[0]=='-'
136966 || (zNew[0]+1=='0' && iTo==1)
136967 ){
136968 if( pLeft->op!=TK_COLUMN
136969 || sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT
136970 || IsVirtual(pLeft->pTab) /* Value might be numeric */
136971 ){
136972 sqlite3ExprDelete(db, pPrefix);
136973 sqlite3ValueFree(pVal);
136974 return 0;
136975 }
136976 }
136977 }
136978 *ppPrefix = pPrefix;
136979
136980 /* If the RHS pattern is a bound parameter, make arrangements to
136981 ** reprepare the statement when that parameter is rebound */
@@ -138321,19 +138345,42 @@
138345 SQLITE_PRIVATE int sqlite3WhereIsOrdered(WhereInfo *pWInfo){
138346 return pWInfo->nOBSat;
138347 }
138348
138349 /*
138350 ** In the ORDER BY LIMIT optimization, if the inner-most loop is known
138351 ** to emit rows in increasing order, and if the last row emitted by the
138352 ** inner-most loop did not fit within the sorter, then we can skip all
138353 ** subsequent rows for the current iteration of the inner loop (because they
138354 ** will not fit in the sorter either) and continue with the second inner
138355 ** loop - the loop immediately outside the inner-most.
138356 **
138357 ** When a row does not fit in the sorter (because the sorter already
138358 ** holds LIMIT+OFFSET rows that are smaller), then a jump is made to the
138359 ** label returned by this function.
138360 **
138361 ** If the ORDER BY LIMIT optimization applies, the jump destination should
138362 ** be the continuation for the second-inner-most loop. If the ORDER BY
138363 ** LIMIT optimization does not apply, then the jump destination should
138364 ** be the continuation for the inner-most loop.
138365 **
138366 ** It is always safe for this routine to return the continuation of the
138367 ** inner-most loop, in the sense that a correct answer will result.
138368 ** Returning the continuation the second inner loop is an optimization
138369 ** that might make the code run a little faster, but should not change
138370 ** the final answer.
138371 */
138372 SQLITE_PRIVATE int sqlite3WhereOrderByLimitOptLabel(WhereInfo *pWInfo){
138373 WhereLevel *pInner;
138374 if( !pWInfo->bOrderedInnerLoop ){
138375 /* The ORDER BY LIMIT optimization does not apply. Jump to the
138376 ** continuation of the inner-most loop. */
138377 return pWInfo->iContinue;
138378 }
138379 pInner = &pWInfo->a[pWInfo->nLevel-1];
138380 assert( pInner->addrNxt!=0 );
138381 return pInner->addrNxt;
138382 }
138383
138384 /*
138385 ** Return the VDBE address or label to jump to in order to continue
138386 ** immediately with the next row of a WHERE clause.
@@ -139197,10 +139244,24 @@
139244 testcase( pTerm->eOperator & WO_IS );
139245 testcase( pTerm->eOperator & WO_ISNULL );
139246 testcase( pTerm->eOperator & WO_ALL );
139247 if( (pTerm->eOperator & ~(WO_EQUIV))==0 ) continue;
139248 if( pTerm->wtFlags & TERM_VNULL ) continue;
139249 if( (pSrc->fg.jointype & JT_LEFT)!=0
139250 && !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
139251 && (pTerm->eOperator & (WO_IS|WO_ISNULL))
139252 ){
139253 /* An "IS" term in the WHERE clause where the virtual table is the rhs
139254 ** of a LEFT JOIN. Do not pass this term to the virtual table
139255 ** implementation, as this can lead to incorrect results from SQL such
139256 ** as:
139257 **
139258 ** "LEFT JOIN vtab WHERE vtab.col IS NULL" */
139259 testcase( pTerm->eOperator & WO_ISNULL );
139260 testcase( pTerm->eOperator & WO_IS );
139261 continue;
139262 }
139263 assert( pTerm->u.leftColumn>=(-1) );
139264 pIdxCons[j].iColumn = pTerm->u.leftColumn;
139265 pIdxCons[j].iTermOffset = i;
139266 op = pTerm->eOperator & WO_ALL;
139267 if( op==WO_IN ) op = WO_EQ;
@@ -142502,10 +142563,11 @@
142563 WHERE_DISTINCTBY, nLoop-1, pFrom->aLoop[nLoop-1], &notUsed);
142564 if( rc==pWInfo->pResultSet->nExpr ){
142565 pWInfo->eDistinct = WHERE_DISTINCT_ORDERED;
142566 }
142567 }
142568 pWInfo->bOrderedInnerLoop = 0;
142569 if( pWInfo->pOrderBy ){
142570 if( pWInfo->wctrlFlags & WHERE_DISTINCTBY ){
142571 if( pFrom->isOrdered==pWInfo->pOrderBy->nExpr ){
142572 pWInfo->eDistinct = WHERE_DISTINCT_ORDERED;
142573 }
@@ -161029,11 +161091,11 @@
161091 */
161092 static int fts3SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){
161093 int rc = SQLITE_OK;
161094 UNUSED_PARAMETER(iSavepoint);
161095 assert( ((Fts3Table *)pVtab)->inTransaction );
161096 assert( ((Fts3Table *)pVtab)->mxSavepoint <= iSavepoint );
161097 TESTONLY( ((Fts3Table *)pVtab)->mxSavepoint = iSavepoint );
161098 if( ((Fts3Table *)pVtab)->bIgnoreSavepoint==0 ){
161099 rc = fts3SyncMethod(pVtab);
161100 }
161101 return rc;
@@ -214325,11 +214387,11 @@
214387 int nArg, /* Number of args */
214388 sqlite3_value **apUnused /* Function arguments */
214389 ){
214390 assert( nArg==0 );
214391 UNUSED_PARAM2(nArg, apUnused);
214392 sqlite3_result_text(pCtx, "fts5: 2018-09-10 16:38:25 564fa75195c5179d0bc86431aaff06136fc65ec63aa9839cd1114b1fbfac928b", -1, SQLITE_TRANSIENT);
214393 }
214394
214395 static int fts5Init(sqlite3 *db){
214396 static const sqlite3_module fts5Mod = {
214397 /* iVersion */ 2,
@@ -219035,12 +219097,12 @@
219097 }
219098 #endif /* SQLITE_CORE */
219099 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
219100
219101 /************** End of stmt.c ************************************************/
219102 #if __LINE__!=219102
219103 #undef SQLITE_SOURCE_ID
219104 #define SQLITE_SOURCE_ID "2018-09-10 19:34:06 74c381b573817d0212153278b5ee5d2238a27a727dcf7ee769365c47bb9falt2"
219105 #endif
219106 /* Return the source-id for this library */
219107 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
219108 /************************** End of sqlite3.c ******************************/
219109
+1 -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.25.0"
127127
#define SQLITE_VERSION_NUMBER 3025000
128
-#define SQLITE_SOURCE_ID "2018-09-06 18:56:36 91aab32e71fcb924e24c02d5f0901f7a474760fc993a7e7436e667512cf5d3c3"
128
+#define SQLITE_SOURCE_ID "2018-09-10 19:34:06 74c381b573817d0212153278b5ee5d2238a27a727dcf7ee769365c47bb9fc40d"
129129
130130
/*
131131
** CAPI3REF: Run-Time Library Version Numbers
132132
** KEYWORDS: sqlite3_version sqlite3_sourceid
133133
**
134134
--- 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.25.0"
127 #define SQLITE_VERSION_NUMBER 3025000
128 #define SQLITE_SOURCE_ID "2018-09-06 18:56:36 91aab32e71fcb924e24c02d5f0901f7a474760fc993a7e7436e667512cf5d3c3"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
134
--- 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.25.0"
127 #define SQLITE_VERSION_NUMBER 3025000
128 #define SQLITE_SOURCE_ID "2018-09-10 19:34:06 74c381b573817d0212153278b5ee5d2238a27a727dcf7ee769365c47bb9fc40d"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
134

Keyboard Shortcuts

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