-C Working\son\sa\sbug:\sDropping\sand\srecreating\sa\stable\swithin\sa\stransaction\ncauses\san\sassertion\sfailure.\s(CVS\s342)
-D 2002-01-09T03:19:59
+C Continued\swork\son\sthe\sDROP/CREATE\sproblem.\s(CVS\s343)
+D 2002-01-09T13:30:41
F Makefile.in 9fa4277413bf1d9cf91365f07d4108d7d87ed2af
F Makefile.template c88ffcb9c339e718f434d0c7f045bcd7eea125af
F README a4c0ba11354ef6ba0776b400d057c59da47a4cc0
F src/TODO af7f3cab0228e34149cf98e073aa83d45878e7e6
F src/btree.c c796e387da340cb628dc1e41f684fc20253f561e
F src/btree.h 9ead7f54c270d8a554e59352ca7318fdaf411390
-F src/build.c 66195e45353b1c56ee12ba74a5743cb7a487f65e
+F src/build.c 1acab23d8d5ef447e16c2b270262fcb18d6c0d90
F src/delete.c f7690efc09ad6a2f1f3f0490e1b0cbb676bb95cf
F src/expr.c 8169261ac56e96c860407a8773ca10b779e32328
F src/hash.c 838a6f2af547dfdc5ff2b438e8f981ea4b74f224
F test/tclsqlite.test feca0f2b23ba51d202d67d71e10ba7a8a1621f82
F test/temptable.test 37acd9e39781c2ff7cff2ba741b6b27ce020a44a
F test/tester.tcl 96db1b49157388edb57e11bf33285e3811a897e4
-F test/trans.test 5f8543d3df10600b36732ebed5b46030073913a1
+F test/trans.test 9306ee5e47e36d0c99185ab33326f988567a868d
F test/unique.test 07776624b82221a80c8b4138ce0dd8b0853bb3ea
F test/update.test 3cf1ca0565f678063c2dfa9a7948d2d66ae1a778
F test/vacuum.test 8acf8669f3b627e54149b25165b034aa06c2432e
F www/sqlite.tcl 8b5884354cb615049aed83039f8dfe1552a44279
F www/tclsqlite.tcl 880ef67cb4f2797b95bf1368fc4e0d8ca0fda956
F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
-P 7deb62241300ff23af5a78dd855f0f69e5f16ffd
-R 4f050fe6f09f01448c2bd7cd3c521994
+P b3656a5cfef91c89de2cbb9790087d0d53c03e6f
+R 03b35c15e5406e6d492b56b49630910a
U drh
-Z 333823479478d2952c0013142638bffb
+Z b941f9b4d1245f388980c0232066edd8
-b3656a5cfef91c89de2cbb9790087d0d53c03e6f
\ No newline at end of file
+0a3aa99e11ec9803cea646092bc21676e75a6670
\ No newline at end of file
** ROLLBACK
** PRAGMA
**
-** $Id: build.c,v 1.62 2002/01/09 03:20:00 drh Exp $
+** $Id: build.c,v 1.63 2002/01/09 13:30:41 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
** Remove the given index from the index hash table, and free
** its memory structures.
**
-** The index is removed from the database hash tables if db!=NULL.
-** But the index is not unlinked from the Table that it indexes.
+** The index is removed from the database hash tables but
+** it is not unlinked from the Table that it indexes.
** Unlinking from the Table must be done by the calling function.
*/
static void sqliteDeleteIndex(sqlite *db, Index *p){
- if( p->zName && db ){
- Index *pOld;
- pOld = sqliteHashInsert(&db->idxHash, p->zName, strlen(p->zName)+1, 0);
- assert( pOld==0 || pOld==p );
- sqliteHashInsert(&db->idxDrop, p, 0, 0);
+ Index *pOld;
+ assert( db!=0 && p->zName!=0 );
+ pOld = sqliteHashInsert(&db->idxHash, p->zName, strlen(p->zName)+1, 0);
+ if( pOld!=0 && pOld!=p ){
+ sqliteHashInsert(&db->idxHash, pOld->zName, strlen(pOld->zName)+1, pOld);
}
+ sqliteHashInsert(&db->idxDrop, p, 0, 0);
sqliteFree(p);
}
}else{
Index *pOld;
pOld = sqliteHashInsert(&db->idxHash, p->zName, strlen(p->zName)+1, 0);
- assert( pOld==p );
+ if( pOld!=0 && pOld!=p ){
+ sqliteHashInsert(&db->idxHash, pOld->zName, strlen(pOld->zName)+1, pOld);
+ }
sqliteHashInsert(&db->idxDrop, p, 0, p);
p->isDropped = 1;
}
** table structure with all its indices.
*/
static void sqliteUnlinkAndDeleteTable(sqlite *db, Table *p){
- if( p->zName && db ){
- Table *pOld;
- pOld = sqliteHashInsert(&db->tblHash, p->zName, strlen(p->zName)+1, 0);
- assert( pOld==0 || pOld==p );
- sqliteHashInsert(&db->tblDrop, p, 0, 0);
- }
+ Table *pOld;
+ assert( db!=0 );
+ pOld = sqliteHashInsert(&db->tblHash, p->zName, strlen(p->zName)+1, 0);
+ assert( pOld==0 || pOld==p );
+ sqliteHashInsert(&db->tblDrop, p, 0, 0);
sqliteDeleteTable(db, p);
}
# This file implements regression tests for SQLite library. The
# focus of this script is database locks.
#
-# $Id: trans.test,v 1.8 2002/01/09 03:20:00 drh Exp $
+# $Id: trans.test,v 1.9 2002/01/09 13:30:42 drh Exp $
set testdir [file dirname $argv0]
}
} {1 {no such table: t1}}
-do_test trans-6.8 {
+# Repeat on a table with an automatically generated index.
+#
+do_test trans-6.10 {
+ execsql2 {
+ CREATE TABLE t1(a unique,b,c);
+ INSERT INTO t1 VALUES(1,2,3);
+ BEGIN TRANSACTION;
+ DROP TABLE t1;
+ CREATE TABLE t1(p unique,q,r);
+ ROLLBACK;
+ SELECT * FROM t1;
+ }
+} {a 1 b 2 c 3}
+do_test trans-6.11 {
+ execsql2 {
+ BEGIN TRANSACTION;
+ DROP TABLE t1;
+ CREATE TABLE t1(p unique,q,r);
+ COMMIT;
+ SELECT * FROM t1;
+ }
+} {}
+do_test trans-6.12 {
+ execsql2 {
+ INSERT INTO t1 VALUES(1,2,3);
+ SELECT * FROM t1;
+ }
+} {p 1 q 2 r 3}
+do_test trans-6.13 {
+ execsql2 {
+ BEGIN TRANSACTION;
+ DROP TABLE t1;
+ CREATE TABLE t1(a unique,b,c);
+ INSERT INTO t1 VALUES(4,5,6);
+ SELECT * FROM t1;
+ DROP TABLE t1;
+ }
+} {a 4 b 5 c 6}
+do_test trans-6.14 {
+ execsql2 {
+ ROLLBACK;
+ SELECT * FROM t1;
+ }
+} {p 1 q 2 r 3}
+do_test trans-6.15 {
+ execsql2 {
+ BEGIN TRANSACTION;
+ DROP TABLE t1;
+ CREATE TABLE t1(a unique,b,c);
+ INSERT INTO t1 VALUES(4,5,6);
+ SELECT * FROM t1;
+ DROP TABLE t1;
+ }
+} {a 4 b 5 c 6}
+do_test trans-6.16 {
+ catchsql {
+ COMMIT;
+ SELECT * FROM t1;
+ }
+} {1 {no such table: t1}}
+
+do_test trans-6.20 {
execsql {
CREATE TABLE t1(a integer primary key,b,c);
INSERT INTO t1 VALUES(1,-2,-3);
SELECT * FROM t1;
}
} {1 -2 -3 4 -5 -6}
-do_test trans-6.9 {
+do_test trans-6.21 {
execsql {
CREATE INDEX i1 ON t1(b);
SELECT * FROM t1 WHERE b<1;
}
} {4 -5 -6 1 -2 -3}
-do_test trans-6.10 {
+do_test trans-6.22 {
execsql {
BEGIN TRANSACTION;
DROP INDEX i1;
ROLLBACK;
}
} {1 -2 -3 4 -5 -6}
-do_test trans-6.11 {
+do_test trans-6.23 {
execsql {
SELECT * FROM t1 WHERE b<1;
}
} {4 -5 -6 1 -2 -3}
-do_test trans-6.12 {
+do_test trans-6.24 {
execsql {
BEGIN TRANSACTION;
DROP TABLE t1;
}
} {4 -5 -6 1 -2 -3}
-do_test trans-6.13 {
+do_test trans-6.25 {
execsql {
BEGIN TRANSACTION;
DROP INDEX i1;
SELECT * FROM t1 WHERE b<1;
}
} {1 -2 -3 4 -5 -6}
-do_test trans-6.14 {
+do_test trans-6.26 {
execsql {
SELECT * FROM t1 WHERE c<1;
}
} {4 -5 -6 1 -2 -3}
-do_test trans-6.15 {
+do_test trans-6.27 {
execsql {
ROLLBACK;
SELECT * FROM t1 WHERE b<1;
}
} {4 -5 -6 1 -2 -3}
-do_test trans-6.16 {
+do_test trans-6.28 {
execsql {
SELECT * FROM t1 WHERE c<1;
}
} {1 -2 -3 4 -5 -6}
+# The following repeats steps 6.20 through 6.28, but puts a "unique"
+# constraint the first field of the table in order to generate an
+# automatic index.
+#
+do_test trans-6.30 {
+ execsql {
+ BEGIN TRANSACTION;
+ DROP TABLE t1;
+ CREATE TABLE t1(a int unique,b,c);
+ COMMIT;
+ INSERT INTO t1 VALUES(1,-2,-3);
+ INSERT INTO t1 VALUES(4,-5,-6);
+ SELECT * FROM t1 ORDER BY a;
+ }
+} {1 -2 -3 4 -5 -6}
+do_test trans-6.31 {
+ execsql {
+ CREATE INDEX i1 ON t1(b);
+ SELECT * FROM t1 WHERE b<1;
+ }
+} {4 -5 -6 1 -2 -3}
+do_test trans-6.32 {
+ execsql {
+ BEGIN TRANSACTION;
+ DROP INDEX i1;
+ SELECT * FROM t1 WHERE b<1;
+ ROLLBACK;
+ }
+} {1 -2 -3 4 -5 -6}
+do_test trans-6.33 {
+ execsql {
+ SELECT * FROM t1 WHERE b<1;
+ }
+} {4 -5 -6 1 -2 -3}
+do_test trans-6.34 {
+ execsql {
+ BEGIN TRANSACTION;
+ DROP TABLE t1;
+ ROLLBACK;
+ SELECT * FROM t1 WHERE b<1;
+ }
+} {4 -5 -6 1 -2 -3}
+do_test trans-6.35 {
+ execsql {
+ BEGIN TRANSACTION;
+ DROP INDEX i1;
+ CREATE INDEX i1 ON t1(c);
+ SELECT * FROM t1 WHERE b<1;
+ }
+} {1 -2 -3 4 -5 -6}
+do_test trans-6.36 {
+ execsql {
+ SELECT * FROM t1 WHERE c<1;
+ }
+} {4 -5 -6 1 -2 -3}
+do_test trans-6.36 {
+ execsql {
+ ROLLBACK;
+ SELECT * FROM t1 WHERE b<1;
+ }
+} {4 -5 -6 1 -2 -3}
+do_test trans-6.38 {
+ execsql {
+ SELECT * FROM t1 WHERE c<1;
+ }
+} {1 -2 -3 4 -5 -6}
finish_test