]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix a problem with the way temporary tables mask permanent tables. (CVS 345)
authordrh <drh@noemail.net>
Thu, 10 Jan 2002 14:31:48 +0000 (14:31 +0000)
committerdrh <drh@noemail.net>
Thu, 10 Jan 2002 14:31:48 +0000 (14:31 +0000)
FossilOrigin-Name: ba89da603135e5f63f6f97ba3adad02682375c07

VERSION
manifest
manifest.uuid
src/build.c
src/main.c
test/temptable.test
test/trans.test
www/changes.tcl

diff --git a/VERSION b/VERSION
index c043eea7767eecb5567ebcbe8d671e45ef2833a8..b1b25a5ffae43c2f07d222b53240d871e7c1789b 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.2.1
+2.2.2
index 5ad3f8a456b5f29ccfa4cc406188cd835051408b..fc3cde128b654dcefbad4db2b6fb56f45d1411a9 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,9 +1,9 @@
-C Version\s2.2.1\s(CVS\s452)
-D 2002-01-09T13:45:00
+C Fix\sa\sproblem\swith\sthe\sway\stemporary\stables\smask\spermanent\stables.\s(CVS\s345)
+D 2002-01-10T14:31:49
 F Makefile.in 9fa4277413bf1d9cf91365f07d4108d7d87ed2af
 F Makefile.template c88ffcb9c339e718f434d0c7f045bcd7eea125af
 F README a4c0ba11354ef6ba0776b400d057c59da47a4cc0
-F VERSION 6565c509ed61af074681258bd346dca53ad38128
+F VERSION e4851f0e1fd8b7411787e28c5062067c23d706f1
 F aclocal.m4 11faa843caa38fd451bc6aeb43e248d1723a269d
 F config.guess f38b1e93d1e0fa6f5a6913e9e7b12774b9232588
 F config.log 6a73d03433669b10a3f0c221198c3f26b9413914
@@ -21,13 +21,13 @@ F sqlite.1 2e2bb0529ef468ade9e4322bd609d0695fb9ded9
 F src/TODO af7f3cab0228e34149cf98e073aa83d45878e7e6
 F src/btree.c c796e387da340cb628dc1e41f684fc20253f561e
 F src/btree.h 9ead7f54c270d8a554e59352ca7318fdaf411390
-F src/build.c 1acab23d8d5ef447e16c2b270262fcb18d6c0d90
+F src/build.c d44fbcfaf0eacd33a4686aa4dda8fc770b640421
 F src/delete.c f7690efc09ad6a2f1f3f0490e1b0cbb676bb95cf
 F src/expr.c 8169261ac56e96c860407a8773ca10b779e32328
 F src/hash.c 838a6f2af547dfdc5ff2b438e8f981ea4b74f224
 F src/hash.h a5f5b3ce2d086a172c5879b0b06a27a82eac9fac
 F src/insert.c 813c37719866c583e6ca7660f94f10230f4e385d
-F src/main.c 46c752711300f1994be4162aaa59cbfb9db0c11e
+F src/main.c bdce5ed20f2828cd5b390c3880d5820b70e09871
 F src/md5.c 52f677bfc590e09f71d07d7e327bd59da738d07c
 F src/os.c 07882cde5c61f26751b8ee76fd84726c1f7e453c
 F src/os.h 00a18e0ae1139a64f1d3ead465ae2b9ff43f3db2
@@ -87,9 +87,9 @@ F test/subselect.test 335d3dad8d585726c447dfee8d9c4f7383c76b78
 F test/table.test 3ef4254d62ece31a3872ab11cdaec846f6fa8fd1
 F test/tableapi.test 51d0c209aa6b1158cb952ec917c656d4ce66e9e4
 F test/tclsqlite.test feca0f2b23ba51d202d67d71e10ba7a8a1621f82
-F test/temptable.test 37acd9e39781c2ff7cff2ba741b6b27ce020a44a
+F test/temptable.test 0e9934283259a5e637eec756a7eefd6964c0f79b
 F test/tester.tcl 96db1b49157388edb57e11bf33285e3811a897e4
-F test/trans.test 9306ee5e47e36d0c99185ab33326f988567a868d
+F test/trans.test 9e49495c06b1c41f889bf4f0fb195a015b126de0
 F test/unique.test 07776624b82221a80c8b4138ce0dd8b0853bb3ea
 F test/update.test 3cf1ca0565f678063c2dfa9a7948d2d66ae1a778
 F test/vacuum.test 8acf8669f3b627e54149b25165b034aa06c2432e
