OLD | NEW |
(Empty) | |
| 1 # 2012 January 4 {} |
| 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 # This file implements regression tests for SQLite library. |
| 12 # |
| 13 # This file implements tests for how the recover module handles cell |
| 14 # overflow. |
| 15 # |
| 16 # $Id$ |
| 17 |
| 18 set testdir [file dirname $argv0] |
| 19 source $testdir/tester.tcl |
| 20 |
| 21 set lorem "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam sagittis
gravida odio vitae ultrices. Nulla facilisi. Maecenas pulvinar, tellus ut biben
dum semper, nibh tellus auctor nulla, in dignissim nisi ipsum id arcu. Nullam ti
ncidunt arcu malesuada turpis faucibus in adipiscing enim mattis. Fusce augue ma
gna, scelerisque sollicitudin egestas in, cursus eu sapien. Pellentesque tempor
risus at lectus convallis a convallis orci ornare. Integer tristique aliquam leo
vel interdum. |
| 22 |
| 23 Phasellus quis dictum nisi. Curabitur at enim non felis pharetra imperdiet. Duis
tempus massa eu leo varius porta. Vestibulum sodales nulla at purus tincidunt u
ltrices. Nam euismod posuere nibh, nec sodales magna luctus ac. Ut commodo hendr
erit mauris vitae gravida. In interdum justo ut sem eleifend convallis. Donec cu
rsus molestie elementum. Suspendisse at nisl tellus, vel consequat mauris. Nulla
m non justo nibh. |
| 24 |
| 25 Maecenas varius sollicitudin libero, nec feugiat turpis facilisis eget. Quisque
et sem risus. Aenean a magna quis purus hendrerit mattis eu vel lorem. Aenean fr
ingilla diam eget tortor lacinia sed mollis eros feugiat. Quisque ac purus sapie
n. Nullam quis tellus vel magna convallis tincidunt. Donec eget ligula at libero
tincidunt congue ut ut lacus. Integer dignissim aliquet congue. Pellentesque se
d risus vitae lorem porta viverra ac eu risus. Vivamus congue suscipit odio pulv
inar aliquet. Aliquam porttitor nunc non sapien auctor et vehicula augue molesti
e. |
| 26 |
| 27 Aliquam et dui ac sem tempus dictum. Fusce arcu nulla, viverra sit amet suscipit
quis, malesuada at felis. Fusce ut diam felis. Fusce id ligula non eros ferment
um sodales in nec quam. Donec tempor bibendum arcu ac adipiscing. Praesent nisl
lectus, tempor ut vehicula eget, mattis a justo. Mauris condimentum luctus eros
a varius. Morbi mollis elit eget velit convallis eu sodales odio egestas. Cum so
ciis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
Vivamus interdum, metus sit amet varius varius, lectus eros semper risus, sed sa
gittis ipsum libero in sapien. Nam lacinia nulla vitae magna facilisis scelerisq
ue. Lorem ipsum dolor sit amet, consectetur adipiscing elit. |
| 28 |
| 29 Donec gravida dignissim eleifend. Aliquam vel tincidunt tortor. Curabitur massa
ante, blandit a auctor at, ullamcorper sed nisl. Class aptent taciti sociosqu ad
litora torquent per conubia nostra, per inceptos himenaeos. Suspendisse ut feli
s a eros egestas ultricies et quis mi. Vivamus ut risus massa. Donec nec ornare
erat. Aliquam ornare, lorem a rhoncus aliquam, tellus diam tincidunt tellus, a m
attis nunc ante ac arcu. Curabitur nec metus id risus commodo ullamcorper eu ut
tortor." |
| 30 |
| 31 # Create a database which needs a multiple overflow pages to test the |
| 32 # transition from main page to overflow, and then overflow to |
| 33 # overflow. |
| 34 do_test recover-overflow-1.0 { |
| 35 db eval { |
| 36 DROP TABLE IF EXISTS overflow; |
| 37 CREATE TABLE overflow (value TEXT); |
| 38 INSERT INTO overflow VALUES ($lorem); |
| 39 |
| 40 DROP TABLE IF EXISTS overflow_recover; |
| 41 CREATE VIRTUAL TABLE temp.overflow_recover USING recover( |
| 42 overflow, |
| 43 value TEXT |
| 44 ); |
| 45 } |
| 46 |
| 47 # Should have root page, leaf page, and 2 overflow pages, because |
| 48 # length(value) is more than 2x page_size. |
| 49 execsql { |
| 50 PRAGMA page_count; |
| 51 PRAGMA page_size; |
| 52 SELECT rowid, TYPEOF(value), length(value), value FROM overflow_recover; |
| 53 } |
| 54 } [list 4 1024 1 text [string length $lorem] $lorem] |
| 55 |
| 56 # No overflow. [1024-35 == 990, overhead of 1-byte rowid, 2-byte |
| 57 # record length, 1-byte header length, 2-byte field type.] |
| 58 set substr [string range $lorem 0 985] |
| 59 do_test recover-overflow-1.1 { |
| 60 db eval { |
| 61 DROP TABLE IF EXISTS overflow; |
| 62 CREATE TABLE overflow (value TEXT); |
| 63 INSERT INTO overflow VALUES ($substr); |
| 64 |
| 65 DROP TABLE IF EXISTS overflow_recover; |
| 66 CREATE VIRTUAL TABLE temp.overflow_recover USING recover( |
| 67 overflow, |
| 68 value TEXT |
| 69 ); |
| 70 } |
| 71 |
| 72 # Trim to remove excess pages from prior tests. |
| 73 db eval {VACUUM} |
| 74 |
| 75 execsql { |
| 76 PRAGMA page_count; |
| 77 PRAGMA page_size; |
| 78 SELECT rowid, TYPEOF(value), length(value), value FROM overflow_recover; |
| 79 } |
| 80 } [list 2 1024 1 text [string length $substr] $substr] |
| 81 |
| 82 # One byte of overflow. |
| 83 set substr [string range $lorem 0 986] |
| 84 do_test recover-overflow-1.2 { |
| 85 db eval { |
| 86 DROP TABLE IF EXISTS overflow; |
| 87 CREATE TABLE overflow (value TEXT); |
| 88 INSERT INTO overflow VALUES ($substr); |
| 89 |
| 90 DROP TABLE IF EXISTS overflow_recover; |
| 91 CREATE VIRTUAL TABLE temp.overflow_recover USING recover( |
| 92 overflow, |
| 93 value TEXT |
| 94 ); |
| 95 } |
| 96 |
| 97 # Trim to remove excess pages from prior tests. |
| 98 db eval {VACUUM} |
| 99 |
| 100 execsql { |
| 101 PRAGMA page_count; |
| 102 PRAGMA page_size; |
| 103 SELECT rowid, TYPEOF(value), length(value), value FROM overflow_recover; |
| 104 } |
| 105 } [list 3 1024 1 text [string length $substr] $substr] |
| 106 |
| 107 # One full overflow page, plus maxLocal in-leaf. [985+1020] |
| 108 set substr [string range $lorem 0 2005] |
| 109 do_test recover-overflow-1.3 { |
| 110 db eval { |
| 111 DROP TABLE IF EXISTS overflow; |
| 112 CREATE TABLE overflow (value TEXT); |
| 113 INSERT INTO overflow VALUES ($substr); |
| 114 |
| 115 DROP TABLE IF EXISTS overflow_recover; |
| 116 CREATE VIRTUAL TABLE temp.overflow_recover USING recover( |
| 117 overflow, |
| 118 value TEXT |
| 119 ); |
| 120 } |
| 121 |
| 122 # Trim to remove excess pages from prior tests. |
| 123 db eval {VACUUM} |
| 124 |
| 125 execsql { |
| 126 PRAGMA page_count; |
| 127 PRAGMA page_size; |
| 128 SELECT rowid, TYPEOF(value), length(value), value FROM overflow_recover; |
| 129 } |
| 130 } [list 3 1024 1 text [string length $substr] $substr] |
| 131 |
| 132 # Overflow to a second overflow page. |
| 133 set substr [string range $lorem 0 2006] |
| 134 do_test recover-overflow-1.4 { |
| 135 db eval { |
| 136 DROP TABLE IF EXISTS overflow; |
| 137 CREATE TABLE overflow (value TEXT); |
| 138 INSERT INTO overflow VALUES ($substr); |
| 139 |
| 140 DROP TABLE IF EXISTS overflow_recover; |
| 141 CREATE VIRTUAL TABLE temp.overflow_recover USING recover( |
| 142 overflow, |
| 143 value TEXT |
| 144 ); |
| 145 } |
| 146 |
| 147 # Trim to remove excess pages from prior tests. |
| 148 db eval {VACUUM} |
| 149 |
| 150 execsql { |
| 151 PRAGMA page_count; |
| 152 PRAGMA page_size; |
| 153 SELECT rowid, TYPEOF(value), length(value), value FROM overflow_recover; |
| 154 } |
| 155 } [list 4 1024 1 text [string length $substr] $substr] |
| 156 |
| 157 finish_test |
OLD | NEW |