2005-08-20 07:03:04 +04:00
|
|
|
# 2005 September 19
|
|
|
|
#
|
|
|
|
# The author disclaims copyright to this source code. In place of
|
|
|
|
# a legal notice, here is a blessing:
|
|
|
|
#
|
|
|
|
# May you do good and not evil.
|
|
|
|
# May you find forgiveness for yourself and forgive others.
|
|
|
|
# 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 statement and
|
|
|
|
# specifically out-of-memory conditions within that command.
|
|
|
|
#
|
2008-10-22 14:45:37 +04:00
|
|
|
# $Id: attachmalloc.test,v 1.10 2008/10/22 10:45:38 danielk1977 Exp $
|
2005-08-20 07:03:04 +04:00
|
|
|
#
|
|
|
|
|
|
|
|
set testdir [file dirname $argv0]
|
|
|
|
source $testdir/tester.tcl
|
|
|
|
|
2007-10-09 12:29:32 +04:00
|
|
|
ifcapable !memdebug||!attach {
|
2007-08-28 03:48:23 +04:00
|
|
|
finish_test
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2007-08-25 17:37:48 +04:00
|
|
|
source $testdir/malloc_common.tcl
|
2005-08-20 07:03:04 +04:00
|
|
|
|
|
|
|
do_malloc_test attachmalloc-1 -tclprep {
|
2010-11-04 23:46:09 +03:00
|
|
|
catch { db close }
|
2005-08-20 07:03:04 +04:00
|
|
|
for {set i 2} {$i<=4} {incr i} {
|
2010-11-04 23:46:09 +03:00
|
|
|
catch { db$i close }
|
2011-08-02 04:57:34 +04:00
|
|
|
forcedelete test$i.db
|
|
|
|
forcedelete test$i.db-journal
|
2005-08-20 07:03:04 +04:00
|
|
|
}
|
|
|
|
} -tclbody {
|
|
|
|
if {[catch {sqlite3 db test.db}]} {
|
|
|
|
error "out of memory"
|
|
|
|
}
|
2008-08-05 00:13:26 +04:00
|
|
|
sqlite3_db_config_lookaside db 0 0 0
|
2007-10-03 12:46:44 +04:00
|
|
|
sqlite3_extended_result_codes db 1
|
2005-08-20 07:03:04 +04:00
|
|
|
} -sqlbody {
|
|
|
|
ATTACH 'test2.db' AS two;
|
|
|
|
CREATE TABLE two.t1(x);
|
|
|
|
ATTACH 'test3.db' AS three;
|
|
|
|
CREATE TABLE three.t1(x);
|
|
|
|
ATTACH 'test4.db' AS four;
|
|
|
|
CREATE TABLE four.t1(x);
|
|
|
|
}
|
|
|
|
|
2008-10-22 14:45:37 +04:00
|
|
|
do_malloc_test attachmalloc-2 -tclprep {
|
2011-08-02 04:57:34 +04:00
|
|
|
forcedelete test2.db
|
|
|
|
forcedelete test2.db-journal
|
2008-10-22 14:45:37 +04:00
|
|
|
sqlite3 db2 test2.db
|
|
|
|
db2 eval {
|
|
|
|
CREATE TABLE t1(a, b, c);
|
|
|
|
CREATE INDEX i1 ON t1(a, b);
|
|
|
|
}
|
|
|
|
db2 close
|
|
|
|
} -sqlbody {
|
|
|
|
CREATE TABLE t1(d, e, f);
|
|
|
|
ATTACH 'test2.db' AS db1;
|
|
|
|
}
|
|
|
|
|
2010-02-23 14:05:26 +03:00
|
|
|
set enable_shared_cache [sqlite3_enable_shared_cache 1]
|
2010-11-04 23:46:09 +03:00
|
|
|
sqlite3 dbaux test3.db
|
2010-02-23 14:05:26 +03:00
|
|
|
dbaux eval {SELECT * FROM sqlite_master}
|
|
|
|
do_malloc_test attachmalloc-3 -sqlbody {
|
|
|
|
SELECT * FROM sqlite_master;
|
2010-11-04 23:46:09 +03:00
|
|
|
ATTACH 'test3.db' AS three;
|
2010-02-23 14:05:26 +03:00
|
|
|
} -cleanup {
|
2010-11-04 23:46:09 +03:00
|
|
|
db eval { DETACH three }
|
2010-02-23 14:05:26 +03:00
|
|
|
}
|
|
|
|
dbaux close
|
|
|
|
sqlite3_enable_shared_cache $enable_shared_cache
|
|
|
|
|
|
|
|
|
2005-08-20 07:03:04 +04:00
|
|
|
finish_test
|