Fossil SCM

Update the built-in SQLite to the latest 3.35 alpha for testing.

drh 2021-01-27 19:50 trunk
Commit 8f8b6e33cd5a19a9989f2db40756cfe555090d9238a83ab831fd9cfade89d740
2 files changed +220 -240 +1 -1
+220 -240
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1186,11 +1186,11 @@
11861186
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
11871187
** [sqlite_version()] and [sqlite_source_id()].
11881188
*/
11891189
#define SQLITE_VERSION "3.35.0"
11901190
#define SQLITE_VERSION_NUMBER 3035000
1191
-#define SQLITE_SOURCE_ID "2021-01-18 12:35:16 c1862abb44873f06ec0d772469d8a2d128ae4670b1e98c2d97b0e2da18df9a04"
1191
+#define SQLITE_SOURCE_ID "2021-01-27 19:15:06 9dc7fc9f04d5c14fc436e5ff5b4c06c1969ddde5857ebeb5dccd59b7c748c339"
11921192
11931193
/*
11941194
** CAPI3REF: Run-Time Library Version Numbers
11951195
** KEYWORDS: sqlite3_version sqlite3_sourceid
11961196
**
@@ -14758,10 +14758,11 @@
1475814758
typedef struct AutoincInfo AutoincInfo;
1475914759
typedef struct Bitvec Bitvec;
1476014760
typedef struct CollSeq CollSeq;
1476114761
typedef struct Column Column;
1476214762
typedef struct Db Db;
14763
+typedef struct DbFixer DbFixer;
1476314764
typedef struct Schema Schema;
1476414765
typedef struct Expr Expr;
1476514766
typedef struct ExprList ExprList;
1476614767
typedef struct FKey FKey;
1476714768
typedef struct FuncDestructor FuncDestructor;
@@ -19102,25 +19103,10 @@
1910219103
char *zSpan; /* Original SQL text of this command */
1910319104
TriggerStep *pNext; /* Next in the link-list */
1910419105
TriggerStep *pLast; /* Last element in link-list. Valid for 1st elem only */
1910519106
};
1910619107
19107
-/*
19108
-** The following structure contains information used by the sqliteFix...
19109
-** routines as they walk the parse tree to make database references
19110
-** explicit.
19111
-*/
19112
-typedef struct DbFixer DbFixer;
19113
-struct DbFixer {
19114
- Parse *pParse; /* The parsing context. Error messages written here */
19115
- Schema *pSchema; /* Fix items to this schema */
19116
- u8 bTemp; /* True for TEMP schema entries */
19117
- const char *zDb; /* Make sure all objects are contained in this database */
19118
- const char *zType; /* Type of the container - used for error messages */
19119
- const Token *pName; /* Name of the container - used for error messages */
19120
-};
19121
-
1912219108
/*
1912319109
** An objected used to accumulate the text of a string where we
1912419110
** do not necessarily know how big the string will be in the end.
1912519111
*/
1912619112
struct sqlite3_str {
@@ -19267,12 +19253,28 @@
1926719253
struct WindowRewrite *pRewrite; /* Window rewrite context */
1926819254
struct WhereConst *pConst; /* WHERE clause constants */
1926919255
struct RenameCtx *pRename; /* RENAME COLUMN context */
1927019256
struct Table *pTab; /* Table of generated column */
1927119257
struct SrcList_item *pSrcItem; /* A single FROM clause item */
19258
+ DbFixer *pFix;
1927219259
} u;
1927319260
};
19261
+
19262
+/*
19263
+** The following structure contains information used by the sqliteFix...
19264
+** routines as they walk the parse tree to make database references
19265
+** explicit.
19266
+*/
19267
+struct DbFixer {
19268
+ Parse *pParse; /* The parsing context. Error messages written here */
19269
+ Walker w; /* Walker object */
19270
+ Schema *pSchema; /* Fix items to this schema */
19271
+ u8 bTemp; /* True for TEMP schema entries */
19272
+ const char *zDb; /* Make sure all objects are contained in this database */
19273
+ const char *zType; /* Type of the container - used for error messages */
19274
+ const Token *pName; /* Name of the container - used for error messages */
19275
+};
1927419276
1927519277
/* Forward declarations */
1927619278
SQLITE_PRIVATE int sqlite3WalkExpr(Walker*, Expr*);
1927719279
SQLITE_PRIVATE int sqlite3WalkExprList(Walker*, ExprList*);
1927819280
SQLITE_PRIVATE int sqlite3WalkSelect(Walker*, Select*);
@@ -19979,11 +19981,10 @@
1997919981
SQLITE_PRIVATE void sqlite3Detach(Parse*, Expr*);
1998019982
SQLITE_PRIVATE void sqlite3FixInit(DbFixer*, Parse*, int, const char*, const Token*);
1998119983
SQLITE_PRIVATE int sqlite3FixSrcList(DbFixer*, SrcList*);
1998219984
SQLITE_PRIVATE int sqlite3FixSelect(DbFixer*, Select*);
1998319985
SQLITE_PRIVATE int sqlite3FixExpr(DbFixer*, Expr*);
19984
-SQLITE_PRIVATE int sqlite3FixExprList(DbFixer*, ExprList*);
1998519986
SQLITE_PRIVATE int sqlite3FixTriggerStep(DbFixer*, TriggerStep*);
1998619987
SQLITE_PRIVATE int sqlite3RealSameAsInt(double,sqlite3_int64);
1998719988
SQLITE_PRIVATE void sqlite3Int64ToText(i64,char*);
1998819989
SQLITE_PRIVATE int sqlite3AtoF(const char *z, double*, int, u8);
1998919990
SQLITE_PRIVATE int sqlite3GetInt32(const char *, int*);
@@ -67720,10 +67721,11 @@
6772067721
assert( nReserve>=0 && nReserve<=255 );
6772167722
if( pageSize>=512 && pageSize<=SQLITE_MAX_PAGE_SIZE &&
6772267723
((pageSize-1)&pageSize)==0 ){
6772367724
assert( (pageSize & 7)==0 );
6772467725
assert( !pBt->pCursor );
67726
+ if( nReserve>32 && pageSize==512 ) pageSize = 1024;
6772567727
pBt->pageSize = (u32)pageSize;
6772667728
freeTempSpace(pBt);
6772767729
}
6772867730
rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize, nReserve);
6772967731
pBt->usableSize = pBt->pageSize - (u16)nReserve;
@@ -90727,12 +90729,14 @@
9072790729
case OP_NewRowid: { /* out2 */
9072890730
i64 v; /* The new rowid */
9072990731
VdbeCursor *pC; /* Cursor of table to get the new rowid */
9073090732
int res; /* Result of an sqlite3BtreeLast() */
9073190733
int cnt; /* Counter to limit the number of searches */
90734
+#ifndef SQLITE_OMIT_AUTOINCREMENT
9073290735
Mem *pMem; /* Register holding largest rowid for AUTOINCREMENT */
9073390736
VdbeFrame *pFrame; /* Root frame of VDBE */
90737
+#endif
9073490738
9073590739
v = 0;
9073690740
res = 0;
9073790741
pOut = out2Prerelease(p, pOp);
9073890742
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
@@ -91728,11 +91732,11 @@
9172891732
if( rc ) goto abort_due_to_error;
9172991733
if( res==0 ){
9173091734
rc = sqlite3BtreeDelete(pCrsr, BTREE_AUXDELETE);
9173191735
if( rc ) goto abort_due_to_error;
9173291736
}else if( pOp->p5 ){
91733
- rc = SQLITE_CORRUPT_INDEX;
91737
+ rc = sqlite3ReportError(SQLITE_CORRUPT_INDEX, __LINE__, "index corruption");
9173491738
goto abort_due_to_error;
9173591739
}
9173691740
assert( pC->deferredMoveto==0 );
9173791741
pC->cacheStatus = CACHE_STALE;
9173891742
pC->seekResult = 0;
@@ -110681,10 +110685,67 @@
110681110685
{0}
110682110686
};
110683110687
codeAttach(pParse, SQLITE_ATTACH, &attach_func, p, p, pDbname, pKey);
110684110688
}
110685110689
#endif /* SQLITE_OMIT_ATTACH */
110690
+
110691
+/*
110692
+** Expression callback used by sqlite3FixAAAA() routines.
110693
+*/
110694
+static int fixExprCb(Walker *p, Expr *pExpr){
110695
+ DbFixer *pFix = p->u.pFix;
110696
+ if( !pFix->bTemp ) ExprSetProperty(pExpr, EP_FromDDL);
110697
+ if( pExpr->op==TK_VARIABLE ){
110698
+ if( pFix->pParse->db->init.busy ){
110699
+ pExpr->op = TK_NULL;
110700
+ }else{
110701
+ sqlite3ErrorMsg(pFix->pParse, "%s cannot use variables", pFix->zType);
110702
+ return WRC_Abort;
110703
+ }
110704
+ }
110705
+ return WRC_Continue;
110706
+}
110707
+
110708
+/*
110709
+** Select callback used by sqlite3FixAAAA() routines.
110710
+*/
110711
+static int fixSelectCb(Walker *p, Select *pSelect){
110712
+ DbFixer *pFix = p->u.pFix;
110713
+ int i;
110714
+ struct SrcList_item *pItem;
110715
+ sqlite3 *db = pFix->pParse->db;
110716
+ int iDb = sqlite3FindDbName(db, pFix->zDb);
110717
+ SrcList *pList = pSelect->pSrc;
110718
+
110719
+ if( NEVER(pList==0) ) return WRC_Continue;
110720
+ for(i=0, pItem=pList->a; i<pList->nSrc; i++, pItem++){
110721
+ if( pFix->bTemp==0 ){
110722
+ if( pItem->zDatabase && iDb!=sqlite3FindDbName(db, pItem->zDatabase) ){
110723
+ sqlite3ErrorMsg(pFix->pParse,
110724
+ "%s %T cannot reference objects in database %s",
110725
+ pFix->zType, pFix->pName, pItem->zDatabase);
110726
+ return WRC_Abort;
110727
+ }
110728
+ sqlite3DbFree(db, pItem->zDatabase);
110729
+ pItem->zDatabase = 0;
110730
+ pItem->pSchema = pFix->pSchema;
110731
+ pItem->fg.fromDDL = 1;
110732
+ }
110733
+#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER)
110734
+ if( sqlite3WalkExpr(&pFix->w, pList->a[i].pOn) ) return WRC_Abort;
110735
+#endif
110736
+ }
110737
+ if( pSelect->pWith ){
110738
+ int i;
110739
+ for(i=0; i<pSelect->pWith->nCte; i++){
110740
+ if( sqlite3WalkSelect(p, pSelect->pWith->a[i].pSelect) ){
110741
+ return WRC_Abort;
110742
+ }
110743
+ }
110744
+ }
110745
+ return WRC_Continue;
110746
+}
110686110747
110687110748
/*
110688110749
** Initialize a DbFixer structure. This routine must be called prior
110689110750
** to passing the structure to one of the sqliteFixAAAA() routines below.
110690110751
*/
@@ -110693,20 +110754,25 @@
110693110754
Parse *pParse, /* Error messages will be written here */
110694110755
int iDb, /* This is the database that must be used */
110695110756
const char *zType, /* "view", "trigger", or "index" */
110696110757
const Token *pName /* Name of the view, trigger, or index */
110697110758
){
110698
- sqlite3 *db;
110699
-
110700
- db = pParse->db;
110759
+ sqlite3 *db = pParse->db;
110701110760
assert( db->nDb>iDb );
110702110761
pFix->pParse = pParse;
110703110762
pFix->zDb = db->aDb[iDb].zDbSName;
110704110763
pFix->pSchema = db->aDb[iDb].pSchema;
110705110764
pFix->zType = zType;
110706110765
pFix->pName = pName;
110707110766
pFix->bTemp = (iDb==1);
110767
+ pFix->w.pParse = pParse;
110768
+ pFix->w.xExprCallback = fixExprCb;
110769
+ pFix->w.xSelectCallback = fixSelectCb;
110770
+ pFix->w.xSelectCallback2 = 0;
110771
+ pFix->w.walkerDepth = 0;
110772
+ pFix->w.eCode = 0;
110773
+ pFix->w.u.pFix = pFix;
110708110774
}
110709110775
110710110776
/*
110711110777
** The following set of routines walk through the parse tree and assign
110712110778
** a specific database to all table references where the database name
@@ -110723,154 +110789,62 @@
110723110789
*/
110724110790
SQLITE_PRIVATE int sqlite3FixSrcList(
110725110791
DbFixer *pFix, /* Context of the fixation */
110726110792
SrcList *pList /* The Source list to check and modify */
110727110793
){
110728
- int i;
110729
- struct SrcList_item *pItem;
110730
- sqlite3 *db = pFix->pParse->db;
110731
- int iDb = sqlite3FindDbName(db, pFix->zDb);
110732
-
110733
- if( NEVER(pList==0) ) return 0;
110734
-
110735
- for(i=0, pItem=pList->a; i<pList->nSrc; i++, pItem++){
110736
- if( pFix->bTemp==0 ){
110737
- if( pItem->zDatabase && iDb!=sqlite3FindDbName(db, pItem->zDatabase) ){
110738
- sqlite3ErrorMsg(pFix->pParse,
110739
- "%s %T cannot reference objects in database %s",
110740
- pFix->zType, pFix->pName, pItem->zDatabase);
110741
- return 1;
110742
- }
110743
- sqlite3DbFree(db, pItem->zDatabase);
110744
- pItem->zDatabase = 0;
110745
- pItem->pSchema = pFix->pSchema;
110746
- pItem->fg.fromDDL = 1;
110747
- }
110748
-#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER)
110749
- if( sqlite3FixSelect(pFix, pItem->pSelect) ) return 1;
110750
- if( sqlite3FixExpr(pFix, pItem->pOn) ) return 1;
110751
-#endif
110752
- if( pItem->fg.isTabFunc && sqlite3FixExprList(pFix, pItem->u1.pFuncArg) ){
110753
- return 1;
110754
- }
110755
- }
110756
- return 0;
110794
+ int res = 0;
110795
+ if( pList ){
110796
+ Select s;
110797
+ memset(&s, 0, sizeof(s));
110798
+ s.pSrc = pList;
110799
+ res = sqlite3WalkSelect(&pFix->w, &s);
110800
+ }
110801
+ return res;
110757110802
}
110758110803
#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER)
110759110804
SQLITE_PRIVATE int sqlite3FixSelect(
110760110805
DbFixer *pFix, /* Context of the fixation */
110761110806
Select *pSelect /* The SELECT statement to be fixed to one database */
110762110807
){
110763
- while( pSelect ){
110764
- if( sqlite3FixExprList(pFix, pSelect->pEList) ){
110765
- return 1;
110766
- }
110767
- if( sqlite3FixSrcList(pFix, pSelect->pSrc) ){
110768
- return 1;
110769
- }
110770
- if( sqlite3FixExpr(pFix, pSelect->pWhere) ){
110771
- return 1;
110772
- }
110773
- if( sqlite3FixExprList(pFix, pSelect->pGroupBy) ){
110774
- return 1;
110775
- }
110776
- if( sqlite3FixExpr(pFix, pSelect->pHaving) ){
110777
- return 1;
110778
- }
110779
- if( sqlite3FixExprList(pFix, pSelect->pOrderBy) ){
110780
- return 1;
110781
- }
110782
- if( sqlite3FixExpr(pFix, pSelect->pLimit) ){
110783
- return 1;
110784
- }
110785
- if( pSelect->pWith ){
110786
- int i;
110787
- for(i=0; i<pSelect->pWith->nCte; i++){
110788
- if( sqlite3FixSelect(pFix, pSelect->pWith->a[i].pSelect) ){
110789
- return 1;
110790
- }
110791
- }
110792
- }
110793
- pSelect = pSelect->pPrior;
110794
- }
110795
- return 0;
110808
+ return sqlite3WalkSelect(&pFix->w, pSelect);
110796110809
}
110797110810
SQLITE_PRIVATE int sqlite3FixExpr(
110798110811
DbFixer *pFix, /* Context of the fixation */
110799110812
Expr *pExpr /* The expression to be fixed to one database */
110800110813
){
110801
- while( pExpr ){
110802
- if( !pFix->bTemp ) ExprSetProperty(pExpr, EP_FromDDL);
110803
- if( pExpr->op==TK_VARIABLE ){
110804
- if( pFix->pParse->db->init.busy ){
110805
- pExpr->op = TK_NULL;
110806
- }else{
110807
- sqlite3ErrorMsg(pFix->pParse, "%s cannot use variables", pFix->zType);
110808
- return 1;
110809
- }
110810
- }
110811
- if( ExprHasProperty(pExpr, EP_TokenOnly|EP_Leaf) ) break;
110812
- if( ExprHasProperty(pExpr, EP_xIsSelect) ){
110813
- if( sqlite3FixSelect(pFix, pExpr->x.pSelect) ) return 1;
110814
- }else{
110815
- if( sqlite3FixExprList(pFix, pExpr->x.pList) ) return 1;
110816
- }
110817
- if( sqlite3FixExpr(pFix, pExpr->pRight) ){
110818
- return 1;
110819
- }
110820
- pExpr = pExpr->pLeft;
110821
- }
110822
- return 0;
110823
-}
110824
-SQLITE_PRIVATE int sqlite3FixExprList(
110825
- DbFixer *pFix, /* Context of the fixation */
110826
- ExprList *pList /* The expression to be fixed to one database */
110827
-){
110828
- int i;
110829
- struct ExprList_item *pItem;
110830
- if( pList==0 ) return 0;
110831
- for(i=0, pItem=pList->a; i<pList->nExpr; i++, pItem++){
110832
- if( sqlite3FixExpr(pFix, pItem->pExpr) ){
110833
- return 1;
110834
- }
110835
- }
110836
- return 0;
110814
+ return sqlite3WalkExpr(&pFix->w, pExpr);
110837110815
}
110838110816
#endif
110839110817
110840110818
#ifndef SQLITE_OMIT_TRIGGER
110841110819
SQLITE_PRIVATE int sqlite3FixTriggerStep(
110842110820
DbFixer *pFix, /* Context of the fixation */
110843110821
TriggerStep *pStep /* The trigger step be fixed to one database */
110844110822
){
110845110823
while( pStep ){
110846
- if( sqlite3FixSelect(pFix, pStep->pSelect) ){
110847
- return 1;
110848
- }
110849
- if( sqlite3FixExpr(pFix, pStep->pWhere) ){
110850
- return 1;
110851
- }
110852
- if( sqlite3FixExprList(pFix, pStep->pExprList) ){
110853
- return 1;
110854
- }
110855
- if( pStep->pFrom && sqlite3FixSrcList(pFix, pStep->pFrom) ){
110824
+ if( sqlite3WalkSelect(&pFix->w, pStep->pSelect)
110825
+ || sqlite3WalkExpr(&pFix->w, pStep->pWhere)
110826
+ || sqlite3WalkExprList(&pFix->w, pStep->pExprList)
110827
+ || sqlite3FixSrcList(pFix, pStep->pFrom)
110828
+ ){
110856110829
return 1;
110857110830
}
110858110831
#ifndef SQLITE_OMIT_UPSERT
110859110832
if( pStep->pUpsert ){
110860110833
Upsert *pUp = pStep->pUpsert;
110861
- if( sqlite3FixExprList(pFix, pUp->pUpsertTarget)
110862
- || sqlite3FixExpr(pFix, pUp->pUpsertTargetWhere)
110863
- || sqlite3FixExprList(pFix, pUp->pUpsertSet)
110864
- || sqlite3FixExpr(pFix, pUp->pUpsertWhere)
110834
+ if( sqlite3WalkExprList(&pFix->w, pUp->pUpsertTarget)
110835
+ || sqlite3WalkExpr(&pFix->w, pUp->pUpsertTargetWhere)
110836
+ || sqlite3WalkExprList(&pFix->w, pUp->pUpsertSet)
110837
+ || sqlite3WalkExpr(&pFix->w, pUp->pUpsertWhere)
110865110838
){
110866110839
return 1;
110867110840
}
110868110841
}
110869110842
#endif
110870110843
pStep = pStep->pNext;
110871110844
}
110845
+
110872110846
return 0;
110873110847
}
110874110848
#endif
110875110849
110876110850
/************** End of attach.c **********************************************/
@@ -119692,11 +119666,13 @@
119692119666
** false.
119693119667
*/
119694119668
SQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3 *db, Expr *pExpr, int *pIsNocase, char *aWc){
119695119669
FuncDef *pDef;
119696119670
int nExpr;
119697
- if( pExpr->op!=TK_FUNCTION || !pExpr->x.pList ){
119671
+ assert( pExpr!=0 );
119672
+ assert( pExpr->op==TK_FUNCTION );
119673
+ if( !pExpr->x.pList ){
119698119674
return 0;
119699119675
}
119700119676
assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
119701119677
nExpr = pExpr->x.pList->nExpr;
119702119678
pDef = sqlite3FindFunction(db, pExpr->u.zToken, nExpr, SQLITE_UTF8, 0);
@@ -122866,11 +122842,13 @@
122866122842
}
122867122843
#endif
122868122844
sqlite3VdbeJumpHere(v, addrInsTop);
122869122845
}
122870122846
122847
+#ifndef SQLITE_OMIT_XFER_OPT
122871122848
insert_end:
122849
+#endif /* SQLITE_OMIT_XFER_OPT */
122872122850
/* Update the sqlite_sequence table by storing the content of the
122873122851
** maximum rowid counter values recorded while inserting into
122874122852
** autoincrement tables.
122875122853
*/
122876122854
if( pParse->nested==0 && pParse->pTriggerTab==0 ){
@@ -142614,15 +142592,11 @@
142614142592
#define TERM_CODED 0x0004 /* This term is already coded */
142615142593
#define TERM_COPIED 0x0008 /* Has a child */
142616142594
#define TERM_ORINFO 0x0010 /* Need to free the WhereTerm.u.pOrInfo object */
142617142595
#define TERM_ANDINFO 0x0020 /* Need to free the WhereTerm.u.pAndInfo obj */
142618142596
#define TERM_OR_OK 0x0040 /* Used during OR-clause processing */
142619
-#ifdef SQLITE_ENABLE_STAT4
142620
-# define TERM_VNULL 0x0080 /* Manufactured x>NULL or x<=NULL term */
142621
-#else
142622
-# define TERM_VNULL 0x0000 /* Disabled if not using stat4 */
142623
-#endif
142597
+#define TERM_VNULL 0x0080 /* Manufactured x>NULL or x<=NULL term */
142624142598
#define TERM_LIKEOPT 0x0100 /* Virtual terms from the LIKE optimization */
142625142599
#define TERM_LIKECOND 0x0200 /* Conditionally this LIKE operator term */
142626142600
#define TERM_LIKE 0x0400 /* The original LIKE operator */
142627142601
#define TERM_IS 0x0800 /* Term.pExpr is an IS operator */
142628142602
#define TERM_VARSELECT 0x1000 /* Term.pExpr contains a correlated sub-query */
@@ -144679,10 +144653,16 @@
144679144653
){
144680144654
SWAP(WhereTerm *, pRangeEnd, pRangeStart);
144681144655
SWAP(u8, bSeekPastNull, bStopAtNull);
144682144656
SWAP(u8, nBtm, nTop);
144683144657
}
144658
+
144659
+ if( iLevel>0 && (pLoop->wsFlags & WHERE_IN_SEEKSCAN)!=0 ){
144660
+ /* In case OP_SeekScan is used, ensure that the index cursor does not
144661
+ ** point to a valid row for the first iteration of this loop. */
144662
+ sqlite3VdbeAddOp1(v, OP_NullRow, iIdxCur);
144663
+ }
144684144664
144685144665
/* Generate code to evaluate all constraint terms using == or IN
144686144666
** and store the values of those terms in an array of registers
144687144667
** starting at regBase.
144688144668
*/
@@ -146894,10 +146874,46 @@
146894146874
){
146895146875
exprAnalyzeExists(pSrc, pWC, idxTerm);
146896146876
}
146897146877
}
146898146878
146879
+ /* The form "x IS NOT NULL" can sometimes be evaluated more efficiently
146880
+ ** as "x>NULL" if x is not an INTEGER PRIMARY KEY. So construct a
146881
+ ** virtual term of that form.
146882
+ **
146883
+ ** The virtual term must be tagged with TERM_VNULL.
146884
+ */
146885
+ else if( pExpr->op==TK_NOTNULL ){
146886
+ if( pExpr->pLeft->op==TK_COLUMN
146887
+ && pExpr->pLeft->iColumn>=0
146888
+ && !ExprHasProperty(pExpr, EP_FromJoin)
146889
+ ){
146890
+ Expr *pNewExpr;
146891
+ Expr *pLeft = pExpr->pLeft;
146892
+ int idxNew;
146893
+ WhereTerm *pNewTerm;
146894
+
146895
+ pNewExpr = sqlite3PExpr(pParse, TK_GT,
146896
+ sqlite3ExprDup(db, pLeft, 0),
146897
+ sqlite3ExprAlloc(db, TK_NULL, 0, 0));
146898
+
146899
+ idxNew = whereClauseInsert(pWC, pNewExpr,
146900
+ TERM_VIRTUAL|TERM_DYNAMIC|TERM_VNULL);
146901
+ if( idxNew ){
146902
+ pNewTerm = &pWC->a[idxNew];
146903
+ pNewTerm->prereqRight = 0;
146904
+ pNewTerm->leftCursor = pLeft->iTable;
146905
+ pNewTerm->u.x.leftColumn = pLeft->iColumn;
146906
+ pNewTerm->eOperator = WO_GT;
146907
+ markTermAsChild(pWC, idxNew, idxTerm);
146908
+ pTerm = &pWC->a[idxTerm];
146909
+ pTerm->wtFlags |= TERM_COPIED;
146910
+ pNewTerm->prereqAll = pTerm->prereqAll;
146911
+ }
146912
+ }
146913
+ }
146914
+
146899146915
146900146916
#ifndef SQLITE_OMIT_LIKE_OPTIMIZATION
146901146917
/* Add constraints to reduce the search space on a LIKE or GLOB
146902146918
** operator.
146903146919
**
@@ -146909,11 +146925,12 @@
146909146925
** termination condition "abd". If case is not significant (the default
146910146926
** for LIKE) then the lower-bound is made all uppercase and the upper-
146911146927
** bound is made all lowercase so that the bounds also work when comparing
146912146928
** BLOBs.
146913146929
*/
146914
- if( pWC->op==TK_AND
146930
+ else if( pExpr->op==TK_FUNCTION
146931
+ && pWC->op==TK_AND
146915146932
&& isLikeOrGlob(pParse, pExpr, &pStr1, &isComplete, &noCase)
146916146933
){
146917146934
Expr *pLeft; /* LHS of LIKE/GLOB operator */
146918146935
Expr *pStr2; /* Copy of pStr1 - RHS of LIKE/GLOB operator */
146919146936
Expr *pNewExpr1;
@@ -146978,10 +146995,69 @@
146978146995
markTermAsChild(pWC, idxNew1, idxTerm);
146979146996
markTermAsChild(pWC, idxNew2, idxTerm);
146980146997
}
146981146998
}
146982146999
#endif /* SQLITE_OMIT_LIKE_OPTIMIZATION */
147000
+
147001
+ /* If there is a vector == or IS term - e.g. "(a, b) == (?, ?)" - create
147002
+ ** new terms for each component comparison - "a = ?" and "b = ?". The
147003
+ ** new terms completely replace the original vector comparison, which is
147004
+ ** no longer used.
147005
+ **
147006
+ ** This is only required if at least one side of the comparison operation
147007
+ ** is not a sub-select. */
147008
+ if( (pExpr->op==TK_EQ || pExpr->op==TK_IS)
147009
+ && (nLeft = sqlite3ExprVectorSize(pExpr->pLeft))>1
147010
+ && sqlite3ExprVectorSize(pExpr->pRight)==nLeft
147011
+ && ( (pExpr->pLeft->flags & EP_xIsSelect)==0
147012
+ || (pExpr->pRight->flags & EP_xIsSelect)==0)
147013
+ && pWC->op==TK_AND
147014
+ ){
147015
+ int i;
147016
+ for(i=0; i<nLeft; i++){
147017
+ int idxNew;
147018
+ Expr *pNew;
147019
+ Expr *pLeft = sqlite3ExprForVectorField(pParse, pExpr->pLeft, i);
147020
+ Expr *pRight = sqlite3ExprForVectorField(pParse, pExpr->pRight, i);
147021
+
147022
+ pNew = sqlite3PExpr(pParse, pExpr->op, pLeft, pRight);
147023
+ transferJoinMarkings(pNew, pExpr);
147024
+ idxNew = whereClauseInsert(pWC, pNew, TERM_DYNAMIC);
147025
+ exprAnalyze(pSrc, pWC, idxNew);
147026
+ }
147027
+ pTerm = &pWC->a[idxTerm];
147028
+ pTerm->wtFlags |= TERM_CODED|TERM_VIRTUAL; /* Disable the original */
147029
+ pTerm->eOperator = 0;
147030
+ }
147031
+
147032
+ /* If there is a vector IN term - e.g. "(a, b) IN (SELECT ...)" - create
147033
+ ** a virtual term for each vector component. The expression object
147034
+ ** used by each such virtual term is pExpr (the full vector IN(...)
147035
+ ** expression). The WhereTerm.u.x.iField variable identifies the index within
147036
+ ** the vector on the LHS that the virtual term represents.
147037
+ **
147038
+ ** This only works if the RHS is a simple SELECT (not a compound) that does
147039
+ ** not use window functions.
147040
+ */
147041
+ else if( pExpr->op==TK_IN
147042
+ && pTerm->u.x.iField==0
147043
+ && pExpr->pLeft->op==TK_VECTOR
147044
+ && pExpr->x.pSelect->pPrior==0
147045
+#ifndef SQLITE_OMIT_WINDOWFUNC
147046
+ && pExpr->x.pSelect->pWin==0
147047
+#endif
147048
+ && pWC->op==TK_AND
147049
+ ){
147050
+ int i;
147051
+ for(i=0; i<sqlite3ExprVectorSize(pExpr->pLeft); i++){
147052
+ int idxNew;
147053
+ idxNew = whereClauseInsert(pWC, pExpr, TERM_VIRTUAL);
147054
+ pWC->a[idxNew].u.x.iField = i+1;
147055
+ exprAnalyze(pSrc, pWC, idxNew);
147056
+ markTermAsChild(pWC, idxNew, idxTerm);
147057
+ }
147058
+ }
146983147059
146984147060
#ifndef SQLITE_OMIT_VIRTUALTABLE
146985147061
/* Add a WO_AUX auxiliary term to the constraint set if the
146986147062
** current expression is of the form "column OP expr" where OP
146987147063
** is an operator that gets passed into virtual tables but which is
@@ -146989,11 +147065,11 @@
146989147065
** is one of MATCH, LIKE, GLOB, REGEXP, !=, IS, IS NOT, or NOT NULL.
146990147066
** This information is used by the xBestIndex methods of
146991147067
** virtual tables. The native query optimizer does not attempt
146992147068
** to do anything with MATCH functions.
146993147069
*/
146994
- if( pWC->op==TK_AND ){
147070
+ else if( pWC->op==TK_AND ){
146995147071
Expr *pRight = 0, *pLeft = 0;
146996147072
int res = isAuxiliaryVtabOperator(db, pExpr, &eOp2, &pLeft, &pRight);
146997147073
while( res-- > 0 ){
146998147074
int idxNew;
146999147075
WhereTerm *pNewTerm;
@@ -147025,106 +147101,10 @@
147025147101
SWAP(Expr*, pLeft, pRight);
147026147102
}
147027147103
}
147028147104
#endif /* SQLITE_OMIT_VIRTUALTABLE */
147029147105
147030
- /* If there is a vector == or IS term - e.g. "(a, b) == (?, ?)" - create
147031
- ** new terms for each component comparison - "a = ?" and "b = ?". The
147032
- ** new terms completely replace the original vector comparison, which is
147033
- ** no longer used.
147034
- **
147035
- ** This is only required if at least one side of the comparison operation
147036
- ** is not a sub-select. */
147037
- if( pWC->op==TK_AND
147038
- && (pExpr->op==TK_EQ || pExpr->op==TK_IS)
147039
- && (nLeft = sqlite3ExprVectorSize(pExpr->pLeft))>1
147040
- && sqlite3ExprVectorSize(pExpr->pRight)==nLeft
147041
- && ( (pExpr->pLeft->flags & EP_xIsSelect)==0
147042
- || (pExpr->pRight->flags & EP_xIsSelect)==0)
147043
- ){
147044
- int i;
147045
- for(i=0; i<nLeft; i++){
147046
- int idxNew;
147047
- Expr *pNew;
147048
- Expr *pLeft = sqlite3ExprForVectorField(pParse, pExpr->pLeft, i);
147049
- Expr *pRight = sqlite3ExprForVectorField(pParse, pExpr->pRight, i);
147050
-
147051
- pNew = sqlite3PExpr(pParse, pExpr->op, pLeft, pRight);
147052
- transferJoinMarkings(pNew, pExpr);
147053
- idxNew = whereClauseInsert(pWC, pNew, TERM_DYNAMIC);
147054
- exprAnalyze(pSrc, pWC, idxNew);
147055
- }
147056
- pTerm = &pWC->a[idxTerm];
147057
- pTerm->wtFlags |= TERM_CODED|TERM_VIRTUAL; /* Disable the original */
147058
- pTerm->eOperator = 0;
147059
- }
147060
-
147061
- /* If there is a vector IN term - e.g. "(a, b) IN (SELECT ...)" - create
147062
- ** a virtual term for each vector component. The expression object
147063
- ** used by each such virtual term is pExpr (the full vector IN(...)
147064
- ** expression). The WhereTerm.u.x.iField variable identifies the index within
147065
- ** the vector on the LHS that the virtual term represents.
147066
- **
147067
- ** This only works if the RHS is a simple SELECT (not a compound) that does
147068
- ** not use window functions.
147069
- */
147070
- if( pWC->op==TK_AND && pExpr->op==TK_IN && pTerm->u.x.iField==0
147071
- && pExpr->pLeft->op==TK_VECTOR
147072
- && pExpr->x.pSelect->pPrior==0
147073
-#ifndef SQLITE_OMIT_WINDOWFUNC
147074
- && pExpr->x.pSelect->pWin==0
147075
-#endif
147076
- ){
147077
- int i;
147078
- for(i=0; i<sqlite3ExprVectorSize(pExpr->pLeft); i++){
147079
- int idxNew;
147080
- idxNew = whereClauseInsert(pWC, pExpr, TERM_VIRTUAL);
147081
- pWC->a[idxNew].u.x.iField = i+1;
147082
- exprAnalyze(pSrc, pWC, idxNew);
147083
- markTermAsChild(pWC, idxNew, idxTerm);
147084
- }
147085
- }
147086
-
147087
-#ifdef SQLITE_ENABLE_STAT4
147088
- /* When sqlite_stat4 histogram data is available an operator of the
147089
- ** form "x IS NOT NULL" can sometimes be evaluated more efficiently
147090
- ** as "x>NULL" if x is not an INTEGER PRIMARY KEY. So construct a
147091
- ** virtual term of that form.
147092
- **
147093
- ** Note that the virtual term must be tagged with TERM_VNULL.
147094
- */
147095
- if( pExpr->op==TK_NOTNULL
147096
- && pExpr->pLeft->op==TK_COLUMN
147097
- && pExpr->pLeft->iColumn>=0
147098
- && !ExprHasProperty(pExpr, EP_FromJoin)
147099
- && OptimizationEnabled(db, SQLITE_Stat4)
147100
- ){
147101
- Expr *pNewExpr;
147102
- Expr *pLeft = pExpr->pLeft;
147103
- int idxNew;
147104
- WhereTerm *pNewTerm;
147105
-
147106
- pNewExpr = sqlite3PExpr(pParse, TK_GT,
147107
- sqlite3ExprDup(db, pLeft, 0),
147108
- sqlite3ExprAlloc(db, TK_NULL, 0, 0));
147109
-
147110
- idxNew = whereClauseInsert(pWC, pNewExpr,
147111
- TERM_VIRTUAL|TERM_DYNAMIC|TERM_VNULL);
147112
- if( idxNew ){
147113
- pNewTerm = &pWC->a[idxNew];
147114
- pNewTerm->prereqRight = 0;
147115
- pNewTerm->leftCursor = pLeft->iTable;
147116
- pNewTerm->u.x.leftColumn = pLeft->iColumn;
147117
- pNewTerm->eOperator = WO_GT;
147118
- markTermAsChild(pWC, idxNew, idxTerm);
147119
- pTerm = &pWC->a[idxTerm];
147120
- pTerm->wtFlags |= TERM_COPIED;
147121
- pNewTerm->prereqAll = pTerm->prereqAll;
147122
- }
147123
- }
147124
-#endif /* SQLITE_ENABLE_STAT4 */
147125
-
147126147106
/* Prevent ON clause terms of a LEFT JOIN from being used to drive
147127147107
** an index for tables to the left of the join.
147128147108
*/
147129147109
testcase( pTerm!=&pWC->a[idxTerm] );
147130147110
pTerm = &pWC->a[idxTerm];
@@ -228086,11 +228066,11 @@
228086228066
int nArg, /* Number of args */
228087228067
sqlite3_value **apUnused /* Function arguments */
228088228068
){
228089228069
assert( nArg==0 );
228090228070
UNUSED_PARAM2(nArg, apUnused);
228091
- sqlite3_result_text(pCtx, "fts5: 2021-01-18 12:35:16 c1862abb44873f06ec0d772469d8a2d128ae4670b1e98c2d97b0e2da18df9a04", -1, SQLITE_TRANSIENT);
228071
+ sqlite3_result_text(pCtx, "fts5: 2021-01-27 19:15:06 9dc7fc9f04d5c14fc436e5ff5b4c06c1969ddde5857ebeb5dccd59b7c748c339", -1, SQLITE_TRANSIENT);
228092228072
}
228093228073
228094228074
/*
228095228075
** Return true if zName is the extension on one of the shadow tables used
228096228076
** by this module.
@@ -233012,12 +232992,12 @@
233012232992
}
233013232993
#endif /* SQLITE_CORE */
233014232994
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
233015232995
233016232996
/************** End of stmt.c ************************************************/
233017
-#if __LINE__!=233017
232997
+#if __LINE__!=232997
233018232998
#undef SQLITE_SOURCE_ID
233019
-#define SQLITE_SOURCE_ID "2021-01-18 12:35:16 c1862abb44873f06ec0d772469d8a2d128ae4670b1e98c2d97b0e2da18dfalt2"
232999
+#define SQLITE_SOURCE_ID "2021-01-27 19:15:06 9dc7fc9f04d5c14fc436e5ff5b4c06c1969ddde5857ebeb5dccd59b7c748alt2"
233020233000
#endif
233021233001
/* Return the source-id for this library */
233022233002
SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
233023233003
/************************** End of sqlite3.c ******************************/
233024233004
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1186,11 +1186,11 @@
1186 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1187 ** [sqlite_version()] and [sqlite_source_id()].
1188 */
1189 #define SQLITE_VERSION "3.35.0"
1190 #define SQLITE_VERSION_NUMBER 3035000
1191 #define SQLITE_SOURCE_ID "2021-01-18 12:35:16 c1862abb44873f06ec0d772469d8a2d128ae4670b1e98c2d97b0e2da18df9a04"
1192
1193 /*
1194 ** CAPI3REF: Run-Time Library Version Numbers
1195 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1196 **
@@ -14758,10 +14758,11 @@
14758 typedef struct AutoincInfo AutoincInfo;
14759 typedef struct Bitvec Bitvec;
14760 typedef struct CollSeq CollSeq;
14761 typedef struct Column Column;
14762 typedef struct Db Db;
 
14763 typedef struct Schema Schema;
14764 typedef struct Expr Expr;
14765 typedef struct ExprList ExprList;
14766 typedef struct FKey FKey;
14767 typedef struct FuncDestructor FuncDestructor;
@@ -19102,25 +19103,10 @@
19102 char *zSpan; /* Original SQL text of this command */
19103 TriggerStep *pNext; /* Next in the link-list */
19104 TriggerStep *pLast; /* Last element in link-list. Valid for 1st elem only */
19105 };
19106
19107 /*
19108 ** The following structure contains information used by the sqliteFix...
19109 ** routines as they walk the parse tree to make database references
19110 ** explicit.
19111 */
19112 typedef struct DbFixer DbFixer;
19113 struct DbFixer {
19114 Parse *pParse; /* The parsing context. Error messages written here */
19115 Schema *pSchema; /* Fix items to this schema */
19116 u8 bTemp; /* True for TEMP schema entries */
19117 const char *zDb; /* Make sure all objects are contained in this database */
19118 const char *zType; /* Type of the container - used for error messages */
19119 const Token *pName; /* Name of the container - used for error messages */
19120 };
19121
19122 /*
19123 ** An objected used to accumulate the text of a string where we
19124 ** do not necessarily know how big the string will be in the end.
19125 */
19126 struct sqlite3_str {
@@ -19267,12 +19253,28 @@
19267 struct WindowRewrite *pRewrite; /* Window rewrite context */
19268 struct WhereConst *pConst; /* WHERE clause constants */
19269 struct RenameCtx *pRename; /* RENAME COLUMN context */
19270 struct Table *pTab; /* Table of generated column */
19271 struct SrcList_item *pSrcItem; /* A single FROM clause item */
 
19272 } u;
19273 };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19274
19275 /* Forward declarations */
19276 SQLITE_PRIVATE int sqlite3WalkExpr(Walker*, Expr*);
19277 SQLITE_PRIVATE int sqlite3WalkExprList(Walker*, ExprList*);
19278 SQLITE_PRIVATE int sqlite3WalkSelect(Walker*, Select*);
@@ -19979,11 +19981,10 @@
19979 SQLITE_PRIVATE void sqlite3Detach(Parse*, Expr*);
19980 SQLITE_PRIVATE void sqlite3FixInit(DbFixer*, Parse*, int, const char*, const Token*);
19981 SQLITE_PRIVATE int sqlite3FixSrcList(DbFixer*, SrcList*);
19982 SQLITE_PRIVATE int sqlite3FixSelect(DbFixer*, Select*);
19983 SQLITE_PRIVATE int sqlite3FixExpr(DbFixer*, Expr*);
19984 SQLITE_PRIVATE int sqlite3FixExprList(DbFixer*, ExprList*);
19985 SQLITE_PRIVATE int sqlite3FixTriggerStep(DbFixer*, TriggerStep*);
19986 SQLITE_PRIVATE int sqlite3RealSameAsInt(double,sqlite3_int64);
19987 SQLITE_PRIVATE void sqlite3Int64ToText(i64,char*);
19988 SQLITE_PRIVATE int sqlite3AtoF(const char *z, double*, int, u8);
19989 SQLITE_PRIVATE int sqlite3GetInt32(const char *, int*);
@@ -67720,10 +67721,11 @@
67720 assert( nReserve>=0 && nReserve<=255 );
67721 if( pageSize>=512 && pageSize<=SQLITE_MAX_PAGE_SIZE &&
67722 ((pageSize-1)&pageSize)==0 ){
67723 assert( (pageSize & 7)==0 );
67724 assert( !pBt->pCursor );
 
67725 pBt->pageSize = (u32)pageSize;
67726 freeTempSpace(pBt);
67727 }
67728 rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize, nReserve);
67729 pBt->usableSize = pBt->pageSize - (u16)nReserve;
@@ -90727,12 +90729,14 @@
90727 case OP_NewRowid: { /* out2 */
90728 i64 v; /* The new rowid */
90729 VdbeCursor *pC; /* Cursor of table to get the new rowid */
90730 int res; /* Result of an sqlite3BtreeLast() */
90731 int cnt; /* Counter to limit the number of searches */
 
90732 Mem *pMem; /* Register holding largest rowid for AUTOINCREMENT */
90733 VdbeFrame *pFrame; /* Root frame of VDBE */
 
90734
90735 v = 0;
90736 res = 0;
90737 pOut = out2Prerelease(p, pOp);
90738 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
@@ -91728,11 +91732,11 @@
91728 if( rc ) goto abort_due_to_error;
91729 if( res==0 ){
91730 rc = sqlite3BtreeDelete(pCrsr, BTREE_AUXDELETE);
91731 if( rc ) goto abort_due_to_error;
91732 }else if( pOp->p5 ){
91733 rc = SQLITE_CORRUPT_INDEX;
91734 goto abort_due_to_error;
91735 }
91736 assert( pC->deferredMoveto==0 );
91737 pC->cacheStatus = CACHE_STALE;
91738 pC->seekResult = 0;
@@ -110681,10 +110685,67 @@
110681 {0}
110682 };
110683 codeAttach(pParse, SQLITE_ATTACH, &attach_func, p, p, pDbname, pKey);
110684 }
110685 #endif /* SQLITE_OMIT_ATTACH */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110686
110687 /*
110688 ** Initialize a DbFixer structure. This routine must be called prior
110689 ** to passing the structure to one of the sqliteFixAAAA() routines below.
110690 */
@@ -110693,20 +110754,25 @@
110693 Parse *pParse, /* Error messages will be written here */
110694 int iDb, /* This is the database that must be used */
110695 const char *zType, /* "view", "trigger", or "index" */
110696 const Token *pName /* Name of the view, trigger, or index */
110697 ){
110698 sqlite3 *db;
110699
110700 db = pParse->db;
110701 assert( db->nDb>iDb );
110702 pFix->pParse = pParse;
110703 pFix->zDb = db->aDb[iDb].zDbSName;
110704 pFix->pSchema = db->aDb[iDb].pSchema;
110705 pFix->zType = zType;
110706 pFix->pName = pName;
110707 pFix->bTemp = (iDb==1);
 
 
 
 
 
 
 
110708 }
110709
110710 /*
110711 ** The following set of routines walk through the parse tree and assign
110712 ** a specific database to all table references where the database name
@@ -110723,154 +110789,62 @@
110723 */
110724 SQLITE_PRIVATE int sqlite3FixSrcList(
110725 DbFixer *pFix, /* Context of the fixation */
110726 SrcList *pList /* The Source list to check and modify */
110727 ){
110728 int i;
110729 struct SrcList_item *pItem;
110730 sqlite3 *db = pFix->pParse->db;
110731 int iDb = sqlite3FindDbName(db, pFix->zDb);
110732
110733 if( NEVER(pList==0) ) return 0;
110734
110735 for(i=0, pItem=pList->a; i<pList->nSrc; i++, pItem++){
110736 if( pFix->bTemp==0 ){
110737 if( pItem->zDatabase && iDb!=sqlite3FindDbName(db, pItem->zDatabase) ){
110738 sqlite3ErrorMsg(pFix->pParse,
110739 "%s %T cannot reference objects in database %s",
110740 pFix->zType, pFix->pName, pItem->zDatabase);
110741 return 1;
110742 }
110743 sqlite3DbFree(db, pItem->zDatabase);
110744 pItem->zDatabase = 0;
110745 pItem->pSchema = pFix->pSchema;
110746 pItem->fg.fromDDL = 1;
110747 }
110748 #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER)
110749 if( sqlite3FixSelect(pFix, pItem->pSelect) ) return 1;
110750 if( sqlite3FixExpr(pFix, pItem->pOn) ) return 1;
110751 #endif
110752 if( pItem->fg.isTabFunc && sqlite3FixExprList(pFix, pItem->u1.pFuncArg) ){
110753 return 1;
110754 }
110755 }
110756 return 0;
110757 }
110758 #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER)
110759 SQLITE_PRIVATE int sqlite3FixSelect(
110760 DbFixer *pFix, /* Context of the fixation */
110761 Select *pSelect /* The SELECT statement to be fixed to one database */
110762 ){
110763 while( pSelect ){
110764 if( sqlite3FixExprList(pFix, pSelect->pEList) ){
110765 return 1;
110766 }
110767 if( sqlite3FixSrcList(pFix, pSelect->pSrc) ){
110768 return 1;
110769 }
110770 if( sqlite3FixExpr(pFix, pSelect->pWhere) ){
110771 return 1;
110772 }
110773 if( sqlite3FixExprList(pFix, pSelect->pGroupBy) ){
110774 return 1;
110775 }
110776 if( sqlite3FixExpr(pFix, pSelect->pHaving) ){
110777 return 1;
110778 }
110779 if( sqlite3FixExprList(pFix, pSelect->pOrderBy) ){
110780 return 1;
110781 }
110782 if( sqlite3FixExpr(pFix, pSelect->pLimit) ){
110783 return 1;
110784 }
110785 if( pSelect->pWith ){
110786 int i;
110787 for(i=0; i<pSelect->pWith->nCte; i++){
110788 if( sqlite3FixSelect(pFix, pSelect->pWith->a[i].pSelect) ){
110789 return 1;
110790 }
110791 }
110792 }
110793 pSelect = pSelect->pPrior;
110794 }
110795 return 0;
110796 }
110797 SQLITE_PRIVATE int sqlite3FixExpr(
110798 DbFixer *pFix, /* Context of the fixation */
110799 Expr *pExpr /* The expression to be fixed to one database */
110800 ){
110801 while( pExpr ){
110802 if( !pFix->bTemp ) ExprSetProperty(pExpr, EP_FromDDL);
110803 if( pExpr->op==TK_VARIABLE ){
110804 if( pFix->pParse->db->init.busy ){
110805 pExpr->op = TK_NULL;
110806 }else{
110807 sqlite3ErrorMsg(pFix->pParse, "%s cannot use variables", pFix->zType);
110808 return 1;
110809 }
110810 }
110811 if( ExprHasProperty(pExpr, EP_TokenOnly|EP_Leaf) ) break;
110812 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
110813 if( sqlite3FixSelect(pFix, pExpr->x.pSelect) ) return 1;
110814 }else{
110815 if( sqlite3FixExprList(pFix, pExpr->x.pList) ) return 1;
110816 }
110817 if( sqlite3FixExpr(pFix, pExpr->pRight) ){
110818 return 1;
110819 }
110820 pExpr = pExpr->pLeft;
110821 }
110822 return 0;
110823 }
110824 SQLITE_PRIVATE int sqlite3FixExprList(
110825 DbFixer *pFix, /* Context of the fixation */
110826 ExprList *pList /* The expression to be fixed to one database */
110827 ){
110828 int i;
110829 struct ExprList_item *pItem;
110830 if( pList==0 ) return 0;
110831 for(i=0, pItem=pList->a; i<pList->nExpr; i++, pItem++){
110832 if( sqlite3FixExpr(pFix, pItem->pExpr) ){
110833 return 1;
110834 }
110835 }
110836 return 0;
110837 }
110838 #endif
110839
110840 #ifndef SQLITE_OMIT_TRIGGER
110841 SQLITE_PRIVATE int sqlite3FixTriggerStep(
110842 DbFixer *pFix, /* Context of the fixation */
110843 TriggerStep *pStep /* The trigger step be fixed to one database */
110844 ){
110845 while( pStep ){
110846 if( sqlite3FixSelect(pFix, pStep->pSelect) ){
110847 return 1;
110848 }
110849 if( sqlite3FixExpr(pFix, pStep->pWhere) ){
110850 return 1;
110851 }
110852 if( sqlite3FixExprList(pFix, pStep->pExprList) ){
110853 return 1;
110854 }
110855 if( pStep->pFrom && sqlite3FixSrcList(pFix, pStep->pFrom) ){
110856 return 1;
110857 }
110858 #ifndef SQLITE_OMIT_UPSERT
110859 if( pStep->pUpsert ){
110860 Upsert *pUp = pStep->pUpsert;
110861 if( sqlite3FixExprList(pFix, pUp->pUpsertTarget)
110862 || sqlite3FixExpr(pFix, pUp->pUpsertTargetWhere)
110863 || sqlite3FixExprList(pFix, pUp->pUpsertSet)
110864 || sqlite3FixExpr(pFix, pUp->pUpsertWhere)
110865 ){
110866 return 1;
110867 }
110868 }
110869 #endif
110870 pStep = pStep->pNext;
110871 }
 
110872 return 0;
110873 }
110874 #endif
110875
110876 /************** End of attach.c **********************************************/
@@ -119692,11 +119666,13 @@
119692 ** false.
119693 */
119694 SQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3 *db, Expr *pExpr, int *pIsNocase, char *aWc){
119695 FuncDef *pDef;
119696 int nExpr;
119697 if( pExpr->op!=TK_FUNCTION || !pExpr->x.pList ){
 
 
119698 return 0;
119699 }
119700 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
119701 nExpr = pExpr->x.pList->nExpr;
119702 pDef = sqlite3FindFunction(db, pExpr->u.zToken, nExpr, SQLITE_UTF8, 0);
@@ -122866,11 +122842,13 @@
122866 }
122867 #endif
122868 sqlite3VdbeJumpHere(v, addrInsTop);
122869 }
122870
 
