1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
|
# 2010 March 25
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
#
# This file implements tests to verify that ticket [cbd054fa6b] has been
# fixed.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
ifcapable !stat4&&!stat3 {
finish_test
return
}
proc s {blob} {
set ret ""
binary scan $blob c* bytes
foreach b $bytes {
set t [binary format c $b]
if {[string is print $t]} {
append ret $t
} else {
append ret .
}
}
return $ret
}
db function s s
do_test tkt-cbd05-1.1 {
db eval {
CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT UNIQUE NOT NULL);
CREATE INDEX t1_x ON t1(b);
INSERT INTO t1 VALUES (NULL, '');
INSERT INTO t1 VALUES (NULL, 'A');
INSERT INTO t1 VALUES (NULL, 'B');
INSERT INTO t1 VALUES (NULL, 'C');
INSERT INTO t1 VALUES (NULL, 'D');
INSERT INTO t1 VALUES (NULL, 'E');
INSERT INTO t1 VALUES (NULL, 'F');
INSERT INTO t1 VALUES (NULL, 'G');
INSERT INTO t1 VALUES (NULL, 'H');
INSERT INTO t1 VALUES (NULL, 'I');
SELECT count(*) FROM t1;
}
} {10}
do_test tkt-cbd05-1.2 {
db eval { ANALYZE; }
ifcapable stat4 {
db eval {
PRAGMA writable_schema = 1;
CREATE VIEW vvv AS
SELECT tbl,idx,neq,nlt,ndlt,test_extract(sample,0) AS sample
FROM sqlite_stat4;
PRAGMA writable_schema = 0;
}
} else {
db eval {
CREATE VIEW vvv AS
SELECT tbl,idx,neq,nlt,ndlt,sample FROM sqlite_stat3;
}
}
} {}
do_test tkt-cbd05-1.3 {
execsql {
SELECT tbl,idx,group_concat(s(sample),' ')
FROM vvv
WHERE idx = 't1_x'
GROUP BY tbl,idx
}
} {t1 t1_x { A B C D E F G H I}}
do_test tkt-cbd05-2.1 {
db eval {
DROP TABLE t1;
CREATE TABLE t1(a INTEGER PRIMARY KEY, b BLOB UNIQUE NOT NULL);
CREATE INDEX t1_x ON t1(b);
INSERT INTO t1 VALUES(NULL, X'');
INSERT INTO t1 VALUES(NULL, X'41');
INSERT INTO t1 VALUES(NULL, X'42');
INSERT INTO t1 VALUES(NULL, X'43');
INSERT INTO t1 VALUES(NULL, X'44');
INSERT INTO t1 VALUES(NULL, X'45');
INSERT INTO t1 VALUES(NULL, X'46');
INSERT INTO t1 VALUES(NULL, X'47');
INSERT INTO t1 VALUES(NULL, X'48');
INSERT INTO t1 VALUES(NULL, X'49');
SELECT count(*) FROM t1;
}
} {10}
do_test tkt-cbd05-2.2 {
db eval {
ANALYZE;
}
} {}
do_test tkt-cbd05-2.3 {
execsql {
SELECT tbl,idx,group_concat(s(sample),' ')
FROM vvv
WHERE idx = 't1_x'
GROUP BY tbl,idx
}
} {t1 t1_x { A B C D E F G H I}}
finish_test
|