xref: /sqlite-3.40.0/ext/fts5/test/fts5plan.test (revision 8210233c)
1# 2014 Dec 20
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# This file focuses on testing the planner (xBestIndex function).
13#
14
15source [file join [file dirname [info script]] fts5_common.tcl]
16set testprefix fts5plan
17
18# If SQLITE_ENABLE_FTS5 is defined, omit this file.
19ifcapable !fts5 {
20  finish_test
21  return
22}
23
24do_execsql_test 1.0 {
25  CREATE TABLE t1(x, y);
26  CREATE VIRTUAL TABLE f1 USING fts5(ff);
27}
28
29do_eqp_test 1.1 {
30  SELECT * FROM t1, f1 WHERE f1 MATCH t1.x
31} {
32  QUERY PLAN
33  |--SCAN t1
34  `--SCAN f1 VIRTUAL TABLE INDEX 0:M1
35}
36
37do_eqp_test 1.2 {
38  SELECT * FROM t1, f1 WHERE f1 > t1.x
39} {
40  QUERY PLAN
41  |--SCAN f1 VIRTUAL TABLE INDEX 0:
42  `--SCAN t1
43}
44
45do_eqp_test 1.3 {
46  SELECT * FROM f1 WHERE f1 MATCH ? ORDER BY ff
47} {
48  QUERY PLAN
49  |--SCAN f1 VIRTUAL TABLE INDEX 0:M1
50  `--USE TEMP B-TREE FOR ORDER BY
51}
52
53do_eqp_test 1.4 {
54  SELECT * FROM f1 ORDER BY rank
55} {
56  QUERY PLAN
57  |--SCAN f1 VIRTUAL TABLE INDEX 0:
58  `--USE TEMP B-TREE FOR ORDER BY
59}
60
61do_eqp_test 1.5 {
62  SELECT * FROM f1 WHERE rank MATCH ?
63} {SCAN f1 VIRTUAL TABLE INDEX 0:r}
64
65finish_test
66