/ Check-in [c22f9feb]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:A failed ATTACH leaves the database in a consistent state. Ticket #811. (CVS 1811)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c22f9feb1bb00d1d54a8a87b557195573463fda9
User & Date: drh 2004-07-19 00:56:24
Context
2004-07-19
02:12
Correctly handle joins of more than 32 tables. Ticket #806. (CVS 1812) check-in: 88064409 user: drh tags: trunk
00:56
A failed ATTACH leaves the database in a consistent state. Ticket #811. (CVS 1811) check-in: c22f9feb user: drh tags: trunk
00:39
When comparing two expressions do not apply affinity to either operand. Ticket #805. (CVS 1810) check-in: 88a4e400 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/attach.c.

     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains code used to implement the ATTACH and DETACH commands.
    13     13   **
    14         -** $Id: attach.c,v 1.21 2004/06/30 09:49:23 danielk1977 Exp $
           14  +** $Id: attach.c,v 1.22 2004/07/19 00:56:24 drh Exp $
    15     15   */
    16     16   #include "sqliteInt.h"
    17     17   
    18     18   /*
    19     19   ** This routine is called by the parser to process an ATTACH statement:
    20     20   **
    21     21   **     ATTACH DATABASE filename AS dbname
................................................................................
   104    104         nKey = 0;
   105    105       }
   106    106       sqliteCodecAttach(db, db->nDb-1, zKey, nKey);
   107    107     }
   108    108   #endif
   109    109     sqliteFree(zFile);
   110    110     db->flags &= ~SQLITE_Initialized;
   111         -  if( pParse->nErr ) return;
   112         -  if( rc==SQLITE_OK ){
          111  +  if( pParse->nErr==0 && rc==SQLITE_OK ){
   113    112       rc = sqlite3ReadSchema(pParse);
   114    113     }
   115    114     if( rc ){
   116    115       int i = db->nDb - 1;
   117    116       assert( i>=2 );
   118    117       if( db->aDb[i].pBt ){
   119    118         sqlite3BtreeClose(db->aDb[i].pBt);

Changes to test/attach3.test.

     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this script is testing the ATTACH and DETACH commands
    13     13   # and schema changes to attached databases.
    14     14   #
    15         -# $Id: attach3.test,v 1.8 2004/06/19 02:22:11 danielk1977 Exp $
           15  +# $Id: attach3.test,v 1.9 2004/07/19 00:56:24 drh Exp $
    16     16   #
    17     17   
    18     18   
    19     19   set testdir [file dirname $argv0]
    20     20   source $testdir/tester.tcl
    21     21   
    22     22   # Create tables t1 and t2 in the main database
................................................................................
   215    215   # Make sure the aux.sqlite_master table is read-only
   216    216   do_test attach3-10.0 {
   217    217     catchsql {
   218    218       INSERT INTO aux.sqlite_master VALUES(1, 2, 3, 4, 5);
   219    219     }
   220    220   } {1 {table sqlite_master may not be modified}}
   221    221   
          222  +# Failure to attach leaves us in a workable state.
          223  +# Ticket #811
          224  +#
          225  +do_test attach3-11.0 {
          226  +  catchsql {
          227  +    ATTACH DATABASE '/nodir/nofile.x' AS notadb;
          228  +  }
          229  +} {1 {unable to open database: /nodir/nofile.x}}
          230  +do_test attach3-11.1 {
          231  +  catchsql {
          232  +    ATTACH DATABASE ':memory:' AS notadb;
          233  +  }
          234  +} {0 {}}
          235  +do_test attach3-11.2 {
          236  +  catchsql {
          237  +    DETACH DATABASE notadb;
          238  +  }
          239  +} {0 {}}
   222    240   
   223    241   finish_test
   224         -
   225         -
   226         -
   227         -