Add the tests that go with the previous commit. (CVS 4258)

FossilOrigin-Name: a87f32e13e91250ab4d9366d2e9a3a7024a12fb9
This commit is contained in:
danielk1977 2007-08-21 13:30:07 +00:00
parent 6e465eb0fc
commit 46abae817e
3 changed files with 98 additions and 6 deletions

View File

@ -1,5 +1,5 @@
C Avoid\sjournalling\san\sextra\spage\swhen\sa\sbtree\sinsert\soperation\suses\sthe\s'quick-balance'\strick.\s(CVS\s4257)
D 2007-08-21T13:11:01
C Add\sthe\stests\sthat\sgo\swith\sthe\sprevious\scommit.\s(CVS\s4258)
D 2007-08-21T13:30:07
F Makefile.in 0c0e53720f658c7a551046442dd7afba0b72bfbe
F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@ -317,6 +317,7 @@ F test/insert3.test 72ea6056811fd234f80d923f977c196089947381
F test/insert4.test 1e27f0a3e5670d5f03c1636f699aa44270945bca
F test/interrupt.test 81555fb0f8179bb2d0dc7151fd75428223f93cf2
F test/intpkey.test af4fd826c4784ec5c93b444de07adea0254d0d30
F test/io.test b2f21c23f920541ba64e7b3251674bd8773c6bc8
F test/ioerr.test 491d42c49bbec598966d26b01ed7901f55e5ee2d
F test/ioerr2.test f938eadb12108048813869b86beee4a2f98e34b8
F test/join.test af0443185378b64878750aa1cf4b83c216f246b4
@ -557,7 +558,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
P 5bced2392ad77aff0aa1ddea83f2ff9e3ffe28a8
R 62bf9d7ba713afd09c97220ab74284f7
P 0da48209140b6c1ba47df799ce6065054b994f02
R cea3f4dd0f8d31322bd710223c9b6fd4
U danielk1977
Z b65c4a9665c9f568889e6d02dbdc7083
Z 0894b0ecd2f2b85dfd7a091f744238da

View File

@ -1 +1 @@
0da48209140b6c1ba47df799ce6065054b994f02
a87f32e13e91250ab4d9366d2e9a3a7024a12fb9

91
test/io.test Normal file
View File

@ -0,0 +1,91 @@
# 2007 August 21
#
# 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.
#
#***********************************************************************
#
# The focus of this file is testing some specific characteristics of the
# 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.1 2007/08/21 13:30:07 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set ::nWrite 0
proc nWrite {db} {
set bt [btree_from_db $db]
array set stats [btree_pager_stats $bt]
set res [expr $stats(write) - $::nWrite]
set ::nWrite $stats(write)
set res
}
do_test io-1.1 {
execsql {
PRAGMA page_size = 1024;
CREATE TABLE abc(a,b);
}
nWrite db
} {2}
# Insert into the table 4 records of aproximately 240 bytes each.
# This should completely fill the root-page of the table. Each
# INSERT causes 2 db pages to be written - the root-page of "abc"
# and page 1 (db change-counter page).
do_test io-1.2 {
set ret [list]
execsql { INSERT INTO abc VALUES(1,randstr(230,230)); }
lappend ret [nWrite db]
execsql { INSERT INTO abc VALUES(2,randstr(230,230)); }
lappend ret [nWrite db]
execsql { INSERT INTO abc VALUES(3,randstr(230,230)); }
lappend ret [nWrite db]
execsql { INSERT INTO abc VALUES(4,randstr(230,230)); }
lappend ret [nWrite db]
} {2 2 2 2}
# Insert another 240 byte record. This causes two leaf pages
# to be added to the root page of abc. 4 pages in total
# are written to the db file - the two leaf pages, the root
# of abc and the change-counter page.
do_test io-1.3 {
execsql { INSERT INTO abc VALUES(5,randstr(230,230)); }
nWrite db
} {4}
# Insert another 3 240 byte records. After this, the tree consists of
# the root-node, which is close to empty, and two leaf pages, both of
# which are full.
do_test io-1.4 {
set ret [list]
execsql { INSERT INTO abc VALUES(6,randstr(230,230)); }
lappend ret [nWrite db]
execsql { INSERT INTO abc VALUES(7,randstr(230,230)); }
lappend ret [nWrite db]
execsql { INSERT INTO abc VALUES(8,randstr(230,230)); }
lappend ret [nWrite db]
} {2 2 2}
#db eval {select * from sqlite_master} {btree_tree_dump [btree_from_db db] 2}
# This insert should use the quick-balance trick to add a third leaf
# to the b-tree used to store table abc. It should only be necessary to
# write to 3 pages to do this: the change-counter, the root-page and
# the new leaf page.
do_test io-1.5 {
execsql { INSERT INTO abc VALUES(9,randstr(230,230)); }
nWrite db
} {3}
#db eval {select * from sqlite_master} {btree_tree_dump [btree_from_db db] 2}
finish_test