aboutsummaryrefslogtreecommitdiff
path: root/ext/fts5/test/fts5expr.test
blob: 49be61d9c43cd91f4b842941fc7e0eb74ed3c370 (plain)
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
# 2024 August 8
#
# 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 fts5expr

# If SQLITE_ENABLE_FTS5 is not defined, omit this file.
ifcapable !fts5 {
  finish_test
  return
}

do_execsql_test 1.0 {
  CREATE VIRTUAL TABLE x1 USING fts5(a);
  INSERT INTO x1(rowid, a) VALUES (113, 'fts5 expr test');
}

do_execsql_test 1.1 {
  SELECT rowid FROM x1('expr');
} {113}

for {set ii 0} {$ii < 300} {incr ii} {
  set expr "expr "
  append expr [string repeat "NOT abcd " $ii]

  if {$ii<257} {
    set res {0 113}
  } else {
    set res {1 {fts5 expression tree is too large (maximum depth 256)}}
  }
  do_catchsql_test 1.1.$ii {
    SELECT rowid FROM x1($expr)
  } $res
}

do_execsql_test 1.2 {
  SELECT rowid FROM x1 WHERE a MATCH '"..."'
} {}

finish_test