1
1
#ifndef USE_LIBSQLITE3
2
2
/******************************************************************************
3
3
** This file is an amalgamation of many separate C source files from SQLite
4
- ** version 3.25.0 . By combining all the individual C code files into this
4
+ ** version 3.25.2 . By combining all the individual C code files into this
5
5
** single large file, the entire code can be compiled as a single translation
6
6
** unit. This allows many compilers to do optimizations that would not be
7
7
** possible if the files were compiled separately. Performance improvements
@@ -1157,9 +1157,9 @@ extern "C" {
1157
1157
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1158
1158
** [sqlite_version()] and [sqlite_source_id()].
1159
1159
*/
1160
- #define SQLITE_VERSION "3.25.0 "
1161
- #define SQLITE_VERSION_NUMBER 3025000
1162
- #define SQLITE_SOURCE_ID "2018-09-15 04:01:47 b63af6c3bd33152742648d5d2e8dc5d5fcbcdd27df409272b6aea00a6f761760 "
1160
+ #define SQLITE_VERSION "3.25.2 "
1161
+ #define SQLITE_VERSION_NUMBER 3025002
1162
+ #define SQLITE_SOURCE_ID "2018-09-25 19:08:10 fb90e7189ae6d62e77ba3a308ca5d683f90bbe633cf681865365b8e92792d1c7 "
1163
1163
1164
1164
/*
1165
1165
** CAPI3REF: Run-Time Library Version Numbers
@@ -16270,6 +16270,7 @@ struct sqlite3 {
16270
16270
#define SQLITE_EnableQPSG 0x00800000 /* Query Planner Stability Guarantee*/
16271
16271
#define SQLITE_TriggerEQP 0x01000000 /* Show trigger EXPLAIN QUERY PLAN */
16272
16272
#define SQLITE_ResetDatabase 0x02000000 /* Reset the database */
16273
+ #define SQLITE_LegacyAlter 0x04000000 /* Legacy ALTER TABLE behaviour */
16273
16274
16274
16275
/* Flags used only if debugging */
16275
16276
#ifdef SQLITE_DEBUG
@@ -32620,7 +32621,11 @@ static struct unix_syscall {
32620
32621
#define osLstat ((int(*)(const char*,struct stat*))aSyscall[27].pCurrent)
32621
32622
32622
32623
#if defined(__linux__) && defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)
32624
+ # ifdef __ANDROID__
32625
+ { "ioctl", (sqlite3_syscall_ptr)(int(*)(int, int, ...))ioctl, 0 },
32626
+ # else
32623
32627
{ "ioctl", (sqlite3_syscall_ptr)ioctl, 0 },
32628
+ # endif
32624
32629
#else
32625
32630
{ "ioctl", (sqlite3_syscall_ptr)0, 0 },
32626
32631
#endif
@@ -89714,7 +89719,10 @@ case OP_VNext: { /* jump */
89714
89719
case OP_VRename: {
89715
89720
sqlite3_vtab *pVtab;
89716
89721
Mem *pName;
89717
-
89722
+ int isLegacy;
89723
+
89724
+ isLegacy = (db->flags & SQLITE_LegacyAlter);
89725
+ db->flags |= SQLITE_LegacyAlter;
89718
89726
pVtab = pOp->p4.pVtab->pVtab;
89719
89727
pName = &aMem[pOp->p1];
89720
89728
assert( pVtab->pModule->xRename );
@@ -89728,6 +89736,7 @@ case OP_VRename: {
89728
89736
rc = sqlite3VdbeChangeEncoding(pName, SQLITE_UTF8);
89729
89737
if( rc ) goto abort_due_to_error;
89730
89738
rc = pVtab->pModule->xRename(pVtab, pName->z);
89739
+ if( isLegacy==0 ) db->flags &= ~SQLITE_LegacyAlter;
89731
89740
sqlite3VtabImportErrmsg(p, pVtab);
89732
89741
p->expired = 0;
89733
89742
if( rc ) goto abort_due_to_error;
@@ -97048,17 +97057,14 @@ static Expr *exprDup(sqlite3 *db, Expr *p, int dupFlags, u8 **pzBuffer){
97048
97057
}
97049
97058
97050
97059
/* Fill in pNew->pLeft and pNew->pRight. */
97060
+ zAlloc += dupedExprNodeSize(p, dupFlags);
97051
97061
if( ExprHasProperty(pNew, EP_Reduced|EP_TokenOnly) ){
97052
- zAlloc += dupedExprNodeSize(p, dupFlags);
97053
97062
if( !ExprHasProperty(pNew, EP_TokenOnly|EP_Leaf) ){
97054
97063
pNew->pLeft = p->pLeft ?
97055
97064
exprDup(db, p->pLeft, EXPRDUP_REDUCE, &zAlloc) : 0;
97056
97065
pNew->pRight = p->pRight ?
97057
97066
exprDup(db, p->pRight, EXPRDUP_REDUCE, &zAlloc) : 0;
97058
97067
}
97059
- if( pzBuffer ){
97060
- *pzBuffer = zAlloc;
97061
- }
97062
97068
}else{
97063
97069
#ifndef SQLITE_OMIT_WINDOWFUNC
97064
97070
if( ExprHasProperty(p, EP_Reduced|EP_TokenOnly) ){
@@ -97078,6 +97084,9 @@ static Expr *exprDup(sqlite3 *db, Expr *p, int dupFlags, u8 **pzBuffer){
97078
97084
pNew->pRight = sqlite3ExprDup(db, p->pRight, 0);
97079
97085
}
97080
97086
}
97087
+ if( pzBuffer ){
97088
+ *pzBuffer = zAlloc;
97089
+ }
97081
97090
}
97082
97091
return pNew;
97083
97092
}
@@ -100629,18 +100638,15 @@ SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Parse *pParse, Expr *pE1, Expr *pE2, i
100629
100638
/*
100630
100639
** This is the Expr node callback for sqlite3ExprImpliesNotNullRow().
100631
100640
** If the expression node requires that the table at pWalker->iCur
100632
- ** have a non-NULL column, then set pWalker->eCode to 1 and abort.
100641
+ ** have one or more non-NULL column, then set pWalker->eCode to 1 and abort.
100642
+ **
100643
+ ** This routine controls an optimization. False positives (setting
100644
+ ** pWalker->eCode to 1 when it should not be) are deadly, but false-negatives
100645
+ ** (never setting pWalker->eCode) is a harmless missed optimization.
100633
100646
*/
100634
100647
static int impliesNotNullRow(Walker *pWalker, Expr *pExpr){
100635
- /* This routine is only called for WHERE clause expressions and so it
100636
- ** cannot have any TK_AGG_COLUMN entries because those are only found
100637
- ** in HAVING clauses. We can get a TK_AGG_FUNCTION in a WHERE clause,
100638
- ** but that is an illegal construct and the query will be rejected at
100639
- ** a later stage of processing, so the TK_AGG_FUNCTION case does not
100640
- ** need to be considered here. */
100641
- assert( pExpr->op!=TK_AGG_COLUMN );
100648
+ testcase( pExpr->op==TK_AGG_COLUMN );
100642
100649
testcase( pExpr->op==TK_AGG_FUNCTION );
100643
-
100644
100650
if( ExprHasProperty(pExpr, EP_FromJoin) ) return WRC_Prune;
100645
100651
switch( pExpr->op ){
100646
100652
case TK_ISNOT:
@@ -101299,20 +101305,6 @@ SQLITE_PRIVATE void sqlite3AlterRenameTable(
101299
101305
goto exit_rename_table;
101300
101306
}
101301
101307
101302
- /* If this is a virtual table, invoke the xRename() function if
101303
- ** one is defined. The xRename() callback will modify the names
101304
- ** of any resources used by the v-table implementation (including other
101305
- ** SQLite tables) that are identified by the name of the virtual table.
101306
- */
101307
- #ifndef SQLITE_OMIT_VIRTUALTABLE
101308
- if( pVTab ){
101309
- int i = ++pParse->nMem;
101310
- sqlite3VdbeLoadString(v, i, zName);
101311
- sqlite3VdbeAddOp4(v, OP_VRename, i, 0, 0,(const char*)pVTab, P4_VTAB);
101312
- sqlite3MayAbort(pParse);
101313
- }
101314
- #endif
101315
-
101316
101308
/* figure out how many UTF-8 characters are in zName */
101317
101309
zTabName = pTab->zName;
101318
101310
nTabName = sqlite3Utf8CharLen(zTabName, -1);
@@ -101370,6 +101362,20 @@ SQLITE_PRIVATE void sqlite3AlterRenameTable(
101370
101362
, zDb, zTabName, zName, zTabName, zDb, zName);
101371
101363
}
101372
101364
101365
+ /* If this is a virtual table, invoke the xRename() function if
101366
+ ** one is defined. The xRename() callback will modify the names
101367
+ ** of any resources used by the v-table implementation (including other
101368
+ ** SQLite tables) that are identified by the name of the virtual table.
101369
+ */
101370
+ #ifndef SQLITE_OMIT_VIRTUALTABLE
101371
+ if( pVTab ){
101372
+ int i = ++pParse->nMem;
101373
+ sqlite3VdbeLoadString(v, i, zName);
101374
+ sqlite3VdbeAddOp4(v, OP_VRename, i, 0, 0,(const char*)pVTab, P4_VTAB);
101375
+ sqlite3MayAbort(pParse);
101376
+ }
101377
+ #endif
101378
+
101373
101379
renameReloadSchema(pParse, iDb);
101374
101380
renameTestSchema(pParse, zDb, iDb==1);
101375
101381
@@ -102206,7 +102212,7 @@ static int renameResolveTrigger(Parse *pParse, const char *zDb){
102206
102212
Table *pTarget = sqlite3LocateTable(pParse, 0, pStep->zTarget, zDb);
102207
102213
if( pTarget==0 ){
102208
102214
rc = SQLITE_ERROR;
102209
- }else{
102215
+ }else if( SQLITE_OK==(rc = sqlite3ViewGetColumnNames(pParse, pTarget)) ) {
102210
102216
SrcList sSrc;
102211
102217
memset(&sSrc, 0, sizeof(sSrc));
102212
102218
sSrc.nSrc = 1;
@@ -102552,17 +102558,20 @@ static void renameTableFunc(
102552
102558
rc = renameParseSql(&sParse, zDb, 1, db, zInput, bTemp);
102553
102559
102554
102560
if( rc==SQLITE_OK ){
102561
+ int isLegacy = (db->flags & SQLITE_LegacyAlter);
102555
102562
if( sParse.pNewTable ){
102556
102563
Table *pTab = sParse.pNewTable;
102557
102564
102558
102565
if( pTab->pSelect ){
102559
- NameContext sNC;
102560
- memset(&sNC, 0, sizeof(sNC));
102561
- sNC.pParse = &sParse;
102562
-
102563
- sqlite3SelectPrep(&sParse, pTab->pSelect, &sNC);
102564
- if( sParse.nErr ) rc = sParse.rc;
102565
- sqlite3WalkSelect(&sWalker, pTab->pSelect);
102566
+ if( isLegacy==0 ){
102567
+ NameContext sNC;
102568
+ memset(&sNC, 0, sizeof(sNC));
102569
+ sNC.pParse = &sParse;
102570
+
102571
+ sqlite3SelectPrep(&sParse, pTab->pSelect, &sNC);
102572
+ if( sParse.nErr ) rc = sParse.rc;
102573
+ sqlite3WalkSelect(&sWalker, pTab->pSelect);
102574
+ }
102566
102575
}else{
102567
102576
/* Modify any FK definitions to point to the new table. */
102568
102577
#ifndef SQLITE_OMIT_FOREIGN_KEY
@@ -102581,15 +102590,19 @@ static void renameTableFunc(
102581
102590
** "CREATE [VIRTUAL] TABLE" bit. */
102582
102591
if( sqlite3_stricmp(zOld, pTab->zName)==0 ){
102583
102592
sCtx.pTab = pTab;
102584
- sqlite3WalkExprList(&sWalker, pTab->pCheck);
102593
+ if( isLegacy==0 ){
102594
+ sqlite3WalkExprList(&sWalker, pTab->pCheck);
102595
+ }
102585
102596
renameTokenFind(&sParse, &sCtx, pTab->zName);
102586
102597
}
102587
102598
}
102588
102599
}
102589
102600
102590
102601
else if( sParse.pNewIndex ){
102591
102602
renameTokenFind(&sParse, &sCtx, sParse.pNewIndex->zName);
102592
- sqlite3WalkExpr(&sWalker, sParse.pNewIndex->pPartIdxWhere);
102603
+ if( isLegacy==0 ){
102604
+ sqlite3WalkExpr(&sWalker, sParse.pNewIndex->pPartIdxWhere);
102605
+ }
102593
102606
}
102594
102607
102595
102608
#ifndef SQLITE_OMIT_TRIGGER
@@ -102602,12 +102615,14 @@ static void renameTableFunc(
102602
102615
renameTokenFind(&sParse, &sCtx, sParse.pNewTrigger->table);
102603
102616
}
102604
102617
102605
- rc = renameResolveTrigger(&sParse, bTemp ? 0 : zDb);
102606
- if( rc==SQLITE_OK ){
102607
- renameWalkTrigger(&sWalker, pTrigger);
102608
- for(pStep=pTrigger->step_list; pStep; pStep=pStep->pNext){
102609
- if( pStep->zTarget && 0==sqlite3_stricmp(pStep->zTarget, zOld) ){
102610
- renameTokenFind(&sParse, &sCtx, pStep->zTarget);
102618
+ if( isLegacy==0 ){
102619
+ rc = renameResolveTrigger(&sParse, bTemp ? 0 : zDb);
102620
+ if( rc==SQLITE_OK ){
102621
+ renameWalkTrigger(&sWalker, pTrigger);
102622
+ for(pStep=pTrigger->step_list; pStep; pStep=pStep->pNext){
102623
+ if( pStep->zTarget && 0==sqlite3_stricmp(pStep->zTarget, zOld) ){
102624
+ renameTokenFind(&sParse, &sCtx, pStep->zTarget);
102625
+ }
102611
102626
}
102612
102627
}
102613
102628
}
@@ -102665,6 +102680,7 @@ static void renameTableTest(
102665
102680
char const *zDb = (const char*)sqlite3_value_text(argv[0]);
102666
102681
char const *zInput = (const char*)sqlite3_value_text(argv[1]);
102667
102682
int bTemp = sqlite3_value_int(argv[4]);
102683
+ int isLegacy = (db->flags & SQLITE_LegacyAlter);
102668
102684
102669
102685
#ifndef SQLITE_OMIT_AUTHORIZATION
102670
102686
sqlite3_xauth xAuth = db->xAuth;
@@ -102677,7 +102693,7 @@ static void renameTableTest(
102677
102693
Parse sParse;
102678
102694
rc = renameParseSql(&sParse, zDb, 1, db, zInput, bTemp);
102679
102695
if( rc==SQLITE_OK ){
102680
- if( sParse.pNewTable && sParse.pNewTable->pSelect ){
102696
+ if( isLegacy==0 && sParse.pNewTable && sParse.pNewTable->pSelect ){
102681
102697
NameContext sNC;
102682
102698
memset(&sNC, 0, sizeof(sNC));
102683
102699
sNC.pParse = &sParse;
@@ -102686,7 +102702,9 @@ static void renameTableTest(
102686
102702
}
102687
102703
102688
102704
else if( sParse.pNewTrigger ){
102689
- rc = renameResolveTrigger(&sParse, bTemp ? 0 : zDb);
102705
+ if( isLegacy==0 ){
102706
+ rc = renameResolveTrigger(&sParse, bTemp ? 0 : zDb);
102707
+ }
102690
102708
if( rc==SQLITE_OK ){
102691
102709
int i1 = sqlite3SchemaToIndex(db, sParse.pNewTrigger->pTabSchema);
102692
102710
int i2 = sqlite3FindDbName(db, zDb);
@@ -107336,10 +107354,6 @@ static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){
107336
107354
}
107337
107355
}
107338
107356
107339
- /* The remaining transformations only apply to b-tree tables, not to
107340
- ** virtual tables */
107341
- if( IN_DECLARE_VTAB ) return;
107342
-
107343
107357
/* Convert the P3 operand of the OP_CreateBtree opcode from BTREE_INTKEY
107344
107358
** into BTREE_BLOBKEY.
107345
107359
*/
@@ -107852,6 +107866,10 @@ SQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){
107852
107866
assert( pTable->pSelect );
107853
107867
pSel = sqlite3SelectDup(db, pTable->pSelect, 0);
107854
107868
if( pSel ){
107869
+ #ifndef SQLITE_OMIT_ALTERTABLE
107870
+ u8 eParseMode = pParse->eParseMode;
107871
+ pParse->eParseMode = PARSE_MODE_NORMAL;
107872
+ #endif
107855
107873
n = pParse->nTab;
107856
107874
sqlite3SrcListAssignCursors(pParse, pSel->pSrc);
107857
107875
pTable->nCol = -1;
@@ -107897,6 +107915,9 @@ SQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){
107897
107915
sqlite3DeleteTable(db, pSelTab);
107898
107916
sqlite3SelectDelete(db, pSel);
107899
107917
db->lookaside.bDisable--;
107918
+ #ifndef SQLITE_OMIT_ALTERTABLE
107919
+ pParse->eParseMode = eParseMode;
107920
+ #endif
107900
107921
} else {
107901
107922
nErr++;
107902
107923
}
@@ -119463,6 +119484,11 @@ static const PragmaName aPragmaName[] = {
119463
119484
/* iArg: */ 0 },
119464
119485
#endif
119465
119486
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
119487
+ {/* zName: */ "legacy_alter_table",
119488
+ /* ePragTyp: */ PragTyp_FLAG,
119489
+ /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
119490
+ /* ColNames: */ 0, 0,
119491
+ /* iArg: */ SQLITE_LegacyAlter },
119466
119492
{/* zName: */ "legacy_file_format",
119467
119493
/* ePragTyp: */ PragTyp_FLAG,
119468
119494
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
@@ -119716,7 +119742,7 @@ static const PragmaName aPragmaName[] = {
119716
119742
/* iArg: */ SQLITE_WriteSchema },
119717
119743
#endif
119718
119744
};
119719
- /* Number of pragmas: 60 on by default, 77 total. */
119745
+ /* Number of pragmas: 61 on by default, 78 total. */
119720
119746
119721
119747
/************** End of pragma.h **********************************************/
119722
119748
/************** Continuing where we left off in pragma.c *********************/
@@ -129184,6 +129210,7 @@ SQLITE_PRIVATE int sqlite3Select(
129184
129210
sqlite3VdbeAddOp2(v, OP_Goto, 0, iBreak);
129185
129211
sqlite3VdbeResolveLabel(v, addrGosub);
129186
129212
VdbeNoopComment((v, "inner-loop subroutine"));
129213
+ sSort.labelOBLopt = 0;
129187
129214
selectInnerLoop(pParse, p, -1, &sSort, &sDistinct, pDest, iCont, iBreak);
129188
129215
sqlite3VdbeResolveLabel(v, iCont);
129189
129216
sqlite3VdbeAddOp1(v, OP_Return, regGosub);
@@ -154756,6 +154783,7 @@ static int openDatabase(
154756
154783
db->nDb = 2;
154757
154784
db->magic = SQLITE_MAGIC_BUSY;
154758
154785
db->aDb = db->aDbStatic;
154786
+ db->lookaside.bDisable = 1;
154759
154787
154760
154788
assert( sizeof(db->aLimit)==sizeof(aHardLimit) );
154761
154789
memcpy(db->aLimit, aHardLimit, sizeof(db->aLimit));
@@ -214417,7 +214445,7 @@ static void fts5SourceIdFunc(
214417
214445
){
214418
214446
assert( nArg==0 );
214419
214447
UNUSED_PARAM2(nArg, apUnused);
214420
- sqlite3_result_text(pCtx, "fts5: 2018-09-15 04:01:47 b63af6c3bd33152742648d5d2e8dc5d5fcbcdd27df409272b6aea00a6f761760 ", -1, SQLITE_TRANSIENT);
214448
+ sqlite3_result_text(pCtx, "fts5: 2018-09-25 19:08:10 fb90e7189ae6d62e77ba3a308ca5d683f90bbe633cf681865365b8e92792d1c7 ", -1, SQLITE_TRANSIENT);
214421
214449
}
214422
214450
214423
214451
static int fts5Init(sqlite3 *db){
@@ -219127,9 +219155,9 @@ SQLITE_API int sqlite3_stmt_init(
219127
219155
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
219128
219156
219129
219157
/************** End of stmt.c ************************************************/
219130
- #if __LINE__!=219129
219158
+ #if __LINE__!=219157
219131
219159
#undef SQLITE_SOURCE_ID
219132
- #define SQLITE_SOURCE_ID "2018-09-15 04:01:47 b63af6c3bd33152742648d5d2e8dc5d5fcbcdd27df409272b6aea00a6f76alt2 "
219160
+ #define SQLITE_SOURCE_ID "2018-09-25 19:08:10 fb90e7189ae6d62e77ba3a308ca5d683f90bbe633cf681865365b8e92792alt2 "
219133
219161
#endif
219134
219162
/* Return the source-id for this library */
219135
219163
SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
0 commit comments