122871 insert_end:
 
122872 /* Update the sqlite_sequence table by storing the content of the
122873 ** maximum rowid counter values recorded while inserting into
122874 ** autoincrement tables.
122875 */
122876 if( pParse->nested==0 && pParse->pTriggerTab==0 ){
@@ -142614,15 +142592,11 @@
142614 #define TERM_CODED 0x0004 /* This term is already coded */
142615 #define TERM_COPIED 0x0008 /* Has a child */
142616 #define TERM_ORINFO 0x0010 /* Need to free the WhereTerm.u.pOrInfo object */
142617 #define TERM_ANDINFO 0x0020 /* Need to free the WhereTerm.u.pAndInfo obj */
142618 #define TERM_OR_OK 0x0040 /* Used during OR-clause processing */
142619 #ifdef SQLITE_ENABLE_STAT4
142620 # define TERM_VNULL 0x0080 /* Manufactured x>NULL or x<=NULL term */
142621 #else
142622 # define TERM_VNULL 0x0000 /* Disabled if not using stat4 */
142623 #endif
142624 #define TERM_LIKEOPT 0x0100 /* Virtual terms from the LIKE optimization */
142625 #define TERM_LIKECOND 0x0200 /* Conditionally this LIKE operator term */
142626 #define TERM_LIKE 0x0400 /* The original LIKE operator */
142627 #define TERM_IS 0x0800 /* Term.pExpr is an IS operator */
142628 #define TERM_VARSELECT 0x1000 /* Term.pExpr contains a correlated sub-query */
@@ -144679,10 +144653,16 @@
144679 ){
144680 SWAP(WhereTerm *, pRangeEnd, pRangeStart);
144681 SWAP(u8, bSeekPastNull, bStopAtNull);
144682 SWAP(u8, nBtm, nTop);
144683 }
 
 
 
 
 
 
144684
144685 /* Generate code to evaluate all constraint terms using == or IN
144686 ** and store the values of those terms in an array of registers
144687 ** starting at regBase.
144688 */
@@ -146894,10 +146874,46 @@
146894 ){
146895 exprAnalyzeExists(pSrc, pWC, idxTerm);
146896 }
146897 }
146898
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146899
146900 #ifndef SQLITE_OMIT_LIKE_OPTIMIZATION
146901 /* Add constraints to reduce the search space on a LIKE or GLOB
146902 ** operator.
146903 **
@@ -146909,11 +146925,12 @@
146909 ** termination condition "abd". If case is not significant (the default
146910 ** for LIKE) then the lower-bound is made all uppercase and the upper-
146911 ** bound is made all lowercase so that the bounds also work when comparing
146912 ** BLOBs.
146913 */
146914 if( pWC->op==TK_AND
 
146915 && isLikeOrGlob(pParse, pExpr, &pStr1, &isComplete, &noCase)
146916 ){
146917 Expr *pLeft; /* LHS of LIKE/GLOB operator */
146918 Expr *pStr2; /* Copy of pStr1 - RHS of LIKE/GLOB operator */
146919 Expr *pNewExpr1;
@@ -146978,10 +146995,69 @@
146978 markTermAsChild(pWC, idxNew1, idxTerm);
146979 markTermAsChild(pWC, idxNew2, idxTerm);
146980 }
146981 }
146982 #endif /* SQLITE_OMIT_LIKE_OPTIMIZATION */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146983
146984 #ifndef SQLITE_OMIT_VIRTUALTABLE
146985 /* Add a WO_AUX auxiliary term to the constraint set if the
146986 ** current expression is of the form "column OP expr" where OP
146987 ** is an operator that gets passed into virtual tables but which is
@@ -146989,11 +147065,11 @@
146989 ** is one of MATCH, LIKE, GLOB, REGEXP, !=, IS, IS NOT, or NOT NULL.
146990 ** This information is used by the xBestIndex methods of
146991 ** virtual tables. The native query optimizer does not attempt
146992 ** to do anything with MATCH functions.
146993 */
146994 if( pWC->op==TK_AND ){
146995 Expr *pRight = 0, *pLeft = 0;
146996 int res = isAuxiliaryVtabOperator(db, pExpr, &eOp2, &pLeft, &pRight);
146997 while( res-- > 0 ){
146998 int idxNew;
146999 WhereTerm *pNewTerm;
@@ -147025,106 +147101,10 @@
147025 SWAP(Expr*, pLeft, pRight);
147026 }
147027 }
147028 #endif /* SQLITE_OMIT_VIRTUALTABLE */
147029
147030 /* If there is a vector == or IS term - e.g. "(a, b) == (?, ?)" - create
147031 ** new terms for each component comparison - "a = ?" and "b = ?". The
147032 ** new terms completely replace the original vector comparison, which is
147033 ** no longer used.
147034 **
147035 ** This is only required if at least one side of the comparison operation
147036 ** is not a sub-select. */
147037 if( pWC->op==TK_AND
147038 && (pExpr->op==TK_EQ || pExpr->op==TK_IS)
147039 && (nLeft = sqlite3ExprVectorSize(pExpr->pLeft))>1
147040 && sqlite3ExprVectorSize(pExpr->pRight)==nLeft
147041 && ( (pExpr->pLeft->flags & EP_xIsSelect)==0
147042 || (pExpr->pRight->flags & EP_xIsSelect)==0)
147043 ){
147044 int i;
147045 for(i=0; i<nLeft; i++){
147046 int idxNew;
147047 Expr *pNew;
147048 Expr *pLeft = sqlite3ExprForVectorField(pParse, pExpr->pLeft, i);
147049 Expr *pRight = sqlite3ExprForVectorField(pParse, pExpr->pRight, i);
147050
147051 pNew = sqlite3PExpr(pParse, pExpr->op, pLeft, pRight);
147052 transferJoinMarkings(pNew, pExpr);
147053 idxNew = whereClauseInsert(pWC, pNew, TERM_DYNAMIC);
147054 exprAnalyze(pSrc, pWC, idxNew);
147055 }
147056 pTerm = &pWC->a[idxTerm];
147057 pTerm->wtFlags |= TERM_CODED|TERM_VIRTUAL; /* Disable the original */
147058 pTerm->eOperator = 0;
147059 }
147060
147061 /* If there is a vector IN term - e.g. "(a, b) IN (SELECT ...)" - create
147062 ** a virtual term for each vector component. The expression object
147063 ** used by each such virtual term is pExpr (the full vector IN(...)
147064 ** expression). The WhereTerm.u.x.iField variable identifies the index within
147065 ** the vector on the LHS that the virtual term represents.
147066 **
147067 ** This only works if the RHS is a simple SELECT (not a compound) that does
147068 ** not use window functions.
147069 */
147070 if( pWC->op==TK_AND && pExpr->op==TK_IN && pTerm->u.x.iField==0
147071 && pExpr->pLeft->op==TK_VECTOR
147072 && pExpr->x.pSelect->pPrior==0
147073 #ifndef SQLITE_OMIT_WINDOWFUNC
147074 && pExpr->x.pSelect->pWin==0
147075 #endif
147076 ){
147077 int i;
147078 for(i=0; i<sqlite3ExprVectorSize(pExpr->pLeft); i++){
147079 int idxNew;
147080 idxNew = whereClauseInsert(pWC, pExpr, TERM_VIRTUAL);
147081 pWC->a[idxNew].u.x.iField = i+1;
147082 exprAnalyze(pSrc, pWC, idxNew);
147083 markTermAsChild(pWC, idxNew, idxTerm);
147084 }
147085 }
147086
147087 #ifdef SQLITE_ENABLE_STAT4
147088 /* When sqlite_stat4 histogram data is available an operator of the
147089 ** form "x IS NOT NULL" can sometimes be evaluated more efficiently
147090 ** as "x>NULL" if x is not an INTEGER PRIMARY KEY. So construct a
147091 ** virtual term of that form.
147092 **
147093 ** Note that the virtual term must be tagged with TERM_VNULL.
147094 */
147095 if( pExpr->op==TK_NOTNULL
147096 && pExpr->pLeft->op==TK_COLUMN
147097 && pExpr->pLeft->iColumn>=0
147098 && !ExprHasProperty(pExpr, EP_FromJoin)
147099 && OptimizationEnabled(db, SQLITE_Stat4)
147100 ){
147101 Expr *pNewExpr;
147102 Expr *pLeft = pExpr->pLeft;
147103 int idxNew;
147104 WhereTerm *pNewTerm;
147105
147106 pNewExpr = sqlite3PExpr(pParse, TK_GT,
147107 sqlite3ExprDup(db, pLeft, 0),
147108 sqlite3ExprAlloc(db, TK_NULL, 0, 0));
147109
147110 idxNew = whereClauseInsert(pWC, pNewExpr,
147111 TERM_VIRTUAL|TERM_DYNAMIC|TERM_VNULL);
147112 if( idxNew ){
147113 pNewTerm = &pWC->a[idxNew];
147114 pNewTerm->prereqRight = 0;
147115 pNewTerm->leftCursor = pLeft->iTable;
147116 pNewTerm->u.x.leftColumn = pLeft->iColumn;
147117 pNewTerm->eOperator = WO_GT;
147118 markTermAsChild(pWC, idxNew, idxTerm);
147119 pTerm = &pWC->a[idxTerm];
147120 pTerm->wtFlags |= TERM_COPIED;
147121 pNewTerm->prereqAll = pTerm->prereqAll;
147122 }
147123 }
147124 #endif /* SQLITE_ENABLE_STAT4 */
147125
147126 /* Prevent ON clause terms of a LEFT JOIN from being used to drive
147127 ** an index for tables to the left of the join.
147128 */
147129 testcase( pTerm!=&pWC->a[idxTerm] );
147130 pTerm = &pWC->a[idxTerm];
@@ -228086,11 +228066,11 @@
228086 int nArg, /* Number of args */
228087 sqlite3_value **apUnused /* Function arguments */
228088 ){
228089 assert( nArg==0 );
228090 UNUSED_PARAM2(nArg, apUnused);
228091 sqlite3_result_text(pCtx, "fts5: 2021-01-18 12:35:16 c1862abb44873f06ec0d772469d8a2d128ae4670b1e98c2d97b0e2da18df9a04", -1, SQLITE_TRANSIENT);
228092 }
228093
228094 /*
228095 ** Return true if zName is the extension on one of the shadow tables used
228096 ** by this module.
@@ -233012,12 +232992,12 @@
233012 }
233013 #endif /* SQLITE_CORE */
233014 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
233015
233016 /************** End of stmt.c ************************************************/
233017 #if __LINE__!=233017
233018 #undef SQLITE_SOURCE_ID
233019 #define SQLITE_SOURCE_ID "2021-01-18 12:35:16 c1862abb44873f06ec0d772469d8a2d128ae4670b1e98c2d97b0e2da18dfalt2"
233020 #endif
233021 /* Return the source-id for this library */
233022 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
233023 /************************** End of sqlite3.c ******************************/
233024
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1186,11 +1186,11 @@
1186 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1187 ** [sqlite_version()] and [sqlite_source_id()].
1188 */
1189 #define SQLITE_VERSION "3.35.0"
1190 #define SQLITE_VERSION_NUMBER 3035000
1191 #define SQLITE_SOURCE_ID "2021-01-27 19:15:06 9dc7fc9f04d5c14fc436e5ff5b4c06c1969ddde5857ebeb5dccd59b7c748c339"
1192
1193 /*
1194 ** CAPI3REF: Run-Time Library Version Numbers
1195 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1196 **
@@ -14758,10 +14758,11 @@
14758 typedef struct AutoincInfo AutoincInfo;
14759 typedef struct Bitvec Bitvec;
14760 typedef struct CollSeq CollSeq;
14761 typedef struct Column Column;
14762 typedef struct Db Db;
14763 typedef struct DbFixer DbFixer;
14764 typedef struct Schema Schema;
14765 typedef struct Expr Expr;
14766 typedef struct ExprList ExprList;
14767 typedef struct FKey FKey;
14768 typedef struct FuncDestructor FuncDestructor;
@@ -19102,25 +19103,10 @@
19103 char *zSpan; /* Original SQL text of this command */
19104 TriggerStep *pNext; /* Next in the link-list */
19105 TriggerStep *pLast; /* Last element in link-list. Valid for 1st elem only */
19106 };
19107
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19108 /*
19109 ** An objected used to accumulate the text of a string where we
19110 ** do not necessarily know how big the string will be in the end.
19111 */
19112 struct sqlite3_str {
@@ -19267,12 +19253,28 @@
19253 struct WindowRewrite *pRewrite; /* Window rewrite context */
19254 struct WhereConst *pConst; /* WHERE clause constants */
19255 struct RenameCtx *pRename; /* RENAME COLUMN context */
19256 struct Table *pTab; /* Table of generated column */
19257 struct SrcList_item *pSrcItem; /* A single FROM clause item */
19258 DbFixer *pFix;
19259 } u;
19260 };
19261
19262 /*
19263 ** The following structure contains information used by the sqliteFix...
19264 ** routines as they walk the parse tree to make database references
19265 ** explicit.
19266 */
19267 struct DbFixer {
19268 Parse *pParse; /* The parsing context. Error messages written here */
19269 Walker w; /* Walker object */
19270 Schema *pSchema; /* Fix items to this schema */
19271 u8 bTemp; /* True for TEMP schema entries */
19272 const char *zDb; /* Make sure all objects are contained in this database */
19273 const char *zType; /* Type of the container - used for error messages */
19274 const Token *pName; /* Name of the container - used for error messages */
19275 };
19276
19277 /* Forward declarations */
19278 SQLITE_PRIVATE int sqlite3WalkExpr(Walker*, Expr*);
19279 SQLITE_PRIVATE int sqlite3WalkExprList(Walker*, ExprList*);
19280 SQLITE_PRIVATE int sqlite3WalkSelect(Walker*, Select*);
@@ -19979,11 +19981,10 @@
19981 SQLITE_PRIVATE void sqlite3Detach(Parse*, Expr*);
19982 SQLITE_PRIVATE void sqlite3FixInit(DbFixer*, Parse*, int, const char*, const Token*);
19983 SQLITE_PRIVATE int sqlite3FixSrcList(DbFixer*, SrcList*);
19984 SQLITE_PRIVATE int sqlite3FixSelect(DbFixer*, Select*);
19985 SQLITE_PRIVATE int sqlite3FixExpr(DbFixer*, Expr*);
 
