From: drh Date: Fri, 5 Nov 2004 22:18:49 +0000 (+0000) Subject: Use sqlite3NestedParse to implement DROP INDEX. (CVS 2071) X-Git-Tag: version-3.6.10~4079 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b17131a084d2d5789ea1607622cc0508afbd543f;p=thirdparty%2Fsqlite.git Use sqlite3NestedParse to implement DROP INDEX. (CVS 2071) FossilOrigin-Name: 0f81aa5b057eab908b46b70ea9e9a42bc2ee8c21 --- diff --git a/manifest b/manifest index 3c0cd0577a..5adb28c094 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Use\ssqlite3NestedParse\sto\simplement\sCREATE\sINDEX.\s(CVS\s2070) -D 2004-11-05T20:58:40 +C Use\ssqlite3NestedParse\sto\simplement\sDROP\sINDEX.\s(CVS\s2071) +D 2004-11-05T22:18:49 F Makefile.in c4d2416860f472a1e3393714d0372074197565df F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457 F README a01693e454a00cc117967e3f9fdab2d4d52e9bc1 @@ -31,7 +31,7 @@ F src/attach.c e49d09dad9f5f9fb10b4b0c1be5a70ae4c45e689 F src/auth.c 3b81f2a42f48a62c2c9c9b0eda31a157c681edea F src/btree.c bf0d3d59ec076f0a37378f8ac6090d157d925c24 F src/btree.h 861e40b759a195ba63819740e484390012cf81ab -F src/build.c d1234774c8eec8f4e0365da14931236ac9ff323b +F src/build.c e498f958ebb4678e103224edd3a5c2ebcc42d18f F src/date.c 34bdb0082db7ec2a83ef00063f7b44e61ee19dad F src/delete.c f0af21a1ede15524a5edd59fe10ef486283a1ee9 F src/expr.c be18081d2959a2cc53846d0fbedfec40fbfa1d6e @@ -252,7 +252,7 @@ F www/tclsqlite.tcl 560ecd6a916b320e59f2917317398f3d59b7cc25 F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9 F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0 F www/whentouse.tcl fdacb0ba2d39831e8a6240d05a490026ad4c4e4c -P b0506bdd701339d63166ada065445776dd499588 -R b008b9e3c2a495feb1a9866c40c60982 +P 47d8ebdaaddcb7a05e1917dd1dee2029c34228a4 +R d45e3580de79d7367f59fbd57af5e6a1 U drh -Z 363f59f6d239c3e53daa03d8d94862e0 +Z 4c43f2f11733856473822a7670e21c59 diff --git a/manifest.uuid b/manifest.uuid index af959ed97d..cc9caa8dd0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -47d8ebdaaddcb7a05e1917dd1dee2029c34228a4 \ No newline at end of file +0f81aa5b057eab908b46b70ea9e9a42bc2ee8c21 \ No newline at end of file diff --git a/src/build.c b/src/build.c index aec47521e9..c796cf3a94 100644 --- a/src/build.c +++ b/src/build.c @@ -24,9 +24,9 @@ ** PRAGMA ** <<<<<<< build.c -** $Id: build.c,v 1.269 2004/11/05 20:58:40 drh Exp $ +** $Id: build.c,v 1.270 2004/11/05 22:18:49 drh Exp $ ======= -** $Id: build.c,v 1.269 2004/11/05 20:58:40 drh Exp $ +** $Id: build.c,v 1.270 2004/11/05 22:18:49 drh Exp $ >>>>>>> 1.262 */ #include "sqliteInt.h" @@ -740,6 +740,7 @@ void sqlite3StartTable( */ if( !db->init.busy && (v = sqlite3GetVdbe(pParse))!=0 ){ sqlite3BeginWriteOperation(pParse, 0, iDb); + /* Every time a new table is created the file-format ** and encoding meta-values are set in the database, in ** case this is the first table created. @@ -752,6 +753,10 @@ void sqlite3StartTable( /* This just creates a place-holder record in the sqlite_master table. ** The record created does not contain anything yet. It will be replaced ** by the real entry in code generated at sqlite3EndTable(). + ** + ** The rowid for the new entry is left on the top of the stack. + ** The rowid value is needed by the code that sqlite3EndTable will + ** generate. */ sqlite3OpenMasterTable(v, iDb); sqlite3VdbeAddOp(v, OP_NewRecno, 0, 0); @@ -2412,28 +2417,15 @@ void sqlite3DropIndex(Parse *pParse, SrcList *pName){ /* Generate code to remove the index and from the master table */ v = sqlite3GetVdbe(pParse); if( v ){ - static const VdbeOpList dropIndex[] = { - { OP_Rewind, 0, ADDR(9), 0}, - { OP_String8, 0, 0, 0}, /* 1 */ - { OP_MemStore, 1, 1, 0}, - { OP_MemLoad, 1, 0, 0}, /* 3 */ - { OP_Column, 0, 1, 0}, - { OP_Eq, 0, ADDR(8), 0}, - { OP_Next, 0, ADDR(3), 0}, - { OP_Goto, 0, ADDR(9), 0}, - { OP_Delete, 0, 0, 0}, /* 8 */ - }; - int base; - - sqlite3BeginWriteOperation(pParse, 0, pIndex->iDb); - sqlite3OpenMasterTable(v, pIndex->iDb); - base = sqlite3VdbeAddOpList(v, ArraySize(dropIndex), dropIndex); - sqlite3VdbeChangeP3(v, base+1, pIndex->zName, 0); - sqlite3ChangeCookie(db, v, pIndex->iDb); - /* sqlite3VdbeAddOp(v, OP_Destroy, pIndex->tnum, pIndex->iDb); */ - destroyRootPage(pParse, pIndex->tnum, pIndex->iDb); - sqlite3VdbeAddOp(v, OP_Close, 0, 0); - sqlite3VdbeOp3(v, OP_DropIndex, pIndex->iDb, 0, pIndex->zName, 0); + int iDb = pIndex->iDb; + sqlite3NestedParse(pParse, + "DELETE FROM %Q.%s WHERE name=%Q", + db->aDb[iDb].zName, SCHEMA_TABLE(iDb), + pIndex->zName + ); + sqlite3ChangeCookie(db, v, iDb); + destroyRootPage(pParse, pIndex->tnum, iDb); + sqlite3VdbeOp3(v, OP_DropIndex, iDb, 0, pIndex->zName, 0); } exit_drop_index: