sqlite
[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.
Brought by drakestapleton
sqlite / ext / fts5 / test / fts5error.test
| 1 | # 2026 October 14 |
| 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 | # This file implements regression tests for SQLite library. The |
| 12 | # focus of this script is testing the FTS5 module. |
| 13 | # |
| 14 | |
| 15 | source [file join [file dirname [info script]] fts5_common.tcl] |
| 16 | set testprefix fts5aa |
| 17 | |
| 18 | # If SQLITE_ENABLE_FTS5 is not defined, omit this file. |
| 19 | ifcapable !fts5 { |
| 20 | finish_test |
| 21 | return |
| 22 | } |
| 23 | |
| 24 | proc myupper {x} { |
| 25 | string toupper $x |
| 26 | } |
| 27 | db func myupper myupper |
| 28 | |
| 29 | do_test 0.1 { |
| 30 | myupper hello |
| 31 | } {HELLO} |
| 32 | |
| 33 | do_execsql_test 1.0 { |
| 34 | CREATE TABLE t1(id INTEGER PRIMARY KEY, x, y); |
| 35 | INSERT INTO t1 VALUES(1, 'one', 'two'); |
| 36 | INSERT INTO t1 VALUES(2, 'three', 'four'); |
| 37 | CREATE VIEW v1 AS SELECT id, x, myupper(y) AS y FROM t1; |
| 38 | |
| 39 | CREATE VIRTUAL TABLE ft1 USING fts5(x, y, content=v1, content_rowid=id); |
| 40 | } |
| 41 | |
| 42 | do_execsql_test 1.1.1 { |
| 43 | INSERT INTO ft1(ft1) VALUES('rebuild'); |
| 44 | } |
| 45 | do_execsql_test 1.1.2 { |
| 46 | SELECT snippet(ft1, -1, '[', ']', '...', 1) FROM ft1('one'); |
| 47 | } {{[one]}} |
| 48 | do_execsql_test 1.1.3 { |
| 49 | INSERT INTO ft1(ft1, rank) VALUES('integrity-check', 1); |
| 50 | } {} |
| 51 | |
| 52 | db close |
| 53 | sqlite3 db test.db |
| 54 | |
| 55 | do_catchsql_test 1.2.1 { |
| 56 | INSERT INTO ft1(ft1) VALUES('rebuild'); |
| 57 | } {1 {no such function: myupper}} |
| 58 | |
| 59 | do_catchsql_test 1.2.2 { |
| 60 | SELECT snippet(ft1, -1, '[', ']', '...', 1) FROM ft1('one'); |
| 61 | } {1 {no such function: myupper}} |
| 62 | |
| 63 | do_catchsql_test 1.2.3 { |
| 64 | INSERT INTO ft1(ft1, rank) VALUES('integrity-check', 1); |
| 65 | } {1 {no such function: myupper}} |
| 66 | |
| 67 | finish_test |
| 68 |