Index: src/build.c ================================================================== --- src/build.c +++ src/build.c @@ -21,11 +21,11 @@ ** BEGIN TRANSACTION ** COMMIT ** ROLLBACK ** PRAGMA ** -** $Id: build.c,v 1.155 2003/05/31 16:21:12 drh Exp $ +** $Id: build.c,v 1.156 2003/07/01 18:13:15 drh Exp $ */ #include "sqliteInt.h" #include /* @@ -1691,12 +1691,12 @@ /* Link the new Index structure to its table and to the other ** in-memory database structures. */ if( !pParse->explain ){ Index *p; - p = sqliteHashInsert(&db->aDb[isTemp].idxHash, - pIndex->zName, strlen(zName)+1, pIndex); + p = sqliteHashInsert(&db->aDb[pIndex->iDb].idxHash, + pIndex->zName, strlen(pIndex->zName)+1, pIndex); if( p ){ assert( p==pIndex ); /* Malloc must have failed */ sqliteFree(pIndex); goto exit_create_index; } ADDED test/attach2.test Index: test/attach2.test ================================================================== --- /dev/null +++ test/attach2.test @@ -0,0 +1,46 @@ +# 2003 July 1 +# +# 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. The +# focus of this script is testing the ATTACH and DETACH commands +# and related functionality. +# +# $Id: attach2.test,v 1.1 2003/07/01 18:13:16 drh Exp $ +# + + +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +# Ticket #354 +# +do_test attach2-1.1 { + db eval { + CREATE TABLE t1(a,b); + CREATE INDEX x1 ON t1(a); + } + file delete -force test2.db + sqlite db2 test2.db + db2 eval { + CREATE TABLE t1(a,b); + CREATE INDEX x1 ON t1(a); + } + catchsql { + ATTACH 'test2.db' AS t2; + } +} {0 {}} + +for {set i 2} {$i<=15} {incr i} { + catch {db$i close} +} +file delete -force test2.db + + +finish_test