1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-12-24 14:17:58 +03:00

Fixes for compilation/testing when the various OMIT macros are defined. (CVS 4423)

FossilOrigin-Name: c8405b15c074c94dab5e33272cf1471f458d11df
This commit is contained in:
danielk1977
2007-09-12 17:01:45 +00:00
parent a430ae8e54
commit 4152e677b8
47 changed files with 932 additions and 789 deletions

View File

@@ -13,7 +13,7 @@
# file format change that may be used in the future to implement
# "ALTER TABLE ... ADD COLUMN".
#
# $Id: alter2.test,v 1.8 2007/05/08 01:08:49 drh Exp $
# $Id: alter2.test,v 1.9 2007/09/12 17:01:45 danielk1977 Exp $
#
set testdir [file dirname $argv0]
@@ -68,11 +68,13 @@ proc get_file_format {{fname test.db}} {
#
proc alter_table {tbl sql {file_format 2}} {
sqlite3 dbat test.db
dbat eval {
set s [string map {' ''} $sql]
set t [string map {' ''} $tbl]
dbat eval [subst {
PRAGMA writable_schema = 1;
UPDATE sqlite_master SET sql = $sql WHERE name = $tbl AND type = 'table';
UPDATE sqlite_master SET sql = '$s' WHERE name = '$t' AND type = 'table';
PRAGMA writable_schema = 0;
}
}]
dbat close
set_file_format 2
}
@@ -259,18 +261,20 @@ do_test alter2-4.5 {
# resets the file format to 1.
#
set default_file_format [expr $SQLITE_DEFAULT_FILE_FORMAT==4 ? 4 : 1]
do_test alter2-5.1 {
set_file_format 2
get_file_format
} {2}
do_test alter2-5.2 {
execsql {
VACUUM;
}
} {}
do_test alter2-5.3 {
get_file_format
} $default_file_format
ifcapable vacuum {
do_test alter2-5.1 {
set_file_format 2
get_file_format
} {2}
do_test alter2-5.2 {
execsql {
VACUUM;
}
} {}
do_test alter2-5.3 {
get_file_format
} $default_file_format
}
#---------------------------------------------------------------------
# Test that when a database with file-format 2 is opened, new
@@ -397,38 +401,40 @@ ifcapable trigger {
#-----------------------------------------------------------------------
# Test creating an index on a column added with a default value.
#
do_test alter2-10.1 {
execsql {
CREATE TABLE t2(a);
INSERT INTO t2 VALUES('a');
INSERT INTO t2 VALUES('b');
INSERT INTO t2 VALUES('c');
INSERT INTO t2 VALUES('d');
}
alter_table t2 {CREATE TABLE t2(a, b DEFAULT X'ABCD', c DEFAULT NULL);} 3
catchsql {
SELECT * FROM sqlite_master;
}
execsql {
SELECT quote(a), quote(b), quote(c) FROM t2 LIMIT 1;
}
} {'a' X'ABCD' NULL}
do_test alter2-10.2 {
execsql {
CREATE INDEX i1 ON t2(b);
SELECT a FROM t2 WHERE b = X'ABCD';
}
} {a b c d}
do_test alter2-10.3 {
execsql {
DELETE FROM t2 WHERE a = 'c';
SELECT a FROM t2 WHERE b = X'ABCD';
}
} {a b d}
do_test alter2-10.4 {
execsql {
SELECT count(b) FROM t2 WHERE b = X'ABCD';
}
} {3}
ifcapable bloblit {
do_test alter2-10.1 {
execsql {
CREATE TABLE t2(a);
INSERT INTO t2 VALUES('a');
INSERT INTO t2 VALUES('b');
INSERT INTO t2 VALUES('c');
INSERT INTO t2 VALUES('d');
}
alter_table t2 {CREATE TABLE t2(a, b DEFAULT X'ABCD', c DEFAULT NULL);} 3
catchsql {
SELECT * FROM sqlite_master;
}
execsql {
SELECT quote(a), quote(b), quote(c) FROM t2 LIMIT 1;
}
} {'a' X'ABCD' NULL}
do_test alter2-10.2 {
execsql {
CREATE INDEX i1 ON t2(b);
SELECT a FROM t2 WHERE b = X'ABCD';
}
} {a b c d}
do_test alter2-10.3 {
execsql {
DELETE FROM t2 WHERE a = 'c';
SELECT a FROM t2 WHERE b = X'ABCD';
}
} {a b d}
do_test alter2-10.4 {
execsql {
SELECT count(b) FROM t2 WHERE b = X'ABCD';
}
} {3}
}
finish_test

View File

@@ -12,7 +12,7 @@
# focus of this script is testing the ATTACH and DETACH commands
# and related functionality.
#
# $Id: attach.test,v 1.45 2007/08/29 17:43:20 drh Exp $
# $Id: attach.test,v 1.46 2007/09/12 17:01:45 danielk1977 Exp $
#
set testdir [file dirname $argv0]
@@ -736,13 +736,15 @@ db close
file delete -force test2.db
file delete -force no-such-file
do_test attach-7.1 {
file delete -force test.db test.db-journal
sqlite3 db test.db
catchsql {
DETACH RAISE ( IGNORE ) IN ( SELECT "AAAAAA" . * ORDER BY
REGISTER LIMIT "AAAAAA" . "AAAAAA" OFFSET RAISE ( IGNORE ) NOT NULL )
}
} {1 {invalid name: "RAISE ( IGNORE ) IN ( SELECT "AAAAAA" . * ORDER BY
REGISTER LIMIT "AAAAAA" . "AAAAAA" OFFSET RAISE ( IGNORE ) NOT NULL )"}}
ifcapable subquery {
do_test attach-7.1 {
file delete -force test.db test.db-journal
sqlite3 db test.db
catchsql {
DETACH RAISE ( IGNORE ) IN ( SELECT "AAAAAA" . * ORDER BY
REGISTER LIMIT "AAAAAA" . "AAAAAA" OFFSET RAISE ( IGNORE ) NOT NULL )
}
} {1 {invalid name: "RAISE ( IGNORE ) IN ( SELECT "AAAAAA" . * ORDER BY
REGISTER LIMIT "AAAAAA" . "AAAAAA" OFFSET RAISE ( IGNORE ) NOT NULL )"}}
}
finish_test

View File

@@ -12,7 +12,7 @@
# file is a copy of "trans.test" modified to run under autovacuum mode.
# the point is to stress the autovacuum logic and try to get it to fail.
#
# $Id: avtrans.test,v 1.5 2007/08/12 20:07:59 drh Exp $
# $Id: avtrans.test,v 1.6 2007/09/12 17:01:45 danielk1977 Exp $
set testdir [file dirname $argv0]
@@ -909,7 +909,7 @@ for {set i 2} {$i<=$limit} {incr i} {
} [expr {$i%2==0}]
} else {
do_test avtrans-9.$i.5-$cnt {
expr {$sqlite_fullsync_count>0}
expr {$sqlite_fullsync_count==0}
} {1}
}
}

View File

@@ -13,7 +13,7 @@
# This file checks to make sure SQLite is able to gracefully
# handle malformed UTF-8.
#
# $Id: badutf.test,v 1.1 2007/05/15 18:35:21 drh Exp $
# $Id: badutf.test,v 1.2 2007/09/12 17:01:45 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -41,49 +41,53 @@ do_test badutf-1.7 {
sqlite3_exec db {SELECT hex('%ff') AS x}
} {0 {x FF}}
do_test badutf-1.10 {
sqlite3 db2 {}
db2 eval {PRAGMA encoding=UTF16be}
sqlite3_exec db2 {SELECT hex('%80') AS x}
} {0 {x 0080}}
do_test badutf-1.11 {
sqlite3_exec db2 {SELECT hex('%81') AS x}
} {0 {x 0081}}
do_test badutf-1.12 {
sqlite3_exec db2 {SELECT hex('%bf') AS x}
} {0 {x 00BF}}
do_test badutf-1.13 {
sqlite3_exec db2 {SELECT hex('%c0') AS x}
} {0 {x FFFD}}
do_test badutf-1.14 {
sqlite3_exec db2 {SELECT hex('%c1') AS x}
} {0 {x FFFD}}
do_test badutf-1.15 {
sqlite3_exec db2 {SELECT hex('%c0%bf') AS x}
} {0 {x FFFD}}
do_test badutf-1.16 {
sqlite3_exec db2 {SELECT hex('%c1%bf') AS x}
} {0 {x FFFD}}
do_test badutf-1.17 {
sqlite3_exec db2 {SELECT hex('%c3%bf') AS x}
} {0 {x 00FF}}
do_test badutf-1.18 {
sqlite3_exec db2 {SELECT hex('%e0') AS x}
} {0 {x FFFD}}
do_test badutf-1.19 {
sqlite3_exec db2 {SELECT hex('%f0') AS x}
} {0 {x FFFD}}
do_test badutf-1.20 {
sqlite3_exec db2 {SELECT hex('%ff') AS x}
} {0 {x FFFD}}
sqlite3 db2 {}
ifcapable utf16 {
do_test badutf-1.10 {
db2 eval {PRAGMA encoding=UTF16be}
sqlite3_exec db2 {SELECT hex('%80') AS x}
} {0 {x 0080}}
do_test badutf-1.11 {
sqlite3_exec db2 {SELECT hex('%81') AS x}
} {0 {x 0081}}
do_test badutf-1.12 {
sqlite3_exec db2 {SELECT hex('%bf') AS x}
} {0 {x 00BF}}
do_test badutf-1.13 {
sqlite3_exec db2 {SELECT hex('%c0') AS x}
} {0 {x FFFD}}
do_test badutf-1.14 {
sqlite3_exec db2 {SELECT hex('%c1') AS x}
} {0 {x FFFD}}
do_test badutf-1.15 {
sqlite3_exec db2 {SELECT hex('%c0%bf') AS x}
} {0 {x FFFD}}
do_test badutf-1.16 {
sqlite3_exec db2 {SELECT hex('%c1%bf') AS x}
} {0 {x FFFD}}
do_test badutf-1.17 {
sqlite3_exec db2 {SELECT hex('%c3%bf') AS x}
} {0 {x 00FF}}
do_test badutf-1.18 {
sqlite3_exec db2 {SELECT hex('%e0') AS x}
} {0 {x FFFD}}
do_test badutf-1.19 {
sqlite3_exec db2 {SELECT hex('%f0') AS x}
} {0 {x FFFD}}
do_test badutf-1.20 {
sqlite3_exec db2 {SELECT hex('%ff') AS x}
} {0 {x FFFD}}
}
do_test badutf-2.1 {
sqlite3_exec db {SELECT '%80'=CAST(x'80' AS text) AS x}
} {0 {x 1}}
do_test badutf-2.2 {
sqlite3_exec db {SELECT CAST('%80' AS blob)=x'80' AS x}
} {0 {x 1}}
ifcapable bloblit {
do_test badutf-2.1 {
sqlite3_exec db {SELECT '%80'=CAST(x'80' AS text) AS x}
} {0 {x 1}}
do_test badutf-2.2 {
sqlite3_exec db {SELECT CAST('%80' AS blob)=x'80' AS x}
} {0 {x 1}}
}
do_test badutf-3.1 {
sqlite3_exec db {SELECT length('%80') AS x}

View File

@@ -12,7 +12,7 @@
# focus of this file is testing that it is OK to create new tables
# and indices while creating existing tables and indices.
#
# $Id: createtab.test,v 1.2 2007/05/04 14:36:22 drh Exp $
# $Id: createtab.test,v 1.3 2007/09/12 17:01:45 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -45,9 +45,15 @@ for {set av 0} {$av<=$upperBound} {incr av} {
SELECT count(*) FROM t1;
}
} {4}
set isUtf16 0
ifcapable utf16 {
set isUtf16 [expr {[execsql {PRAGMA encoding}] != "UTF-8"}]
}
do_test createtab-$av.2 {
file size test.db
} [expr {1024*(4+($av!=0)+([execsql {PRAGMA encoding}]!="UTF-8")*2)}]
} [expr {1024*(4+($av!=0)+(${isUtf16}*2))}]
# Start reading the table
#

View File

@@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is testing built-in functions.
#
# $Id: func.test,v 1.68 2007/09/03 11:04:22 danielk1977 Exp $
# $Id: func.test,v 1.69 2007/09/12 17:01:45 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -324,9 +324,11 @@ do_test func-9.5 {
# generated by randomblob(). So this seems like a good place to test
# hex().
#
do_test func-9.10 {
execsql {SELECT hex(x'00112233445566778899aAbBcCdDeEfF')}
} {00112233445566778899AABBCCDDEEFF}
ifcapable bloblit {
do_test func-9.10 {
execsql {SELECT hex(x'00112233445566778899aAbBcCdDeEfF')}
} {00112233445566778899AABBCCDDEEFF}
}
set encoding [db one {PRAGMA encoding}]
if {$encoding=="UTF-16le"} {
do_test func-9.11-utf16le {
@@ -797,15 +799,17 @@ do_test func-21.8 {
}
} {0123456789012345678901234567890123456789012345678901234567890123456789}
do_test func-21.9 {
# Attempt to exploit a buffer-overflow that at one time existed
# in the REPLACE function.
set ::str "[string repeat A 29998]CC[string repeat A 35537]"
set ::rep [string repeat B 65536]
execsql {
SELECT LENGTH(REPLACE($::str, 'C', $::rep));
}
} [expr 29998 + 2*65536 + 35537]
ifcapable tclvar {
do_test func-21.9 {
# Attempt to exploit a buffer-overflow that at one time existed
# in the REPLACE function.
set ::str "[string repeat A 29998]CC[string repeat A 35537]"
set ::rep [string repeat B 65536]
execsql {
SELECT LENGTH(REPLACE($::str, 'C', $::rep));
}
} [expr 29998 + 2*65536 + 35537]
}
# Tests for the TRIM, LTRIM and RTRIM functions.
#

View File

@@ -9,13 +9,13 @@
#
#***********************************************************************
#
# $Id: incrblob_err.test,v 1.7 2007/08/30 11:48:32 danielk1977 Exp $
# $Id: incrblob_err.test,v 1.8 2007/09/12 17:01:45 danielk1977 Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
ifcapable {!incrblob || !memdebug} {
ifcapable {!incrblob || !memdebug || !tclvar} {
finish_test
return
}

View File

@@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is testing corner cases of the INSERT statement.
#
# $Id: insert3.test,v 1.6 2007/04/16 17:07:55 drh Exp $
# $Id: insert3.test,v 1.7 2007/09/12 17:01:45 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -156,13 +156,16 @@ do_test insert3-3.6 {
SELECT * FROM t5;
}
} {1 xyz 2 xyz}
do_test insert3-3.7 {
execsql {
CREATE TABLE t6(x,y DEFAULT 4.3, z DEFAULT x'6869');
INSERT INTO t6 DEFAULT VALUES;
SELECT * FROM t6;
}
} {{} 4.3 hi}
ifcapable bloblit {
do_test insert3-3.7 {
execsql {
CREATE TABLE t6(x,y DEFAULT 4.3, z DEFAULT x'6869');
INSERT INTO t6 DEFAULT VALUES;
SELECT * FROM t6;
}
} {{} 4.3 hi}
}
db close
finish_test

View File

@@ -11,11 +11,16 @@
# This file implements regression tests for SQLite library. The
# focus of this file is testing the INSERT transfer optimization.
#
# $Id: insert4.test,v 1.6 2007/09/03 17:30:07 danielk1977 Exp $
# $Id: insert4.test,v 1.7 2007/09/12 17:01:45 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
ifcapable !view||!subquery {
finish_test
return
}
# The sqlite3_xferopt_count variable is incremented whenever the
# insert transfer optimization applies.
#

View File

@@ -13,7 +13,7 @@
# IO traffic generated by SQLite (making sure SQLite is not writing out
# more database pages than it has to, stuff like that).
#
# $Id: io.test,v 1.9 2007/09/03 17:02:50 drh Exp $
# $Id: io.test,v 1.10 2007/09/12 17:01:45 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -361,40 +361,42 @@ do_test io-2.11.2 {
# Test cases io-3.* test the IOCAP_SEQUENTIAL optimization.
#
sqlite3_simulate_device -char sequential -sectorsize 0
do_test io-3.1 {
db close
file delete -force test.db test.db-journal
sqlite3 db test.db
file size test.db
} {0}
do_test io-3.2 {
execsql { CREATE TABLE abc(a, b) }
nSync
execsql {
PRAGMA cache_size = 10;
BEGIN;
INSERT INTO abc VALUES('hello', 'world');
INSERT INTO abc SELECT * FROM abc;
INSERT INTO abc SELECT * FROM abc;
INSERT INTO abc SELECT * FROM abc;
INSERT INTO abc SELECT * FROM abc;
INSERT INTO abc SELECT * FROM abc;
INSERT INTO abc SELECT * FROM abc;
INSERT INTO abc SELECT * FROM abc;
INSERT INTO abc SELECT * FROM abc;
INSERT INTO abc SELECT * FROM abc;
INSERT INTO abc SELECT * FROM abc;
INSERT INTO abc SELECT * FROM abc;
}
# File has grown - showing there was a cache-spill - but there
# have been no calls to fsync():
list [file size test.db] [nSync]
} {31744 0}
do_test io-3.3 {
# The COMMIT requires a single fsync() - to the database file.
execsql { COMMIT }
list [file size test.db] [nSync]
} {39936 1}
ifcapable pager_pragmas {
do_test io-3.1 {
db close
file delete -force test.db test.db-journal
sqlite3 db test.db
file size test.db
} {0}
do_test io-3.2 {
execsql { CREATE TABLE abc(a, b) }
nSync
execsql {
PRAGMA cache_size = 10;
BEGIN;
INSERT INTO abc VALUES('hello', 'world');
INSERT INTO abc SELECT * FROM abc;
INSERT INTO abc SELECT * FROM abc;
INSERT INTO abc SELECT * FROM abc;
INSERT INTO abc SELECT * FROM abc;
INSERT INTO abc SELECT * FROM abc;
INSERT INTO abc SELECT * FROM abc;
INSERT INTO abc SELECT * FROM abc;
INSERT INTO abc SELECT * FROM abc;
INSERT INTO abc SELECT * FROM abc;
INSERT INTO abc SELECT * FROM abc;
INSERT INTO abc SELECT * FROM abc;
}
# File has grown - showing there was a cache-spill - but there
# have been no calls to fsync():
list [file size test.db] [nSync]
} {31744 0}
do_test io-3.3 {
# The COMMIT requires a single fsync() - to the database file.
execsql { COMMIT }
list [file size test.db] [nSync]
} {39936 1}
}
#----------------------------------------------------------------------
# Test cases io-4.* test the IOCAP_SAFE_APPEND optimization.
@@ -468,13 +470,15 @@ do_test io-4.3.1 {
}
expr {[file size test.db]/1024}
} {43}
do_test io-4.3.2 {
execsql {
PRAGMA synchronous = full;
PRAGMA cache_size = 10;
PRAGMA synchronous;
}
} {2}
ifcapable pager_pragmas {
do_test io-4.3.2 {
execsql {
PRAGMA synchronous = full;
PRAGMA cache_size = 10;
PRAGMA synchronous;
}
} {2}
}
do_test io-4.3.3 {
execsql {
BEGIN;

View File

@@ -15,11 +15,16 @@
# The tests in this file use special facilities that are only
# available in the SQLite test fixture.
#
# $Id: ioerr2.test,v 1.5 2007/05/23 16:23:09 danielk1977 Exp $
# $Id: ioerr2.test,v 1.6 2007/09/12 17:01:45 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
ifcapable !integrityck {
finish_test
return
}
do_test ioerr2-1.1 {
execsql {
PRAGMA cache_size = 10;

View File

@@ -13,7 +13,7 @@
# in particular the optimizations that occur to help those operators
# run faster.
#
# $Id: like.test,v 1.6 2007/06/11 12:56:15 drh Exp $
# $Id: like.test,v 1.7 2007/09/12 17:01:45 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -389,7 +389,8 @@ do_test like-5.8 {
#
do_test like-6.1 {
foreach x { 'abc 'bcd 'def 'ax } {
db eval {INSERT INTO t2 VALUES($x)}
set x2 '[string map {' ''} $x]'
db eval "INSERT INTO t2 VALUES($x2)"
}
execsql {
SELECT * FROM t2 WHERE x LIKE '''a%'

View File

@@ -16,7 +16,7 @@
# to see what happens in the library if a malloc were to really fail
# due to an out-of-memory situation.
#
# $Id: malloc.test,v 1.47 2007/09/04 01:25:49 drh Exp $
# $Id: malloc.test,v 1.48 2007/09/12 17:01:45 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -31,26 +31,28 @@ ifcapable !memdebug {
source $testdir/malloc_common.tcl
do_malloc_test 1 -tclprep {
db close
} -tclbody {
if {[catch {sqlite3 db test.db}]} {
error "out of memory"
}
} -sqlbody {
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(
a int, b float, c double, d text, e varchar(20),
primary key(a,b,c)
);
CREATE INDEX i1 ON t1(a,b);
INSERT INTO t1 VALUES(1,2.3,4.5,'hi',x'746865726500');
INSERT INTO t1 VALUES(6,7.0,0.8,'hello','out yonder');
SELECT * FROM t1;
SELECT avg(b) FROM t1 GROUP BY a HAVING b>20.0;
DELETE FROM t1 WHERE a IN (SELECT min(a) FROM t1);
SELECT count(*) FROM t1;
}
ifcapable bloblit&&subquery {
do_malloc_test 1 -tclprep {
db close
} -tclbody {
if {[catch {sqlite3 db test.db}]} {
error "out of memory"
}
} -sqlbody {
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(
a int, b float, c double, d text, e varchar(20),
primary key(a,b,c)
);
CREATE INDEX i1 ON t1(a,b);
INSERT INTO t1 VALUES(1,2.3,4.5,'hi',x'746865726500');
INSERT INTO t1 VALUES(6,7.0,0.8,'hello','out yonder');
SELECT * FROM t1;
SELECT avg(b) FROM t1 GROUP BY a HAVING b>20.0;
DELETE FROM t1 WHERE a IN (SELECT min(a) FROM t1);
SELECT count(*) FROM t1;
}
}
# Ensure that no file descriptors were leaked.
do_test malloc-1.X {
@@ -58,25 +60,27 @@ do_test malloc-1.X {
set sqlite_open_file_count
} {0}
do_malloc_test 2 -sqlbody {
CREATE TABLE t1(a int, b int default 'abc', c int default 1);
CREATE INDEX i1 ON t1(a,b);
INSERT INTO t1 VALUES(1,1,'99 abcdefghijklmnopqrstuvwxyz');
INSERT INTO t1 VALUES(2,4,'98 abcdefghijklmnopqrstuvwxyz');
INSERT INTO t1 VALUES(3,9,'97 abcdefghijklmnopqrstuvwxyz');
INSERT INTO t1 VALUES(4,16,'96 abcdefghijklmnopqrstuvwxyz');
INSERT INTO t1 VALUES(5,25,'95 abcdefghijklmnopqrstuvwxyz');
INSERT INTO t1 VALUES(6,36,'94 abcdefghijklmnopqrstuvwxyz');
SELECT 'stuff', count(*) as 'other stuff', max(a+10) FROM t1;
UPDATE t1 SET b=b||b||b||b;
UPDATE t1 SET b=a WHERE a in (10,12,22);
INSERT INTO t1(c,b,a) VALUES(20,10,5);
INSERT INTO t1 SELECT * FROM t1
WHERE a IN (SELECT a FROM t1 WHERE a<10);
DELETE FROM t1 WHERE a>=10;
DROP INDEX i1;
DELETE FROM t1;
}
ifcapable subquery {
do_malloc_test 2 -sqlbody {
CREATE TABLE t1(a int, b int default 'abc', c int default 1);
CREATE INDEX i1 ON t1(a,b);
INSERT INTO t1 VALUES(1,1,'99 abcdefghijklmnopqrstuvwxyz');
INSERT INTO t1 VALUES(2,4,'98 abcdefghijklmnopqrstuvwxyz');
INSERT INTO t1 VALUES(3,9,'97 abcdefghijklmnopqrstuvwxyz');
INSERT INTO t1 VALUES(4,16,'96 abcdefghijklmnopqrstuvwxyz');
INSERT INTO t1 VALUES(5,25,'95 abcdefghijklmnopqrstuvwxyz');
INSERT INTO t1 VALUES(6,36,'94 abcdefghijklmnopqrstuvwxyz');
SELECT 'stuff', count(*) as 'other stuff', max(a+10) FROM t1;
UPDATE t1 SET b=b||b||b||b;
UPDATE t1 SET b=a WHERE a in (10,12,22);
INSERT INTO t1(c,b,a) VALUES(20,10,5);
INSERT INTO t1 SELECT * FROM t1
WHERE a IN (SELECT a FROM t1 WHERE a<10);
DELETE FROM t1 WHERE a>=10;
DROP INDEX i1;
DELETE FROM t1;
}
}
# Ensure that no file descriptors were leaked.
do_test malloc-2.X {
@@ -108,23 +112,25 @@ do_test malloc-3.X {
set sqlite_open_file_count
} {0}
do_malloc_test 4 -sqlbody {
BEGIN TRANSACTION;
CREATE TABLE t1(a int, b int, c int);
CREATE INDEX i1 ON t1(a,b);
INSERT INTO t1 VALUES(1,1,99);
INSERT INTO t1 VALUES(2,4,98);
INSERT INTO t1 VALUES(3,9,97);
INSERT INTO t1 VALUES(4,16,96);
INSERT INTO t1 VALUES(5,25,95);
INSERT INTO t1 VALUES(6,36,94);
UPDATE t1 SET b=a WHERE a in (10,12,22);
INSERT INTO t1 SELECT * FROM t1
WHERE a IN (SELECT a FROM t1 WHERE a<10);
DROP INDEX i1;
DELETE FROM t1;
COMMIT;
}
ifcapable subquery {
do_malloc_test 4 -sqlbody {
BEGIN TRANSACTION;
CREATE TABLE t1(a int, b int, c int);
CREATE INDEX i1 ON t1(a,b);
INSERT INTO t1 VALUES(1,1,99);
INSERT INTO t1 VALUES(2,4,98);
INSERT INTO t1 VALUES(3,9,97);
INSERT INTO t1 VALUES(4,16,96);
INSERT INTO t1 VALUES(5,25,95);
INSERT INTO t1 VALUES(6,36,94);
UPDATE t1 SET b=a WHERE a in (10,12,22);
INSERT INTO t1 SELECT * FROM t1
WHERE a IN (SELECT a FROM t1 WHERE a<10);
DROP INDEX i1;
DELETE FROM t1;
COMMIT;
}
}
# Ensure that no file descriptors were leaked.
do_test malloc-4.X {
@@ -132,21 +138,23 @@ do_test malloc-4.X {
set sqlite_open_file_count
} {0}
do_malloc_test 5 -sqlbody {
BEGIN TRANSACTION;
CREATE TABLE t1(a,b);
CREATE TABLE t2(x,y);
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
INSERT INTO t2(x,y) VALUES(new.rowid,1);
INSERT INTO t2(x,y) SELECT * FROM t2;
INSERT INTO t2 SELECT * FROM t2;
UPDATE t2 SET y=y+1 WHERE x=new.rowid;
SELECT 123;
DELETE FROM t2 WHERE x=new.rowid;
END;
INSERT INTO t1(a,b) VALUES(2,3);
COMMIT;
}
ifcapable trigger {
do_malloc_test 5 -sqlbody {
BEGIN TRANSACTION;
CREATE TABLE t1(a,b);
CREATE TABLE t2(x,y);
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
INSERT INTO t2(x,y) VALUES(new.rowid,1);
INSERT INTO t2(x,y) SELECT * FROM t2;
INSERT INTO t2 SELECT * FROM t2;
UPDATE t2 SET y=y+1 WHERE x=new.rowid;
SELECT 123;
DELETE FROM t2 WHERE x=new.rowid;
END;
INSERT INTO t1(a,b) VALUES(2,3);
COMMIT;
}
}
# Ensure that no file descriptors were leaked.
do_test malloc-5.X {
@@ -154,25 +162,27 @@ do_test malloc-5.X {
set sqlite_open_file_count
} {0}
do_malloc_test 6 -sqlprep {
BEGIN TRANSACTION;
CREATE TABLE t1(a);
INSERT INTO t1 VALUES(1);
INSERT INTO t1 SELECT a*2 FROM t1;
INSERT INTO t1 SELECT a*2 FROM t1;
INSERT INTO t1 SELECT a*2 FROM t1;
INSERT INTO t1 SELECT a*2 FROM t1;
INSERT INTO t1 SELECT a*2 FROM t1;
INSERT INTO t1 SELECT a*2 FROM t1;
INSERT INTO t1 SELECT a*2 FROM t1;
INSERT INTO t1 SELECT a*2 FROM t1;
INSERT INTO t1 SELECT a*2 FROM t1;
INSERT INTO t1 SELECT a*2 FROM t1;
DELETE FROM t1 where rowid%5 = 0;
COMMIT;
} -sqlbody {
VACUUM;
}
ifcapable vacuum {
do_malloc_test 6 -sqlprep {
BEGIN TRANSACTION;
CREATE TABLE t1(a);
INSERT INTO t1 VALUES(1);
INSERT INTO t1 SELECT a*2 FROM t1;
INSERT INTO t1 SELECT a*2 FROM t1;
INSERT INTO t1 SELECT a*2 FROM t1;
INSERT INTO t1 SELECT a*2 FROM t1;
INSERT INTO t1 SELECT a*2 FROM t1;
INSERT INTO t1 SELECT a*2 FROM t1;
INSERT INTO t1 SELECT a*2 FROM t1;
INSERT INTO t1 SELECT a*2 FROM t1;
INSERT INTO t1 SELECT a*2 FROM t1;
INSERT INTO t1 SELECT a*2 FROM t1;
DELETE FROM t1 where rowid%5 = 0;
COMMIT;
} -sqlbody {
VACUUM;
}
}
do_malloc_test 7 -sqlprep {
CREATE TABLE t1(a, b);
@@ -198,7 +208,7 @@ do_malloc_test 7 -sqlprep {
#
# These tests only run if UTF-16 support is compiled in.
#
if {$::sqlite_options(utf16)} {
ifcapable utf16 {
set ::STMT {}
do_malloc_test 8 -tclprep {
set sql "SELECT '[string repeat abc 20]', '[string repeat def 20]', ?"
@@ -334,20 +344,22 @@ proc string_compare {a b} {
# Test for malloc() failures in sqlite3_create_collation() and
# sqlite3_create_collation16().
#
do_malloc_test 15 -start 4 -tclbody {
db collate string_compare string_compare
if {[catch {add_test_collate db 1 1 1} msg]} {
if {$msg=="SQLITE_NOMEM"} {set msg "out of memory"}
error $msg
}
db complete {SELECT "hello """||'world"' [microsoft], * FROM anicetable;}
db complete {-- Useful comment}
execsql {
CREATE TABLE t1(a, b COLLATE string_compare);
INSERT INTO t1 VALUES(10, 'string');
INSERT INTO t1 VALUES(10, 'string2');
ifcapable utf16 {
do_malloc_test 15 -start 4 -tclbody {
db collate string_compare string_compare
if {[catch {add_test_collate db 1 1 1} msg]} {
if {$msg=="SQLITE_NOMEM"} {set msg "out of memory"}
error $msg
}
db complete {SELECT "hello """||'world"' [microsoft], * FROM anicetable;}
db complete {-- Useful comment}
execsql {
CREATE TABLE t1(a, b COLLATE string_compare);
INSERT INTO t1 VALUES(10, 'string');
INSERT INTO t1 VALUES(10, 'string2');
}
}
}
@@ -364,58 +376,62 @@ do_malloc_test 16 -tclbody {
# Test handling of malloc() failures in sqlite3_open16().
#
do_malloc_test 17 -tclbody {
set DB2 0
set STMT 0
# open database using sqlite3_open16()
set filename [encoding convertto unicode test.db]
append filename "\x00\x00"
set DB2 [sqlite3_open16 $filename -unused]
if {0==$DB2} {
error "out of memory"
}
# Prepare statement
set rc [catch {sqlite3_prepare $DB2 {SELECT * FROM sqlite_master} -1 X} msg]
if {$rc} {
error [string range $msg 4 end]
}
set STMT $msg
# Finalize statement
set rc [sqlite3_finalize $STMT]
if {$rc!="SQLITE_OK"} {
error [sqlite3_errmsg $DB2]
}
set STMT 0
# Close database
set rc [sqlite3_close $DB2]
if {$rc!="SQLITE_OK"} {
error [sqlite3_errmsg $DB2]
}
set DB2 0
} -cleanup {
if {$STMT!="0"} {
sqlite3_finalize $STMT
}
if {$DB2!="0"} {
ifcapable utf16 {
do_malloc_test 17 -tclbody {
set DB2 0
set STMT 0
# open database using sqlite3_open16()
set filename [encoding convertto unicode test.db]
append filename "\x00\x00"
set DB2 [sqlite3_open16 $filename -unused]
if {0==$DB2} {
error "out of memory"
}
# Prepare statement
set rc [catch {sqlite3_prepare $DB2 {SELECT * FROM sqlite_master} -1 X} msg]
if {$rc} {
error [string range $msg 4 end]
}
set STMT $msg
# Finalize statement
set rc [sqlite3_finalize $STMT]
if {$rc!="SQLITE_OK"} {
error [sqlite3_errmsg $DB2]
}
set STMT 0
# Close database
set rc [sqlite3_close $DB2]
if {$rc!="SQLITE_OK"} {
error [sqlite3_errmsg $DB2]
}
set DB2 0
} -cleanup {
if {$STMT!="0"} {
sqlite3_finalize $STMT
}
if {$DB2!="0"} {
set rc [sqlite3_close $DB2]
}
}
}
# Test handling of malloc() failures in sqlite3_errmsg16().
#
do_malloc_test 18 -tclbody {
catch {
db eval "SELECT [string repeat longcolumnname 10] FROM sqlite_master"
} msg
if {$msg=="out of memory"} {error $msg}
set utf16 [sqlite3_errmsg16 [sqlite3_connection_pointer db]]
binary scan $utf16 c* bytes
if {[llength $bytes]==0} {
error "out of memory"
ifcapable utf16 {
do_malloc_test 18 -tclbody {
catch {
db eval "SELECT [string repeat longcolumnname 10] FROM sqlite_master"
} msg
if {$msg=="out of memory"} {error $msg}
set utf16 [sqlite3_errmsg16 [sqlite3_connection_pointer db]]
binary scan $utf16 c* bytes
if {[llength $bytes]==0} {
error "out of memory"
}
}
}
@@ -470,9 +486,11 @@ do_malloc_test 20 -tclprep {
# Test malloc failure whilst installing a foreign key.
#
do_malloc_test 21 -sqlbody {
CREATE TABLE abc(a, b, c, FOREIGN KEY(a) REFERENCES abc(b))
}
ifcapable foreignkey {
do_malloc_test 21 -sqlbody {
CREATE TABLE abc(a, b, c, FOREIGN KEY(a) REFERENCES abc(b))
}
}
# Test malloc failure in an sqlite3_prepare_v2() call.
#

View File

@@ -11,7 +11,7 @@
# This file contains additional out-of-memory checks (see malloc.tcl)
# added to expose a bug in out-of-memory handling for sqlite3_value_text()
#
# $Id: malloc8.test,v 1.5 2007/09/03 16:12:10 drh Exp $
# $Id: malloc8.test,v 1.6 2007/09/12 17:01:45 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -59,13 +59,15 @@ do_malloc_test malloc8-3 -sqlprep {
} -sqlbody {
SELECT length(a), substr(a, 4, 4) FROM t1;
}
do_malloc_test malloc8-4 -sqlprep {
PRAGMA encoding='UTF-16';
CREATE TABLE t1(a);
INSERT INTO t1
VALUES('0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ');
} -sqlbody {
SELECT julianday(a,a) FROM t1;
ifcapable datetime {
do_malloc_test malloc8-4 -sqlprep {
PRAGMA encoding='UTF-16';
CREATE TABLE t1(a);
INSERT INTO t1
VALUES('0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ');
} -sqlbody {
SELECT julianday(a,a) FROM t1;
}
}
do_malloc_test malloc8-5 -sqlprep {
PRAGMA encoding='UTF-16';

View File

@@ -10,7 +10,7 @@
#***********************************************************************
# This file contains additional out-of-memory checks (see malloc.tcl).
#
# $Id: mallocA.test,v 1.5 2007/09/03 16:12:10 drh Exp $
# $Id: mallocA.test,v 1.6 2007/09/12 17:01:45 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -44,17 +44,19 @@ file copy test.db test.db.bu
do_malloc_test mallocA-1 -testdb test.db.bu -sqlbody {
ANALYZE
}
do_malloc_test mallocA-2 -testdb test.db.bu -sqlbody {
REINDEX;
}
do_malloc_test mallocA-3 -testdb test.db.bu -sqlbody {
REINDEX t1;
}
do_malloc_test mallocA-4 -testdb test.db.bu -sqlbody {
REINDEX main.t1;
}
do_malloc_test mallocA-5 -testdb test.db.bu -sqlbody {
REINDEX nocase;
ifcapable reindex {
do_malloc_test mallocA-2 -testdb test.db.bu -sqlbody {
REINDEX;
}
do_malloc_test mallocA-3 -testdb test.db.bu -sqlbody {
REINDEX t1;
}
do_malloc_test mallocA-4 -testdb test.db.bu -sqlbody {
REINDEX main.t1;
}
do_malloc_test mallocA-5 -testdb test.db.bu -sqlbody {
REINDEX nocase;
}
}
# Ensure that no file descriptors were leaked.

View File

@@ -13,7 +13,7 @@
# that they have little in common.
#
#
# $Id: mallocB.test,v 1.5 2007/09/03 16:12:10 drh Exp $
# $Id: mallocB.test,v 1.6 2007/09/12 17:01:45 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -32,7 +32,9 @@ do_malloc_test mallocB-1 -sqlbody {SELECT - 456}
do_malloc_test mallocB-2 -sqlbody {SELECT - 456.1}
do_malloc_test mallocB-3 -sqlbody {SELECT random()}
do_malloc_test mallocB-4 -sqlbody {SELECT zeroblob(1000)}
do_malloc_test mallocB-5 -sqlbody {SELECT * FROM (SELECT 1) GROUP BY 1;}
ifcapable subquery {
do_malloc_test mallocB-5 -sqlbody {SELECT * FROM (SELECT 1) GROUP BY 1;}
}
# The following test checks that there are no resource leaks following a
# malloc() failure in sqlite3_set_auxdata().

View File

@@ -12,14 +12,14 @@
# This file tests aspects of the malloc failure while parsing
# CREATE TABLE statements in auto_vacuum mode.
#
# $Id: mallocC.test,v 1.5 2007/09/03 16:12:10 drh Exp $
# $Id: mallocC.test,v 1.6 2007/09/12 17:01:45 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# Only run these tests if memory debugging is turned on.
#
ifcapable !memdebug {
ifcapable !memdebug||!compound {
puts "Skipping mallocC tests: not compiled with -DSQLITE_MEMDEBUG..."
finish_test
return

View File

@@ -13,7 +13,7 @@
# This file implements tests for miscellanous features that were
# left out of other test files.
#
# $Id: misc2.test,v 1.27 2007/04/06 01:03:34 drh Exp $
# $Id: misc2.test,v 1.28 2007/09/12 17:01:45 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -157,201 +157,203 @@ do_test misc2-6.1 {
# 2006-08-16: This has changed. It is now permitted to update
# the table being SELECTed from within the callback of the query.
#
do_test misc2-7.1 {
db close
file delete -force test.db
sqlite3 db test.db
execsql {
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(1);
INSERT INTO t1 VALUES(2);
INSERT INTO t1 VALUES(3);
SELECT * FROM t1;
}
} {1 2 3}
do_test misc2-7.2 {
set rc [catch {
db eval {SELECT rowid FROM t1} {} {
db eval "DELETE FROM t1 WHERE rowid=$rowid"
ifcapable tclvar {
do_test misc2-7.1 {
db close
file delete -force test.db
sqlite3 db test.db
execsql {
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(1);
INSERT INTO t1 VALUES(2);
INSERT INTO t1 VALUES(3);
SELECT * FROM t1;
}
} msg]
lappend rc $msg
} {0 {}}
do_test misc2-7.3 {
execsql {SELECT * FROM t1}
} {}
do_test misc2-7.4 {
execsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(1);
INSERT INTO t1 VALUES(2);
INSERT INTO t1 VALUES(3);
INSERT INTO t1 VALUES(4);
}
db eval {SELECT rowid, x FROM t1} {
if {$x & 1} {
db eval {DELETE FROM t1 WHERE rowid=$rowid}
} {1 2 3}
do_test misc2-7.2 {
set rc [catch {
db eval {SELECT rowid FROM t1} {} {
db eval "DELETE FROM t1 WHERE rowid=$rowid"
}
} msg]
lappend rc $msg
} {0 {}}
do_test misc2-7.3 {
execsql {SELECT * FROM t1}
} {}
do_test misc2-7.4 {
execsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(1);
INSERT INTO t1 VALUES(2);
INSERT INTO t1 VALUES(3);
INSERT INTO t1 VALUES(4);
}
}
execsql {SELECT * FROM t1}
} {2 4}
do_test misc2-7.5 {
execsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(1);
INSERT INTO t1 VALUES(2);
INSERT INTO t1 VALUES(3);
INSERT INTO t1 VALUES(4);
}
db eval {SELECT rowid, x FROM t1} {
if {$x & 1} {
db eval {DELETE FROM t1 WHERE rowid=$rowid+1}
db eval {SELECT rowid, x FROM t1} {
if {$x & 1} {
db eval {DELETE FROM t1 WHERE rowid=$rowid}
}
}
}
execsql {SELECT * FROM t1}
} {1 3}
do_test misc2-7.6 {
execsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(1);
INSERT INTO t1 VALUES(2);
INSERT INTO t1 VALUES(3);
INSERT INTO t1 VALUES(4);
}
db eval {SELECT rowid, x FROM t1} {
if {$x & 1} {
db eval {DELETE FROM t1}
execsql {SELECT * FROM t1}
} {2 4}
do_test misc2-7.5 {
execsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(1);
INSERT INTO t1 VALUES(2);
INSERT INTO t1 VALUES(3);
INSERT INTO t1 VALUES(4);
}
}
execsql {SELECT * FROM t1}
} {}
do_test misc2-7.7 {
execsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(1);
INSERT INTO t1 VALUES(2);
INSERT INTO t1 VALUES(3);
INSERT INTO t1 VALUES(4);
}
db eval {SELECT rowid, x FROM t1} {
if {$x & 1} {
db eval {UPDATE t1 SET x=x+100 WHERE rowid=$rowid}
db eval {SELECT rowid, x FROM t1} {
if {$x & 1} {
db eval {DELETE FROM t1 WHERE rowid=$rowid+1}
}
}
}
execsql {SELECT * FROM t1}
} {101 2 103 4}
do_test misc2-7.8 {
execsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(1);
}
db eval {SELECT rowid, x FROM t1} {
if {$x<10} {
db eval {INSERT INTO t1 VALUES($x+1)}
execsql {SELECT * FROM t1}
} {1 3}
do_test misc2-7.6 {
execsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(1);
INSERT INTO t1 VALUES(2);
INSERT INTO t1 VALUES(3);
INSERT INTO t1 VALUES(4);
}
}
execsql {SELECT * FROM t1}
} {1 2 3 4 5 6 7 8 9 10}
# Repeat the tests 7.1 through 7.8 about but this time do the SELECTs
# in reverse order so that we exercise the sqlite3BtreePrev() routine
# instead of sqlite3BtreeNext()
#
do_test misc2-7.11 {
db close
file delete -force test.db
sqlite3 db test.db
execsql {
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(1);
INSERT INTO t1 VALUES(2);
INSERT INTO t1 VALUES(3);
SELECT * FROM t1;
}
} {1 2 3}
do_test misc2-7.12 {
set rc [catch {
db eval {SELECT rowid FROM t1 ORDER BY rowid DESC} {} {
db eval "DELETE FROM t1 WHERE rowid=$rowid"
db eval {SELECT rowid, x FROM t1} {
if {$x & 1} {
db eval {DELETE FROM t1}
}
}
} msg]
lappend rc $msg
} {0 {}}
do_test misc2-7.13 {
execsql {SELECT * FROM t1}
} {}
do_test misc2-7.14 {
execsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(1);
INSERT INTO t1 VALUES(2);
INSERT INTO t1 VALUES(3);
INSERT INTO t1 VALUES(4);
}
db eval {SELECT rowid, x FROM t1 ORDER BY rowid DESC} {
if {$x & 1} {
db eval {DELETE FROM t1 WHERE rowid=$rowid}
execsql {SELECT * FROM t1}
} {}
do_test misc2-7.7 {
execsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(1);
INSERT INTO t1 VALUES(2);
INSERT INTO t1 VALUES(3);
INSERT INTO t1 VALUES(4);
}
}
execsql {SELECT * FROM t1}
} {2 4}
do_test misc2-7.15 {
execsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(1);
INSERT INTO t1 VALUES(2);
INSERT INTO t1 VALUES(3);
INSERT INTO t1 VALUES(4);
}
db eval {SELECT rowid, x FROM t1} {
if {$x & 1} {
db eval {DELETE FROM t1 WHERE rowid=$rowid+1}
db eval {SELECT rowid, x FROM t1} {
if {$x & 1} {
db eval {UPDATE t1 SET x=x+100 WHERE rowid=$rowid}
}
}
}
execsql {SELECT * FROM t1}
} {1 3}
do_test misc2-7.16 {
execsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(1);
INSERT INTO t1 VALUES(2);
INSERT INTO t1 VALUES(3);
INSERT INTO t1 VALUES(4);
}
db eval {SELECT rowid, x FROM t1 ORDER BY rowid DESC} {
if {$x & 1} {
db eval {DELETE FROM t1}
execsql {SELECT * FROM t1}
} {101 2 103 4}
do_test misc2-7.8 {
execsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(1);
}
}
execsql {SELECT * FROM t1}
} {}
do_test misc2-7.17 {
execsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(1);
INSERT INTO t1 VALUES(2);
INSERT INTO t1 VALUES(3);
INSERT INTO t1 VALUES(4);
}
db eval {SELECT rowid, x FROM t1 ORDER BY rowid DESC} {
if {$x & 1} {
db eval {UPDATE t1 SET x=x+100 WHERE rowid=$rowid}
db eval {SELECT rowid, x FROM t1} {
if {$x<10} {
db eval {INSERT INTO t1 VALUES($x+1)}
}
}
}
execsql {SELECT * FROM t1}
} {101 2 103 4}
do_test misc2-7.18 {
execsql {
DELETE FROM t1;
INSERT INTO t1(rowid,x) VALUES(10,10);
}
db eval {SELECT rowid, x FROM t1 ORDER BY rowid DESC} {
if {$x>1} {
db eval {INSERT INTO t1(rowid,x) VALUES($x-1,$x-1)}
execsql {SELECT * FROM t1}
} {1 2 3 4 5 6 7 8 9 10}
# Repeat the tests 7.1 through 7.8 about but this time do the SELECTs
# in reverse order so that we exercise the sqlite3BtreePrev() routine
# instead of sqlite3BtreeNext()
#
do_test misc2-7.11 {
db close
file delete -force test.db
sqlite3 db test.db
execsql {
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(1);
INSERT INTO t1 VALUES(2);
INSERT INTO t1 VALUES(3);
SELECT * FROM t1;
}
}
execsql {SELECT * FROM t1}
} {1 2 3 4 5 6 7 8 9 10}
} {1 2 3}
do_test misc2-7.12 {
set rc [catch {
db eval {SELECT rowid FROM t1 ORDER BY rowid DESC} {} {
db eval "DELETE FROM t1 WHERE rowid=$rowid"
}
} msg]
lappend rc $msg
} {0 {}}
do_test misc2-7.13 {
execsql {SELECT * FROM t1}
} {}
do_test misc2-7.14 {
execsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(1);
INSERT INTO t1 VALUES(2);
INSERT INTO t1 VALUES(3);
INSERT INTO t1 VALUES(4);
}
db eval {SELECT rowid, x FROM t1 ORDER BY rowid DESC} {
if {$x & 1} {
db eval {DELETE FROM t1 WHERE rowid=$rowid}
}
}
execsql {SELECT * FROM t1}
} {2 4}
do_test misc2-7.15 {
execsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(1);
INSERT INTO t1 VALUES(2);
INSERT INTO t1 VALUES(3);
INSERT INTO t1 VALUES(4);
}
db eval {SELECT rowid, x FROM t1} {
if {$x & 1} {
db eval {DELETE FROM t1 WHERE rowid=$rowid+1}
}
}
execsql {SELECT * FROM t1}
} {1 3}
do_test misc2-7.16 {
execsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(1);
INSERT INTO t1 VALUES(2);
INSERT INTO t1 VALUES(3);
INSERT INTO t1 VALUES(4);
}
db eval {SELECT rowid, x FROM t1 ORDER BY rowid DESC} {
if {$x & 1} {
db eval {DELETE FROM t1}
}
}
execsql {SELECT * FROM t1}
} {}
do_test misc2-7.17 {
execsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(1);
INSERT INTO t1 VALUES(2);
INSERT INTO t1 VALUES(3);
INSERT INTO t1 VALUES(4);
}
db eval {SELECT rowid, x FROM t1 ORDER BY rowid DESC} {
if {$x & 1} {
db eval {UPDATE t1 SET x=x+100 WHERE rowid=$rowid}
}
}
execsql {SELECT * FROM t1}
} {101 2 103 4}
do_test misc2-7.18 {
execsql {
DELETE FROM t1;
INSERT INTO t1(rowid,x) VALUES(10,10);
}
db eval {SELECT rowid, x FROM t1 ORDER BY rowid DESC} {
if {$x>1} {
db eval {INSERT INTO t1(rowid,x) VALUES($x-1,$x-1)}
}
}
execsql {SELECT * FROM t1}
} {1 2 3 4 5 6 7 8 9 10}
}
db close
file delete -force test.db

View File

@@ -13,7 +13,7 @@
# This file implements tests for miscellanous features that were
# left out of other test files.
#
# $Id: misc5.test,v 1.16 2007/01/03 23:37:29 drh Exp $
# $Id: misc5.test,v 1.17 2007/09/12 17:01:45 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -582,22 +582,24 @@ sqlite3 db test.db
# Ticket #1911
#
do_test misc5-9.1 {
execsql {
SELECT name, type FROM sqlite_master WHERE name IS NULL
UNION
SELECT type, name FROM sqlite_master WHERE type IS NULL
ORDER BY 1, 2, 1, 2, 1, 2
}
} {}
do_test misc5-9.2 {
execsql {
SELECT name, type FROM sqlite_master WHERE name IS NULL
UNION
SELECT type, name FROM sqlite_master WHERE type IS NULL
ORDER BY 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2
}
} {}
ifcapable compound {
do_test misc5-9.1 {
execsql {
SELECT name, type FROM sqlite_master WHERE name IS NULL
UNION
SELECT type, name FROM sqlite_master WHERE type IS NULL
ORDER BY 1, 2, 1, 2, 1, 2
}
} {}
do_test misc5-9.2 {
execsql {
SELECT name, type FROM sqlite_master WHERE name IS NULL
UNION
SELECT type, name FROM sqlite_master WHERE type IS NULL
ORDER BY 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2
}
} {}
}
# Ticket #1912. Make the tokenizer require a space after a numeric
# literal.

View File

@@ -12,7 +12,7 @@
#
# This file implements tests for the PRAGMA command.
#
# $Id: pragma2.test,v 1.2 2007/06/27 10:20:01 drh Exp $
# $Id: pragma2.test,v 1.3 2007/09/12 17:01:45 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -24,7 +24,7 @@ source $testdir/tester.tcl
# pragma2-3.*: Test trying to write to the freelist_count is a no-op.
#
ifcapable !pragma {
ifcapable !pragma||!schema_pragmas {
finish_test
return
}

View File

@@ -21,11 +21,16 @@
# sqlite3_value_bytes()
# sqlite3_value_bytes16()
#
# $Id: ptrchng.test,v 1.1 2007/04/27 17:16:22 drh Exp $
# $Id: ptrchng.test,v 1.2 2007/09/12 17:01:45 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
ifcapable !bloblit {
finish_test
return
}
# Register the "pointer_change" SQL function.
#
sqlite3_create_function db

View File

@@ -13,7 +13,7 @@
# caused by an ON CONFLICT ROLLBACK clause aborts any other pending
# statements.
#
# $Id: rollback.test,v 1.5 2007/08/30 02:26:54 drh Exp $
# $Id: rollback.test,v 1.6 2007/09/12 17:01:45 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -58,17 +58,17 @@ ifcapable conflict {
# Try to continue with the SELECT statement
#
btree_breakpoint
do_test rollback-1.5 {
sqlite3_step $STMT
} {SQLITE_ERROR}
# Restart the SELECT statement
#
do_test rollback-1.6 { sqlite3_reset $STMT } {SQLITE_ABORT}
} else {
do_test rollback-1.6 { sqlite3_reset $STMT } {SQLITE_OK}
}
# Restart the SELECT statement
#
do_test rollback-1.6 {
sqlite3_reset $STMT
} {SQLITE_ABORT}
do_test rollback-1.7 {
sqlite3_step $STMT
} {SQLITE_ROW}

View File

@@ -10,7 +10,7 @@
# focus of this file is testing compute SELECT statements and nested
# views.
#
# $Id: select7.test,v 1.10 2007/06/07 10:55:36 drh Exp $
# $Id: select7.test,v 1.11 2007/09/12 17:01:45 danielk1977 Exp $
set testdir [file dirname $argv0]
@@ -138,20 +138,22 @@ ifcapable {subquery && compound} {
# Verify that an error occurs if you have too many terms on a
# compound select statement.
#
if {$SQLITE_MAX_COMPOUND_SELECT>0} {
set sql {SELECT 0}
set result 0
for {set i 1} {$i<$SQLITE_MAX_COMPOUND_SELECT} {incr i} {
append sql " UNION ALL SELECT $i"
lappend result $i
ifcapable compound {
if {$SQLITE_MAX_COMPOUND_SELECT>0} {
set sql {SELECT 0}
set result 0
for {set i 1} {$i<$SQLITE_MAX_COMPOUND_SELECT} {incr i} {
append sql " UNION ALL SELECT $i"
lappend result $i
}
do_test select7-6.1 {
catchsql $sql
} [list 0 $result]
append sql { UNION ALL SELECT 99999999}
do_test select7-6.2 {
catchsql $sql
} {1 {too many terms in compound SELECT}}
}
do_test select7-6.1 {
catchsql $sql
} [list 0 $result]
append sql { UNION ALL SELECT 99999999}
do_test select7-6.2 {
catchsql $sql
} {1 {too many terms in compound SELECT}}
}
finish_test

View File

@@ -9,7 +9,7 @@
#
#***********************************************************************
#
# $Id: shared.test,v 1.26 2007/09/01 16:16:16 danielk1977 Exp $
# $Id: shared.test,v 1.27 2007/09/12 17:01:45 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -865,14 +865,16 @@ do_test shared-$av.11.11 {
# This tests that if it is impossible to free any pages, SQLite will
# exceed the limit set by PRAGMA cache_size.
do_test shared-$av.12.1 {
file delete -force test.db test.db-journal
sqlite3 db test.db
execsql {
PRAGMA cache_size = 10;
PRAGMA cache_size;
}
} {10}
file delete -force test.db test.db-journal
sqlite3 db test.db
ifcapable pager_pragmas {
do_test shared-$av.12.1 {
execsql {
PRAGMA cache_size = 10;
PRAGMA cache_size;
}
} {10}
}
do_test shared-$av.12.2 {
set ::db_handles [list]
for {set i 1} {$i < 15} {incr i} {

View File

@@ -13,12 +13,17 @@
# A database corruption bug that occurs in auto_vacuum mode when
# the soft_heap_limit is set low enough to be triggered.
#
# $Id: softheap1.test,v 1.2 2007/08/12 20:07:59 drh Exp $
# $Id: softheap1.test,v 1.3 2007/09/12 17:01:45 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
ifcapable !integrityck {
finish_test
return
}
sqlite3_soft_heap_limit 5000
do_test softheap1-1.1 {
execsql {

View File

@@ -12,7 +12,7 @@
# focus of this script is testing that the overflow-page related
# enhancements added after version 3.3.17 speed things up.
#
# $Id: speed3.test,v 1.3 2007/08/22 02:56:44 drh Exp $
# $Id: speed3.test,v 1.4 2007/09/12 17:01:45 danielk1977 Exp $
#
#---------------------------------------------------------------------
@@ -34,6 +34,12 @@
set testdir [file dirname $argv0]
source $testdir/tester.tcl
ifcapable !tclvar {
finish_test
return
}
speed_trial_init speed1
# Set a uniform random seed

View File

@@ -11,11 +11,16 @@
# This file implements regression tests for SQLite library. The
# focus of this file is testing the built-in SUBSTR() functions.
#
# $Id: substr.test,v 1.1 2007/05/15 01:13:47 drh Exp $
# $Id: substr.test,v 1.2 2007/09/12 17:01:45 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
ifcapable !tclvar {
finish_test
return
}
# Create a table to work with.
#
execsql {

View File

@@ -12,7 +12,7 @@
# focus of this file is testing the sqlite_exec_printf() and
# sqlite_get_table_printf() APIs.
#
# $Id: tableapi.test,v 1.12 2007/01/05 00:14:28 drh Exp $
# $Id: tableapi.test,v 1.13 2007/09/12 17:01:45 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -206,9 +206,11 @@ do_test tableapi-5.2 {
sqlite3_get_table_printf $::dbx {SELECT * FROM t2} {}
} {0 2 100 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 x16 x17 x18 x19 x20 x21 x22 x23 x24 x25 x26 x27 x28 x29 x30 x31 x32 x33 x34 x35 x36 x37 x38 x39 x40 x41 x42 x43 x44 x45 x46 x47 x48 x49 x50 x51 x52 x53 x54 x55 x56 x57 x58 x59 x60 x61 x62 x63 x64 x65 x66 x67 x68 x69 x70 x71 x72 x73 x74 x75 x76 x77 x78 x79 x80 x81 x82 x83 x84 x85 x86 x87 x88 x89 x90 x91 x92 x93 x94 x95 x96 x97 x98 x99 x100 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100}
do_test tableapi-6.1 {
sqlite3_get_table_printf $::dbx {PRAGMA user_version} {}
} {0 1 1 user_version 0}
ifcapable schema_pragmas {
do_test tableapi-6.1 {
sqlite3_get_table_printf $::dbx {PRAGMA user_version} {}
} {0 1 1 user_version 0}
}
do_test tableapi-99.0 {
sqlite3_close $::dbx

View File

@@ -15,7 +15,7 @@
# interface is pretty well tested. This file contains some addition
# tests for fringe issues that the main test suite does not cover.
#
# $Id: tclsqlite.test,v 1.61 2007/09/01 06:51:28 danielk1977 Exp $
# $Id: tclsqlite.test,v 1.62 2007/09/12 17:01:45 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -460,35 +460,37 @@ do_test tcl-12.1 {
# of $aaa, that objects are treated as bytearray and are inserted
# as BLOBs.
#
do_test tcl-13.1 {
db eval {CREATE TABLE t5(x BLOB)}
set x abc123
db eval {INSERT INTO t5 VALUES($x)}
db eval {SELECT typeof(x) FROM t5}
} {text}
do_test tcl-13.2 {
binary scan $x H notUsed
db eval {
DELETE FROM t5;
INSERT INTO t5 VALUES($x);
SELECT typeof(x) FROM t5;
}
} {text}
do_test tcl-13.3 {
db eval {
DELETE FROM t5;
INSERT INTO t5 VALUES(@x);
SELECT typeof(x) FROM t5;
}
} {blob}
do_test tcl-13.4 {
set y 1234
db eval {
DELETE FROM t5;
INSERT INTO t5 VALUES(@y);
SELECT hex(x), typeof(x) FROM t5
}
} {31323334 blob}
ifcapable tclvar {
do_test tcl-13.1 {
db eval {CREATE TABLE t5(x BLOB)}
set x abc123
db eval {INSERT INTO t5 VALUES($x)}
db eval {SELECT typeof(x) FROM t5}
} {text}
do_test tcl-13.2 {
binary scan $x H notUsed
db eval {
DELETE FROM t5;
INSERT INTO t5 VALUES($x);
SELECT typeof(x) FROM t5;
}
} {text}
do_test tcl-13.3 {
db eval {
DELETE FROM t5;
INSERT INTO t5 VALUES(@x);
SELECT typeof(x) FROM t5;
}
} {blob}
do_test tcl-13.4 {
set y 1234
db eval {
DELETE FROM t5;
INSERT INTO t5 VALUES(@y);
SELECT hex(x), typeof(x) FROM t5
}
} {31323334 blob}
}
finish_test

View File

@@ -14,11 +14,15 @@
# fixed.
#
#
# $Id: tkt2141.test,v 1.1 2007/01/04 01:20:29 drh Exp $
# $Id: tkt2141.test,v 1.2 2007/09/12 17:01:45 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
ifcapable !subquery {
finish_test
return
}
do_test tkt2141-1.1 {
execsql {

View File

@@ -14,11 +14,15 @@
# fixed.
#
#
# $Id: tkt2192.test,v 1.1 2007/01/26 19:04:00 drh Exp $
# $Id: tkt2192.test,v 1.2 2007/09/12 17:01:45 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
ifcapable !datetime {
finish_test
return
}
do_test tkt2191-1.1 {
execsql {

View File

@@ -28,11 +28,16 @@
# raw OP_Column in all places where a table column is extracted from
# the database.
#
# $Id: tkt2251.test,v 1.1 2007/02/24 15:18:51 drh Exp $
# $Id: tkt2251.test,v 1.2 2007/09/12 17:01:45 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
ifcapable !altertable {
finish_test
return
}
# Create sample data. Verify that the default value and type of an added
# column is correct for aggregates.
do_test tkt2251-1.1 {

View File

@@ -9,13 +9,13 @@
#
#***********************************************************************
#
# $Id: tkt2332.test,v 1.3 2007/05/04 19:03:03 danielk1977 Exp $
# $Id: tkt2332.test,v 1.4 2007/09/12 17:01:45 danielk1977 Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
ifcapable {!incrblob} {
ifcapable !incrblob||!tclvar {
finish_test
return
}

View File

@@ -9,12 +9,17 @@
#
#***********************************************************************
#
# $Id: tkt2339.test,v 1.1 2007/05/06 20:04:25 drh Exp $
# $Id: tkt2339.test,v 1.2 2007/09/12 17:01:45 danielk1977 Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
ifcapable !subquery||!compound {
finish_test
return
}
do_test tkt2339.1 {
execsql {
create table t1(num int);

View File

@@ -16,7 +16,7 @@
# any statement other than a COMMIT, an I/O error is returned instead
# of SQLITE_BUSY.
#
# $Id: tkt2409.test,v 1.2 2007/06/15 12:41:02 drh Exp $
# $Id: tkt2409.test,v 1.3 2007/09/12 17:01:45 danielk1977 Exp $
# Test Outline:
#
@@ -40,6 +40,11 @@
set testdir [file dirname $argv0]
source $testdir/tester.tcl
ifcapable !pager_pragmas {
finish_test
return
}
sqlite3_extended_result_codes $::DB 1
# Aquire a read-lock on the database using handle [db2].

View File

@@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this script is database locks.
#
# $Id: trans.test,v 1.36 2007/07/13 10:36:48 drh Exp $
# $Id: trans.test,v 1.37 2007/09/12 17:01:45 danielk1977 Exp $
set testdir [file dirname $argv0]
@@ -908,7 +908,7 @@ for {set i 2} {$i<=$limit} {incr i} {
} [expr {$i%2==0}]
} else {
do_test trans-9.$i.5-$cnt {
expr {$sqlite_fullsync_count>0}
expr {$sqlite_fullsync_count==0}
} {1}
}
}

View File

@@ -12,7 +12,7 @@
# focus of this file is testing the use of indices in WHERE clauses
# based on recent changes to the optimizer.
#
# $Id: where2.test,v 1.11 2007/02/23 23:13:34 drh Exp $
# $Id: where2.test,v 1.12 2007/09/12 17:01:45 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -328,37 +328,41 @@ do_test where2-6.11.4 {
SELECT * FROM t2249b CROSS JOIN t2249a WHERE a='hello' OR b=a;
}
} {123 0123 nosort t2249b {} t2249a {}}
do_test where2-6.12 {
# In this case, the +b disables the affinity conflict and allows
# the OR optimization to be used again. The result is now an empty
# set, the same as in where2-6.9.
queryplan {
SELECT * FROM t2249b CROSS JOIN t2249a WHERE a=+b OR a='hello';
}
} {nosort t2249b {} {} sqlite_autoindex_t2249a_1}
do_test where2-6.12.2 {
# In this case, the +b disables the affinity conflict and allows
# the OR optimization to be used again. The result is now an empty
# set, the same as in where2-6.9.
queryplan {
SELECT * FROM t2249b CROSS JOIN t2249a WHERE a='hello' OR +b=a;
}
} {nosort t2249b {} {} sqlite_autoindex_t2249a_1}
do_test where2-6.12.3 {
# In this case, the +b disables the affinity conflict and allows
# the OR optimization to be used again. The result is now an empty
# set, the same as in where2-6.9.
queryplan {
SELECT * FROM t2249b CROSS JOIN t2249a WHERE +b=a OR a='hello';
}
} {nosort t2249b {} {} sqlite_autoindex_t2249a_1}
do_test where2-6.13 {
# The addition of +a on the second term disabled the OR optimization.
# But we should still get the same empty-set result as in where2-6.9.
queryplan {
SELECT * FROM t2249b CROSS JOIN t2249a WHERE a=+b OR +a='hello';
}
} {nosort t2249b {} t2249a {}}
ifcapable explain {
do_test where2-6.12 {
# In this case, the +b disables the affinity conflict and allows
# the OR optimization to be used again. The result is now an empty
# set, the same as in where2-6.9.
queryplan {
SELECT * FROM t2249b CROSS JOIN t2249a WHERE a=+b OR a='hello';
}
} {nosort t2249b {} {} sqlite_autoindex_t2249a_1}
do_test where2-6.12.2 {
# In this case, the +b disables the affinity conflict and allows
# the OR optimization to be used again. The result is now an empty
# set, the same as in where2-6.9.
queryplan {
SELECT * FROM t2249b CROSS JOIN t2249a WHERE a='hello' OR +b=a;
}
} {nosort t2249b {} {} sqlite_autoindex_t2249a_1}
}
ifcapable explain {
do_test where2-6.12.3 {
# In this case, the +b disables the affinity conflict and allows
# the OR optimization to be used again. The result is now an empty
# set, the same as in where2-6.9.
queryplan {
SELECT * FROM t2249b CROSS JOIN t2249a WHERE +b=a OR a='hello';
}
} {nosort t2249b {} {} sqlite_autoindex_t2249a_1}
do_test where2-6.13 {
# The addition of +a on the second term disabled the OR optimization.
# But we should still get the same empty-set result as in where2-6.9.
queryplan {
SELECT * FROM t2249b CROSS JOIN t2249a WHERE a=+b OR +a='hello';
}
} {nosort t2249b {} t2249a {}}
}
# Variations on the order of terms in a WHERE clause in order
# to make sure the OR optimizer can recognize them all.
@@ -367,21 +371,23 @@ do_test where2-6.20 {
SELECT * FROM t2249a x CROSS JOIN t2249a y WHERE x.a=y.a
}
} {0123 0123 nosort x {} {} sqlite_autoindex_t2249a_1}
do_test where2-6.21 {
queryplan {
SELECT * FROM t2249a x CROSS JOIN t2249a y WHERE x.a=y.a OR y.a='hello'
}
} {0123 0123 nosort x {} {} sqlite_autoindex_t2249a_1}
do_test where2-6.22 {
queryplan {
SELECT * FROM t2249a x CROSS JOIN t2249a y WHERE y.a=x.a OR y.a='hello'
}
} {0123 0123 nosort x {} {} sqlite_autoindex_t2249a_1}
do_test where2-6.23 {
queryplan {
SELECT * FROM t2249a x CROSS JOIN t2249a y WHERE y.a='hello' OR x.a=y.a
}
} {0123 0123 nosort x {} {} sqlite_autoindex_t2249a_1}
ifcapable explain {
do_test where2-6.21 {
queryplan {
SELECT * FROM t2249a x CROSS JOIN t2249a y WHERE x.a=y.a OR y.a='hello'
}
} {0123 0123 nosort x {} {} sqlite_autoindex_t2249a_1}
do_test where2-6.22 {
queryplan {
SELECT * FROM t2249a x CROSS JOIN t2249a y WHERE y.a=x.a OR y.a='hello'
}
} {0123 0123 nosort x {} {} sqlite_autoindex_t2249a_1}
do_test where2-6.23 {
queryplan {
SELECT * FROM t2249a x CROSS JOIN t2249a y WHERE y.a='hello' OR x.a=y.a
}
} {0123 0123 nosort x {} {} sqlite_autoindex_t2249a_1}
}
# Unique queries (queries that are guaranteed to return only a single
# row of result) do not call the sorter. But all tables must give
@@ -580,7 +586,7 @@ ifcapable subquery {
# Make sure WHERE clauses of the form A=1 AND (B=2 OR B=3) are optimized
# when we have an index on A and B.
#
ifcapable or_opt {
ifcapable or_opt&&tclvar {
do_test where2-9.1 {
execsql {
BEGIN;

View File

@@ -15,11 +15,16 @@
# that IS NULL phrases are correctly optimized. But you can never
# have too many tests, so some other tests are thrown in as well.
#
# $Id: where4.test,v 1.4 2007/06/02 07:54:38 danielk1977 Exp $
# $Id: where4.test,v 1.5 2007/09/12 17:01:45 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
ifcapable !tclvar||!bloblit {
finish_test
return
}
# Build some test data
#
do_test where4-1.0 {

View File

@@ -13,7 +13,7 @@
# including the sqlite3_bind_zeroblob(), sqlite3_result_zeroblob(),
# and the built-in zeroblob() SQL function.
#
# $Id: zeroblob.test,v 1.9 2007/09/04 12:18:42 drh Exp $
# $Id: zeroblob.test,v 1.10 2007/09/12 17:01:45 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -110,23 +110,27 @@ do_test zeroblob-2.2 {
# DISTINCT works for zeroblobs
#
do_test zeroblob-3.1 {
execsql {
SELECT count(DISTINCT a) FROM (
SELECT x'00000000000000000000' AS a
UNION ALL
SELECT zeroblob(10) AS a
)
}
} {1}
ifcapable bloblit&&subquery&&compound {
do_test zeroblob-3.1 {
execsql {
SELECT count(DISTINCT a) FROM (
SELECT x'00000000000000000000' AS a
UNION ALL
SELECT zeroblob(10) AS a
)
}
} {1}
}
# Concatentation works with zeroblob
#
do_test zeroblob-4.1 {
execsql {
SELECT hex(zeroblob(2) || x'61')
}
} {000061}
ifcapable bloblit {
do_test zeroblob-4.1 {
execsql {
SELECT hex(zeroblob(2) || x'61')
}
} {000061}
}
# Check various CAST(...) operations on zeroblob.
#