/ Check-in [24191373]
Login

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

Overview
Comment:Additional attach testing. I now believe that ticket #317 was fixed by check-in (981). (CVS 985)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 24191373796b7fd6255ef9b70ce2344326308113
User & Date: drh 2003-05-17 19:23:52
Context
2003-05-19
23:55
Fix segfault that occurs when opening a non-existing database in the shell then immediately doing ".q". (CVS 986) check-in: e8566cf5 user: drh tags: trunk
2003-05-17
19:23
Additional attach testing. I now believe that ticket #317 was fixed by check-in (981). (CVS 985) check-in: 24191373 user: drh tags: trunk
19:04
Prevent an infinite loop when deleting a table that has a TEMP trigger. (CVS 984) check-in: c8c823b0 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to test/attach.test.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
...
287
288
289
290
291
292
293
294













































































295
296
297
298
299
300
#    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: attach.test,v 1.4 2003/05/17 17:35:13 drh Exp $
#

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

for {set i 2} {$i<=15} {incr i} {
  file delete -force test$i.db
................................................................................
} {21 x 22 y}
do_test attach-2.10 {
  execsql {
    SELECT type, name, tbl_name FROM sqlite_master;
  } db2
} {table t2 t2 table tx tx trigger r1 t2 index i2 t2}
do_test attach-2.11 {
  catchsql { pragma vdbe_trace=on;
    SELECT * FROM t2 WHERE x>5;
  }
} {1 {database schema has changed}}
do_test attach-2.12 {
  execsql {
    PRAGMA database_list
  }
................................................................................
  db close
  sqlite db test.db
  execsql {
    ATTACH 'test2.db' AS db2;
    SELECT type, name, tbl_name FROM db2.sqlite_master;
  }
} {table t2 t2 table tx tx trigger r1 t2 index i2 t2}














































































for {set i 2} {$i<=15} {incr i} {
  catch {db$i close}
}


finish_test







|







 







|







 








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






8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
...
287
288
289
290
291
292
293
294
295
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
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
#    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: attach.test,v 1.5 2003/05/17 19:23:52 drh Exp $
#

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

for {set i 2} {$i<=15} {incr i} {
  file delete -force test$i.db
................................................................................
} {21 x 22 y}
do_test attach-2.10 {
  execsql {
    SELECT type, name, tbl_name FROM sqlite_master;
  } db2
} {table t2 t2 table tx tx trigger r1 t2 index i2 t2}
do_test attach-2.11 {
  catchsql { 
    SELECT * FROM t2 WHERE x>5;
  }
} {1 {database schema has changed}}
do_test attach-2.12 {
  execsql {
    PRAGMA database_list
  }
................................................................................
  db close
  sqlite db test.db
  execsql {
    ATTACH 'test2.db' AS db2;
    SELECT type, name, tbl_name FROM db2.sqlite_master;
  }
} {table t2 t2 table tx tx trigger r1 t2 index i2 t2}

do_test attach-3.1 {
  db close
  db2 close
  sqlite db test.db
  sqlite db2 test2.db
  execsql {
    SELECT * FROM t1
  }
} {1 2 3 4}
do_test attach-3.2 {
  catchsql {
    SELECT * FROM t2
  }
} {1 {no such table: t2}}
do_test attach-3.3 {
  catchsql {
    ATTACH DATABASE 'test2.db' AS db2;
    SELECT * FROM t2
  }
} {0 {21 x 22 y}}

# Even though main has a transaction, test2.db should not be locked.
do_test attach-3.4 {
  execsql BEGIN
  catchsql {
    SELECT * FROM t2;
  } db2;
} {0 {21 x 22 y}}

# Reading from db2 should not lock test2.db
do_test attach-3.5 {
  execsql {SELECT * FROM t2}
  catchsql {
    SELECT * FROM t2;
  } db2;
} {0 {21 x 22 y}}

# Making a change to db2 causes test2.ddb to become locked.
do_test attach-3.6 {
  execsql {
    UPDATE t2 SET x=x+1 WHERE x=50;
  }
  catchsql {
    SELECT * FROM t2;
  } db2;
} {1 {database is locked}}

do_test attach-3.7 {
  execsql ROLLBACK
  execsql {SELECT * FROM t2} db2
} {21 x 22 y}
do_test attach-3.8 {
  execsql BEGIN
  execsql BEGIN db2
  catchsql {SELECT * FROM t2}
} {1 {database is locked}}
do_test attach-3.9 {
  catchsql {SELECT * FROM t2} db2
} {0 {21 x 22 y}}
do_test attach-3.10 {
  execsql {SELECT * FROM t1}
} {1 2 3 4}
do_test attach-3.11 {
  catchsql {UPDATE t1 SET a=a+1}
} {0 {}}
do_test attach-3.12 {
  execsql {SELECT * FROM t1}
} {2 2 4 4}
do_test attach-3.13 {
  catchsql {UPDATE t2 SET x=x+1 WHERE x=50}
} {1 {database is locked}}
do_test attach-3.14 {
  # the "database is locked" error on the previous test should have
  # caused a rollback.
  execsql {SELECT * FROM t1}
} {1 2 3 4}

for {set i 2} {$i<=15} {incr i} {
  catch {db$i close}
}


finish_test