1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-30 19:03:16 +03:00

Do not crash when a corrupt database contains two indices with the same name. (CVS 3684)

FossilOrigin-Name: 48b2a40008a09881ed9da3548095495a3d4a6647
This commit is contained in:
danielk1977
2007-03-13 16:32:25 +00:00
parent 7f906d63ff
commit d45a0315cb
4 changed files with 43 additions and 16 deletions

View File

@ -13,7 +13,7 @@
# This file implements tests to make sure SQLite does not crash or
# segfault if it sees a corrupt database file.
#
# $Id: corrupt2.test,v 1.3 2007/02/14 12:32:13 drh Exp $
# $Id: corrupt2.test,v 1.4 2007/03/13 16:32:25 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -105,4 +105,31 @@ do_test corrupt2-1.5 {
} {1 {database disk image is malformed}}
db2 close
# Corrupt a database by having 2 indices of the same name:
do_test corrupt2-2.1 {
file delete -force corrupt.db
file delete -force corrupt.db-journal
copy_file test.db corrupt.db
sqlite3 db2 corrupt.db
execsql {
CREATE INDEX a1 ON abc(a);
CREATE INDEX a2 ON abc(b);
PRAGMA writable_schema = 1;
UPDATE sqlite_master
SET name = 'a3', sql = 'CREATE INDEX a3' || substr(sql, 16, 10000)
WHERE type = 'index';
PRAGMA writable_schema = 0;
} db2
db2 close
sqlite3 db2 corrupt.db
catchsql {
SELECT * FROM sqlite_master;
} db2
} {1 {malformed database schema - index a3 already exists}}
db2 close
finish_test