Index: third_party/sqlite/src/src/alter.c |
diff --git a/third_party/sqlite/src/src/alter.c b/third_party/sqlite/src/src/alter.c |
index aa3fa929f82353aeaeb73d61a73c812af0620507..dd060248b8f7a97500426c5ce8acc368943f9123 100644 |
--- a/third_party/sqlite/src/src/alter.c |
+++ b/third_party/sqlite/src/src/alter.c |
@@ -77,8 +77,8 @@ static void renameTableFunc( |
assert( len>0 ); |
} while( token!=TK_LP && token!=TK_USING ); |
- zRet = sqlite3MPrintf(db, "%.*s\"%w\"%s", ((u8*)tname.z) - zSql, zSql, |
- zTableName, tname.z+tname.n); |
+ zRet = sqlite3MPrintf(db, "%.*s\"%w\"%s", (int)(((u8*)tname.z) - zSql), |
+ zSql, zTableName, tname.z+tname.n); |
sqlite3_result_text(context, zRet, -1, SQLITE_DYNAMIC); |
} |
} |
@@ -116,6 +116,7 @@ static void renameParentFunc( |
int token; /* Type of token */ |
UNUSED_PARAMETER(NotUsed); |
+ if( zInput==0 || zOld==0 ) return; |
for(z=zInput; *z; z=z+n){ |
n = sqlite3GetToken(z, &token); |
if( token==TK_REFERENCES ){ |
@@ -130,7 +131,7 @@ static void renameParentFunc( |
sqlite3Dequote(zParent); |
if( 0==sqlite3StrICmp((const char *)zOld, zParent) ){ |
char *zOut = sqlite3MPrintf(db, "%s%.*s\"%w\"", |
- (zOutput?zOutput:""), z-zInput, zInput, (const char *)zNew |
+ (zOutput?zOutput:""), (int)(z-zInput), zInput, (const char *)zNew |
); |
sqlite3DbFree(db, zOutput); |
zOutput = zOut; |
@@ -173,8 +174,8 @@ static void renameTriggerFunc( |
UNUSED_PARAMETER(NotUsed); |
/* The principle used to locate the table name in the CREATE TRIGGER |
- ** statement is that the table name is the first token that is immediatedly |
- ** preceded by either TK_ON or TK_DOT and immediatedly followed by one |
+ ** statement is that the table name is the first token that is immediately |
+ ** preceded by either TK_ON or TK_DOT and immediately followed by one |
** of TK_WHEN, TK_BEGIN or TK_FOR. |
*/ |
if( zSql ){ |
@@ -216,8 +217,8 @@ static void renameTriggerFunc( |
/* Variable tname now contains the token that is the old table-name |
** in the CREATE TRIGGER statement. |
*/ |
- zRet = sqlite3MPrintf(db, "%.*s\"%w\"%s", ((u8*)tname.z) - zSql, zSql, |
- zTableName, tname.z+tname.n); |
+ zRet = sqlite3MPrintf(db, "%.*s\"%w\"%s", (int)(((u8*)tname.z) - zSql), |
+ zSql, zTableName, tname.z+tname.n); |
sqlite3_result_text(context, zRet, -1, SQLITE_DYNAMIC); |
} |
} |
@@ -358,14 +359,14 @@ static void reloadTableSchema(Parse *pParse, Table *pTab, const char *zName){ |
/* Reload the table, index and permanent trigger schemas. */ |
zWhere = sqlite3MPrintf(pParse->db, "tbl_name=%Q", zName); |
if( !zWhere ) return; |
- sqlite3VdbeAddOp4(v, OP_ParseSchema, iDb, 0, 0, zWhere, P4_DYNAMIC); |
+ sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere); |
#ifndef SQLITE_OMIT_TRIGGER |
/* Now, if the table is not stored in the temp database, reload any temp |
** triggers. Don't use IN(...) in case SQLITE_OMIT_SUBQUERY is defined. |
*/ |
if( (zWhere=whereTempTriggers(pParse, pTab))!=0 ){ |
- sqlite3VdbeAddOp4(v, OP_ParseSchema, 1, 0, 0, zWhere, P4_DYNAMIC); |
+ sqlite3VdbeAddParseSchemaOp(v, 1, zWhere); |
} |
#endif |
} |
@@ -414,7 +415,7 @@ void sqlite3AlterRenameTable( |
assert( pSrc->nSrc==1 ); |
assert( sqlite3BtreeHoldsAllMutexes(pParse->db) ); |
- pTab = sqlite3LocateTable(pParse, 0, pSrc->a[0].zName, pSrc->a[0].zDatabase); |
+ pTab = sqlite3LocateTableItem(pParse, 0, &pSrc->a[0]); |
if( !pTab ) goto exit_rename_table; |
iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema); |
zDb = db->aDb[iDb].zName; |
@@ -469,7 +470,7 @@ void sqlite3AlterRenameTable( |
} |
#endif |
- /* Begin a transaction and code the VerifyCookie for database iDb. |
+ /* Begin a transaction for database iDb. |
** Then modify the schema cookie (since the ALTER TABLE modifies the |
** schema). Open a statement transaction if the table is a virtual |
** table. |
@@ -530,7 +531,7 @@ void sqlite3AlterRenameTable( |
"WHEN name LIKE 'sqlite_autoindex%%' AND type='index' THEN " |
"'sqlite_autoindex_' || %Q || substr(name,%d+18) " |
"ELSE name END " |
- "WHERE tbl_name=%Q AND " |
+ "WHERE tbl_name=%Q COLLATE nocase AND " |
"(type='table' OR type='index' OR type='trigger');", |
zDb, SCHEMA_TABLE(iDb), zName, zName, zName, |
#ifndef SQLITE_OMIT_TRIGGER |
@@ -605,6 +606,7 @@ void sqlite3MinimumFileFormat(Parse *pParse, int iDb, int minFormat){ |
sqlite3VdbeUsesBtree(v, iDb); |
sqlite3VdbeAddOp2(v, OP_Integer, minFormat, r2); |
j1 = sqlite3VdbeAddOp3(v, OP_Ge, r2, 0, r1); |
+ sqlite3VdbeChangeP5(v, SQLITE_NOTNULL); VdbeCoverage(v); |
sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, r2); |
sqlite3VdbeJumpHere(v, j1); |
sqlite3ReleaseTempReg(pParse, r1); |
@@ -664,7 +666,7 @@ void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){ |
** If there is a NOT NULL constraint, then the default value for the |
** column must not be NULL. |
*/ |
- if( pCol->isPrimKey ){ |
+ if( pCol->colFlags & COLFLAG_PRIMKEY ){ |
sqlite3ErrorMsg(pParse, "Cannot add a PRIMARY KEY column"); |
return; |
} |
@@ -687,7 +689,7 @@ void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){ |
** can handle (i.e. not CURRENT_TIME etc.) |
*/ |
if( pDflt ){ |
- sqlite3_value *pVal; |
+ sqlite3_value *pVal = 0; |
if( sqlite3ValueFromExpr(db, pDflt, SQLITE_UTF8, SQLITE_AFF_NONE, &pVal) ){ |
db->mallocFailed = 1; |
return; |
@@ -757,7 +759,7 @@ void sqlite3AlterBeginAddColumn(Parse *pParse, SrcList *pSrc){ |
assert( pParse->pNewTable==0 ); |
assert( sqlite3BtreeHoldsAllMutexes(db) ); |
if( db->mallocFailed ) goto exit_begin_add_column; |
- pTab = sqlite3LocateTable(pParse, 0, pSrc->a[0].zName, pSrc->a[0].zDatabase); |
+ pTab = sqlite3LocateTableItem(pParse, 0, &pSrc->a[0]); |
if( !pTab ) goto exit_begin_add_column; |
#ifndef SQLITE_OMIT_VIRTUALTABLE |