aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordan <dan@noemail.net>2011-04-09 17:32:58 +0000
committerdan <dan@noemail.net>2011-04-09 17:32:58 +0000
commit579667537a4bb6029d19ed46fcc7ace2fdca1cad (patch)
tree03d8c4d5e8cb28de5a2d6107990d5f17cf395cbc /src
parent7687c83d4c8837e42d6b813695fec95afd00dc9d (diff)
downloadsqlite-579667537a4bb6029d19ed46fcc7ace2fdca1cad.tar.gz
sqlite-579667537a4bb6029d19ed46fcc7ace2fdca1cad.zip
Add VerifyCookie instructions to "DROP XXX IF EXISTS" statements if the specified database object does not exist when the statement is prepared.
FossilOrigin-Name: a46f32900a013aa6bb2dad2a9ed3ce00ab2493fd
Diffstat (limited to 'src')
-rw-r--r--src/build.c18
-rw-r--r--src/sqliteInt.h1
-rw-r--r--src/trigger.c2
3 files changed, 21 insertions, 0 deletions
diff --git a/src/build.c b/src/build.c
index 2d1d8dc6a..83a1db840 100644
--- a/src/build.c
+++ b/src/build.c
@@ -2003,6 +2003,7 @@ void sqlite3DropTable(Parse *pParse, SrcList *pName, int isView, int noErr){
if( noErr ) db->suppressErr--;
if( pTab==0 ){
+ if( noErr ) sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase);
goto exit_drop_table;
}
iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
@@ -2917,6 +2918,8 @@ void sqlite3DropIndex(Parse *pParse, SrcList *pName, int ifExists){
if( pIndex==0 ){
if( !ifExists ){
sqlite3ErrorMsg(pParse, "no such index: %S", pName, 0);
+ }else{
+ sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase);
}
pParse->checkSchema = 1;
goto exit_drop_index;
@@ -3507,6 +3510,21 @@ void sqlite3CodeVerifySchema(Parse *pParse, int iDb){
}
/*
+** If argument zDb is NULL, then call sqlite3CodeVerifySchema() for each
+** attached database. Otherwise, invoke it for the database named zDb only.
+*/
+void sqlite3CodeVerifyNamedSchema(Parse *pParse, const char *zDb){
+ sqlite3 *db = pParse->db;
+ int i;
+ for(i=0; i<db->nDb; i++){
+ Db *pDb = &db->aDb[i];
+ if( pDb->pBt && (!zDb || 0==sqlite3StrICmp(zDb, pDb->zName)) ){
+ sqlite3CodeVerifySchema(pParse, i);
+ }
+ }
+}
+
+/*
** Generate VDBE code that prepares for doing an operation that
** might change the database.
**
diff --git a/src/sqliteInt.h b/src/sqliteInt.h
index d66374277..ea0925e41 100644
--- a/src/sqliteInt.h
+++ b/src/sqliteInt.h
@@ -2768,6 +2768,7 @@ void sqlite3PrngRestoreState(void);
void sqlite3PrngResetState(void);
void sqlite3RollbackAll(sqlite3*);
void sqlite3CodeVerifySchema(Parse*, int);
+void sqlite3CodeVerifyNamedSchema(Parse*, const char *zDb);
void sqlite3BeginTransaction(Parse*, int);
void sqlite3CommitTransaction(Parse*);
void sqlite3RollbackTransaction(Parse*);
diff --git a/src/trigger.c b/src/trigger.c
index 8952ad59a..0f3f5bad3 100644
--- a/src/trigger.c
+++ b/src/trigger.c
@@ -502,6 +502,8 @@ void sqlite3DropTrigger(Parse *pParse, SrcList *pName, int noErr){
if( !pTrigger ){
if( !noErr ){
sqlite3ErrorMsg(pParse, "no such trigger: %S", pName, 0);
+ }else{
+ sqlite3CodeVerifyNamedSchema(pParse, zDb);
}
pParse->checkSchema = 1;
goto drop_trigger_cleanup;