AryaWu/sqlite
0
1# 2019-04-112#3# The author disclaims copyright to this source code. In place of4# 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. The12# focus of this file is testing the sqlite_dbpage virtual table.13#14 15set testdir [file dirname $argv0]16source $testdir/tester.tcl17set testprefix dbdata18 19ifcapable !vtab||!compound {20 finish_test21 return22}23if { [catch { db enable_load_extension 1 }]24 || [catch { db eval { SELECT load_extension('../dbdata') } }] 25} {26 finish_test27 return28}29 30do_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');34}35 36do_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'45}46 47breakpoint48do_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'63}64 65set big [string repeat big 2000]66do_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} $big70 71do_execsql_test 1.4 {72 DELETE FROM t1;73 INSERT INTO t1 VALUES(NULL, randomblob(5050));74}75do_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}]80 81#-------------------------------------------------------------------------82reset_db83db enable_load_extension 184db eval { SELECT load_extension('../dbdata') }85 86do_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<1091 )92 INSERT INTO t1 SELECT randomblob(900) FROM s;93}94 95do_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 2199}100 101do_execsql_test 2.2 {102 SELECT * FROM sqlite_dbptr WHERE pgno=3;103} {104 3 24 3 23105}106 107do_execsql_test 2.3 {108 SELECT * FROM sqlite_dbptr109} {110 2 25 2 6 2 7 2 9 2 11 2 13 2 15 2 17 2 19 2 21111 3 24 3 23112}113 114 115finish_test116 