1c2c66a03Sshess# 2008 June 26 2c2c66a03Sshess# 3c2c66a03Sshess# The author disclaims copyright to this source code. In place of 4c2c66a03Sshess# a legal notice, here is a blessing: 5c2c66a03Sshess# 6c2c66a03Sshess# May you do good and not evil. 7c2c66a03Sshess# May you find forgiveness for yourself and forgive others. 8c2c66a03Sshess# May you share freely, never taking more than you give. 9c2c66a03Sshess# 10c2c66a03Sshess#************************************************************************* 11c2c66a03Sshess# This file implements regression tests for SQLite library. The focus 12c2c66a03Sshess# of this script is testing the FTS3 module's optimize() function. 13c2c66a03Sshess# 14c2c66a03Sshess 15c2c66a03Sshessset testdir [file dirname $argv0] 16c2c66a03Sshesssource $testdir/tester.tcl 1709977bb9Sdansource $testdir/fts3_common.tcl 18c2c66a03Sshess 19c2c66a03Sshess# If SQLITE_ENABLE_FTS3 is not defined, omit this file. 20c2c66a03Sshessifcapable !fts3 { 21c2c66a03Sshess finish_test 22c2c66a03Sshess return 23c2c66a03Sshess} 24c2c66a03Sshess 25c2c66a03Sshess#************************************************************************* 26c2c66a03Sshess# Utility function to check for the expected terms in the segment 27c2c66a03Sshess# level/index. _all version does same but for entire index. 28c2c66a03Sshessproc check_terms {test level index terms} { 2909977bb9Sdan set where "level = $level AND idx = $index" 3009977bb9Sdan do_test $test.terms [list fts3_terms t1 $where] $terms 31c2c66a03Sshess} 32c2c66a03Sshessproc check_terms_all {test terms} { 3309977bb9Sdan do_test $test.terms [list fts3_terms t1 1] $terms 34c2c66a03Sshess} 35c2c66a03Sshess 36c2c66a03Sshess# Utility function to check for the expected doclist for the term in 37c2c66a03Sshess# segment level/index. _all version does same for entire index. 38c2c66a03Sshessproc check_doclist {test level index term doclist} { 3909977bb9Sdan set where "level = $level AND idx = $index" 4009977bb9Sdan do_test $test.doclist [list fts3_doclist t1 $term $where] $doclist 41c2c66a03Sshess} 42c2c66a03Sshessproc check_doclist_all {test term doclist} { 4309977bb9Sdan do_test $test.doclist [list fts3_doclist t1 $term 1] $doclist 44c2c66a03Sshess} 45c2c66a03Sshess 46c2c66a03Sshess#************************************************************************* 47c2c66a03Sshess# Test results when all rows are deleted and one is added back. 48c2c66a03Sshess# Previously older segments would continue to exist, but now the index 49c2c66a03Sshess# should be dropped when the table is empty. The results should look 50c2c66a03Sshess# exactly like we never added the earlier rows in the first place. 51c2c66a03Sshessdb eval { 52c2c66a03Sshess DROP TABLE IF EXISTS t1; 53c2c66a03Sshess CREATE VIRTUAL TABLE t1 USING fts3(c); 54c2c66a03Sshess INSERT INTO t1 (docid, c) VALUES (1, 'This is a test'); 55c2c66a03Sshess INSERT INTO t1 (docid, c) VALUES (2, 'That was a test'); 56c2c66a03Sshess INSERT INTO t1 (docid, c) VALUES (3, 'This is a test'); 57c2c66a03Sshess DELETE FROM t1 WHERE 1=1; -- Delete each row rather than dropping table. 58c2c66a03Sshess INSERT INTO t1 (docid, c) VALUES (1, 'This is a test'); 59c2c66a03Sshess} 60c2c66a03Sshess 61c2c66a03Sshess# Should be a single initial segment. 62c2c66a03Sshessdo_test fts3d-1.segments { 63c2c66a03Sshess execsql { 64c2c66a03Sshess SELECT level, idx FROM t1_segdir ORDER BY level, idx; 65c2c66a03Sshess } 66c2c66a03Sshess} {0 0} 67c2c66a03Sshessdo_test fts3d-1.matches { 68c2c66a03Sshess execsql { 69c2c66a03Sshess SELECT OFFSETS(t1) FROM t1 70c2c66a03Sshess WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY docid; 71c2c66a03Sshess } 72c2c66a03Sshess} {{0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4}} 73c2c66a03Sshess 74c2c66a03Sshesscheck_terms_all fts3d-1.1 {a is test this} 75c2c66a03Sshesscheck_doclist_all fts3d-1.1.1 a {[1 0[2]]} 76c2c66a03Sshesscheck_doclist_all fts3d-1.1.2 is {[1 0[1]]} 77c2c66a03Sshesscheck_doclist_all fts3d-1.1.3 test {[1 0[3]]} 78c2c66a03Sshesscheck_doclist_all fts3d-1.1.4 this {[1 0[0]]} 79c2c66a03Sshess 80c2c66a03Sshesscheck_terms fts3d-1.2 0 0 {a is test this} 81c2c66a03Sshesscheck_doclist fts3d-1.2.1 0 0 a {[1 0[2]]} 82c2c66a03Sshesscheck_doclist fts3d-1.2.2 0 0 is {[1 0[1]]} 83c2c66a03Sshesscheck_doclist fts3d-1.2.3 0 0 test {[1 0[3]]} 84c2c66a03Sshesscheck_doclist fts3d-1.2.4 0 0 this {[1 0[0]]} 85c2c66a03Sshess 867d9ef0d0Sshess#************************************************************************* 877d9ef0d0Sshess# Test results when everything is optimized manually. 887d9ef0d0Sshess# NOTE(shess): This is a copy of fts3c-1.3. I've pulled a copy here 897d9ef0d0Sshess# because fts3d-2 and fts3d-3 should have identical results. 907d9ef0d0Sshessdb eval { 917d9ef0d0Sshess DROP TABLE IF EXISTS t1; 927d9ef0d0Sshess CREATE VIRTUAL TABLE t1 USING fts3(c); 937d9ef0d0Sshess INSERT INTO t1 (docid, c) VALUES (1, 'This is a test'); 947d9ef0d0Sshess INSERT INTO t1 (docid, c) VALUES (2, 'That was a test'); 957d9ef0d0Sshess INSERT INTO t1 (docid, c) VALUES (3, 'This is a test'); 967d9ef0d0Sshess DELETE FROM t1 WHERE docid IN (1,3); 977d9ef0d0Sshess DROP TABLE IF EXISTS t1old; 987d9ef0d0Sshess ALTER TABLE t1 RENAME TO t1old; 997d9ef0d0Sshess CREATE VIRTUAL TABLE t1 USING fts3(c); 1007d9ef0d0Sshess INSERT INTO t1 (docid, c) SELECT docid, c FROM t1old; 1017d9ef0d0Sshess DROP TABLE t1old; 1027d9ef0d0Sshess} 1037d9ef0d0Sshess 1047d9ef0d0Sshess# Should be a single optimal segment with the same logical results. 1057d9ef0d0Sshessdo_test fts3d-2.segments { 1067d9ef0d0Sshess execsql { 1077d9ef0d0Sshess SELECT level, idx FROM t1_segdir ORDER BY level, idx; 1087d9ef0d0Sshess } 1097d9ef0d0Sshess} {0 0} 1107d9ef0d0Sshessdo_test fts3d-2.matches { 1117d9ef0d0Sshess execsql { 1127d9ef0d0Sshess SELECT OFFSETS(t1) FROM t1 1137d9ef0d0Sshess WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY docid; 1147d9ef0d0Sshess } 1157d9ef0d0Sshess} {{0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4}} 1167d9ef0d0Sshess 1177d9ef0d0Sshesscheck_terms_all fts3d-2.1 {a test that was} 1187d9ef0d0Sshesscheck_doclist_all fts3d-2.1.1 a {[2 0[2]]} 1197d9ef0d0Sshesscheck_doclist_all fts3d-2.1.2 test {[2 0[3]]} 1207d9ef0d0Sshesscheck_doclist_all fts3d-2.1.3 that {[2 0[0]]} 1217d9ef0d0Sshesscheck_doclist_all fts3d-2.1.4 was {[2 0[1]]} 1227d9ef0d0Sshess 1237d9ef0d0Sshesscheck_terms fts3d-2.2 0 0 {a test that was} 1247d9ef0d0Sshesscheck_doclist fts3d-2.2.1 0 0 a {[2 0[2]]} 1257d9ef0d0Sshesscheck_doclist fts3d-2.2.2 0 0 test {[2 0[3]]} 1267d9ef0d0Sshesscheck_doclist fts3d-2.2.3 0 0 that {[2 0[0]]} 1277d9ef0d0Sshesscheck_doclist fts3d-2.2.4 0 0 was {[2 0[1]]} 1287d9ef0d0Sshess 1297d9ef0d0Sshess#************************************************************************* 1307d9ef0d0Sshess# Test results when everything is optimized via optimize(). 1317d9ef0d0Sshessdb eval { 1327d9ef0d0Sshess DROP TABLE IF EXISTS t1; 1337d9ef0d0Sshess CREATE VIRTUAL TABLE t1 USING fts3(c); 1347d9ef0d0Sshess INSERT INTO t1 (docid, c) VALUES (1, 'This is a test'); 1357d9ef0d0Sshess INSERT INTO t1 (docid, c) VALUES (2, 'That was a test'); 1367d9ef0d0Sshess INSERT INTO t1 (docid, c) VALUES (3, 'This is a test'); 1377d9ef0d0Sshess DELETE FROM t1 WHERE docid IN (1,3); 1387d9ef0d0Sshess SELECT OPTIMIZE(t1) FROM t1 LIMIT 1; 1397d9ef0d0Sshess} 1407d9ef0d0Sshess 1417d9ef0d0Sshess# Should be a single optimal segment with the same logical results. 1427d9ef0d0Sshessdo_test fts3d-3.segments { 1437d9ef0d0Sshess execsql { 1447d9ef0d0Sshess SELECT level, idx FROM t1_segdir ORDER BY level, idx; 1457d9ef0d0Sshess } 1467d9ef0d0Sshess} {0 0} 1477d9ef0d0Sshessdo_test fts3d-3.matches { 1487d9ef0d0Sshess execsql { 1497d9ef0d0Sshess SELECT OFFSETS(t1) FROM t1 1507d9ef0d0Sshess WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY docid; 1517d9ef0d0Sshess } 1527d9ef0d0Sshess} {{0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4}} 1537d9ef0d0Sshess 1547d9ef0d0Sshesscheck_terms_all fts3d-3.1 {a test that was} 1557d9ef0d0Sshesscheck_doclist_all fts3d-3.1.1 a {[2 0[2]]} 1567d9ef0d0Sshesscheck_doclist_all fts3d-3.1.2 test {[2 0[3]]} 1577d9ef0d0Sshesscheck_doclist_all fts3d-3.1.3 that {[2 0[0]]} 1587d9ef0d0Sshesscheck_doclist_all fts3d-3.1.4 was {[2 0[1]]} 1597d9ef0d0Sshess 1607d9ef0d0Sshesscheck_terms fts3d-3.2 0 0 {a test that was} 1617d9ef0d0Sshesscheck_doclist fts3d-3.2.1 0 0 a {[2 0[2]]} 1627d9ef0d0Sshesscheck_doclist fts3d-3.2.2 0 0 test {[2 0[3]]} 1637d9ef0d0Sshesscheck_doclist fts3d-3.2.3 0 0 that {[2 0[0]]} 1647d9ef0d0Sshesscheck_doclist fts3d-3.2.4 0 0 was {[2 0[1]]} 1657d9ef0d0Sshess 1667d9ef0d0Sshess#************************************************************************* 1677d9ef0d0Sshess# Test optimize() against a table involving segment merges. 1687d9ef0d0Sshess# NOTE(shess): Since there's no transaction, each of the INSERT/UPDATE 1697d9ef0d0Sshess# statements generates a segment. 1707d9ef0d0Sshessdb eval { 1717d9ef0d0Sshess DROP TABLE IF EXISTS t1; 1727d9ef0d0Sshess CREATE VIRTUAL TABLE t1 USING fts3(c); 1737d9ef0d0Sshess 1747d9ef0d0Sshess INSERT INTO t1 (rowid, c) VALUES (1, 'This is a test'); 1757d9ef0d0Sshess INSERT INTO t1 (rowid, c) VALUES (2, 'That was a test'); 1767d9ef0d0Sshess INSERT INTO t1 (rowid, c) VALUES (3, 'This is a test'); 1777d9ef0d0Sshess 1787d9ef0d0Sshess UPDATE t1 SET c = 'This is a test one' WHERE rowid = 1; 1797d9ef0d0Sshess UPDATE t1 SET c = 'That was a test one' WHERE rowid = 2; 1807d9ef0d0Sshess UPDATE t1 SET c = 'This is a test one' WHERE rowid = 3; 1817d9ef0d0Sshess 1827d9ef0d0Sshess UPDATE t1 SET c = 'This is a test two' WHERE rowid = 1; 1837d9ef0d0Sshess UPDATE t1 SET c = 'That was a test two' WHERE rowid = 2; 1847d9ef0d0Sshess UPDATE t1 SET c = 'This is a test two' WHERE rowid = 3; 1857d9ef0d0Sshess 1867d9ef0d0Sshess UPDATE t1 SET c = 'This is a test three' WHERE rowid = 1; 1877d9ef0d0Sshess UPDATE t1 SET c = 'That was a test three' WHERE rowid = 2; 1887d9ef0d0Sshess UPDATE t1 SET c = 'This is a test three' WHERE rowid = 3; 1897d9ef0d0Sshess 1907d9ef0d0Sshess UPDATE t1 SET c = 'This is a test four' WHERE rowid = 1; 1917d9ef0d0Sshess UPDATE t1 SET c = 'That was a test four' WHERE rowid = 2; 1927d9ef0d0Sshess UPDATE t1 SET c = 'This is a test four' WHERE rowid = 3; 1937d9ef0d0Sshess 1947d9ef0d0Sshess UPDATE t1 SET c = 'This is a test' WHERE rowid = 1; 1957d9ef0d0Sshess UPDATE t1 SET c = 'That was a test' WHERE rowid = 2; 1967d9ef0d0Sshess UPDATE t1 SET c = 'This is a test' WHERE rowid = 3; 1977d9ef0d0Sshess} 1987d9ef0d0Sshess 1997d9ef0d0Sshess# 2 segments in level 0, 1 in level 1 (18 segments created, 16 2007d9ef0d0Sshess# merged). 2017d9ef0d0Sshessdo_test fts3d-4.segments { 2027d9ef0d0Sshess execsql { 2037d9ef0d0Sshess SELECT level, idx FROM t1_segdir ORDER BY level, idx; 2047d9ef0d0Sshess } 2057d9ef0d0Sshess} {0 0 0 1 1 0} 2067d9ef0d0Sshess 2077d9ef0d0Sshessdo_test fts3d-4.matches { 2087d9ef0d0Sshess execsql { 2097d9ef0d0Sshess SELECT OFFSETS(t1) FROM t1 2107d9ef0d0Sshess WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY docid; 2117d9ef0d0Sshess } 2127d9ef0d0Sshess} [list {0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4} \ 2137d9ef0d0Sshess {0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4} \ 2147d9ef0d0Sshess {0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4}] 2157d9ef0d0Sshess 2167b96f2faSmistachkindb eval {SELECT c FROM t1 } 217c0caea21Sdancheck_terms_all fts3d-4.1 {a four is test that this was} 2187d9ef0d0Sshesscheck_doclist_all fts3d-4.1.1 a {[1 0[2]] [2 0[2]] [3 0[2]]} 2197d9ef0d0Sshesscheck_doclist_all fts3d-4.1.2 four {} 2207d9ef0d0Sshesscheck_doclist_all fts3d-4.1.3 is {[1 0[1]] [3 0[1]]} 221c0caea21Sdan#check_doclist_all fts3d-4.1.4 one {} 2227d9ef0d0Sshesscheck_doclist_all fts3d-4.1.5 test {[1 0[3]] [2 0[3]] [3 0[3]]} 2237d9ef0d0Sshesscheck_doclist_all fts3d-4.1.6 that {[2 0[0]]} 2247d9ef0d0Sshesscheck_doclist_all fts3d-4.1.7 this {[1 0[0]] [3 0[0]]} 225c0caea21Sdan#check_doclist_all fts3d-4.1.8 three {} 226c0caea21Sdan#check_doclist_all fts3d-4.1.9 two {} 2277d9ef0d0Sshesscheck_doclist_all fts3d-4.1.10 was {[2 0[1]]} 2287d9ef0d0Sshess 2297d9ef0d0Sshesscheck_terms fts3d-4.2 0 0 {a four test that was} 2307d9ef0d0Sshesscheck_doclist fts3d-4.2.1 0 0 a {[2 0[2]]} 2317d9ef0d0Sshesscheck_doclist fts3d-4.2.2 0 0 four {[2]} 2327d9ef0d0Sshesscheck_doclist fts3d-4.2.3 0 0 test {[2 0[3]]} 2337d9ef0d0Sshesscheck_doclist fts3d-4.2.4 0 0 that {[2 0[0]]} 2347d9ef0d0Sshesscheck_doclist fts3d-4.2.5 0 0 was {[2 0[1]]} 2357d9ef0d0Sshess 2367d9ef0d0Sshesscheck_terms fts3d-4.3 0 1 {a four is test this} 2377d9ef0d0Sshesscheck_doclist fts3d-4.3.1 0 1 a {[3 0[2]]} 2387d9ef0d0Sshesscheck_doclist fts3d-4.3.2 0 1 four {[3]} 2397d9ef0d0Sshesscheck_doclist fts3d-4.3.3 0 1 is {[3 0[1]]} 2407d9ef0d0Sshesscheck_doclist fts3d-4.3.4 0 1 test {[3 0[3]]} 2417d9ef0d0Sshesscheck_doclist fts3d-4.3.5 0 1 this {[3 0[0]]} 2427d9ef0d0Sshess 243c0caea21Sdancheck_terms fts3d-4.4 1 0 {a four is test that this was} 2447d9ef0d0Sshesscheck_doclist fts3d-4.4.1 1 0 a {[1 0[2]] [2 0[2]] [3 0[2]]} 245c0caea21Sdancheck_doclist fts3d-4.4.2 1 0 four {[2 0[4]] [3 0[4]]} 2467d9ef0d0Sshesscheck_doclist fts3d-4.4.3 1 0 is {[1 0[1]] [3 0[1]]} 247c0caea21Sdan#check_doclist fts3d-4.4.4 1 0 one {[1] [2] [3]} 2487d9ef0d0Sshesscheck_doclist fts3d-4.4.5 1 0 test {[1 0[3]] [2 0[3]] [3 0[3]]} 2497d9ef0d0Sshesscheck_doclist fts3d-4.4.6 1 0 that {[2 0[0]]} 2507d9ef0d0Sshesscheck_doclist fts3d-4.4.7 1 0 this {[1 0[0]] [3 0[0]]} 251c0caea21Sdan#check_doclist fts3d-4.4.8 1 0 three {[1] [2] [3]} 252c0caea21Sdan#check_doclist fts3d-4.4.9 1 0 two {[1] [2] [3]} 2537d9ef0d0Sshesscheck_doclist fts3d-4.4.10 1 0 was {[2 0[1]]} 2547d9ef0d0Sshess 2557d9ef0d0Sshess# Optimize should leave the result in the level of the highest-level 2567d9ef0d0Sshess# prior segment. 2577d9ef0d0Sshessdo_test fts3d-4.5 { 2587d9ef0d0Sshess execsql { 2597d9ef0d0Sshess SELECT OPTIMIZE(t1) FROM t1 LIMIT 1; 2607d9ef0d0Sshess SELECT level, idx FROM t1_segdir ORDER BY level, idx; 2617d9ef0d0Sshess } 2627d9ef0d0Sshess} {{Index optimized} 1 0} 2637d9ef0d0Sshess 2647d9ef0d0Sshess# Identical to fts3d-4.matches. 2657d9ef0d0Sshessdo_test fts3d-4.5.matches { 2667d9ef0d0Sshess execsql { 2677d9ef0d0Sshess SELECT OFFSETS(t1) FROM t1 2687d9ef0d0Sshess WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY docid; 2697d9ef0d0Sshess } 2707d9ef0d0Sshess} [list {0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4} \ 2717d9ef0d0Sshess {0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4} \ 2727d9ef0d0Sshess {0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4}] 2737d9ef0d0Sshess 2747d9ef0d0Sshesscheck_terms_all fts3d-4.5.1 {a is test that this was} 2757d9ef0d0Sshesscheck_doclist_all fts3d-4.5.1.1 a {[1 0[2]] [2 0[2]] [3 0[2]]} 2767d9ef0d0Sshesscheck_doclist_all fts3d-4.5.1.2 is {[1 0[1]] [3 0[1]]} 2777d9ef0d0Sshesscheck_doclist_all fts3d-4.5.1.3 test {[1 0[3]] [2 0[3]] [3 0[3]]} 2787d9ef0d0Sshesscheck_doclist_all fts3d-4.5.1.4 that {[2 0[0]]} 2797d9ef0d0Sshesscheck_doclist_all fts3d-4.5.1.5 this {[1 0[0]] [3 0[0]]} 2807d9ef0d0Sshesscheck_doclist_all fts3d-4.5.1.6 was {[2 0[1]]} 2817d9ef0d0Sshess 2827d9ef0d0Sshesscheck_terms fts3d-4.5.2 1 0 {a is test that this was} 2837d9ef0d0Sshesscheck_doclist fts3d-4.5.2.1 1 0 a {[1 0[2]] [2 0[2]] [3 0[2]]} 2847d9ef0d0Sshesscheck_doclist fts3d-4.5.2.2 1 0 is {[1 0[1]] [3 0[1]]} 2857d9ef0d0Sshesscheck_doclist fts3d-4.5.2.3 1 0 test {[1 0[3]] [2 0[3]] [3 0[3]]} 2867d9ef0d0Sshesscheck_doclist fts3d-4.5.2.4 1 0 that {[2 0[0]]} 2877d9ef0d0Sshesscheck_doclist fts3d-4.5.2.5 1 0 this {[1 0[0]] [3 0[0]]} 2887d9ef0d0Sshesscheck_doclist fts3d-4.5.2.6 1 0 was {[2 0[1]]} 2897d9ef0d0Sshess 2907d9ef0d0Sshess# Re-optimizing does nothing. 2917d9ef0d0Sshessdo_test fts3d-5.0 { 2927d9ef0d0Sshess execsql { 2937d9ef0d0Sshess SELECT OPTIMIZE(t1) FROM t1 LIMIT 1; 2947d9ef0d0Sshess SELECT level, idx FROM t1_segdir ORDER BY level, idx; 2957d9ef0d0Sshess } 2967d9ef0d0Sshess} {{Index already optimal} 1 0} 2977d9ef0d0Sshess 2987d9ef0d0Sshess# Even if we move things around, still does nothing. 299*0f0d3ddfSdrhsqlite3_db_config db DEFENSIVE 0 3007d9ef0d0Sshessdo_test fts3d-5.1 { 3017d9ef0d0Sshess execsql { 3027d9ef0d0Sshess UPDATE t1_segdir SET level = 2 WHERE level = 1 AND idx = 0; 3037d9ef0d0Sshess SELECT OPTIMIZE(t1) FROM t1 LIMIT 1; 3047d9ef0d0Sshess SELECT level, idx FROM t1_segdir ORDER BY level, idx; 3057d9ef0d0Sshess } 3067d9ef0d0Sshess} {{Index already optimal} 2 0} 307c2c66a03Sshess 30898655a69Sdrh 30998655a69Sdrh# ALTER TABLE RENAME should work regardless of the database encoding. 31098655a69Sdrh# 31198655a69Sdrhdo_test fts3d-6.0 { 31298655a69Sdrh db close 31398655a69Sdrh forcedelete test.db 31498655a69Sdrh sqlite3 db test.db 31598655a69Sdrh db eval { 31698655a69Sdrh PRAGMA encoding=UTF8; 31798655a69Sdrh CREATE VIRTUAL TABLE fts USING fts3(a,b,c); 31898655a69Sdrh SELECT name FROM sqlite_master WHERE name GLOB '???_*' ORDER BY 1; 31998655a69Sdrh } 32098655a69Sdrh} {fts_content fts_segdir fts_segments} 32198655a69Sdrhdo_test fts3d-6.1 { 32298655a69Sdrh db eval { 32398655a69Sdrh ALTER TABLE fts RENAME TO xyz; 32498655a69Sdrh SELECT name FROM sqlite_master WHERE name GLOB '???_*' ORDER BY 1; 32598655a69Sdrh } 32698655a69Sdrh} {xyz_content xyz_segdir xyz_segments} 32798655a69Sdrhdo_test fts3d-6.2 { 32898655a69Sdrh db close 32998655a69Sdrh forcedelete test.db 33098655a69Sdrh sqlite3 db test.db 33198655a69Sdrh db eval { 33298655a69Sdrh PRAGMA encoding=UTF16le; 33398655a69Sdrh CREATE VIRTUAL TABLE fts USING fts3(a,b,c); 33498655a69Sdrh SELECT name FROM sqlite_master WHERE name GLOB '???_*' ORDER BY 1; 33598655a69Sdrh } 33698655a69Sdrh} {fts_content fts_segdir fts_segments} 33798655a69Sdrhdo_test fts3d-6.3 { 33898655a69Sdrh db eval { 33998655a69Sdrh ALTER TABLE fts RENAME TO xyz; 34098655a69Sdrh SELECT name FROM sqlite_master WHERE name GLOB '???_*' ORDER BY 1; 34198655a69Sdrh } 34298655a69Sdrh} {xyz_content xyz_segdir xyz_segments} 34398655a69Sdrhdo_test fts3d-6.4 { 34498655a69Sdrh db close 34598655a69Sdrh forcedelete test.db 34698655a69Sdrh sqlite3 db test.db 34798655a69Sdrh db eval { 34898655a69Sdrh PRAGMA encoding=UTF16be; 34998655a69Sdrh CREATE VIRTUAL TABLE fts USING fts3(a,b,c); 35098655a69Sdrh SELECT name FROM sqlite_master WHERE name GLOB '???_*' ORDER BY 1; 35198655a69Sdrh } 35298655a69Sdrh} {fts_content fts_segdir fts_segments} 35398655a69Sdrhdo_test fts3d-6.5 { 35498655a69Sdrh db eval { 35598655a69Sdrh ALTER TABLE fts RENAME TO xyz; 35698655a69Sdrh SELECT name FROM sqlite_master WHERE name GLOB '???_*' ORDER BY 1; 35798655a69Sdrh } 35898655a69Sdrh} {xyz_content xyz_segdir xyz_segments} 35982d25da5Sdan 36082d25da5Sdan# ALTER TABLE RENAME on an FTS3 table following an incr-merge op. 36182d25da5Sdan# 36282d25da5Sdando_test fts3d-6.6 { 36382d25da5Sdan execsql { INSERT INTO xyz(xyz) VALUES('merge=2,2') } 36482d25da5Sdan sqlite3 db test.db 36582d25da5Sdan execsql { 36682d25da5Sdan ALTER TABLE xyz RENAME TO ott; 36782d25da5Sdan SELECT name FROM sqlite_master WHERE name GLOB '???_*' ORDER BY 1; 36882d25da5Sdan } 36982d25da5Sdan} {ott_content ott_segdir ott_segments ott_stat} 37098655a69Sdrh 37198655a69Sdrh 372c2c66a03Sshessfinish_test 373