Skip to content

Commit 9cb060a

Browse files
committed
upgrade amalgamation code
1 parent e85a279 commit 9cb060a

File tree

2 files changed

+89
-61
lines changed

2 files changed

+89
-61
lines changed

sqlite3-binding.c

Lines changed: 86 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef USE_LIBSQLITE3
22
/******************************************************************************
33
** 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
55
** single large file, the entire code can be compiled as a single translation
66
** unit. This allows many compilers to do optimizations that would not be
77
** possible if the files were compiled separately. Performance improvements
@@ -1157,9 +1157,9 @@ extern "C" {
11571157
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
11581158
** [sqlite_version()] and [sqlite_source_id()].
11591159
*/
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"
11631163

11641164
/*
11651165
** CAPI3REF: Run-Time Library Version Numbers
@@ -16270,6 +16270,7 @@ struct sqlite3 {
1627016270
#define SQLITE_EnableQPSG 0x00800000 /* Query Planner Stability Guarantee*/
1627116271
#define SQLITE_TriggerEQP 0x01000000 /* Show trigger EXPLAIN QUERY PLAN */
1627216272
#define SQLITE_ResetDatabase 0x02000000 /* Reset the database */
16273+
#define SQLITE_LegacyAlter 0x04000000 /* Legacy ALTER TABLE behaviour */
1627316274

