2019-09-02 17:46:12 +03:00
|
|
|
# 2019 September 02
|
|
|
|
#
|
|
|
|
# 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 regression tests for SQLite library. The
|
|
|
|
# focus of this script is testing the FTS5 module.
|
|
|
|
#
|
|
|
|
|
|
|
|
source [file join [file dirname [info script]] fts5_common.tcl]
|
|
|
|
set testprefix fts5misc
|
|
|
|
|
|
|
|
# If SQLITE_ENABLE_FTS5 is not defined, omit this file.
|
|
|
|
ifcapable !fts5 {
|
|
|
|
finish_test
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
do_execsql_test 1.0 {
|
|
|
|
CREATE VIRTUAL TABLE t1 USING fts5(a);
|
|
|
|
}
|
|
|
|
|
|
|
|
do_catchsql_test 1.1.1 {
|
|
|
|
SELECT highlight(t1, 4, '<b>', '</b>') FROM t1('*');
|
|
|
|
} {1 {unknown special query: }}
|
|
|
|
do_catchsql_test 1.1.2 {
|
|
|
|
SELECT a FROM t1
|
|
|
|
WHERE rank = (SELECT highlight(t1, 4, '<b>', '</b>') FROM t1('*'));
|
|
|
|
} {1 {unknown special query: }}
|
|
|
|
|
|
|
|
do_catchsql_test 1.2.1 {
|
|
|
|
SELECT highlight(t1, 4, '<b>', '</b>') FROM t1('*id');
|
|
|
|
} {0 {{}}}
|
|
|
|
|
|
|
|
do_catchsql_test 1.2.2 {
|
|
|
|
SELECT a FROM t1
|
|
|
|
WHERE rank = (SELECT highlight(t1, 4, '<b>', '</b>') FROM t1('*id'));
|
|
|
|
} {0 {}}
|
|
|
|
|
|
|
|
do_catchsql_test 1.3.1 {
|
|
|
|
SELECT highlight(t1, 4, '<b>', '</b>') FROM t1('*reads');
|
|
|
|
} {1 {no such cursor: 1}}
|
|
|
|
|
|
|
|
do_catchsql_test 1.3.2 {
|
|
|
|
SELECT a FROM t1
|
|
|
|
WHERE rank = (SELECT highlight(t1, 4, '<b>', '</b>') FROM t1('*reads'));
|
|
|
|
} {1 {no such cursor: 1}}
|
|
|
|
|
|
|
|
db close
|
|
|
|
sqlite3 db test.db
|
|
|
|
|
|
|
|
do_catchsql_test 1.3.3 {
|
|
|
|
SELECT a FROM t1
|
|
|
|
WHERE rank = (SELECT highlight(t1, 4, '<b>', '</b>') FROM t1('*reads'));
|
|
|
|
} {1 {no such cursor: 1}}
|
|
|
|
|
2019-10-07 21:43:21 +03:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
reset_db
|
|
|
|
do_execsql_test 2.0 {
|
|
|
|
CREATE TABLE t0(c0);
|
|
|
|
CREATE VIRTUAL TABLE vt0 USING fts5(c0);
|
|
|
|
}
|
|
|
|
do_execsql_test 2.1.1 {
|
|
|
|
BEGIN TRANSACTION;
|
|
|
|
INSERT INTO vt0(c0) VALUES ('xyz');
|
|
|
|
}
|
|
|
|
do_execsql_test 2.1.2 {
|
|
|
|
ALTER TABLE t0 ADD COLUMN c5;
|
|
|
|
}
|
|
|
|
do_execsql_test 2.1.3 {
|
|
|
|
INSERT INTO vt0(vt0) VALUES('integrity-check');
|
|
|
|
}
|
|
|
|
do_execsql_test 2.1.4 {
|
|
|
|
INSERT INTO vt0(c0) VALUES ('abc');
|
|
|
|
COMMIT
|
|
|
|
}
|
|
|
|
do_execsql_test 2.1.5 {
|
|
|
|
INSERT INTO vt0(vt0) VALUES('integrity-check');
|
|
|
|
}
|
|
|
|
|
|
|
|
reset_db
|
|
|
|
do_execsql_test 2.2.1 {
|
|
|
|
CREATE TABLE t0(c0);
|
|
|
|
CREATE VIRTUAL TABLE vt0 USING fts5(c0);
|
|
|
|
BEGIN TRANSACTION;
|
|
|
|
INSERT INTO vt0(c0) VALUES ('xyz');
|
|
|
|
}
|
|
|
|
|
|
|
|
breakpoint
|
|
|
|
do_execsql_test 2.2.2 {
|
|
|
|
ALTER TABLE t0 RENAME TO t1;
|
|
|
|
}
|
|
|
|
do_execsql_test 2.2.3 {
|
|
|
|
INSERT INTO vt0(vt0) VALUES('integrity-check');
|
|
|
|
}
|
|
|
|
do_execsql_test 2.2.4 {
|
|
|
|
INSERT INTO vt0(c0) VALUES ('abc');
|
|
|
|
COMMIT;
|
|
|
|
}
|
|
|
|
do_execsql_test 2.2.5 {
|
|
|
|
INSERT INTO vt0(vt0) VALUES('integrity-check');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-09-02 17:46:12 +03:00
|
|
|
finish_test
|
|
|
|
|