@@ -105,7 +105,7 @@ F www/arch.fig d5f9752a4dbf242e9cfffffd3f5762b6c63b3bcf
 F www/arch.png 82ef36db1143828a7abc88b1e308a5f55d4336f4
 F www/arch.tcl 72a0c80e9054cc7025a50928d28d9c75c02c2b8b
 F www/c_interface.tcl 9123810452845783fac8e3184929463d9e70d609
-F www/changes.tcl 33d23e9b4a41665d1f88e0e5d87a1c891b223080
+F www/changes.tcl adfe78519e374df4d85d93f6439c4ff9eaae0020
 F www/crosscompile.tcl 3622ebbe518927a3854a12de51344673eb2dd060
 F www/download.tcl 1ea61f9d89a2a5a9b2cee36b0d5cf97321bdefe0
 F www/dynload.tcl 02eb8273aa78cfa9070dd4501dca937fb22b466c
@@ -119,7 +119,7 @@ F www/speed.tcl 83457b2bf6bb430900bd48ca3dd98264d9a916a5
 F www/sqlite.tcl 8b5884354cb615049aed83039f8dfe1552a44279
 F www/tclsqlite.tcl 880ef67cb4f2797b95bf1368fc4e0d8ca0fda956
 F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
-P e78b1ea23ccda4bc476fbb070586dcac2cc83331
-R af480a8ae42089cfdb3a02b61e4f93f1
+P 61c38f3bfef430f39aa98e9e7fa37324132b4381
+R 86d121727b37f70f571d7ff2f6e92a47
 U drh
-Z 3dbcd152ef063de125b37abe863b56e2
+Z 03a2bc05be0a98dd6da8d500e8918359
index 71e4f66a2c0d6bd730a3b94b1efb23bd359b518c..85a59a92c9b635fa203ed69f7291035e37036462 100644 (file)
@@ -1 +1 @@
-61c38f3bfef430f39aa98e9e7fa37324132b4381
\ No newline at end of file
+ba89da603135e5f63f6f97ba3adad02682375c07
\ No newline at end of file
index d6bd5d653bf65480ed80944d1d4cb3a108c26ff1..431854e117e84660cab4b9619e9654e66296ea57 100644 (file)
@@ -25,7 +25,7 @@
 **     ROLLBACK
 **     PRAGMA
 **