19986 SQLITE_PRIVATE int sqlite3FixTriggerStep(DbFixer*, TriggerStep*);
19987 SQLITE_PRIVATE int sqlite3RealSameAsInt(double,sqlite3_int64);
19988 SQLITE_PRIVATE void sqlite3Int64ToText(i64,char*);
19989 SQLITE_PRIVATE int sqlite3AtoF(const char *z, double*, int, u8);
19990 SQLITE_PRIVATE int sqlite3GetInt32(const char *, int*);
@@ -67720,10 +67721,11 @@
67721 assert( nReserve>=0 && nReserve<=255 );
67722 if( pageSize>=512 && pageSize<=SQLITE_MAX_PAGE_SIZE &&
67723 ((pageSize-1)&pageSize)==0 ){
67724 assert( (pageSize & 7)==0 );
67725 assert( !pBt->pCursor );
67726 if( nReserve>32 && pageSize==512 ) pageSize = 1024;
67727 pBt->pageSize = (u32)pageSize;
67728 freeTempSpace(pBt);
67729 }
67730 rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize, nReserve);
67731 pBt->usableSize = pBt->pageSize - (u16)nReserve;
@@ -90727,12 +90729,14 @@
90729 case OP_NewRowid: { /* out2 */
90730 i64 v; /* The new rowid */
90731 VdbeCursor *pC; /* Cursor of table to get the new rowid */
90732 int res; /* Result of an sqlite3BtreeLast() */
90733 int cnt; /* Counter to limit the number of searches */
90734 #ifndef SQLITE_OMIT_AUTOINCREMENT
90735 Mem *pMem; /* Register holding largest rowid for AUTOINCREMENT */
90736 VdbeFrame *pFrame; /* Root frame of VDBE */
90737 #endif
90738
90739 v = 0;
90740 res = 0;
90741 pOut = out2Prerelease(p, pOp);
90742 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
@@ -91728,11 +91732,11 @@
91732 if( rc ) goto abort_due_to_error;
91733 if( res==0 ){
91734 rc = sqlite3BtreeDelete(pCrsr, BTREE_AUXDELETE);
91735 if( rc ) goto abort_due_to_error;
91736 }else if( pOp->p5 ){
91737 rc = sqlite3ReportError(SQLITE_CORRUPT_INDEX, __LINE__, "index corruption");
91738 goto abort_due_to_error;
91739 }
91740 assert( pC->deferredMoveto==0 );
91741 pC->cacheStatus = CACHE_STALE;
91742 pC->seekResult = 0;
@@ -110681,10 +110685,67 @@
110685 {0}
110686 };
110687 codeAttach(pParse, SQLITE_ATTACH, &attach_func, p, p, pDbname, pKey);
110688 }
110689 #endif /* SQLITE_OMIT_ATTACH */
110690
110691 /*
110692 ** Expression callback used by sqlite3FixAAAA() routines.
110693 */
110694 static int fixExprCb(Walker *p, Expr *pExpr){
110695 DbFixer *pFix = p->u.pFix;
110696 if( !pFix->bTemp ) ExprSetProperty(pExpr, EP_FromDDL);
110697 if( pExpr->op==TK_VARIABLE ){
110698 if( pFix->pParse->db->init.busy ){
110699 pExpr->op = TK_NULL;
110700 }else{
110701 sqlite3ErrorMsg(pFix->pParse, "%s cannot use variables", pFix->zType);
110702 return WRC_Abort;
110703 }
110704 }
110705 return WRC_Continue;
110706 }
110707
110708 /*
110709 ** Select callback used by sqlite3FixAAAA() routines.
110710 */
110711 static int fixSelectCb(Walker *p, Select *pSelect){
110712 DbFixer *pFix = p->u.pFix;
110713 int i;
110714 struct SrcList_item *pItem;
110715 sqlite3 *db = pFix->pParse->db;
110716 int iDb = sqlite3FindDbName(db, pFix->zDb);
110717 SrcList *pList = pSelect->pSrc;
110718
110719 if( NEVER(pList==0) ) return WRC_Continue;
110720 for(i=0, pItem=pList->a; i<pList->nSrc; i++, pItem++){
110721 if( pFix->bTemp==0 ){
110722 if( pItem->zDatabase && iDb!=sqlite3FindDbName(db, pItem->zDatabase) ){
110723 sqlite3ErrorMsg(pFix->pParse,
110724 "%s %T cannot reference objects in database %s",
110725 pFix->zType, pFix->pName, pItem->zDatabase);
110726 return WRC_Abort;
110727 }
110728 sqlite3DbFree(db, pItem->zDatabase);
110729 pItem->zDatabase = 0;
110730 pItem->pSchema = pFix->pSchema;
110731 pItem->fg.fromDDL = 1;
110732 }
110733 #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER)
110734 if( sqlite3WalkExpr(&pFix->w, pList->a[i].pOn) ) return WRC_Abort;
110735 #endif
110736 }
110737 if( pSelect->pWith ){
110738 int i;
110739 for(i=0; i<pSelect->pWith->nCte; i++){
110740 if( sqlite3WalkSelect(p, pSelect->pWith->a[i].pSelect) ){
110741 return WRC_Abort;
110742 }
110743 }
110744 }
110745 return WRC_Continue;
110746 }
110747
110748 /*
110749 ** Initialize a DbFixer structure. This routine must be called prior
110750 ** to passing the structure to one of the sqliteFixAAAA() routines below.
110751 */
@@ -110693,20 +110754,25 @@
110754 Parse *pParse, /* Error messages will be written here */
110755 int iDb, /* This is the database that must be used */
110756 const char *zType, /* "view", "trigger", or "index" */
110757 const Token *pName /* Name of the view, trigger, or index */
110758 ){
110759 sqlite3 *db = pParse->db;
 
 
110760 assert( db->nDb>iDb );
110761 pFix->pParse = pParse;
110762 pFix->zDb = db->aDb[iDb].zDbSName;
110763 pFix->pSchema = db->aDb[iDb].pSchema;
110764 pFix->zType = zType;
110765 pFix->pName = pName;
110766 pFix->bTemp = (iDb==1);
110767 pFix->w.pParse = pParse;
110768 pFix->w.xExprCallback = fixExprCb;
110769 pFix->w.xSelectCallback = fixSelectCb;
110770 pFix->w.xSelectCallback2 = 0;
110771 pFix->w.walkerDepth = 0;
110772 pFix->w.eCode = 0;
110773 pFix->w.u.pFix = pFix;
110774 }
110775
110776 /*
110777 ** The following set of routines walk through the parse tree and assign
110778 ** a specific database to all table references where the database name
@@ -110723,154 +110789,62 @@
110789 */
110790 SQLITE_PRIVATE int sqlite3FixSrcList(
110791 DbFixer *pFix, /* Context of the fixation */
110792 SrcList *pList /* The Source list to check and modify */
110793 ){
110794 int res = 0;
110795 if( pList ){
110796 Select s;
110797 memset(&s, 0, sizeof(s));
110798 s.pSrc = pList;
110799 res = sqlite3WalkSelect(&pFix->w, &s);
110800 }
110801 return res;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110802 }
110803 #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER)
110804 SQLITE_PRIVATE int sqlite3FixSelect(
110805 DbFixer *pFix, /* Context of the fixation */
110806 Select *pSelect /* The SELECT statement to be fixed to one database */
110807 ){
110808 return sqlite3WalkSelect(&pFix->w, pSelect);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110809 }
110810 SQLITE_PRIVATE int sqlite3FixExpr(
110811 DbFixer *pFix, /* Context of the fixation */
110812 Expr *pExpr /* The expression to be fixed to one database */
110813 ){
110814 return sqlite3WalkExpr(&pFix->w, pExpr);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110815 }
110816 #endif
110817
110818 #ifndef SQLITE_OMIT_TRIGGER
110819 SQLITE_PRIVATE int sqlite3FixTriggerStep(
110820 DbFixer *pFix, /* Context of the fixation */
110821 TriggerStep *pStep /* The trigger step be fixed to one database */
110822 ){
110823 while( pStep ){
110824 if( sqlite3WalkSelect(&pFix->w, pStep->pSelect)
110825 || sqlite3WalkExpr(&pFix->w, pStep->pWhere)
110826 || sqlite3WalkExprList(&pFix->w, pStep->pExprList)
110827 || sqlite3FixSrcList(pFix, pStep->pFrom)
110828 ){
 
 
 
 
 
110829 return 1;
110830 }
110831 #ifndef SQLITE_OMIT_UPSERT
110832 if( pStep->pUpsert ){
110833 Upsert *pUp = pStep->pUpsert;
110834 if( sqlite3WalkExprList(&pFix->w, pUp->pUpsertTarget)
110835 || sqlite3WalkExpr(&pFix->w, pUp->pUpsertTargetWhere)
110836 || sqlite3WalkExprList(&pFix->w, pUp->pUpsertSet)
110837 || sqlite3WalkExpr(&pFix->w, pUp->pUpsertWhere)
110838 ){
110839 return 1;
110840 }
110841 }
110842 #endif
110843 pStep = pStep->pNext;
110844 }
110845
110846 return 0;
110847 }
110848 #endif
110849
110850 /************** End of attach.c **********************************************/
@@ -119692,11 +119666,13 @@
119666 ** false.
119667 */
119668 SQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3 *db, Expr *pExpr, int *pIsNocase, char *aWc){
119669 FuncDef *pDef;
119670 int nExpr;
119671 assert( pExpr!=0 );
119672 assert( pExpr->op==TK_FUNCTION );
119673 if( !pExpr->x.pList ){
119674 return 0;
119675 }
119676 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
119677 nExpr = pExpr->x.pList->nExpr;
119678 pDef = sqlite3FindFunction(db, pExpr->u.zToken, nExpr, SQLITE_UTF8, 0);
@@ -122866,11 +122842,13 @@
122842 }
122843 #endif
122844 sqlite3VdbeJumpHere(v, addrInsTop);
122845 }
122846
122847 #ifndef SQLITE_OMIT_XFER_OPT
122848 insert_end:
122849 #endif /* SQLITE_OMIT_XFER_OPT */
122850 /* Update the sqlite_sequence table by storing the content of the
122851 ** maximum rowid counter values recorded while inserting into
122852 ** autoincrement tables.
122853 */
122854 if( pParse->nested==0 && pParse->pTriggerTab==0 ){
@@ -142614,15 +142592,11 @@
142592 #define TERM_CODED 0x0004 /* This term is already coded */
142593 #define TERM_COPIED 0x0008 /* Has a child */
142594 #define TERM_ORINFO 0x0010 /* Need to free the WhereTerm.u.pOrInfo object */
142595 #define TERM_ANDINFO 0x0020 /* Need to free the WhereTerm.u.pAndInfo obj */
142596 #define TERM_OR_OK 0x0040 /* Used during OR-clause processing */
142597 #define TERM_VNULL 0x0080 /* Manufactured x>NULL or x<=NULL term */
 
 
 
 
142598 #define TERM_LIKEOPT 0x0100 /* Virtual terms from the LIKE optimization */
142599 #define TERM_LIKECOND 0x0200 /* Conditionally this LIKE operator term */
142600 #define TERM_LIKE 0x0400 /* The original LIKE operator */
142601 #define TERM_IS 0x0800 /* Term.pExpr is an IS operator */
142602 #define TERM_VARSELECT 0x1000 /* Term.pExpr contains a correlated sub-query */
@@ -144679,10 +144653,16 @@
144653 ){
144654 SWAP(WhereTerm *, pRangeEnd, pRangeStart);
144655 SWAP(u8, bSeekPastNull, bStopAtNull);
144656 SWAP(u8, nBtm, nTop);
144657 }
144658
144659 if( iLevel>0 && (pLoop->wsFlags & WHERE_IN_SEEKSCAN)!=0 ){
144660 /* In case OP_SeekScan is used, ensure that the index cursor does not
144661 ** point to a valid row for the first iteration of this loop. */
144662 sqlite3VdbeAddOp1(v, OP_NullRow, iIdxCur);
144663 }
144664
144665 /* Generate code to evaluate all constraint terms using == or IN
144666 ** and store the values of those terms in an array of registers
144667 ** starting at regBase.
144668 */
@@ -146894,10 +146874,46 @@
146874 ){
146875 exprAnalyzeExists(pSrc, pWC, idxTerm);
146876 }
146877 }
146878
146879 /* The form "x IS NOT NULL" can sometimes be evaluated more efficiently
146880 ** as "x>NULL" if x is not an INTEGER PRIMARY KEY. So construct a
146881 ** virtual term of that form.
146882 **
146883 ** The virtual term must be tagged with TERM_VNULL.
146884 */
146885 else if( pExpr->op==TK_NOTNULL ){
146886 if( pExpr->pLeft->op==TK_COLUMN
146887 && pExpr->pLeft->iColumn>=0
146888 && !ExprHasProperty(pExpr, EP_FromJoin)
146889 ){
146890 Expr *pNewExpr;
146891 Expr *pLeft = pExpr->pLeft;
146892 int idxNew;
146893 WhereTerm *pNewTerm;
146894
146895 pNewExpr = sqlite3PExpr(pParse, TK_GT,
146896 sqlite3ExprDup(db, pLeft, 0),
146897 sqlite3ExprAlloc(db, TK_NULL, 0, 0));
146898
146899 idxNew = whereClauseInsert(pWC, pNewExpr,
146900 TERM_VIRTUAL|TERM_DYNAMIC|TERM_VNULL);
146901 if( idxNew ){
146902 pNewTerm = &pWC->a[idxNew];
146903 pNewTerm->prereqRight = 0;
146904 pNewTerm->leftCursor = pLeft->iTable;
146905 pNewTerm->u.x.leftColumn = pLeft->iColumn;
146906 pNewTerm->eOperator = WO_GT;
146907 markTermAsChild(pWC, idxNew, idxTerm);
146908 pTerm = &pWC->a[idxTerm];
146909 pTerm->wtFlags |= TERM_COPIED;
146910 pNewTerm->prereqAll = pTerm->prereqAll;
146911 }
146912 }
146913 }
146914
146915
146916 #ifndef SQLITE_OMIT_LIKE_OPTIMIZATION
146917 /* Add constraints to reduce the search space on a LIKE or GLOB
146918 ** operator.
146919 **
@@ -146909,11 +146925,12 @@
146925 ** termination condition "abd". If case is not significant (the default
146926 ** for LIKE) then the lower-bound is made all uppercase and the upper-
146927 ** bound is made all lowercase so that the bounds also work when comparing
146928 ** BLOBs.
146929 */
146930 else if( pExpr->op==TK_FUNCTION
146931 && pWC->op==TK_AND
146932 && isLikeOrGlob(pParse, pExpr, &pStr1, &isComplete, &noCase)
146933 ){
146934 Expr *pLeft; /* LHS of LIKE/GLOB operator */
146935 Expr *pStr2; /* Copy of pStr1 - RHS of LIKE/GLOB operator */
146936 Expr *pNewExpr1;
@@ -146978,10 +146995,69 @@
146995 markTermAsChild(pWC, idxNew1, idxTerm);
146996 markTermAsChild(pWC, idxNew2, idxTerm);
146997 }
146998 }
146999 #endif /* SQLITE_OMIT_LIKE_OPTIMIZATION */
147000
147001 /* If there is a vector == or IS term - e.g. "(a, b) == (?, ?)" - create
147002 ** new terms for each component comparison - "a = ?" and "b = ?". The
147003 ** new terms completely replace the original vector comparison, which is
147004 ** no longer used.
147005 **
147006 ** This is only required if at least one side of the comparison operation
147007 ** is not a sub-select. */
147008 if( (pExpr->op==TK_EQ || pExpr->op==TK_IS)
147009 && (nLeft = sqlite3ExprVectorSize(pExpr->pLeft))>1
147010 && sqlite3ExprVectorSize(pExpr->pRight)==nLeft
147011 && ( (pExpr->pLeft->flags & EP_xIsSelect)==0
147012 || (pExpr->pRight->flags & EP_xIsSelect)==0)
147013 && pWC->op==TK_AND
147014 ){
147015 int i;
147016 for(i=0; i<nLeft; i++){
147017 int idxNew;
147018 Expr *pNew;
147019 Expr *pLeft = sqlite3ExprForVectorField(pParse, pExpr->pLeft, i);
147020 Expr *pRight = sqlite3ExprForVectorField(pParse, pExpr->pRight, i);
147021
147022 pNew = sqlite3PExpr(pParse, pExpr->op, pLeft, pRight);
147023 transferJoinMarkings(pNew, pExpr);
147024 idxNew = whereClauseInsert(pWC, pNew, TERM_DYNAMIC);
147025 exprAnalyze(pSrc, pWC, idxNew);
147026 }
147027 pTerm = &pWC->a[idxTerm];
147028 pTerm->wtFlags |= TERM_CODED|TERM_VIRTUAL; /* Disable the original */
147029 pTerm->eOperator = 0;
147030 }
147031
147032 /* If there is a vector IN term - e.g. "(a, b) IN (SELECT ...)" - create
147033 ** a virtual term for each vector component. The expression object
147034 ** used by each such virtual term is pExpr (the full vector IN(...)
147035 ** expression). The WhereTerm.u.x.iField variable identifies the index within
147036 ** the vector on the LHS that the virtual term represents.
147037 **
147038 ** This only works if the RHS is a simple SELECT (not a compound) that does
147039 ** not use window functions.
147040 */
147041 else if( pExpr->op==TK_IN
147042 && pTerm->u.x.iField==0
147043 && pExpr->pLeft->op==TK_VECTOR
147044 && pExpr->x.pSelect->pPrior==0
147045 #ifndef SQLITE_OMIT_WINDOWFUNC
147046 && pExpr->x.pSelect->pWin==0
147047 #endif
147048 && pWC->op==TK_AND
147049 ){
147050 int i;
147051 for(i=0; i<sqlite3ExprVectorSize(pExpr->pLeft); i++){
147052 int idxNew;
147053 idxNew = whereClauseInsert(pWC, pExpr, TERM_VIRTUAL);
147054 pWC->a[idxNew].u.x.iField = i+1;
147055 exprAnalyze(pSrc, pWC, idxNew);
147056 markTermAsChild(pWC, idxNew, idxTerm);
147057 }
147058 }
147059
147060 #ifndef SQLITE_OMIT_VIRTUALTABLE
147061 /* Add a WO_AUX auxiliary term to the constraint set if the
147062 ** current expression is of the form "column OP expr" where OP
147063 ** is an operator that gets passed into virtual tables but which is
@@ -146989,11 +147065,11 @@
147065 ** is one of MATCH, LIKE, GLOB, REGEXP, !=, IS, IS NOT, or NOT NULL.
147066 ** This information is used by the xBestIndex methods of
147067 ** virtual tables. The native query optimizer does not attempt
147068 ** to do anything with MATCH functions.
147069 */
147070 else if( pWC->op==TK_AND ){
147071 Expr *pRight = 0, *pLeft = 0;
147072 int res = isAuxiliaryVtabOperator(db, pExpr, &eOp2, &pLeft, &pRight);
147073 while( res-- > 0 ){
147074 int idxNew;
147075 WhereTerm *pNewTerm;
@@ -147025,106 +147101,10 @@
147101 SWAP(Expr*, pLeft, pRight);
147102 }
147103 }
147104 #endif /* SQLITE_OMIT_VIRTUALTABLE */
147105
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147106 /* Prevent ON clause terms of a LEFT JOIN from being used to drive
147107 ** an index for tables to the left of the join.
147108 */
147109 testcase( pTerm!=&pWC->a[idxTerm] );
147110 pTerm = &pWC->a[idxTerm];
@@ -228086,11 +228066,11 @@
228066 int nArg, /* Number of args */
228067 sqlite3_value **apUnused /* Function arguments */
228068 ){
228069 assert( nArg==0 );
228070 UNUSED_PARAM2(nArg, apUnused);
228071 sqlite3_result_text(pCtx, "fts5: 2021-01-27 19:15:06 9dc7fc9f04d5c14fc436e5ff5b4c06c1969ddde5857ebeb5dccd59b7c748c339", -1, SQLITE_TRANSIENT);
228072 }
228073
228074 /*
228075 ** Return true if zName is the extension on one of the shadow tables used
228076 ** by this module.
@@ -233012,12 +232992,12 @@
232992 }
232993 #endif /* SQLITE_CORE */
232994 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
232995
232996 /************** End of stmt.c ************************************************/
232997 #if __LINE__!=232997
232998 #undef SQLITE_SOURCE_ID
232999 #define SQLITE_SOURCE_ID "2021-01-27 19:15:06 9dc7fc9f04d5c14fc436e5ff5b4c06c1969ddde5857ebeb5dccd59b7c748alt2"
233000 #endif
233001 /* Return the source-id for this library */
233002 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
233003 /************************** End of sqlite3.c ******************************/
233004
+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.35.0"
127127
#define SQLITE_VERSION_NUMBER 3035000
128
-#define SQLITE_SOURCE_ID "2021-01-18 12:35:16 c1862abb44873f06ec0d772469d8a2d128ae4670b1e98c2d97b0e2da18df9a04"
128
+#define SQLITE_SOURCE_ID "2021-01-27 19:15:06 9dc7fc9f04d5c14fc436e5ff5b4c06c1969ddde5857ebeb5dccd59b7c748c339"
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.35.0"
127 #define SQLITE_VERSION_NUMBER 3035000
128 #define SQLITE_SOURCE_ID "2021-01-18 12:35:16 c1862abb44873f06ec0d772469d8a2d128ae4670b1e98c2d97b0e2da18df9a04"
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.35.0"
127 #define SQLITE_VERSION_NUMBER 3035000
128 #define SQLITE_SOURCE_ID "2021-01-27 19:15:06 9dc7fc9f04d5c14fc436e5ff5b4c06c1969ddde5857ebeb5dccd59b7c748c339"
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