Remove entries from the sqlite_stat1 table whenever an index is dropped. Related to #3033. (CVS 4989)
FossilOrigin-Name: 349aab42c7896f04ecb6ca33f08a4c194051e837
This commit is contained in:
parent
5c070538f1
commit
006015d8e5
16
manifest
16
manifest
@ -1,5 +1,5 @@
|
||||
C Additional\sreductions\sin\sthe\suse\sof\smemset().\s(CVS\s4988)
|
||||
D 2008-04-11T15:36:03
|
||||
C Remove\sentries\sfrom\sthe\ssqlite_stat1\stable\swhenever\san\sindex\sis\sdropped.\sRelated\sto\s#3033.\s(CVS\s4989)
|
||||
D 2008-04-11T17:11:27
|
||||
F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
|
||||
F Makefile.in b861627d91df5ee422c54237aa38296954dc0151
|
||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||
@ -89,7 +89,7 @@ F src/btmutex.c 483ced3c52205b04b97df69161fadbf87f4f1ea2
|
||||
F src/btree.c ee340ad90103fe70526f7b0c3728d185dd470f20
|
||||
F src/btree.h c66cb17c6fffa84a88926dbef173bab4ae692fd4
|
||||
F src/btreeInt.h 8a2718652ed9413dc6acbb02a5c5a23a35a6e983
|
||||
F src/build.c 5d36a6041202a1f3a8b2eee3a631cbce74e5f696
|
||||
F src/build.c e6f17bbb031c78e55389e3b90cd5cb150efef2b1
|
||||
F src/callback.c 77b302b0d41468dcda78c70e706e5b84577f0fa0
|
||||
F src/complete.c 4cf68fd75d60257524cbe74f87351b9848399131
|
||||
F src/date.c e41ce4513fb0e359dc678d6bddb4ace135fe365d
|
||||
@ -192,7 +192,7 @@ F test/alter.test 1426bb4c8609731622a9bf9dd48c39f5931c4d7d
|
||||
F test/alter2.test dd55146e812622c8fc51fd2216bcd8dca8880752
|
||||
F test/alter3.test 25b95a136708f22b87184fa6a4309eea03d65153
|
||||
F test/altermalloc.test 29d4a8400277efb4ba8ffe90804c6dc2fdfbf063
|
||||
F test/analyze.test 309ae29d81dbc2e4b07c3c16ba615889deb77c46
|
||||
F test/analyze.test 0bc15f67015ec7fddbae12081a25d82747967c1f
|
||||
F test/async.test aecaa46ed0618a3c338f3651ca4f10fbb4021044
|
||||
F test/async2.test 8998e089b0fbb3d84cdd51c25a78833486d721af
|
||||
F test/async3.test 9ffa0977a78cc6351862a1583be2b1eecd41736d
|
||||
@ -627,7 +627,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
|
||||
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
||||
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
|
||||
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
|
||||
P 2589955507fc1717891c4e07d1d658eb41660b87
|
||||
R 5f1fdbfbc3f059f074e757b0a0ddca69
|
||||
U drh
|
||||
Z d3ce6c7669ecb46cdd062d07f32b98f2
|
||||
P 38746c54385e3cb456cda660ea50769b5424db30
|
||||
R 9391d0fdc944a8562cddc95195f4991f
|
||||
U danielk1977
|
||||
Z 00d7394476c64d4bc2a531edfc49d684
|
||||
|
@ -1 +1 @@
|
||||
38746c54385e3cb456cda660ea50769b5424db30
|
||||
349aab42c7896f04ecb6ca33f08a4c194051e837
|
16
src/build.c
16
src/build.c
@ -22,7 +22,7 @@
|
||||
** COMMIT
|
||||
** ROLLBACK
|
||||
**
|
||||
** $Id: build.c,v 1.479 2008/04/02 16:29:31 drh Exp $
|
||||
** $Id: build.c,v 1.480 2008/04/11 17:11:27 danielk1977 Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include <ctype.h>
|
||||
@ -2072,6 +2072,14 @@ void sqlite3DropTable(Parse *pParse, SrcList *pName, int isView, int noErr){
|
||||
sqlite3NestedParse(pParse,
|
||||
"DELETE FROM %Q.%s WHERE tbl_name=%Q and type!='trigger'",
|
||||
pDb->zName, SCHEMA_TABLE(iDb), pTab->zName);
|
||||
|
||||
/* Drop any statistics from the sqlite_stat1 table, if it exists */
|
||||
if( sqlite3FindTable(db, "sqlite_stat1", db->aDb[iDb].zName) ){
|
||||
sqlite3NestedParse(pParse,
|
||||
"DELETE FROM %Q.sqlite_stat1 WHERE tbl=%Q", pDb->zName, pTab->zName
|
||||
);
|
||||
}
|
||||
|
||||
if( !isView && !IsVirtual(pTab) ){
|
||||
destroyTable(pParse, pTab);
|
||||
}
|
||||
@ -2857,6 +2865,12 @@ void sqlite3DropIndex(Parse *pParse, SrcList *pName, int ifExists){
|
||||
db->aDb[iDb].zName, SCHEMA_TABLE(iDb),
|
||||
pIndex->zName
|
||||
);
|
||||
if( sqlite3FindTable(db, "sqlite_stat1", db->aDb[iDb].zName) ){
|
||||
sqlite3NestedParse(pParse,
|
||||
"DELETE FROM %Q.sqlite_stat1 WHERE idx=%Q",
|
||||
db->aDb[iDb].zName, pIndex->zName
|
||||
);
|
||||
}
|
||||
sqlite3ChangeCookie(pParse, iDb);
|
||||
destroyRootPage(pParse, pIndex->tnum, iDb);
|
||||
sqlite3VdbeAddOp4(v, OP_DropIndex, iDb, 0, 0, pIndex->zName, 0);
|
||||
|
@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library.
|
||||
# This file implements tests for the ANALYZE command.
|
||||
#
|
||||
# $Id: analyze.test,v 1.6 2008/03/19 13:03:34 drh Exp $
|
||||
# $Id: analyze.test,v 1.7 2008/04/11 17:11:27 danielk1977 Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -165,7 +165,7 @@ do_test analyze-3.5 {
|
||||
ANALYZE t1;
|
||||
SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;
|
||||
}
|
||||
} {t1i1 {5 3} t1i2 {5 2} t1i3 {5 3 1} t2i1 {5 3} t2i2 {5 2} t2i3 {5 3 1}}
|
||||
} {t1i1 {5 3} t1i2 {5 2} t1i3 {5 3 1} t2i1 {5 3} t2i2 {5 2}}
|
||||
do_test analyze-3.6 {
|
||||
execsql {
|
||||
ANALYZE t2;
|
||||
@ -187,11 +187,40 @@ do_test analyze-3.8 {
|
||||
CREATE INDEX t3i3 ON t3(d,b,c,a);
|
||||
DROP TABLE t1;
|
||||
DROP TABLE t2;
|
||||
SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;
|
||||
}
|
||||
} {}
|
||||
do_test analyze-3.9 {
|
||||
execsql {
|
||||
ANALYZE;
|
||||
SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;
|
||||
}
|
||||
} {t3i1 {5 3} t3i2 {5 3 1 1 1} t3i3 {5 5 2 1 1}}
|
||||
|
||||
do_test analyze-3.10 {
|
||||
execsql {
|
||||
CREATE TABLE [silly " name](a, b, c);
|
||||
CREATE INDEX 'foolish '' name' ON [silly " name](a, b);
|
||||
CREATE INDEX 'another foolish '' name' ON [silly " name](c);
|
||||
INSERT INTO [silly " name] VALUES(1, 2, 3);
|
||||
INSERT INTO [silly " name] VALUES(4, 5, 6);
|
||||
ANALYZE;
|
||||
SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;
|
||||
}
|
||||
} {{another foolish ' name} {2 1} {foolish ' name} {2 1 1} t3i1 {5 3} t3i2 {5 3 1 1 1} t3i3 {5 5 2 1 1}}
|
||||
do_test analyze-3.11 {
|
||||
execsql {
|
||||
DROP INDEX "foolish ' name";
|
||||
SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;
|
||||
}
|
||||
} {{another foolish ' name} {2 1} t3i1 {5 3} t3i2 {5 3 1 1 1} t3i3 {5 5 2 1 1}}
|
||||
do_test analyze-3.11 {
|
||||
execsql {
|
||||
DROP TABLE "silly "" name";
|
||||
SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;
|
||||
}
|
||||
} {t3i1 {5 3} t3i2 {5 3 1 1 1} t3i3 {5 5 2 1 1}}
|
||||
|
||||
# Try corrupting the sqlite_stat1 table and make sure the
|
||||
# database is still able to function.
|
||||
#
|
||||
|
Loading…
x
Reference in New Issue
Block a user