3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
11 # This file implements regression tests for SQLite library.
13 # This file implements tests for how the recover module handles cell
18 set testdir [file dirname $argv0]
19 source $testdir/tester.tcl
21 set lorem "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam sagittis gravida odio vitae ultrices. Nulla facilisi. Maecenas pulvinar, tellus ut bibendum semper, nibh tellus auctor nulla, in dignissim nisi ipsum id arcu. Nullam tincidunt arcu malesuada turpis faucibus in adipiscing enim mattis. Fusce augue magna, scelerisque sollicitudin egestas in, cursus eu sapien. Pellentesque tempor risus at lectus convallis a convallis orci ornare. Integer tristique aliquam leo vel interdum.
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 ultrices. Nam euismod posuere nibh, nec sodales magna luctus ac. Ut commodo hendrerit mauris vitae gravida. In interdum justo ut sem eleifend convallis. Donec cursus molestie elementum. Suspendisse at nisl tellus, vel consequat mauris. Nullam non justo nibh.
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 fringilla diam eget tortor lacinia sed mollis eros feugiat. Quisque ac purus sapien. Nullam quis tellus vel magna convallis tincidunt. Donec eget ligula at libero tincidunt congue ut ut lacus. Integer dignissim aliquet congue. Pellentesque sed risus vitae lorem porta viverra ac eu risus. Vivamus congue suscipit odio pulvinar aliquet. Aliquam porttitor nunc non sapien auctor et vehicula augue molestie.
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 fermentum 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 sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vivamus interdum, metus sit amet varius varius, lectus eros semper risus, sed sagittis ipsum libero in sapien. Nam lacinia nulla vitae magna facilisis scelerisque. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
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 felis 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 mattis nunc ante ac arcu. Curabitur nec metus id risus commodo ullamcorper eu ut tortor."
31 # Create a database which needs a multiple overflow pages to test the
32 # transition from main page to overflow, and then overflow to
34 do_test recover-overflow-1.0 {
36 DROP TABLE IF EXISTS overflow;
37 CREATE TABLE overflow (value TEXT);
38 INSERT INTO overflow VALUES ($lorem);
40 DROP TABLE IF EXISTS overflow_recover;
41 CREATE VIRTUAL TABLE temp.overflow_recover USING recover(
47 # Should have root page, leaf page, and 2 overflow pages, because
48 # length(value) is more than 2x page_size.
52 SELECT rowid, TYPEOF(value), length(value), value FROM overflow_recover;
54 } [list 4 1024 1 text [string length $lorem] $lorem]
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 {
61 DROP TABLE IF EXISTS overflow;
62 CREATE TABLE overflow (value TEXT);
63 INSERT INTO overflow VALUES ($substr);
65 DROP TABLE IF EXISTS overflow_recover;
66 CREATE VIRTUAL TABLE temp.overflow_recover USING recover(
72 # Trim to remove excess pages from prior tests.
78 SELECT rowid, TYPEOF(value), length(value), value FROM overflow_recover;
80 } [list 2 1024 1 text [string length $substr] $substr]
82 # One byte of overflow.
83 set substr [string range $lorem 0 986]
84 do_test recover-overflow-1.2 {
86 DROP TABLE IF EXISTS overflow;
87 CREATE TABLE overflow (value TEXT);
88 INSERT INTO overflow VALUES ($substr);
90 DROP TABLE IF EXISTS overflow_recover;
91 CREATE VIRTUAL TABLE temp.overflow_recover USING recover(
97 # Trim to remove excess pages from prior tests.
103 SELECT rowid, TYPEOF(value), length(value), value FROM overflow_recover;
105 } [list 3 1024 1 text [string length $substr] $substr]
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 {
111 DROP TABLE IF EXISTS overflow;
112 CREATE TABLE overflow (value TEXT);
113 INSERT INTO overflow VALUES ($substr);
115 DROP TABLE IF EXISTS overflow_recover;
116 CREATE VIRTUAL TABLE temp.overflow_recover USING recover(
122 # Trim to remove excess pages from prior tests.
128 SELECT rowid, TYPEOF(value), length(value), value FROM overflow_recover;
130 } [list 3 1024 1 text [string length $substr] $substr]
132 # Overflow to a second overflow page.
133 set substr [string range $lorem 0 2006]
134 do_test recover-overflow-1.4 {
136 DROP TABLE IF EXISTS overflow;
137 CREATE TABLE overflow (value TEXT);
138 INSERT INTO overflow VALUES ($substr);
140 DROP TABLE IF EXISTS overflow_recover;
141 CREATE VIRTUAL TABLE temp.overflow_recover USING recover(
147 # Trim to remove excess pages from prior tests.
153 SELECT rowid, TYPEOF(value), length(value), value FROM overflow_recover;
155 } [list 4 1024 1 text [string length $substr] $substr]