-** $Id: build.c,v 1.63 2002/01/09 13:30:41 drh Exp $
+** $Id: build.c,v 1.64 2002/01/10 14:31:49 drh Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -205,7 +205,7 @@ void sqliteUnlinkAndDeleteIndex(sqlite *db, Index *pIndex){
 ** executed.  If a ROLLBACK occurs, the indices are moved back into
 ** the main index hash table.
 */
-void sqlitePendingDropIndex(sqlite *db, Index *p){
+static void sqlitePendingDropIndex(sqlite *db, Index *p){
   if( !p->isCommit ){
     sqliteUnlinkAndDeleteIndex(db, p);
   }else{
@@ -273,7 +273,7 @@ static void sqliteUnlinkAndDeleteTable(sqlite *db, Table *p){
 ** then the tables on the drop queue are moved back into the main
 ** hash table.
 */
-void sqlitePendingDropTable(sqlite *db, Table *pTbl){
+static void sqlitePendingDropTable(sqlite *db, Table *pTbl){
   if( !pTbl->isCommit ){
     sqliteUnlinkAndDeleteTable(db, pTbl);
   }else{
@@ -954,6 +954,7 @@ void sqliteCreateIndex(
     zName = 0;
     sqliteSetString(&zName, "(", pTab->zName, " autoindex ", zBuf, 0);
     if( zName==0 ) goto exit_create_index;
+    hideName = sqliteFindIndex(db, zName)!=0;
   }
 
   /* If pList==0, it means this routine was called to make a primary
index 5a6118afd77896385dd2c63cc826b9881e043a40..e80b87a1bae2a55934e8fc65c9aed6815c1c174f 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.54 2002/01/09 03:20:00 drh Exp $
+** $Id: main.c,v 1.55 2002/01/10 14:31:49 drh Exp $
 */
 #include "sqliteInt.h"
 #include "os.h"
@@ -73,7 +73,12 @@ static int sqliteOpenCb(void *pDb, int argc, char **argv, char **azColName){
         */
         Index *pIndex = sqliteFindIndex(db, argv[1]);
         if( pIndex==0 || pIndex->tnum!=0 ){
-          nErr++;
+          /* This can occur if there exists an index on a TEMP table which
+          ** has the same name as another index on a permanent index.  Since
+          ** the permanent table is hidden by the TEMP table, we can also
+          ** safely ignore the index on the permanent table.
+          */
+          /* Do Nothing */;
         }else{
           pIndex->tnum = atoi(argv[2]);
         }
index efc815a134d6e95f62f1190ec4bda40984bf141a..213ba81d49162b9fff04939646aefe488682627d 100644 (file)
@@ -12,7 +12,7 @@
 #
 # This file implements tests for temporary tables and indices.
 #
-# $Id: temptable.test,v 1.3 2001/10/09 12:39:24 drh Exp $
+# $Id: temptable.test,v 1.4 2002/01/10 14:31:49 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -148,11 +148,11 @@ do_test temptable-3.4 {
 # hides the existance of the permanent table.
 #
 do_test temptable-4.1 {
-  db2 eval {
+  execsql {
     CREATE TEMP TABLE t2(x,y);
     INSERT INTO t2 VALUES(10,20);
     SELECT * FROM t2;
-  }
+  } db2
 } {10 20}
 do_test temptable-4.2 {
   execsql {
@@ -162,68 +162,139 @@ do_test temptable-4.2 {
   }
 } {9 8 7}
 do_test temptable-4.3 {
-  set r [catch {db2 eval {SELECT * FROM t2}} msg]
-  lappend r $msg
+  catchsql {
+    SELECT * FROM t2;
+  } db2
 } {1 {database schema has changed}}
 do_test temptable-4.4 {
-  set r [catch {db2 eval {SELECT * FROM t2}} msg]
-  lappend r $msg
+  catchsql {
+    SELECT * FROM t2;
+  } db2
 } {0 {10 20}}
 do_test temptable-4.5 {
-  db2 eval {DROP TABLE t2}
-  set r [catch {db2 eval {SELECT * FROM t2}} msg]
-  lappend r $msg
+  catchsql {
+    DROP TABLE t2;
+    SELECT * FROM t2;
+  } db2
 } {1 {no such table: t2}}
 do_test temptable-4.6 {
   db2 close
   sqlite db2 ./test.db
-  set r [catch {db2 eval {SELECT * FROM t2}} msg]
-  lappend r $msg
+  catchsql {
+    SELECT * FROM t2;
+  } db2
 } {0 {9 8 7}}
+do_test temptable-4.7 {
+  catchsql {
+    DROP TABLE t2;
+    SELECT * FROM t2;
+  }
+} {1 {no such table: t2}}
+do_test temptable-4.8 {
+  db2 close
+  sqlite db2 ./test.db
+  execsql {
+    CREATE TEMP TABLE t2(x unique,y);
+    INSERT INTO t2 VALUES(1,2);
+    SELECT * FROM t2;
+  } db2
+} {1 2}
+do_test temptable-4.9 {
+  execsql {
+    CREATE TABLE t2(x unique, y);
+    INSERT INTO t2 VALUES(3,4);
+    SELECT * FROM t2;
+  }
+} {3 4}
+do_test temptable-4.10 {
+  catchsql {
+    SELECT * FROM t2;
+  } db2
+} {1 {database schema has changed}}
+do_test temptable-4.11 {
+  execsql {
+    SELECT * FROM t2;
+  } db2
+} {1 2}
+do_test temptable-4.12 {
+  execsql {
+    SELECT * FROM t2;
+  }
+} {3 4}
+do_test temptable-4.13 {
+  catchsql {
+    DROP TABLE t2;
+    SELECT * FROM t2;
+  } db2
+} {1 {no such table: t2}}
+do_test temptable-4.14 {
+  execsql {
+    SELECT * FROM t2;
+  }
+} {3 4}
+do_test temptable-4.15 {
+  db2 close
+  sqlite db2 ./test.db
+  execsql {
+    SELECT * FROM t2;
+  } db2
+} {3 4}
 
 # Now create a temporary table in db2 and a permanent index in db.  The
 # temporary table in db2 should mask the name of the permanent index,
 # but the permanent index should still be accessible and should still
-# be updated when its correspnding table changes.
+# be updated when its corresponding table changes.
 #
 do_test temptable-5.1 {
-  db2 eval {CREATE TEMP TABLE mask(a,b,c)}
+  execsql {
+    CREATE TEMP TABLE mask(a,b,c)
+  } db2
   execsql {
     CREATE INDEX mask ON t2(x);
     SELECT * FROM t2;
   }
-} {9 8 7}
+} {3 4}
 do_test temptable-5.2 {
-  set r [catch {db2 eval {SELECT * FROM t2}} msg]
-  lappend r $msg
+  catchsql {
+    SELECT * FROM t2;
+  } db2
 } {1 {database schema has changed}}
 do_test temptable-5.3 {
-  set r [catch {db2 eval {SELECT * FROM t2}} msg]
-  lappend r $msg
-} {0 {9 8 7}}
+  catchsql {
+    SELECT * FROM t2;
+  } db2
+} {0 {3 4}}
 do_test temptable-5.4 {
-  execsql {SELECT y FROM t2 WHERE x=9}
-} {8}
+  execsql {
+    SELECT y FROM t2 WHERE x=3
+  }
+} {4}
 do_test temptable-5.5 {
-  db2 eval {SELECT y FROM t2 WHERE x=9}
-} {8}
+  execsql {
+    SELECT y FROM t2 WHERE x=3
+  } db2
+} {4}
 do_test temptable-5.6 {
-  db2 eval {
-    INSERT INTO t2 VALUES(1,2,3);
+  execsql {
+    INSERT INTO t2 VALUES(1,2);
     SELECT y FROM t2 WHERE x=1;
-  }
+  } db2
 } {2}
 do_test temptable-5.7 {
-  db2 eval {SELECT y FROM t2 WHERE x=9}
-} {8}
+  execsql {
+    SELECT y FROM t2 WHERE x=3
+  } db2
+} {4}
 do_test temptable-5.8 {
   execsql {
     SELECT y FROM t2 WHERE x=1;
   }
 } {2}
 do_test temptable-5.9 {
-  execsql {SELECT y FROM t2 WHERE x=9}
-} {8}
+  execsql {
+    SELECT y FROM t2 WHERE x=3
+  }
+} {4}
 
 db2 close
 
index 51f3b253ad7d8fd8b1d794cda213ad0f0e3883f9..1f0d6ac3113493ef3bb9f207b81dbce9a4781080 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this script is database locks.
 #
-# $Id: trans.test,v 1.9 2002/01/09 13:30:42 drh Exp $
+# $Id: trans.test,v 1.10 2002/01/10 14:31:49 drh Exp $
 
 
 set testdir [file dirname $argv0]
@@ -646,13 +646,19 @@ do_test trans-6.36 {
     SELECT * FROM t1 WHERE c<1;
   }
 } {4 -5 -6 1 -2 -3}
-do_test trans-6.36 {
+do_test trans-6.37 {
+  execsql {
+    DROP INDEX i1;
+    SELECT * FROM t1 WHERE c<1;
+  }
+} {1 -2 -3 4 -5 -6}
+do_test trans-6.38 {
   execsql {
     ROLLBACK;
     SELECT * FROM t1 WHERE b<1;
   }
 } {4 -5 -6 1 -2 -3}
-do_test trans-6.38 {
+do_test trans-6.39 {
   execsql {
     SELECT * FROM t1 WHERE c<1;
   }
index eea8a085fdc8cf5f35956f1273f5d22bc8e899a2..38a3aab77f883ae66fa99a16b18365f86d1726ef 100644 (file)
@@ -17,6 +17,11 @@ proc chng {date desc} {
   puts "<DD><P><UL>$desc</UL></P></DD>"
 }
 
+chng {2002 Jan 10 (2.2.2)} {
+<li>Bug fix: An assertion was failing when a temporary table with an index
+    had the same name as a permanent table created by a separate process.</li>
+}
+
 chng {2002 Jan 9 (2.2.1)} {
 <li>Bug fix: An attempt to delete a single row of a table with a WHERE
     clause of "ROWID=x" when no such rowid exists was causing an error.</li>