os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/tkt1873.test
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
# 2006 June 27
sl@0
     2
#
sl@0
     3
# The author disclaims copyright to this source code.  In place of
sl@0
     4
# a legal notice, here is a blessing:
sl@0
     5
#
sl@0
     6
#    May you do good and not evil.
sl@0
     7
#    May you find forgiveness for yourself and forgive others.
sl@0
     8
#    May you share freely, never taking more than you give.
sl@0
     9
#
sl@0
    10
#***********************************************************************
sl@0
    11
# This file implements regression tests for SQLite library.
sl@0
    12
#
sl@0
    13
# This file implements tests to verify that ticket #1873 has been
sl@0
    14
# fixed.  
sl@0
    15
#
sl@0
    16
#
sl@0
    17
# $Id: tkt1873.test,v 1.2 2007/10/09 08:29:33 danielk1977 Exp $
sl@0
    18
sl@0
    19
set testdir [file dirname $argv0]
sl@0
    20
source $testdir/tester.tcl
sl@0
    21
sl@0
    22
ifcapable !attach {
sl@0
    23
  finish_test
sl@0
    24
  return
sl@0
    25
}
sl@0
    26
sl@0
    27
file delete -force test2.db test2.db-journal
sl@0
    28
sl@0
    29
do_test tkt1873-1.1 {
sl@0
    30
  execsql {
sl@0
    31
    CREATE TABLE t1(x, y);
sl@0
    32
    ATTACH 'test2.db' AS aux;
sl@0
    33
    CREATE TABLE aux.t2(x, y);
sl@0
    34
    INSERT INTO t1 VALUES(1, 2);
sl@0
    35
    INSERT INTO t1 VALUES(3, 4);
sl@0
    36
    INSERT INTO t2 VALUES(5, 6);
sl@0
    37
    INSERT INTO t2 VALUES(7, 8);
sl@0
    38
  }
sl@0
    39
} {}
sl@0
    40
sl@0
    41
do_test tkt1873-1.2 {
sl@0
    42
  set rc [catch {
sl@0
    43
    db eval {SELECT * FROM t2 LIMIT 1} {
sl@0
    44
      db eval {DETACH aux}
sl@0
    45
    }
sl@0
    46
  } msg]
sl@0
    47
  list $rc $msg
sl@0
    48
} {1 {database aux is locked}}
sl@0
    49
sl@0
    50
do_test tkt1873-1.3 {
sl@0
    51
  set rc [catch {
sl@0
    52
    db eval {SELECT * FROM t1 LIMIT 1} {
sl@0
    53
      db eval {DETACH aux}
sl@0
    54
    }
sl@0
    55
  } msg]
sl@0
    56
  list $rc $msg
sl@0
    57
} {0 {}}
sl@0
    58
sl@0
    59
do_test tkt1873-1.4 {
sl@0
    60
  catchsql {
sl@0
    61
    select * from t2;
sl@0
    62
  }
sl@0
    63
} {1 {no such table: t2}}
sl@0
    64
sl@0
    65
do_test tkt1873-1.5 {
sl@0
    66
  catchsql {
sl@0
    67
    ATTACH 'test2.db' AS aux;
sl@0
    68
    select * from t2;
sl@0
    69
  }
sl@0
    70
} {0 {5 6 7 8}}
sl@0
    71
sl@0
    72
finish_test