Index: src/attach.c ================================================================== --- src/attach.c +++ src/attach.c @@ -9,11 +9,11 @@ ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains code used to implement the ATTACH and DETACH commands. ** -** $Id: attach.c,v 1.21 2004/06/30 09:49:23 danielk1977 Exp $ +** $Id: attach.c,v 1.22 2004/07/19 00:56:24 drh Exp $ */ #include "sqliteInt.h" /* ** This routine is called by the parser to process an ATTACH statement: @@ -106,12 +106,11 @@ sqliteCodecAttach(db, db->nDb-1, zKey, nKey); } #endif sqliteFree(zFile); db->flags &= ~SQLITE_Initialized; - if( pParse->nErr ) return; - if( rc==SQLITE_OK ){ + if( pParse->nErr==0 && rc==SQLITE_OK ){ rc = sqlite3ReadSchema(pParse); } if( rc ){ int i = db->nDb - 1; assert( i>=2 ); Index: test/attach3.test ================================================================== --- test/attach3.test +++ test/attach3.test @@ -10,11 +10,11 @@ #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script is testing the ATTACH and DETACH commands # and schema changes to attached databases. # -# $Id: attach3.test,v 1.8 2004/06/19 02:22:11 danielk1977 Exp $ +# $Id: attach3.test,v 1.9 2004/07/19 00:56:24 drh Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -217,11 +217,25 @@ catchsql { INSERT INTO aux.sqlite_master VALUES(1, 2, 3, 4, 5); } } {1 {table sqlite_master may not be modified}} +# Failure to attach leaves us in a workable state. +# Ticket #811 +# +do_test attach3-11.0 { + catchsql { + ATTACH DATABASE '/nodir/nofile.x' AS notadb; + } +} {1 {unable to open database: /nodir/nofile.x}} +do_test attach3-11.1 { + catchsql { + ATTACH DATABASE ':memory:' AS notadb; + } +} {0 {}} +do_test attach3-11.2 { + catchsql { + DETACH DATABASE notadb; + } +} {0 {}} finish_test - - - -