bigrow.test revision 2
2N/A
2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A# 2001 September 23
2N/A#
2N/A# The author disclaims copyright to this source code. In place of
2N/A# a legal notice, here is a blessing:
2N/A#
2N/A# May you do good and not evil.
2N/A# May you find forgiveness for yourself and forgive others.
2N/A# May you share freely, never taking more than you give.
2N/A#
2N/A#***********************************************************************
2N/A# This file implements regression tests for SQLite library. The
2N/A# focus of this file is stressing the library by putting large amounts
2N/A# of data in a single row of a table.
2N/A#
2N/A# $Id: bigrow.test,v 1.4 2001/11/24 00:31:47 drh Exp $
2N/A
2N/Aset testdir [file dirname $argv0]
2N/Asource $testdir/tester.tcl
2N/A
2N/A# Make a big string that we can use for test data
2N/A#
2N/Ado_test bigrow-1.0 {
2N/A set ::bigstr {}
2N/A for {set i 1} {$i<=9999} {incr i} {
2N/A set sep [string index "abcdefghijklmnopqrstuvwxyz" [expr {$i%26}]]
2N/A append ::bigstr "$sep [format %04d $i] "
2N/A }
2N/A string length $::bigstr
2N/A} {69993}
2N/A
2N/A# Make a table into which we can insert some but records.
2N/A#
2N/Ado_test bigrow-1.1 {
2N/A execsql {
2N/A CREATE TABLE t1(a text, b text, c text);
2N/A SELECT name FROM sqlite_master
2N/A WHERE type='table' OR type='index'
2N/A ORDER BY name
2N/A }
2N/A} {t1}
2N/A
2N/Ado_test bigrow-1.2 {
2N/A set ::big1 [string range $::bigstr 0 65519]
2N/A set sql "INSERT INTO t1 VALUES('abc',"
2N/A append sql "'$::big1', 'xyz');"
2N/A execsql $sql
2N/A execsql {SELECT a, c FROM t1}
2N/A} {abc xyz}
2N/Ado_test bigrow-1.3 {
2N/A execsql {SELECT b FROM t1}
2N/A} [list $::big1]
2N/Ado_test bigrow-1.4 {
2N/A set ::big2 [string range $::bigstr 0 65520]
2N/A set sql "INSERT INTO t1 VALUES('abc2',"
2N/A append sql "'$::big2', 'xyz2');"
2N/A set r [catch {execsql $sql} msg]
2N/A lappend r $msg
2N/A} {0 {}}
2N/Ado_test bigrow-1.4.1 {
2N/A execsql {SELECT b FROM t1 ORDER BY c}
2N/A} [list $::big1 $::big2]
2N/Ado_test bigrow-1.4.2 {
2N/A execsql {SELECT c FROM t1 ORDER BY c}
2N/A} {xyz xyz2}
2N/Ado_test bigrow-1.4.3 {
2N/A execsql {DELETE FROM t1 WHERE a='abc2'}
2N/A execsql {SELECT c FROM t1}
2N/A} {xyz}
2N/A
2N/Ado_test bigrow-1.5 {
2N/A execsql {
2N/A UPDATE t1 SET a=b, b=a;
2N/A SELECT b,c FROM t1
2N/A }
2N/A} {abc xyz}
2N/Ado_test bigrow-1.6 {
2N/A execsql {
2N/A SELECT * FROM t1
2N/A }
2N/A} [list $::big1 abc xyz]
2N/Ado_test bigrow-1.7 {
2N/A execsql {
2N/A INSERT INTO t1 VALUES('1','2','3');
2N/A INSERT INTO t1 VALUES('A','B','C');
2N/A SELECT b FROM t1 WHERE a=='1';
2N/A }
2N/A} {2}
2N/Ado_test bigrow-1.8 {
2N/A execsql "SELECT b FROM t1 WHERE a=='$::big1'"
2N/A} {abc}
2N/Ado_test bigrow-1.9 {
2N/A execsql "SELECT b FROM t1 WHERE a!='$::big1' ORDER BY a"
2N/A} {2 B}
2N/A
2N/A# Try doing some indexing on big columns
2N/A#
2N/Ado_test bigrow-2.1 {
2N/A execsql {
2N/A CREATE INDEX i1 ON t1(a)
2N/A }
2N/A execsql "SELECT b FROM t1 WHERE a=='$::big1'"
2N/A} {abc}
2N/Ado_test bigrow-2.2 {
2N/A execsql {
2N/A UPDATE t1 SET a=b, b=a
2N/A }
2N/A execsql "SELECT b FROM t1 WHERE a=='abc'"
2N/A} [list $::big1]
2N/Ado_test bigrow-2.3 {
2N/A execsql {
2N/A UPDATE t1 SET a=b, b=a
2N/A }
2N/A execsql "SELECT b FROM t1 WHERE a=='$::big1'"
2N/A} {abc}
2N/Acatch {unset ::bigstr}
2N/Acatch {unset ::big1}
2N/Acatch {unset ::big2}
2N/A
2N/A# Mosts of the tests above were created back when rows were limited in
2N/A# size to 64K. Now rows can be much bigger. Test that logic. Also
2N/A# make sure things work correctly at the transition boundries between
2N/A# row sizes of 256 to 257 bytes and from 65536 to 65537 bytes.
2N/A#
2N/A# We begin by testing the 256..257 transition.
2N/A#
2N/Ado_test bigrow-3.1 {
2N/A execsql {
2N/A DELETE FROM t1;
2N/A INSERT INTO t1(a,b,c) VALUES('one','abcdefghijklmnopqrstuvwxyz0123','hi');
2N/A }
2N/A execsql {SELECT a,length(b),c FROM t1}
2N/A} {one 30 hi}
2N/Ado_test bigrow-3.2 {
2N/A execsql {
2N/A UPDATE t1 SET b=b||b;
2N/A UPDATE t1 SET b=b||b;
2N/A UPDATE t1 SET b=b||b;
2N/A }
2N/A execsql {SELECT a,length(b),c FROM t1}
2N/A} {one 240 hi}
2N/Afor {set i 1} {$i<10} {incr i} {
2N/A do_test bigrow-3.3.$i {
2N/A execsql "UPDATE t1 SET b=b||'$i'"
2N/A execsql {SELECT a,length(b),c FROM t1}
2N/A } "one [expr {240+$i}] hi"
2N/A}
2N/A
2N/A# Now test the 65536..65537 row-size transition.
2N/A#
2N/Ado_test bigrow-4.1 {
2N/A execsql {
2N/A DELETE FROM t1;
2N/A INSERT INTO t1(a,b,c) VALUES('one','abcdefghijklmnopqrstuvwxyz0123','hi');
2N/A }
2N/A execsql {SELECT a,length(b),c FROM t1}
2N/A} {one 30 hi}
2N/Ado_test bigrow-4.2 {
2N/A execsql {
2N/A UPDATE t1 SET b=b||b;
2N/A UPDATE t1 SET b=b||b;
2N/A UPDATE t1 SET b=b||b;
2N/A UPDATE t1 SET b=b||b;
2N/A UPDATE t1 SET b=b||b;
2N/A UPDATE t1 SET b=b||b;
2N/A UPDATE t1 SET b=b||b;
2N/A UPDATE t1 SET b=b||b;
2N/A UPDATE t1 SET b=b||b;
2N/A UPDATE t1 SET b=b||b;
2N/A UPDATE t1 SET b=b||b;
2N/A UPDATE t1 SET b=b||b;
2N/A }
2N/A execsql {SELECT a,length(b),c FROM t1}
2N/A} {one 122880 hi}
2N/Ado_test bigrow-4.3 {
2N/A execsql {
2N/A UPDATE t1 SET b=substr(b,1,65515)
2N/A }
2N/A execsql {SELECT a,length(b),c FROM t1}
2N/A} {one 65515 hi}
2N/Afor {set i 1} {$i<10} {incr i} {
2N/A do_test bigrow-4.4.$i {
2N/A execsql "UPDATE t1 SET b=b||'$i'"
2N/A execsql {SELECT a,length(b),c FROM t1}
2N/A } "one [expr {65515+$i}] hi"
2N/A}
2N/A
2N/A# Check to make sure the library recovers safely if a row contains
2N/A# too much data.
2N/A#
2N/Ado_test bigrow-5.1 {
2N/A execsql {
2N/A DELETE FROM t1;
2N/A INSERT INTO t1(a,b,c) VALUES('one','abcdefghijklmnopqrstuvwxyz0123','hi');
2N/A }
2N/A execsql {SELECT a,length(b),c FROM t1}
2N/A} {one 30 hi}
2N/Aset i 1
2N/Afor {set sz 60} {$sz<1048560} {incr sz $sz} {
2N/A do_test bigrow-5.2.$i {
2N/A execsql {
2N/A UPDATE t1 SET b=b||b;
2N/A SELECT a,length(b),c FROM t1;
2N/A }
2N/A } "one $sz hi"
2N/A incr i
2N/A}
2N/Ado_test bigrow-5.3 {
2N/A set r [catch {execsql {UPDATE t1 SET b=b||b}} msg]
2N/A lappend r $msg
2N/A} {1 {too much data for one table row}}
2N/Ado_test bigrow-5.4 {
2N/A execsql {DROP TABLE t1}
2N/A} {}
2N/A
2N/Afinish_test