]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add the tests that go with the previous commit. (CVS 4258)
authordanielk1977 <danielk1977@noemail.net>
Tue, 21 Aug 2007 13:30:07 +0000 (13:30 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Tue, 21 Aug 2007 13:30:07 +0000 (13:30 +0000)
FossilOrigin-Name: a87f32e13e91250ab4d9366d2e9a3a7024a12fb9

manifest
manifest.uuid
test/io.test [new file with mode: 0644]

index f03b48d0aed3b1f6cb89d946115297a6868e31ef..5f0f29e9017d332be87a085ca8e45b7040e3e130 100644 (file)
--- a/manifest
+++ b/manifest
@@ -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
index 52d3aa52d4bbb69fb3c589fb71fc17e8463c7315..17df4849c6082270d32fcbf9a16bd0cc7bc2720f 100644 (file)
@@ -1 +1 @@
-0da48209140b6c1ba47df799ce6065054b994f02
\ No newline at end of file
+a87f32e13e91250ab4d9366d2e9a3a7024a12fb9
\ No newline at end of file
diff --git a/test/io.test b/test/io.test
new file mode 100644 (file)
index 0000000..d29f469
--- /dev/null
@@ -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
+