1# 2019-04-11 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. The 12# focus of this file is testing the sqlite_dbpage virtual table. 13# 14 15set testdir [file dirname $argv0] 16source $testdir/tester.tcl 17set testprefix dbdata 18 19ifcapable !vtab||!compound { 20 finish_test 21 return 22} 23db enable_load_extension 1 24if { [catch { db eval { SELECT load_extension('../dbdata') } }] } { 25 finish_test 26 return 27} 28 29do_execsql_test 1.0 { 30 CREATE TABLE T1(a, b); 31 INSERT INTO t1(rowid, a ,b) VALUES(5, 'v', 'five'); 32 INSERT INTO t1(rowid, a, b) VALUES(10, 'x', 'ten'); 33} 34 35do_execsql_test 1.1 { 36 SELECT pgno, cell, field, quote(value) FROM sqlite_dbdata WHERE pgno=2; 37} { 38 2 0 -1 5 39 2 0 0 'v' 40 2 0 1 'five' 41 2 1 -1 10 42 2 1 0 'x' 43 2 1 1 'ten' 44} 45 46breakpoint 47do_execsql_test 1.2 { 48 SELECT pgno, cell, field, quote(value) FROM sqlite_dbdata; 49} { 50 1 0 -1 1 51 1 0 0 'table' 52 1 0 1 'T1' 53 1 0 2 'T1' 54 1 0 3 2 55 1 0 4 {'CREATE TABLE T1(a, b)'} 56 2 0 -1 5 57 2 0 0 'v' 58 2 0 1 'five' 59 2 1 -1 10 60 2 1 0 'x' 61 2 1 1 'ten' 62} 63 64set big [string repeat big 2000] 65do_execsql_test 1.3 { 66 INSERT INTO t1 VALUES(NULL, $big); 67 SELECT value FROM sqlite_dbdata WHERE pgno=2 AND cell=2 AND field=1; 68} $big 69 70#------------------------------------------------------------------------- 71reset_db 72db enable_load_extension 1 73db eval { SELECT load_extension('../dbdata') } 74 75do_execsql_test 2.0 { 76 CREATE TABLE t1(a); 77 CREATE INDEX i1 ON t1(a); 78 WITH s(i) AS ( 79 SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<10 80 ) 81 INSERT INTO t1 SELECT randomblob(900) FROM s; 82} 83 84do_execsql_test 2.1 { 85 SELECT * FROM sqlite_dbptr WHERE pgno=2; 86} { 87 2 25 2 6 2 7 2 9 2 11 2 13 2 15 2 17 2 19 2 21 88} 89 90do_execsql_test 2.2 { 91 SELECT * FROM sqlite_dbptr WHERE pgno=3; 92} { 93 3 24 3 23 94} 95 96do_execsql_test 2.3 { 97 SELECT * FROM sqlite_dbptr 98} { 99 2 25 2 6 2 7 2 9 2 11 2 13 2 15 2 17 2 19 2 21 100 3 24 3 23 101} 102 103 104finish_test 105