]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Detect and report a particular type of database corruption that would
authordrh <drh@noemail.net>
Tue, 22 Jan 2008 16:35:36 +0000 (16:35 +0000)
committerdrh <drh@noemail.net>
Tue, 22 Jan 2008 16:35:36 +0000 (16:35 +0000)
formerly cause a segfault. (CVS 4739)

FossilOrigin-Name: 6ed2d9f82e2c81d5f6c22a4e05c1a2cb5eedd10c

manifest
manifest.uuid
src/prepare.c
test/corrupt5.test [new file with mode: 0644]

index 05bd6aed29c8d7d77195005910ceaaafcbc8c725..05e219fd1bccae059446269ca27e694a15b548c2 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Remove\sdead\scode\sfrom\sthe\slemon-generated\sparser.\s\sBetter\stesting\nof\sthe\ssqlite3_file_control()\sinterface,\sand\sin\sparticular\smake\ssure\nthe\sinterface\sworks\son\s:memory:\sdatabases.\s(CVS\s4738)
-D 2008-01-22T14:50:17
+C Detect\sand\sreport\sa\sparticular\stype\sof\sdatabase\scorruption\sthat\swould\nformerly\scause\sa\ssegfault.\s(CVS\s4739)
+D 2008-01-22T16:35:37
 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
 F Makefile.in 936bcacced594b24b8fdcfc0fc0efc00e15de8a8
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -128,7 +128,7 @@ F src/pager.c fae75270b4e2b2542b905791087f0c52142974f8
 F src/pager.h f504f7ae84060fee0416a853e368d3d113c3d6fa
 F src/parse.y bcc6092d2577f4b525e09928b3ed164965e35c54
 F src/pragma.c 2bb8d6882b9a330e041acd05fb6aff5a01bf0a08
-F src/prepare.c 505afbfebcca809f655e04725832bfbfdf1ce697
+F src/prepare.c f0e9e0f25aad4bf9acf489874c5d8d87887a39e7
 F src/printf.c eb27822ba2eec669161409ca31279a24c26ac910
 F src/random.c 02ef38b469237482f1ea14a78b2087cfbaec48bd
 F src/select.c 9fb094cc0c8acdcbf3581fdfc4490e997b5d1d1e
@@ -241,6 +241,7 @@ F test/corrupt.test 18c7a995b1af76a8c8600b996257f2c7b7bff083
 F test/corrupt2.test 572f8df0303d0ce63ddad5c5c9101a83a345ae46
 F test/corrupt3.test 263e8bb04e2728df832fddf6973cf54c91db0c32
 F test/corrupt4.test acdb01afaedf529004b70e55de1a6f5a05ae7fff
+F test/corrupt5.test 36073300a786b546fb17d39955d5105b9c8b3582
 F test/crash.test 1b6ac8410689ff78028887f445062dc897c9ac89
 F test/crash2.test 26d7a4c5520201e5de2c696ea51ab946b59dc0e9
 F test/crash3.test 0b09687ae1a3ccbcefdfaeb4b963e26e36255d76
@@ -612,7 +613,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
 F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P 17e7bd6c3f507ffc6b56f54ae8c70730e8246f39
-R 14b9fd5f5ecc09fd70e45747e2da0096
+P 83ca4fc7dc18d6deca58fe4181905eb9754e03da
+R 3417650ecd944a7908b0954ce87245ba
 U drh
-Z fed5347d72dd07a023e0d7f58e92c261
+Z 1684be0f0cf3c808fc0b04aa7d971ebc
index a93fc0c80bf13bf03105e8158d94896cbe4b9cec..cc8803f2dc2e75be8ba398760a77ac361b89882c 100644 (file)
@@ -1 +1 @@
-83ca4fc7dc18d6deca58fe4181905eb9754e03da
\ No newline at end of file
+6ed2d9f82e2c81d5f6c22a4e05c1a2cb5eedd10c
\ No newline at end of file
index ed18ad28350f20b16080fc9e97cf14a6ea5a694c..b8fb25ea77b9cdcdcd82d55d0ce2f59531d681b7 100644 (file)
@@ -13,7 +13,7 @@
 ** interface, and routines that contribute to loading the database schema
 ** from disk.
 **
-** $Id: prepare.c,v 1.72 2008/01/22 01:48:09 drh Exp $
+** $Id: prepare.c,v 1.73 2008/01/22 16:35:37 drh Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -86,6 +86,8 @@ int sqlite3InitCallback(void *pInit, int argc, char **argv, char **azColName){
       sqlite3_free(zErr);
       return 1;
     }
+  }else if( argv[2]==0 ){
+    corruptSchema(pData, 0);
   }else{
     /* If the SQL column is blank it means this is an index that
     ** was created to be the PRIMARY KEY or to fulfill a UNIQUE
diff --git a/test/corrupt5.test b/test/corrupt5.test
new file mode 100644 (file)
index 0000000..07f0ff6
--- /dev/null
@@ -0,0 +1,44 @@
+# 2008 Jan 22
+#
+# The author disclaims copyright to this source code.  In place of
+# a legal notice, here is a blessing:
+#
+#    May you do good and not evil.
+#    May you find forgiveness for yourself and forgive others.
+#    May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to make sure SQLite does not crash or
+# segfault if it sees a corrupt database file.
+#
+# $Id: corrupt5.test,v 1.1 2008/01/22 16:35:37 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# We must have the page_size pragma for these tests to work.
+#
+ifcapable !pager_pragmas {
+  finish_test
+  return
+}
+
+# Create a database with a freelist containing at least two pages.
+#
+do_test corrupt5-1.1 {
+  execsql {
+    CREATE TABLE t1(a,b,c);
+    CREATE INDEX i1 ON t1(a,b);
+    PRAGMA writable_schema=ON;
+    UPDATE sqlite_master SET name=NULL, sql=NULL WHERE name='i1';
+  }
+  db close
+  sqlite3 db test.db
+  catchsql {
+    SELECT * FROM t1
+  }
+} {1 {malformed database schema}}
+
+finish_test