JS error message and doc typos reported in the forum. No code changes.
[sqlite.git] / test / dbdata.test
blob5b1150c78f18322e8f9dfde6bdde6bfd6d686369
1 # 2019-04-11
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.  The
12 # focus of this file is testing the sqlite_dbpage virtual table.
15 set testdir [file dirname $argv0]
16 source $testdir/tester.tcl
17 set testprefix dbdata
19 ifcapable !vtab||!compound {
20   finish_test
21   return
23 if { [catch { db enable_load_extension 1 }]
24   || [catch { db eval { SELECT load_extension('../dbdata') } }] 
25 } {
26   finish_test
27   return
30 do_execsql_test 1.0 {
31   CREATE TABLE T1(a, b);
32   INSERT INTO t1(rowid, a ,b) VALUES(5, 'v', 'five');
33   INSERT INTO t1(rowid, a, b) VALUES(10, 'x', 'ten');
36 do_execsql_test 1.1 {
37   SELECT pgno, cell, field, quote(value) FROM sqlite_dbdata WHERE pgno=2;
38 } {
39   2 0 -1 5 
40   2 0  0 'v' 
41   2 0  1 'five' 
42   2 1 -1 10 
43   2 1  0 'x' 
44   2 1  1 'ten'
47 breakpoint
48 do_execsql_test 1.2 {
49   SELECT pgno, cell, field, quote(value) FROM sqlite_dbdata;
50 } {
51   1 0 -1 1 
52   1 0 0 'table' 
53   1 0 1 'T1' 
54   1 0 2 'T1' 
55   1 0 3 2 
56   1 0 4 {'CREATE TABLE T1(a, b)'}
57   2 0 -1 5 
58   2 0  0 'v' 
59   2 0  1 'five' 
60   2 1 -1 10 
61   2 1  0 'x' 
62   2 1  1 'ten'
65 set big [string repeat big 2000]
66 do_execsql_test 1.3 {
67   INSERT INTO t1 VALUES(NULL, $big);
68   SELECT value FROM sqlite_dbdata WHERE pgno=2 AND cell=2 AND field=1;
69 } $big
71 do_execsql_test 1.4 {
72   DELETE FROM t1;
73   INSERT INTO t1 VALUES(NULL, randomblob(5050));
75 do_test 1.5 {
76   execsql {
77     SELECT quote(value) FROM sqlite_dbdata WHERE pgno=2 AND cell=0 AND field=1;
78   }
79 } [db one {SELECT quote(b) FROM t1}]
81 #-------------------------------------------------------------------------
82 reset_db
83 db enable_load_extension 1
84 db eval { SELECT load_extension('../dbdata') }
86 do_execsql_test 2.0 {
87   CREATE TABLE t1(a);
88   CREATE INDEX i1 ON t1(a);
89   WITH s(i) AS (
90     SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<10
91   )
92   INSERT INTO t1 SELECT randomblob(900) FROM s;
95 do_execsql_test 2.1 {
96   SELECT * FROM sqlite_dbptr WHERE pgno=2;
97 } {
98   2 25   2 6   2 7   2 9   2 11   2 13   2 15   2 17   2 19   2 21
101 do_execsql_test 2.2 {
102   SELECT * FROM sqlite_dbptr WHERE pgno=3;
103 } {
104   3 24   3 23
107 do_execsql_test 2.3 {
108   SELECT * FROM sqlite_dbptr
109 } {
110   2 25   2 6   2 7   2 9   2 11   2 13   2 15   2 17   2 19   2 21
111   3 24   3 23
115 finish_test