gitlab.com/CoiaPrant/sqlite3@v1.19.1/testdata/tcl/vacuum6.test (about) 1 # 2016-08-19 2 # 3 # The author disclaims copyright to this source code. In place of 4 # a legal notice, here is a blessing: 5 # 6 # May you do good and not evil. 7 # May you find forgiveness for yourself and forgive others. 8 # May you share freely, never taking more than you give. 9 # 10 #*********************************************************************** 11 # 12 # This file implements a test for VACUUM on attached databases. 13 # 14 15 set testdir [file dirname $argv0] 16 source $testdir/tester.tcl 17 set testprefix vacuum6 18 19 # If the VACUUM statement is disabled in the current build, skip all 20 # the tests in this file. 21 # 22 ifcapable !vacuum { 23 finish_test 24 return 25 } 26 27 28 do_execsql_test 1.0 { 29 CREATE TABLE t1(x INTEGER PRIMARY KEY, y); 30 INSERT INTO t1 VALUES(1, 1); 31 } {} 32 33 do_execsql_test 1.1 { 34 VACUUM 35 } 36 37 reset_db 38 do_execsql_test 1.2 { 39 CREATE TABLE t1(x,b); 40 CREATE INDEX x1 ON t1(x); 41 CREATE INDEX x2 ON t1(x); 42 CREATE INDEX x3 ON t1(x); 43 INSERT INTO t1 SELECT 2,''; 44 VACUUM; 45 } 46 47 #------------------------------------------------------------------------- 48 # 49 reset_db 50 foreach {tn sz} {1 400 2 4000 3 9999} { 51 reset_db 52 do_execsql_test 2.$tn.1 { 53 CREATE TABLE t1(a INTEGER PRIMARY KEY, b); 54 WITH s(i) AS ( 55 SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<100 56 ) 57 INSERT INTO t1 SELECT i, randomblob($sz) FROM s; 58 } 59 60 do_execsql_test 2.$tn.2 { 61 vacuum; 62 } 63 64 do_execsql_test 2.$tn.3 { 65 PRAGMA integrity_check; 66 } {ok} 67 } 68 69 reset_db 70 do_execsql_test 3.0 { 71 PRAGMA page_size = 1024; 72 CREATE TABLE t1(x INTEGER PRIMARY KEY, y); 73 INSERT INTO t1 VALUES(2, randomblob(1200)); 74 } {} 75 do_execsql_test 3.1 { 76 PRAGMA page_size = 512; 77 VACUUM; 78 } 79 do_execsql_test 3.2 { 80 PRAGMA integrity_check 81 } {ok} 82 83 #------------------------------------------------------------------------- 84 # 85 reset_db 86 do_execsql_test 4.0 { 87 CREATE TABLE tx(a, b); 88 CREATE INDEX i1 ON tx(b); 89 WITH s(i) AS ( 90 SELECT 8000 UNION ALL SELECT i+1 FROM s WHERE i<10000 91 ) 92 INSERT INTO tx SELECT i, randomblob(i) FROM s; 93 94 SELECT sum(length(b)) FROM tx; 95 } {18009000} 96 foreach {tn pgsz av} { 97 1 2048 0 98 2 1024 1 99 3 65536 0 100 4 8192 1 101 5 512 0 102 6 4096 1 103 } { 104 do_execsql_test 4.1.$tn.1 " 105 PRAGMA page_size = $pgsz; 106 PRAGMA auto_vacuum = $av; 107 " 108 do_execsql_test 4.1.$tn.2 VACUUM 109 integrity_check 4.1.$tn.3 110 } 111 112 finish_test