1627416275
/* Flags used only if debugging */
1627516276
#ifdef SQLITE_DEBUG
@@ -32620,7 +32621,11 @@ static struct unix_syscall {
3262032621
#define osLstat ((int(*)(const char*,struct stat*))aSyscall[27].pCurrent)
3262132622

3262232623
#if defined(__linux__) && defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)
32624+
# ifdef __ANDROID__
32625+
{ "ioctl", (sqlite3_syscall_ptr)(int(*)(int, int, ...))ioctl, 0 },
32626+
# else
3262332627
{ "ioctl", (sqlite3_syscall_ptr)ioctl, 0 },
32628+
# endif
3262432629
#else
3262532630
{ "ioctl", (sqlite3_syscall_ptr)0, 0 },
3262632631
#endif
@@ -89714,7 +89719,10 @@ case OP_VNext: { /* jump */
8971489719
case OP_VRename: {
8971589720
sqlite3_vtab *pVtab;
8971689721
Mem *pName;
89717-
89722+
int isLegacy;
89723+
89724+
isLegacy = (db->flags & SQLITE_LegacyAlter);
89725+
db->flags |= SQLITE_LegacyAlter;
8971889726
pVtab = pOp->p4.pVtab->pVtab;
8971989727
pName = &aMem[pOp->p1];
8972089728
assert( pVtab->pModule->xRename );
@@ -89728,6 +89736,7 @@ case OP_VRename: {
8972889736
rc = sqlite3VdbeChangeEncoding(pName, SQLITE_UTF8);
8972989737
if( rc ) goto abort_due_to_error;
8973089738
rc = pVtab->pModule->xRename(pVtab, pName->z);
89739+
if( isLegacy==0 ) db->flags &= ~SQLITE_LegacyAlter;
8973189740
sqlite3VtabImportErrmsg(p, pVtab);
8973289741
p->expired = 0;
8973389742
if( rc ) goto abort_due_to_error;
@@ -97048,17 +97057,14 @@ static Expr *exprDup(sqlite3 *db, Expr *p, int dupFlags, u8 **pzBuffer){
9704897057
}
9704997058

9705097059
/* Fill in pNew->pLeft and pNew->pRight. */
97060+
zAlloc += dupedExprNodeSize(p, dupFlags);
9705197061
if( ExprHasProperty(pNew, EP_Reduced|EP_TokenOnly) ){
97052-
zAlloc += dupedExprNodeSize(p, dupFlags);
9705397062
if( !ExprHasProperty(pNew, EP_TokenOnly|EP_Leaf) ){
9705497063
pNew->pLeft = p->pLeft ?
9705597064
exprDup(db, p->pLeft, EXPRDUP_REDUCE, &zAlloc) : 0;
9705697065
pNew->pRight = p->pRight ?
9705797066
exprDup(db, p->pRight, EXPRDUP_REDUCE, &zAlloc) : 0;
9705897067
}
97059-
if( pzBuffer ){
97060-
*pzBuffer = zAlloc;
97061-
}
9706297068
}else{
9706397069
#ifndef SQLITE_OMIT_WINDOWFUNC
9706497070
if( ExprHasProperty(p, EP_Reduced|EP_TokenOnly) ){
@@ -97078,6 +97084,9 @@ static Expr *exprDup(sqlite3 *db, Expr *p, int dupFlags, u8 **pzBuffer){
9707897084
pNew->pRight = sqlite3ExprDup(db, p->pRight, 0);
9707997085
}
9708097086
}
97087+
if( pzBuffer ){
97088+
*pzBuffer = zAlloc;
97089+
}
9708197090
}
9708297091
return pNew;
9708397092
}
@@ -100629,18 +100638,15 @@ SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Parse *pParse, Expr *pE1, Expr *pE2, i
100629100638
/*
100630100639
** This is the Expr node callback for sqlite3ExprImpliesNotNullRow().
100631100640
** 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.
100633100646
*/
100634100647
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 );
100642100649
testcase( pExpr->op==TK_AGG_FUNCTION );
100643-
100644100650
if( ExprHasProperty(pExpr, EP_FromJoin) ) return WRC_Prune;
100645100651
switch( pExpr->op ){
100646100652
case TK_ISNOT:
@@ -101299,20 +101305,6 @@ SQLITE_PRIVATE void sqlite3AlterRenameTable(
101299101305
goto exit_rename_table;
101300101306
}
101301101307

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-
101316101308
/* figure out how many UTF-8 characters are in zName */
101317101309
zTabName = pTab->zName;
101318101310
nTabName = sqlite3Utf8CharLen(zTabName, -1);
@@ -101370,6 +101362,20 @@ SQLITE_PRIVATE void sqlite3AlterRenameTable(
101370101362
, zDb, zTabName, zName, zTabName, zDb, zName);
101371101363
}
101372101364

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+
101373101379
renameReloadSchema(pParse, iDb);
101374101380
renameTestSchema(pParse, zDb, iDb==1);
101375101381

@@ -102206,7 +102212,7 @@ static int renameResolveTrigger(Parse *pParse, const char *zDb){
102206102212
Table *pTarget = sqlite3LocateTable(pParse, 0, pStep->zTarget, zDb);
102207102213
if( pTarget==0 ){
102208102214
rc = SQLITE_ERROR;
102209-
}else{
102215+
}else if( SQLITE_OK==(rc = sqlite3ViewGetColumnNames(pParse, pTarget)) ){
102210102216
SrcList sSrc;
102211102217
memset(&sSrc, 0, sizeof(sSrc));
102212102218
sSrc.nSrc = 1;
@@ -102552,17 +102558,20 @@ static void renameTableFunc(
102552102558
rc = renameParseSql(&sParse, zDb, 1, db, zInput, bTemp);
102553102559

102554102560
if( rc==SQLITE_OK ){
102561+
int isLegacy = (db->flags & SQLITE_LegacyAlter);
102555102562
if( sParse.pNewTable ){
102556102563
Table *pTab = sParse.pNewTable;
102557102564

102558102565
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+
}
102566102575
}else{
102567102576
/* Modify any FK definitions to point to the new table. */
102568102577
#ifndef SQLITE_OMIT_FOREIGN_KEY
@@ -102581,15 +102590,19 @@ static void renameTableFunc(
102581102590
** "CREATE [VIRTUAL] TABLE" bit. */
102582102591
if( sqlite3_stricmp(zOld, pTab->zName)==0 ){
102583102592
sCtx.pTab = pTab;
102584-
sqlite3WalkExprList(&sWalker, pTab->pCheck);
102593+
if( isLegacy==0 ){
102594+
sqlite3WalkExprList(&sWalker, pTab->pCheck);
102595+
}
102585102596
renameTokenFind(&sParse, &sCtx, pTab->zName);
102586102597
}
102587102598
}
102588102599
}
102589102600

102590102601
else if( sParse.pNewIndex ){
102591102602
renameTokenFind(&sParse, &sCtx, sParse.pNewIndex->zName);
102592-
sqlite3WalkExpr(&sWalker, sParse.pNewIndex->pPartIdxWhere);
102603+
if( isLegacy==0 ){
102604+
sqlite3WalkExpr(&sWalker, sParse.pNewIndex->pPartIdxWhere);
102605+
}
102593102606
}
102594102607

102595102608
#ifndef SQLITE_OMIT_TRIGGER
@@ -102602,12 +102615,14 @@ static void renameTableFunc(
102602102615
renameTokenFind(&sParse, &sCtx, sParse.pNewTrigger->table);
102603102616
}
102604102617

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+
}
102611102626
}
102612102627
}
102613102628
}
@@ -102665,6 +102680,7 @@ static void renameTableTest(
102665102680
char const *zDb = (const char*)sqlite3_value_text(argv[0]);
102666102681
char const *zInput = (const char*)sqlite3_value_text(argv[1]);
102667102682
int bTemp = sqlite3_value_int(argv[4]);
102683+
int isLegacy = (db->flags & SQLITE_LegacyAlter);
102668102684

102669102685
#ifndef SQLITE_OMIT_AUTHORIZATION
102670102686
sqlite3_xauth xAuth = db->xAuth;
@@ -102677,7 +102693,7 @@ static void renameTableTest(
102677102693
Parse sParse;
102678102694
rc = renameParseSql(&sParse, zDb, 1, db, zInput, bTemp);
102679102695
if( rc==SQLITE_OK ){
102680-
if( sParse.pNewTable && sParse.pNewTable->pSelect ){
102696+
if( isLegacy==0 && sParse.pNewTable && sParse.pNewTable->pSelect ){
102681102697
NameContext sNC;
102682102698
memset(&sNC, 0, sizeof(sNC));
102683102699
sNC.pParse = &sParse;
@@ -102686,7 +102702,9 @@ static void renameTableTest(
102686102702
}
102687102703

102688102704
else if( sParse.pNewTrigger ){
102689-
rc = renameResolveTrigger(&sParse, bTemp ? 0 : zDb);
102705+
if( isLegacy==0 ){
102706+
rc = renameResolveTrigger(&sParse, bTemp ? 0 : zDb);
102707+
}
102690102708
if( rc==SQLITE_OK ){
102691102709
int i1 = sqlite3SchemaToIndex(db, sParse.pNewTrigger->pTabSchema);
102692102710
int i2 = sqlite3FindDbName(db, zDb);
@@ -107336,10 +107354,6 @@ static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){
107336107354
}
107337107355
}
107338107356

107339-
/* The remaining transformations only apply to b-tree tables, not to
107340-
** virtual tables */
107341-
if( IN_DECLARE_VTAB ) return;
107342-
107343107357
/* Convert the P3 operand of the OP_CreateBtree opcode from BTREE_INTKEY
107344107358
** into BTREE_BLOBKEY.
107345107359
*/
@@ -107852,6 +107866,10 @@ SQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){
107852107866
assert( pTable->pSelect );
107853107867
pSel = sqlite3SelectDup(db, pTable->pSelect, 0);
107854107868
if( pSel ){
107869+
#ifndef SQLITE_OMIT_ALTERTABLE
107870+
u8 eParseMode = pParse->eParseMode;
107871+
pParse->eParseMode = PARSE_MODE_NORMAL;
107872+
#endif
107855107873
n = pParse->nTab;
107856107874
sqlite3SrcListAssignCursors(pParse, pSel->pSrc);
107857107875
pTable->nCol = -1;
@@ -107897,6 +107915,9 @@ SQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){
107897107915
sqlite3DeleteTable(db, pSelTab);
107898107916
sqlite3SelectDelete(db, pSel);
107899107917
db->lookaside.bDisable--;
107918+
#ifndef SQLITE_OMIT_ALTERTABLE
107919+
pParse->eParseMode = eParseMode;
107920+
#endif
107900107921
} else {
107901107922
nErr++;
107902107923
}
@@ -119463,6 +119484,11 @@ static const PragmaName aPragmaName[] = {
119463119484
/* iArg: */ 0 },
119464119485
#endif
119465119486
#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 },
119466119492
{/* zName: */ "legacy_file_format",
119467119493
/* ePragTyp: */ PragTyp_FLAG,
119468119494
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
@@ -119716,7 +119742,7 @@ static const PragmaName aPragmaName[] = {
119716119742
/* iArg: */ SQLITE_WriteSchema },
119717119743
#endif
119718119744
};
119719-
/* Number of pragmas: 60 on by default, 77 total. */
119745+
/* Number of pragmas: 61 on by default, 78 total. */
119720119746

119721119747
/************** End of pragma.h **********************************************/
119722119748
/************** Continuing where we left off in pragma.c *********************/
@@ -129184,6 +129210,7 @@ SQLITE_PRIVATE int sqlite3Select(
129184129210
sqlite3VdbeAddOp2(v, OP_Goto, 0, iBreak);
129185129211
sqlite3VdbeResolveLabel(v, addrGosub);
129186129212
VdbeNoopComment((v, "inner-loop subroutine"));
129213+
sSort.labelOBLopt = 0;
129187129214
selectInnerLoop(pParse, p, -1, &sSort, &sDistinct, pDest, iCont, iBreak);
129188129215
sqlite3VdbeResolveLabel(v, iCont);
129189129216
sqlite3VdbeAddOp1(v, OP_Return, regGosub);
@@ -154756,6 +154783,7 @@ static int openDatabase(
154756154783
db->nDb = 2;
154757154784
db->magic = SQLITE_MAGIC_BUSY;
154758154785
db->aDb = db->aDbStatic;
154786+
db->lookaside.bDisable = 1;
154759154787

154760154788
assert( sizeof(db->aLimit)==sizeof(aHardLimit) );
154761154789
memcpy(db->aLimit, aHardLimit, sizeof(db->aLimit));
@@ -214417,7 +214445,7 @@ static void fts5SourceIdFunc(
214417214445
){
214418214446
assert( nArg==0 );
214419214447
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);
214421214449
}
214422214450

214423214451
static int fts5Init(sqlite3 *db){
@@ -219127,9 +219155,9 @@ SQLITE_API int sqlite3_stmt_init(
219127219155
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
219128219156

219129219157
/************** End of stmt.c ************************************************/
219130-
#if __LINE__!=219129
219158+
#if __LINE__!=219157
219131219159
#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"
219133219161
#endif
219134219162
/* Return the source-id for this library */
219135219163
SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }

sqlite3-binding.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ extern "C" {
124124
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
125125
** [sqlite_version()] and [sqlite_source_id()].
126126
*/
127-
#define SQLITE_VERSION "3.25.0"
128-
#define SQLITE_VERSION_NUMBER 3025000
129-
#define SQLITE_SOURCE_ID "2018-09-15 04:01:47 b63af6c3bd33152742648d5d2e8dc5d5fcbcdd27df409272b6aea00a6f761760"
127+
#define SQLITE_VERSION "3.25.2"
128+
#define SQLITE_VERSION_NUMBER 3025002
129+
#define SQLITE_SOURCE_ID "2018-09-25 19:08:10 fb90e7189ae6d62e77ba3a308ca5d683f90bbe633cf681865365b8e92792d1c7"
130130

131131
/*
132132
** CAPI3REF: Run-Time Library Version Numbers

0 commit comments

Comments
 (0)