]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
A few more auto-vacuum tests. (CVS 2079)
authordanielk1977 <danielk1977@noemail.net>
Mon, 8 Nov 2004 12:32:50 +0000 (12:32 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Mon, 8 Nov 2004 12:32:50 +0000 (12:32 +0000)
FossilOrigin-Name: 9d4a60bbd67704ff3a9503678db94498dc700ccc

manifest
manifest.uuid
test/autovacuum.test

index 54c9663c20fea079f829844a232437251b2170b2..1ff9d0a13fad3064db9be1d0d56eff79f68e72fb 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Check\sin\sthe\sfile\sautovacuum_crash.test\sthat\sshould\sbe\spart\sof\sthe\sprevious\scheck-in.\s(CVS\s2078)
-D 2004-11-08T09:51:09
+C A\sfew\smore\sauto-vacuum\stests.\s(CVS\s2079)
+D 2004-11-08T12:32:50
 F Makefile.in c4d2416860f472a1e3393714d0372074197565df
 F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
 F README a01693e454a00cc117967e3f9fdab2d4d52e9bc1
@@ -87,7 +87,7 @@ F test/attach.test e305dd59a375e37c658c6d401f19f8a95880bf9a
 F test/attach2.test 399128a7b3b209a339a8dbf53ca2ed42eb982d1a
 F test/attach3.test 287af46653e7435b2d1eda10d8115dcc8a6883e2
 F test/auth.test 1cc252d9e7b3bdc1314199cbf3a0d3c5ed026c21
-F test/autovacuum.test e70d46d598aa4146a3069d830ec8002e384bebbc
+F test/autovacuum.test dbc4a52e446949c176b7575b318fed42c6f9708e
 F test/autovacuum_crash.test 2dca85cbcc497098e45e8847c86407eb3554f3d4
 F test/bigfile.test d3744a8821ce9abb8697f2826a3e3d22b719e89f
 F test/bigrow.test f0aeb7573dcb8caaafea76454be3ade29b7fc747
@@ -254,7 +254,7 @@ F www/tclsqlite.tcl 560ecd6a916b320e59f2917317398f3d59b7cc25
 F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
 F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0
 F www/whentouse.tcl fdacb0ba2d39831e8a6240d05a490026ad4c4e4c
-P 839ad771a6e781426c0fd624a4d1c91a5fcf8546
-R 37e7a6896bb83fe6ca31bd0c2f87ec77
+P 9d7cd1f732ba6f9d69fc30100a4608b74f212b76
+R 332706045c880050ac7896f172870779
 U danielk1977
-Z 814a17f9647b04f65674b145dd495a31
+Z e559ccf849c343b03d2edaffd64c8f69
index f15cf86cdb3f74385dc029defd3d2c28158b7016..88da4aaed084bab547a39db63d75fa4cc39dba64 100644 (file)
@@ -1 +1 @@
-9d7cd1f732ba6f9d69fc30100a4608b74f212b76
\ No newline at end of file
+9d4a60bbd67704ff3a9503678db94498dc700ccc
\ No newline at end of file
index b768d7fd4b5e7296a6aa9dd197584977bf153d72..26ede2d9f3133cc33e3e35f69b111b37d872a732 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this file is testing the SELECT statement.
 #
-# $Id: autovacuum.test,v 1.9 2004/11/05 15:45:11 danielk1977 Exp $
+# $Id: autovacuum.test,v 1.10 2004/11/08 12:32:50 danielk1977 Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -128,6 +128,12 @@ foreach delete_order $delete_orders {
 #                   the free root-page location.
 # autovacuum-2.4.*: Check that a table can be created correctly when the
 #                   root-page it requires is on the free-list.
+# autovacuum-2.5.*: Check that a table with indices can be dropped. This
+#                   is slightly tricky because dropping one of the
+#                   indices/table btrees could move the root-page of another.
+#                   The code-generation layer of SQLite overcomes this problem
+#                   by dropping the btrees in descending order of root-pages.
+#                   This test ensures that this actually happens.
 #
 do_test autovacuum-2.1.1 {
   execsql {
@@ -293,6 +299,135 @@ do_test autovacuum-2.4.7 {
   file_pages
 } 1
 
+# Create some tables with indices to drop.
+do_test autovacuum-2.5.1 {
+  execsql {
+    CREATE TABLE av1(a PRIMARY KEY, b, c);
+    INSERT INTO av1 VALUES('av1 a', 'av1 b', 'av1 c');
+
+    CREATE TABLE av2(a PRIMARY KEY, b, c);
+    CREATE INDEX av2_i1 ON av2(b);
+    CREATE INDEX av2_i2 ON av2(c);
+    INSERT INTO av2 VALUES('av2 a', 'av2 b', 'av2 c');
+
+    CREATE TABLE av3(a PRIMARY KEY, b, c);
+    CREATE INDEX av3_i1 ON av3(b);
+    INSERT INTO av3 VALUES('av3 a', 'av3 b', 'av3 c');
+
+    CREATE TABLE av4(a, b, c);
+    CREATE INDEX av4_i1 ON av4(a);
+    CREATE INDEX av4_i2 ON av4(b);
+    CREATE INDEX av4_i3 ON av4(c);
+    CREATE INDEX av4_i4 ON av4(a, b, c);
+    INSERT INTO av4 VALUES('av4 a', 'av4 b', 'av4 c');
+  }
+} {}
+
+do_test autovacuum-2.5.2 {
+  execsql {
+    SELECT name, rootpage FROM sqlite_master;
+  }
+} [list av1 4  sqlite_autoindex_av1_1 3 \
+        av2 6  sqlite_autoindex_av2_1 5 av2_i1 7 av2_i2 8 \
+        av3 10 sqlite_autoindex_av3_1 9 av3_i1 11 \
+        av4 12 av4_i1 13 av4_i2 14 av4_i3 15 av4_i4 16 \
+]
+
+# The following 4 tests are SELECT queries that use the indices created.
+# If the root-pages in the internal schema are not updated correctly when
+# a table or indice is moved, these queries will fail. They are repeated
+# after each table is dropped (i.e. as test cases 2.5.*.[1..4]).
+do_test autovacuum-2.5.2.1 {
+  execsql {
+    SELECT * FROM av1 WHERE a = 'av1 a';
+  }
+} {{av1 a} {av1 b} {av1 c}}
+do_test autovacuum-2.5.2.2 {
+  execsql {
+    SELECT * FROM av2 WHERE a = 'av2 a' AND b = 'av2 b' AND c = 'av2 c'
+  }
+} {{av2 a} {av2 b} {av2 c}}
+do_test autovacuum-2.5.2.3 {
+  execsql {
+    SELECT * FROM av3 WHERE a = 'av3 a' AND b = 'av3 b';
+  }
+} {{av3 a} {av3 b} {av3 c}}
+do_test autovacuum-2.5.2.4 {
+  execsql {
+    SELECT * FROM av4 WHERE a = 'av4 a' AND b = 'av4 b' AND c = 'av4 c';
+  }
+} {{av4 a} {av4 b} {av4 c}}
+
+# Drop table av3. Indices av4_i2, av4_i3 and av4_i4 are moved to fill the two
+# root pages vacated. The operation proceeds as:
+# Step 1: Delete av3_i1 (root-page 11). Move root-page of av4_i4 to page 11.
+# Step 2: Delete av3 (root-page 10). Move root-page of av4_i3 to page 10.
+# Step 3: Delete sqlite_autoindex_av1_3 (root-page 9). Move av4_i2 to page 9.
+do_test autovacuum-2.5.3 {
+  execsql {
+    DROP TABLE av3;
+    SELECT name, rootpage FROM sqlite_master;
+  }
+} [list av1 4  sqlite_autoindex_av1_1 3 \
+        av2 6  sqlite_autoindex_av2_1 5 av2_i1 7 av2_i2 8 \
+        av4 12 av4_i1 13 av4_i2 9 av4_i3 10 av4_i4 11 \
+]
+do_test autovacuum-2.5.2.1 {
+  execsql {
+    SELECT * FROM av1 WHERE a = 'av1 a';
+  }
+} {{av1 a} {av1 b} {av1 c}}
+do_test autovacuum-2.5.2.2 {
+  execsql {
+    SELECT * FROM av2 WHERE a = 'av2 a' AND b = 'av2 b' AND c = 'av2 c'
+  }
+} {{av2 a} {av2 b} {av2 c}}
+do_test autovacuum-2.5.2.4 {
+  execsql {
+    SELECT * FROM av4 WHERE a = 'av4 a' AND b = 'av4 b' AND c = 'av4 c';
+  }
+} {{av4 a} {av4 b} {av4 c}}
+
+# Drop table av1:
+# Step 1: Delete av1 (root page 4). Root-page of av4_i1 fills the gap.
+# Step 2: Delete sqlite_autoindex_av1_1 (root page 3). Move av4 to the gap.
+do_test autovacuum-2.5.4 {
+  execsql {
+    DROP TABLE av1;
+    SELECT name, rootpage FROM sqlite_master;
+  }
+} [list av2 6  sqlite_autoindex_av2_1 5 av2_i1 7 av2_i2 8 \
+        av4 3 av4_i1 4 av4_i2 9 av4_i3 10 av4_i4 11 \
+]
+do_test autovacuum-2.5.2.2 {
+  execsql {
+    SELECT * FROM av2 WHERE a = 'av2 a' AND b = 'av2 b' AND c = 'av2 c'
+  }
+} {{av2 a} {av2 b} {av2 c}}
+do_test autovacuum-2.5.2.4 {
+  execsql {
+    SELECT * FROM av4 WHERE a = 'av4 a' AND b = 'av4 b' AND c = 'av4 c';
+  }
+} {{av4 a} {av4 b} {av4 c}}
+
+# Drop table av4:
+# Step 1: Delete av4_i4.
+# Step 2: Delete av4_i3.
+# Step 3: Delete av4_i2.
+# Step 4: Delete av4_i1. av2_i2 replaces it.
+# Step 5: Delete av4. av2_i1 replaces it.
+do_test autovacuum-2.5.4 {
+  execsql {
+    DROP TABLE av4;
+    SELECT name, rootpage FROM sqlite_master;
+  }
+} [list av2 6 sqlite_autoindex_av2_1 5 av2_i1 3 av2_i2 4]
+do_test autovacuum-2.5.2.2 {
+  execsql {
+    SELECT * FROM av2 WHERE a = 'av2 a' AND b = 'av2 b' AND c = 'av2 c'
+  }
+} {{av2 a} {av2 b} {av2 c}}
+
 #--------------------------------------------------------------------------
 # Test cases autovacuum-3.* test the operation of the "PRAGMA auto_vacuum"
 # command.