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 115 116 117 118 119 120 121 122 123 124 125 126 127
|
# 2018 December 28
#
# 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.
#
#***********************************************************************
#
# The tests in this file test edge cases surrounding DROP TABLE on
# virtual tables.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
ifcapable !vtab { finish_test ; return }
source $testdir/fts3_common.tcl
source $testdir/malloc_common.tcl
set testprefix vtabdrop
#-------------------------------------------------------------------------
# Test that if a DROP TABLE is executed against an rtree table, but the
# xDestroy() call fails, the rtree table is not dropped, the sqlite_master
# table is not modified and the internal schema remains intact.
#
ifcapable rtree {
do_execsql_test 1.0 {
CREATE VIRTUAL TABLE rt USING rtree(id, x1, x2);
CREATE TABLE t1(x, y);
INSERT INTO t1 VALUES(1, 2);
}
do_test 1.1 {
execsql {
BEGIN;
INSERT INTO t1 VALUES(3, 4);
}
db eval { SELECT * FROM t1 } {
catchsql { DROP TABLE rt }
}
execsql COMMIT
} {}
do_execsql_test 1.2 {
SELECT name FROM sqlite_master ORDER BY 1;
SELECT * FROM t1;
SELECT * FROM rt;
} {rt rt_node rt_parent rt_rowid t1 1 2 3 4}
db close
sqlite3 db test.db
do_execsql_test 1.3 {
SELECT name FROM sqlite_master ORDER BY 1;
} {rt rt_node rt_parent rt_rowid t1}
}
#-------------------------------------------------------------------------
# Same as tests 1.*, except with fts5 instead of rtree.
#
ifcapable fts5 {
reset_db
do_execsql_test 2.0 {
CREATE VIRTUAL TABLE ft USING fts5(x);
CREATE TABLE t1(x, y);
INSERT INTO t1 VALUES(1, 2);
}
do_test 2.1 {
execsql {
BEGIN;
INSERT INTO t1 VALUES(3, 4);
}
db eval { SELECT * FROM t1 } {
catchsql { DROP TABLE ft }
}
execsql COMMIT
} {}
do_execsql_test 2.2 {
SELECT name FROM sqlite_master ORDER BY 1;
} {ft ft_config ft_content ft_data ft_docsize ft_idx t1}
db close
sqlite3 db test.db
do_execsql_test 2.3 {
SELECT name FROM sqlite_master ORDER BY 1;
} {ft ft_config ft_content ft_data ft_docsize ft_idx t1}
}
#-------------------------------------------------------------------------
# Same as tests 1.*, except with fts3 instead of rtree.
#
ifcapable fts3 {
reset_db
do_execsql_test 2.0 {
CREATE VIRTUAL TABLE ft USING fts3(x);
CREATE TABLE t1(x, y);
INSERT INTO t1 VALUES(1, 2);
}
do_test 2.1 {
execsql {
BEGIN;
INSERT INTO t1 VALUES(3, 4);
}
db eval { SELECT * FROM t1 } {
catchsql { DROP TABLE ft }
}
execsql COMMIT
} {}
do_execsql_test 2.2 {
SELECT name FROM sqlite_master ORDER BY 1;
} {ft ft_content ft_segdir ft_segments sqlite_autoindex_ft_segdir_1 t1}
db close
sqlite3 db test.db
do_execsql_test 2.3 {
SELECT name FROM sqlite_master ORDER BY 1;
} {ft ft_content ft_segdir ft_segments sqlite_autoindex_ft_segdir_1 t1}
}
finish_test
|