From e36d23a85ebff914d74bb541558c2b6082b78edb Mon Sep 17 00:00:00 2001 From: dan miller Date: Sat, 20 Oct 2007 02:49:29 +0000 Subject: sqlite source (unix build) added to libraries --- .../sqlite/unix/sqlite-3.5.1/test/altermalloc.test | 68 ++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 libraries/sqlite/unix/sqlite-3.5.1/test/altermalloc.test (limited to 'libraries/sqlite/unix/sqlite-3.5.1/test/altermalloc.test') diff --git a/libraries/sqlite/unix/sqlite-3.5.1/test/altermalloc.test b/libraries/sqlite/unix/sqlite-3.5.1/test/altermalloc.test new file mode 100644 index 0000000..8c6c8d8 --- /dev/null +++ b/libraries/sqlite/unix/sqlite-3.5.1/test/altermalloc.test @@ -0,0 +1,68 @@ +# 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 ALTER TABLE statement and +# specifically out-of-memory conditions within that command. +# +# $Id: altermalloc.test,v 1.7 2007/10/03 08:46:45 danielk1977 Exp $ +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +# If SQLITE_OMIT_ALTERTABLE is defined, omit this file. +ifcapable !altertable||!memdebug { + finish_test + return +} + +source $testdir/malloc_common.tcl + +do_malloc_test altermalloc-1 -tclprep { + db close +} -tclbody { + if {[catch {sqlite3 db test.db}]} { + error "out of memory" + } + sqlite3_extended_result_codes db 1 +} -sqlbody { + CREATE TABLE t1(a int); + ALTER TABLE t1 ADD COLUMN b INTEGER DEFAULT NULL; + ALTER TABLE t1 ADD COLUMN c TEXT DEFAULT 'default-text'; + ALTER TABLE t1 RENAME TO t2; +} + +# Test malloc() failure on an ALTER TABLE on a virtual table. +# +ifcapable vtab { + do_malloc_test altermalloc-vtab -tclprep { + sqlite3 db2 test.db + sqlite3_extended_result_codes db2 1 + register_echo_module [sqlite3_connection_pointer db2] + db2 eval { + CREATE TABLE t1(a, b VARCHAR, c INTEGER); + CREATE VIRTUAL TABLE t1echo USING echo(t1); + } + db2 close + + register_echo_module [sqlite3_connection_pointer db] + } -tclbody { + set rc [catch {db eval { ALTER TABLE t1echo RENAME TO t1_echo }} msg] + if {$msg eq "vtable constructor failed: t1echo"} { + set msg "out of memory" + } + if {$rc} { + error $msg + } + } +} + +finish_test -- cgit v1.1