3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
11 # This file implements regression tests for SQLite library. The
12 # focus of this file is testing ORDER BY optimizations on joins
13 # that involve virtual tables.
17 set testdir [file dirname $argv0]
18 source $testdir/tester.tcl
19 set ::testprefix orderby7
27 CREATE VIRTUAL TABLE fts USING fts3(content TEXT);
28 INSERT INTO fts(rowid,content)
29 VALUES(1,'this is a test of the fts3 virtual'),
30 (2,'table used as part of a join together'),
31 (3,'with the DISTINCT keyword. There was'),
32 (4,'a bug at one time (2013-06 through 2014-04)'),
33 (5,'that prevented this from working correctly.'),
34 (11,'a row that occurs twice'),
35 (12,'a row that occurs twice');
37 CREATE TABLE t1(x TEXT PRIMARY KEY, y);
38 INSERT OR IGNORE INTO t1 SELECT content, rowid+100 FROM fts;
41 SELECT DISTINCT fts.rowid, t1.y
43 WHERE fts MATCH 'that twice'
48 SELECT DISTINCT fts.rowid, t1.x
50 WHERE fts MATCH 'that twice'
53 } {11 {a row that occurs twice} 12 {a row that occurs twice}}
57 WHERE fts MATCH 'that twice'
60 } {{a row that occurs twice}}
64 WHERE fts MATCH 'that twice'
67 } {{a row that occurs twice} {a row that occurs twice}}
71 WHERE fts MATCH 'that twice'
73 } {{a row that occurs twice}}
77 WHERE fts MATCH 'that twice'
79 } {{a row that occurs twice} {a row that occurs twice}}
87 } {{a row that occurs twice}}
94 } {{a row that occurs twice} 111}
101 } {{a row that occurs twice} 111}