]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix a bug that was preventing the library from opening existing files. (CVS 1358)
authordanielk1977 <danielk1977@noemail.net>
Tue, 11 May 2004 09:50:02 +0000 (09:50 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Tue, 11 May 2004 09:50:02 +0000 (09:50 +0000)
FossilOrigin-Name: ad064bd429602fcac26b377841da90a1a56f5966

manifest
manifest.uuid
src/main.c
test/insert.test

index 99b7273276d229d2888bf907d1b9a1b4db545cca..83d6a4775f78ba5a4c0c984ffb75c306978b03ba 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\san\soffset\sproblem\sin\sthe\smeta\svalues\sthat\swas\scausing\sproblems\sfor\nmany\stests.\s(CVS\s1357)
-D 2004-05-11T09:31:32
+C Fix\sa\sbug\sthat\swas\spreventing\sthe\slibrary\sfrom\sopening\sexisting\sfiles.\s(CVS\s1358)
+D 2004-05-11T09:50:02
 F Makefile.in ab7b0d5118e2da97bac66be8684a1034e3500f5a
 F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -36,7 +36,7 @@ F src/func.c 6cf6501f092b41c8cd9368b09c287016c0576438
 F src/hash.c 440c2f8cb373ee1b4e13a0988489c7cd95d55b6f
 F src/hash.h 762d95f1e567664d1eafc1687de755626be962fb
 F src/insert.c 1e63d2774c4d893363e0c072f19d4c92a4ab982d
-F src/main.c 4cbf83c0933fe713c4afd3dc5e401621f28f0304
+F src/main.c a5e34ce9bbb9afbb26a95a1e2b125ef496cfc0d4
 F src/md5.c 8e39fdae6d8776b87558e91dcc94740c9b635a9c
 F src/os.c ddcda92f7fd71b4513c57c1ec797917f206d504e
 F src/os.h fbb2f6595fc34fa351830d88fe1c6b85118f0383
@@ -92,7 +92,7 @@ F test/func.test 000515779001ac6899eec4b54e65c6e2501279d4
 F test/hook.test 1a67ce0cd64a6455d016962542f2822458dccc49
 F test/in.test 0de39b02ceeca90993b096822fb5a884661c5b47
 F test/index.test 9295deefbdb6dedbe01be8905f0c448fe5bd4079
-F test/insert.test a17b7f7017097afb2727aa5b67ceeb7ab0a120a1
+F test/insert.test 105e559e024051ea0ba5ccd2a219490028e1ead5
 F test/insert2.test c288375a64dad3295044714f0dfed4a193cf067f
 F test/interrupt.test 9142ce4448605127640eda5e283952f75f67ed91
 F test/intpkey.test 9320af48415c594afd4e15f8ef0daa272e05502e
@@ -188,7 +188,7 @@ F www/sqlite.tcl 3c83b08cf9f18aa2d69453ff441a36c40e431604
 F www/tclsqlite.tcl b9271d44dcf147a93c98f8ecf28c927307abd6da
 F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1
 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
-P b5d2771ee0e9c77967b4a64a97dcd56c067bc7b8
-R 1b4242c65713f0f29255a1791a6ffefa
-U drh
-Z 8117037867ee67a6186c1779813eefbc
+P 6d378cb7e7e081bb3bcd3a347bc1e02f50ee25cc
+R 3321970d5631b366601597c20640c500
+U danielk1977
+Z d4c411227edd2aba44aecc234d337019
index 31ba0ada07253f52ea027f87a6dc806b3d1abb6e..c8e6484023ed35c4614c680c02f6bb2dca72ae47 100644 (file)
@@ -1 +1 @@
-6d378cb7e7e081bb3bcd3a347bc1e02f50ee25cc
\ No newline at end of file
+ad064bd429602fcac26b377841da90a1a56f5966
\ No newline at end of file
index 96a8b000f5d6f0c7d785b299746de453d7328719..fe7ace864bdd607a03bf70a17719b27894d376ee 100644 (file)
@@ -14,7 +14,7 @@
 ** other files are for internal use by SQLite and should not be
 ** accessed by users of the library.
 **
-** $Id: main.c,v 1.173 2004/05/11 09:31:32 drh Exp $
+** $Id: main.c,v 1.174 2004/05/11 09:50:02 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 #include "os.h"
@@ -165,9 +165,9 @@ static int sqlite3InitOne(sqlite *db, int iDb, char **pzErrMsg){
 
   /* The following SQL will read the schema from the master tables.
   */
-  static char init_script[] = 
-     "SELECT type, name, rootpage, sql, 1 FROM sqlite_temp_master "
-     "UNION ALL "
+  static char init_script1[] = 
+     "SELECT type, name, rootpage, sql, 1 FROM sqlite_temp_master";
+  static char init_script2[] = 
      "SELECT type, name, rootpage, sql, 0 FROM sqlite_master";
 
   assert( iDb>=0 && iDb!=1 && iDb<db->nDb );
@@ -285,7 +285,19 @@ static int sqlite3InitOne(sqlite *db, int iDb, char **pzErrMsg){
     rc = SQLITE_OK;
   }else{
     if( iDb==0 ){
-      rc = sqlite3_exec(db, init_script, sqlite3InitCallback, &initData, 0);
+      /* This SQL statement tries to read the temp.* schema from the
+      ** sqlite_temp_master table. It might return SQLITE_EMPTY. We
+      ** unset the SQLITE_InternChanges flag temporarily to ensure
+      ** that the sqlite_master entry is not removed from the internal
+      ** schema if this does return SQLITE_EMPTY.
+      */
+      assert( db->flags&SQLITE_InternChanges );
+      db->flags &= ~SQLITE_InternChanges;
+      rc = sqlite3_exec(db, init_script1, sqlite3InitCallback, &initData, 0);
+      db->flags |= SQLITE_InternChanges;
+      if( rc==SQLITE_OK || rc==SQLITE_EMPTY ){
+        rc = sqlite3_exec(db, init_script2, sqlite3InitCallback, &initData, 0);
+      }
     }else{
       char *zSql = 0;
       sqlite3SetString(&zSql, 
index f2081c250f42d420419dd271632302b5c2042d67..07ddbdd5f9e1b2b694466b58f51a6a9b2234b8ce 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this file is testing the INSERT statement.
 #
-# $Id: insert.test,v 1.15 2003/06/15 23:42:25 drh Exp $
+# $Id: insert.test,v 1.16 2004/05/11 09:50:02 danielk1977 Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -225,19 +225,24 @@ do_test insert-5.3 {
   }]
   expr {[lsearch $x OpenTemp]>0}
 } {1}
+
 do_test insert-5.4 {
   # Verify that table "test1" begins on page 3.  This should be the same
   # page number used by "t4" above.
+  #
+  # Update for v3 - the first table now begins on page 2 of each file, not 3.
   execsql {
     SELECT rootpage FROM sqlite_master WHERE name='test1';
   }
-} {3}
+} {2}
 do_test insert-5.5 {
   # Verify that "t4" begins on page 3.
+  #
+  # Update for v3 - the first table now begins on page 2 of each file, not 3.
   execsql {
     SELECT rootpage FROM sqlite_temp_master WHERE name='t4';
   }
-} {3}
+} {2}
 do_test insert-5.6 {
   # This should not use an intermediate temporary table.
   execsql {