1# 2010 March 25 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# 12# This file implements tests to verify that ticket [cbd054fa6b] has been 13# fixed. 14# 15 16set testdir [file dirname $argv0] 17source $testdir/tester.tcl 18 19ifcapable !stat2 { 20 finish_test 21 return 22} 23 24do_test tkt-cbd05-1.1 { 25 db eval { 26 CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT UNIQUE NOT NULL); 27 CREATE INDEX t1_x ON t1(b); 28 INSERT INTO t1 VALUES (NULL, ''); 29 INSERT INTO t1 VALUES (NULL, 'A'); 30 INSERT INTO t1 VALUES (NULL, 'B'); 31 INSERT INTO t1 VALUES (NULL, 'C'); 32 INSERT INTO t1 VALUES (NULL, 'D'); 33 INSERT INTO t1 VALUES (NULL, 'E'); 34 INSERT INTO t1 VALUES (NULL, 'F'); 35 INSERT INTO t1 VALUES (NULL, 'G'); 36 INSERT INTO t1 VALUES (NULL, 'H'); 37 INSERT INTO t1 VALUES (NULL, 'I'); 38 SELECT count(*) FROM t1; 39 } 40} {10} 41do_test tkt-cbd05-1.2 { 42 db eval { 43 ANALYZE; 44 } 45} {} 46do_test tkt-cbd05-1.3 { 47 execsql { 48 SELECT tbl,idx,group_concat(sample,' ') 49 FROM sqlite_stat2 50 WHERE idx = 't1_x' 51 GROUP BY tbl,idx 52 } 53} {t1 t1_x { A B C D E F G H I}} 54 55do_test tkt-cbd05-2.1 { 56 db eval { 57 DROP TABLE t1; 58 CREATE TABLE t1(a INTEGER PRIMARY KEY, b BLOB UNIQUE NOT NULL); 59 CREATE INDEX t1_x ON t1(b); 60 INSERT INTO t1 VALUES(NULL, X''); 61 INSERT INTO t1 VALUES(NULL, X'41'); 62 INSERT INTO t1 VALUES(NULL, X'42'); 63 INSERT INTO t1 VALUES(NULL, X'43'); 64 INSERT INTO t1 VALUES(NULL, X'44'); 65 INSERT INTO t1 VALUES(NULL, X'45'); 66 INSERT INTO t1 VALUES(NULL, X'46'); 67 INSERT INTO t1 VALUES(NULL, X'47'); 68 INSERT INTO t1 VALUES(NULL, X'48'); 69 INSERT INTO t1 VALUES(NULL, X'49'); 70 SELECT count(*) FROM t1; 71 } 72} {10} 73do_test tkt-cbd05-2.2 { 74 db eval { 75 ANALYZE; 76 } 77} {} 78do_test tkt-cbd05-2.3 { 79 execsql { 80 SELECT tbl,idx,group_concat(sample,' ') 81 FROM sqlite_stat2 82 WHERE idx = 't1_x' 83 GROUP BY tbl,idx 84 } 85} {t1 t1_x { A B C D E F G H I}} 86 87finish_test 88