1c47fd8e0Sdrh# 2009 April 30 2c47fd8e0Sdrh# 3c47fd8e0Sdrh# The author disclaims copyright to this source code. In place of 4c47fd8e0Sdrh# a legal notice, here is a blessing: 5c47fd8e0Sdrh# 6c47fd8e0Sdrh# May you do good and not evil. 7c47fd8e0Sdrh# May you find forgiveness for yourself and forgive others. 8c47fd8e0Sdrh# May you share freely, never taking more than you give. 9c47fd8e0Sdrh# 10c47fd8e0Sdrh#*********************************************************************** 11c47fd8e0Sdrh# 12c47fd8e0Sdrh# Make sure that attaching the same database multiple times in 13c47fd8e0Sdrh# shared cache mode fails. 14c47fd8e0Sdrh# 15c47fd8e0Sdrh# $Id: shared7.test,v 1.1 2009/04/30 13:30:33 drh Exp $ 16c47fd8e0Sdrh 17c47fd8e0Sdrhset testdir [file dirname $argv0] 18c47fd8e0Sdrhsource $testdir/tester.tcl 19c47fd8e0Sdrhifcapable !shared_cache { finish_test ; return } 20c47fd8e0Sdrh 21c47fd8e0Sdrhdo_test shared7-1.1 { 22c47fd8e0Sdrh set ::enable_shared_cache [sqlite3_enable_shared_cache 1] 23c47fd8e0Sdrh sqlite3_enable_shared_cache 24c47fd8e0Sdrh} {1} 25c47fd8e0Sdrh 26*cf9fca46Sdrh# EVIDENCE-OF: R-05098-06501 In shared cache mode, attempting to attach 27*cf9fca46Sdrh# the same database file more than once results in an error. 28*cf9fca46Sdrh# 29c47fd8e0Sdrhdo_test shared7-1.2 { 30c47fd8e0Sdrh db close 31c47fd8e0Sdrh sqlite3 db test.db 32c47fd8e0Sdrh db eval { 33c47fd8e0Sdrh CREATE TABLE t1(x); 34c47fd8e0Sdrh } 35c47fd8e0Sdrh catchsql { 36c47fd8e0Sdrh ATTACH 'test.db' AS err1; 37c47fd8e0Sdrh } 38c47fd8e0Sdrh} {1 {database is already attached}} 39c47fd8e0Sdrh 40c47fd8e0Sdrhdo_test shared7-1.3 { 41fda06befSmistachkin forcedelete test2.db test2.db-journal 42c47fd8e0Sdrh db eval { 43c47fd8e0Sdrh ATTACH 'test2.db' AS test2; 44c47fd8e0Sdrh CREATE TABLE test2.t2(y); 45c47fd8e0Sdrh } 46c47fd8e0Sdrh catchsql { 47c47fd8e0Sdrh ATTACH 'test2.db' AS err2; 48c47fd8e0Sdrh } 49c47fd8e0Sdrh} {1 {database is already attached}} 50c47fd8e0Sdrhdo_test shared7-1.4 { 51c47fd8e0Sdrh catchsql { 52c47fd8e0Sdrh ATTACH 'test.db' AS err1; 53c47fd8e0Sdrh } 54c47fd8e0Sdrh} {1 {database is already attached}} 55c47fd8e0Sdrh 56c47fd8e0Sdrh 57c47fd8e0Sdrhsqlite3_enable_shared_cache $::enable_shared_cache 58c47fd8e0Sdrhfinish_test 59