11/******************************************************************************
22** This file is an amalgamation of many separate C source files from SQLite
3- ** version 3.35.0 . By combining all the individual C code files into this
3+ ** version 3.35.2 . By combining all the individual C code files into this
44** single large file, the entire code can be compiled as a single translation
55** unit. This allows many compilers to do optimizations that would not be
66** possible if the files were compiled separately. Performance improvements
@@ -1186,9 +1186,9 @@ extern "C" {
11861186** [sqlite3_libversion_number()], [sqlite3_sourceid()],
11871187** [sqlite_version()] and [sqlite_source_id()].
11881188*/
1189- #define SQLITE_VERSION "3.35.0 "
1190- #define SQLITE_VERSION_NUMBER 3035000
1191- #define SQLITE_SOURCE_ID "2021-03-12 15:10:09 acd63062eb06748bfe9e4886639e4f2b54ea6a496a83f10716abbaba4115500b "
1189+ #define SQLITE_VERSION "3.35.2 "
1190+ #define SQLITE_VERSION_NUMBER 3035002
1191+ #define SQLITE_SOURCE_ID "2021-03-17 19:07:21 ea80f3002f4120f5dcee76e8779dfdc88e1e096c5cdd06904c20fd26d50c3827 "
11921192
11931193/*
11941194** CAPI3REF: Run-Time Library Version Numbers
@@ -17007,7 +17007,10 @@ struct sqlite3 {
1700717007 unsigned orphanTrigger : 1; /* Last statement is orphaned TEMP trigger */
1700817008 unsigned imposterTable : 1; /* Building an imposter table */
1700917009 unsigned reopenMemdb : 1; /* ATTACH is really a reopen using MemDB */
17010+ unsigned bDropColumn : 1; /* Doing schema check after DROP COLUMN */
1701017011 char **azInit; /* "type", "name", and "tbl_name" columns */
17012+ /* or if bDropColumn, then azInit[0] is the */
17013+ /* name of the column being dropped */
1701117014 } init;
1701217015 int nVdbeActive; /* Number of VDBEs currently running */
1701317016 int nVdbeRead; /* Number of active VDBEs that read or write */
@@ -22868,6 +22871,7 @@ static int isDate(
2286822871 int eType;
2286922872 memset(p, 0, sizeof(*p));
2287022873 if( argc==0 ){
22874+ if( !sqlite3NotPureFunc(context) ) return 1;
2287122875 return setDateTimeToCurrent(context, p);
2287222876 }
2287322877 if( (eType = sqlite3_value_type(argv[0]))==SQLITE_FLOAT
@@ -99167,6 +99171,7 @@ static int lookupName(
9916799171 assert( pExpr->op==TK_ID );
9916899172 if( ExprHasProperty(pExpr,EP_DblQuoted)
9916999173 && areDoubleQuotedStringsEnabled(db, pTopNC)
99174+ && (db->init.bDropColumn==0 || sqlite3StrICmp(zCol, db->init.azInit[0])!=0)
9917099175 ){
9917199176 /* If a double-quoted identifier does not match any known column name,
9917299177 ** then treat it as a string.
@@ -99181,6 +99186,11 @@ static int lookupName(
9918199186 ** Someday, I hope to get rid of this hack. Unfortunately there is
9918299187 ** a huge amount of legacy SQL that uses it. So for now, we just
9918399188 ** issue a warning.
99189+ **
99190+ ** 2021-03-15: ticket 1c24a659e6d7f3a1
99191+ ** Do not do the ID-to-STRING conversion when doing the schema
99192+ ** sanity check following a DROP COLUMN if the identifer name matches
99193+ ** the name of the column being dropped.
9918499194 */
9918599195 sqlite3_log(SQLITE_WARNING,
9918699196 "double-quoted string literal: \"%w\"", zCol);
@@ -106780,17 +106790,18 @@ static void renameTestSchema(
106780106790 Parse *pParse, /* Parse context */
106781106791 const char *zDb, /* Name of db to verify schema of */
106782106792 int bTemp, /* True if this is the temp db */
106783- const char *zWhen /* "when" part of error message */
106793+ const char *zWhen, /* "when" part of error message */
106794+ const char *zDropColumn /* Name of column being dropped */
106784106795){
106785106796 pParse->colNamesSet = 1;
106786106797 sqlite3NestedParse(pParse,
106787106798 "SELECT 1 "
106788106799 "FROM \"%w\"." DFLT_SCHEMA_TABLE " "
106789106800 "WHERE name NOT LIKE 'sqliteX_%%' ESCAPE 'X'"
106790106801 " AND sql NOT LIKE 'create virtual%%'"
106791- " AND sqlite_rename_test(%Q, sql, type, name, %d, %Q)=NULL ",
106802+ " AND sqlite_rename_test(%Q, sql, type, name, %d, %Q, %Q )=NULL ",
106792106803 zDb,
106793- zDb, bTemp, zWhen
106804+ zDb, bTemp, zWhen, zDropColumn
106794106805 );
106795106806
106796106807 if( bTemp==0 ){
@@ -106799,8 +106810,8 @@ static void renameTestSchema(
106799106810 "FROM temp." DFLT_SCHEMA_TABLE " "
106800106811 "WHERE name NOT LIKE 'sqliteX_%%' ESCAPE 'X'"
106801106812 " AND sql NOT LIKE 'create virtual%%'"
106802- " AND sqlite_rename_test(%Q, sql, type, name, 1, %Q)=NULL ",
106803- zDb, zWhen
106813+ " AND sqlite_rename_test(%Q, sql, type, name, 1, %Q, %Q )=NULL ",
106814+ zDb, zWhen, zDropColumn
106804106815 );
106805106816 }
106806106817}
@@ -106963,7 +106974,7 @@ SQLITE_PRIVATE void sqlite3AlterRenameTable(
106963106974 "sql = sqlite_rename_table(%Q, type, name, sql, %Q, %Q, 1), "
106964106975 "tbl_name = "
106965106976 "CASE WHEN tbl_name=%Q COLLATE nocase AND "
106966- " sqlite_rename_test(%Q, sql, type, name, 1, 'after rename') "
106977+ " sqlite_rename_test(%Q, sql, type, name, 1, 'after rename',0 ) "
106967106978 "THEN %Q ELSE tbl_name END "
106968106979 "WHERE type IN ('view', 'trigger')"
106969106980 , zDb, zTabName, zName, zTabName, zDb, zName);
@@ -106983,7 +106994,7 @@ SQLITE_PRIVATE void sqlite3AlterRenameTable(
106983106994#endif
106984106995
106985106996 renameReloadSchema(pParse, iDb, INITFLAG_AlterRename);
106986- renameTestSchema(pParse, zDb, iDb==1, "after rename");
106997+ renameTestSchema(pParse, zDb, iDb==1, "after rename", 0 );
106987106998
106988106999exit_rename_table:
106989107000 sqlite3SrcListDelete(db, pSrc);
@@ -107351,7 +107362,7 @@ SQLITE_PRIVATE void sqlite3AlterRenameColumn(
107351107362
107352107363 /* Drop and reload the database schema. */
107353107364 renameReloadSchema(pParse, iSchema, INITFLAG_AlterRename);
107354- renameTestSchema(pParse, zDb, iSchema==1, "after rename");
107365+ renameTestSchema(pParse, zDb, iSchema==1, "after rename", 0 );
107355107366
107356107367 exit_rename_column:
107357107368 sqlite3SrcListDelete(db, pSrc);
@@ -107775,12 +107786,17 @@ static int renameParseSql(
107775107786 const char *zDb, /* Name of schema SQL belongs to */
107776107787 sqlite3 *db, /* Database handle */
107777107788 const char *zSql, /* SQL to parse */
107778- int bTemp /* True if SQL is from temp schema */
107789+ int bTemp, /* True if SQL is from temp schema */
107790+ const char *zDropColumn /* Name of column being dropped */
107779107791){
107780107792 int rc;
107781107793 char *zErr = 0;
107782107794
107783107795 db->init.iDb = bTemp ? 1 : sqlite3FindDbName(db, zDb);
107796+ if( zDropColumn ){
107797+ db->init.bDropColumn = 1;
107798+ db->init.azInit = (char**)&zDropColumn;
107799+ }
107784107800
107785107801 /* Parse the SQL statement passed as the first argument. If no error
107786107802 ** occurs and the parse does not result in a new table, index or
@@ -107813,6 +107829,7 @@ static int renameParseSql(
107813107829#endif
107814107830
107815107831 db->init.iDb = 0;
107832+ db->init.bDropColumn = 0;
107816107833 return rc;
107817107834}
107818107835
@@ -108114,7 +108131,7 @@ static void renameColumnFunc(
108114108131#ifndef SQLITE_OMIT_AUTHORIZATION
108115108132 db->xAuth = 0;
108116108133#endif
108117- rc = renameParseSql(&sParse, zDb, db, zSql, bTemp);
108134+ rc = renameParseSql(&sParse, zDb, db, zSql, bTemp, 0 );
108118108135
108119108136 /* Find tokens that need to be replaced. */
108120108137 memset(&sWalker, 0, sizeof(Walker));
@@ -108156,12 +108173,12 @@ static void renameColumnFunc(
108156108173 for(pIdx=sParse.pNewIndex; pIdx; pIdx=pIdx->pNext){
108157108174 sqlite3WalkExprList(&sWalker, pIdx->aColExpr);
108158108175 }
108159- }
108160108176#ifndef SQLITE_OMIT_GENERATED_COLUMNS
108161- for(i=0; i<sParse.pNewTable->nCol; i++){
108162- sqlite3WalkExpr(&sWalker, sParse.pNewTable->aCol[i].pDflt);
108163- }
108177+ for(i=0; i<sParse.pNewTable->nCol; i++){
108178+ sqlite3WalkExpr(&sWalker, sParse.pNewTable->aCol[i].pDflt);
108179+ }
108164108180#endif
108181+ }
108165108182
108166108183 for(pFKey=sParse.pNewTable->pFKey; pFKey; pFKey=pFKey->pNextFrom){
108167108184 for(i=0; i<pFKey->nCol; i++){
@@ -108318,7 +108335,7 @@ static void renameTableFunc(
108318108335 sWalker.xSelectCallback = renameTableSelectCb;
108319108336 sWalker.u.pRename = &sCtx;
108320108337
108321- rc = renameParseSql(&sParse, zDb, db, zInput, bTemp);
108338+ rc = renameParseSql(&sParse, zDb, db, zInput, bTemp, 0 );
108322108339
108323108340 if( rc==SQLITE_OK ){
108324108341 int isLegacy = (db->flags & SQLITE_LegacyAlter);
@@ -108434,6 +108451,7 @@ static void renameTableFunc(
108434108451** 3: Object name.
108435108452** 4: True if object is from temp schema.
108436108453** 5: "when" part of error message.
108454+ ** 6: Name of column being dropped, or NULL.
108437108455**
108438108456** Unless it finds an error, this function normally returns NULL. However, it
108439108457** returns integer value 1 if:
@@ -108452,6 +108470,7 @@ static void renameTableTest(
108452108470 int bTemp = sqlite3_value_int(argv[4]);
108453108471 int isLegacy = (db->flags & SQLITE_LegacyAlter);
108454108472 char const *zWhen = (const char*)sqlite3_value_text(argv[5]);
108473+ char const *zDropColumn = (const char*)sqlite3_value_text(argv[6]);
108455108474
108456108475#ifndef SQLITE_OMIT_AUTHORIZATION
108457108476 sqlite3_xauth xAuth = db->xAuth;
@@ -108462,7 +108481,7 @@ static void renameTableTest(
108462108481 if( zDb && zInput ){
108463108482 int rc;
108464108483 Parse sParse;
108465- rc = renameParseSql(&sParse, zDb, db, zInput, bTemp);
108484+ rc = renameParseSql(&sParse, zDb, db, zInput, bTemp, zDropColumn );
108466108485 if( rc==SQLITE_OK ){
108467108486 if( isLegacy==0 && sParse.pNewTable && sParse.pNewTable->pSelect ){
108468108487 NameContext sNC;
@@ -108530,7 +108549,7 @@ static void dropColumnFunc(
108530108549#endif
108531108550
108532108551 UNUSED_PARAMETER(NotUsed);
108533- rc = renameParseSql(&sParse, zDb, db, zSql, iSchema==1);
108552+ rc = renameParseSql(&sParse, zDb, db, zSql, iSchema==1, 0 );
108534108553 if( rc!=SQLITE_OK ) goto drop_column_done;
108535108554 pTab = sParse.pNewTable;
108536108555 if( pTab==0 || pTab->nCol==1 || iCol>=pTab->nCol ){
@@ -108623,7 +108642,7 @@ SQLITE_PRIVATE void sqlite3AlterDropColumn(Parse *pParse, SrcList *pSrc, Token *
108623108642 iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
108624108643 assert( iDb>=0 );
108625108644 zDb = db->aDb[iDb].zDbSName;
108626- renameTestSchema(pParse, zDb, iDb==1, "");
108645+ renameTestSchema(pParse, zDb, iDb==1, "", 0 );
108627108646 sqlite3NestedParse(pParse,
108628108647 "UPDATE \"%w\"." DFLT_SCHEMA_TABLE " SET "
108629108648 "sql = sqlite_drop_column(%d, sql, %d) "
@@ -108633,7 +108652,7 @@ SQLITE_PRIVATE void sqlite3AlterDropColumn(Parse *pParse, SrcList *pSrc, Token *
108633108652
108634108653 /* Drop and reload the database schema. */
108635108654 renameReloadSchema(pParse, iDb, INITFLAG_AlterDrop);
108636- renameTestSchema(pParse, zDb, iDb==1, "after drop column");
108655+ renameTestSchema(pParse, zDb, iDb==1, "after drop column", zCol );
108637108656
108638108657 /* Edit rows of table on disk */
108639108658 if( pParse->nErr==0 && (pTab->aCol[iCol].colFlags & COLFLAG_VIRTUAL)==0 ){
@@ -108693,7 +108712,7 @@ SQLITE_PRIVATE void sqlite3AlterFunctions(void){
108693108712 static FuncDef aAlterTableFuncs[] = {
108694108713 INTERNAL_FUNCTION(sqlite_rename_column, 9, renameColumnFunc),
108695108714 INTERNAL_FUNCTION(sqlite_rename_table, 7, renameTableFunc),
108696- INTERNAL_FUNCTION(sqlite_rename_test, 6 , renameTableTest),
108715+ INTERNAL_FUNCTION(sqlite_rename_test, 7 , renameTableTest),
108697108716 INTERNAL_FUNCTION(sqlite_drop_column, 3, dropColumnFunc),
108698108717 };
108699108718 sqlite3InsertBuiltinFuncs(aAlterTableFuncs, ArraySize(aAlterTableFuncs));
@@ -135118,6 +135137,7 @@ static int flattenSubquery(
135118135137 if( (p->selFlags & SF_Recursive) ) return 0;
135119135138
135120135139 if( pSrc->nSrc>1 ){
135140+ if( pParse->nSelect>500 ) return 0;
135121135141 aCsrMap = sqlite3DbMallocZero(db, pParse->nTab*sizeof(int));
135122135142 }
135123135143 }
@@ -135194,6 +135214,7 @@ static int flattenSubquery(
135194135214 if( pNew==0 ){
135195135215 p->pPrior = pPrior;
135196135216 }else{
135217+ pNew->selId = ++pParse->nSelect;
135197135218 if( aCsrMap && db->mallocFailed==0 ){
135198135219 renumberCursors(pParse, pNew, iFrom, aCsrMap);
135199135220 }
@@ -229192,7 +229213,7 @@ static void fts5SourceIdFunc(
229192229213){
229193229214 assert( nArg==0 );
229194229215 UNUSED_PARAM2(nArg, apUnused);
229195- sqlite3_result_text(pCtx, "fts5: 2021-03-12 15:10:09 acd63062eb06748bfe9e4886639e4f2b54ea6a496a83f10716abbaba4115500b ", -1, SQLITE_TRANSIENT);
229216+ sqlite3_result_text(pCtx, "fts5: 2021-03-17 19:07:21 ea80f3002f4120f5dcee76e8779dfdc88e1e096c5cdd06904c20fd26d50c3827 ", -1, SQLITE_TRANSIENT);
229196229217}
229197229218
229198229219/*
@@ -234118,9 +234139,9 @@ SQLITE_API int sqlite3_stmt_init(
234118234139#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
234119234140
234120234141/************** End of stmt.c ************************************************/
234121- #if __LINE__!=234121
234142+ #if __LINE__!=234142
234122234143#undef SQLITE_SOURCE_ID
234123- #define SQLITE_SOURCE_ID "2021-03-12 15:10:09 acd63062eb06748bfe9e4886639e4f2b54ea6a496a83f10716abbaba4115alt2 "
234144+ #define SQLITE_SOURCE_ID "2021-03-17 19:07:21 ea80f3002f4120f5dcee76e8779dfdc88e1e096c5cdd06904c20fd26d50calt2 "
234124234145#endif
234125234146/* Return the source-id for this library */
234126234147SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
0 commit comments