SQLite

Check-in [5b814b5df6]
Login

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

Overview
Comment:Fix for ticket #114: Correctly handle SQLITE_BUSY if it occurs during database initialization. (CVS 696)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 5b814b5df667ccc91d85fbb7f96e523483e9219b
User & Date: drh 2002-07-30 18:43:41.000
Context
2002-07-31
00:32
Fix for ticket #104: Make triggers on views work properly even after closing and reopening the database. Also fixed an unrelated bug in the version 2.6.0 database format upgrade logic. The upgrade logic bug was found while testing the trigger fixes. (CVS 697) (check-in: 04973fc2a6 user: drh tags: trunk)
2002-07-30
18:43
Fix for ticket #114: Correctly handle SQLITE_BUSY if it occurs during database initialization. (CVS 696) (check-in: 5b814b5df6 user: drh tags: trunk)
17:42
Fix for ticket #111: Update the documentation to explain that you may not start a transaction in one thread and complete it in another thread under Linux Threads where each thread has its own process ID. (CVS 695) (check-in: 0b0c0492cc user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/main.c.
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
**
*************************************************************************
** Main file for the SQLite library.  The routines in this file
** implement the programmer interface to the library.  Routines in
** other files are for internal use by SQLite and should not be
** accessed by users of the library.
**
** $Id: main.c,v 1.92 2002/07/19 19:03:42 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
#include <ctype.h>

/*
** A pointer to this structure is used to communicate information







|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
**
*************************************************************************
** Main file for the SQLite library.  The routines in this file
** implement the programmer interface to the library.  Routines in
** other files are for internal use by SQLite and should not be
** accessed by users of the library.
**
** $Id: main.c,v 1.93 2002/07/30 18:43:41 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
#include <ctype.h>

/*
** A pointer to this structure is used to communicate information
234
235
236
237
238
239
240
241



242
243
244
245
246

247
248
249
250
251
252
253
    pTab->readOnly = 1;
  }

  /* Create a cursor to hold the database open
  */
  if( db->pBe==0 ) return SQLITE_OK;
  rc = sqliteBtreeCursor(db->pBe, 2, 0, &curMain);
  if( rc ) return rc;




  /* Get the database meta information
  */
  rc = sqliteBtreeGetMeta(db->pBe, meta);
  if( rc ){

    sqliteBtreeCloseCursor(curMain);
    return rc;
  }
  db->schema_cookie = meta[1];
  db->next_cookie = db->schema_cookie;
  db->file_format = meta[2];
  size = meta[3];







|
>
>
>





>







234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
    pTab->readOnly = 1;
  }

  /* Create a cursor to hold the database open
  */
  if( db->pBe==0 ) return SQLITE_OK;
  rc = sqliteBtreeCursor(db->pBe, 2, 0, &curMain);
  if( rc ){
    sqliteResetInternalSchema(db);
    return rc;
  }

  /* Get the database meta information
  */
  rc = sqliteBtreeGetMeta(db->pBe, meta);
  if( rc ){
    sqliteResetInternalSchema(db);
    sqliteBtreeCloseCursor(curMain);
    return rc;
  }
  db->schema_cookie = meta[1];
  db->next_cookie = db->schema_cookie;
  db->file_format = meta[2];
  size = meta[3];
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
  }

  /* If the database is in formats 1 or 2, then upgrade it to
  ** version 3.  This will reconstruct all indices.  If the
  ** upgrade fails for any reason (ex: out of disk space, database
  ** is read only, interrupt receive, etc.) then refuse to open.
  */
  if( db->file_format<3 ){
    char *zErr = 0;
    InitData initData;
    int meta[SQLITE_N_BTREE_META];

    initData.db = db;
    initData.pzErrMsg = &zErr;
    db->file_format = 3;







|







374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
  }

  /* If the database is in formats 1 or 2, then upgrade it to
  ** version 3.  This will reconstruct all indices.  If the
  ** upgrade fails for any reason (ex: out of disk space, database
  ** is read only, interrupt receive, etc.) then refuse to open.
  */
  if( rc==SQLITE_OK && db->file_format<3 ){
    char *zErr = 0;
    InitData initData;
    int meta[SQLITE_N_BTREE_META];

    initData.db = db;
    initData.pzErrMsg = &zErr;
    db->file_format = 3;
Changes to test/misc1.test.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests for miscellanous features that were
# left out of other test files.
#
# $Id: misc1.test,v 1.10 2002/06/28 01:02:39 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# Test the creation and use of tables that have a large number
# of columns.
#







|







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests for miscellanous features that were
# left out of other test files.
#
# $Id: misc1.test,v 1.11 2002/07/30 18:43:42 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# Test the creation and use of tables that have a large number
# of columns.
#
296
297
298
299
300
301
302
303
















304
} {102}
do_test misc1-10.9 {
  catchsql "UPDATE manycol SET x1=x1+1 $::where AND rowid>0"
} {1 {WHERE clause too complex - no more than 100 terms allowed}}
do_test misc1-10.10 {
  execsql {SELECT x1 FROM manycol WHERE x0=100}
} {102}

















finish_test








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
} {102}
do_test misc1-10.9 {
  catchsql "UPDATE manycol SET x1=x1+1 $::where AND rowid>0"
} {1 {WHERE clause too complex - no more than 100 terms allowed}}
do_test misc1-10.10 {
  execsql {SELECT x1 FROM manycol WHERE x0=100}
} {102}

# Make sure the initialization works even if a database is opened while
# another process has the database locked.
#
do_test misc1-11.1 {
  execsql {BEGIN}
  sqlite db2 test.db
  set rc [catch {db2 eval {SELECT count(*) FROM t1}} msg]
  lappend rc $msg
} {1 {database is locked}}
do_test misc1-11.2 {
  execsql {COMMIT}
  set rc [catch {db2 eval {SELECT count(*) FROM t1}} msg]
  db2 close
  lappend rc $msg
} {0 3}

finish_test