interplane.Get Omega
Read in your language

sqlite

[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.

Brought by drakestapleton

branch master Branches Tags History

sqlite / ext / fts5 / test / fts5vocab3.test

54 lines · 1518 bytes Raw Blame History
1# 2026 October 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# The tests in this file focus on queries against fts5vocab tables that
13# require the same row to be identified across more than one scan of the
14# table - multi-index OR and RIGHT JOIN.
15#
16
17source [file join [file dirname [info script]] fts5_common.tcl]
18set testprefix fts5vocab3
19
20# If SQLITE_ENABLE_FTS5 is not defined, omit this file.
21ifcapable !fts5 {
22 finish_test
23 return
24}
25
26do_execsql_test 1.0 {
27 CREATE VIRTUAL TABLE ft USING fts5(x);
28 INSERT INTO ft VALUES('apple banana');
29 CREATE VIRTUAL TABLE v_row USING fts5vocab(ft, 'row');
30 CREATE VIRTUAL TABLE v_col USING fts5vocab(ft, 'col');
31 CREATE VIRTUAL TABLE v_inst USING fts5vocab(ft, 'instance');
32}
33
34foreach {tn tbl} {
35 1 v_row
36 2 v_col
37 3 v_inst
38} {
39 # Multi-index OR. The order of the rows returned is not defined.
40 do_test 1.$tn.1 {
41 lsort [execsql "SELECT term FROM $tbl WHERE term='banana' OR term<'c'"]
42 } {apple banana}
43
44 # RIGHT JOIN. The unmatched row for 'apple' must be returned.
45 do_execsql_test 1.$tn.2 "
46 SELECT t.a, v.term
47 FROM (SELECT 'banana' AS a) t RIGHT JOIN $tbl v ON v.term = t.a
48 ORDER BY v.term
49 " {
50 {} apple banana banana
51 }
52}
53
54finish_test