1: # 2011 December 06
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.
12: #
13: # This file implements tests to verify that ticket [3a77c9714e] has been
14: # fixed.
15:
16: set testdir [file dirname $argv0]
17: source $testdir/tester.tcl
18:
19: set testprefix "tkt-3a77c9714e"
20:
21: do_execsql_test 1.1 {
22: CREATE TABLE t1(t1_id INTEGER PRIMARY KEY, t1_title TEXT);
23: CREATE TABLE t2(t2_id INTEGER PRIMARY KEY, t2_title TEXT);
24: CREATE TABLE t3(t3_id INTEGER PRIMARY KEY, t3_title TEXT);
25:
26: INSERT INTO t1 (t1_id, t1_title) VALUES (888, 'ABCDEF');
27: INSERT INTO t2 (t2_id, t2_title) VALUES (999, 'ABCDEF');
28: INSERT INTO t3 (t3_id, t3_title) VALUES (999, 'ABCDEF');
29: }
30:
31: do_execsql_test 1.2 {
32: SELECT t1_title, t2_title
33: FROM t1 LEFT JOIN t2
34: WHERE
35: t2_id = (SELECT t3_id FROM
36: ( SELECT t3_id FROM t3 WHERE t3_title=t1_title LIMIT 500 )
37: )
38: } {ABCDEF ABCDEF}
39:
40: do_execsql_test 2.1 {
41: CREATE TABLE [Beginnings] (
42: [Id] INTEGER PRIMARY KEY AUTOINCREMENT,[Title] TEXT, [EndingId] INTEGER
43: );
44: CREATE TABLE [Endings] (Id INT,Title TEXT,EndingId INT);
45: INSERT INTO Beginnings (Id, Title, EndingId) VALUES (1, 'FACTOR', 18);
46: INSERT INTO Beginnings (Id, Title, EndingId) VALUES (2, 'SWIMM', 18);
47: INSERT INTO Endings (Id, Title, EndingId) VALUES (1, 'ING', 18);
48: }
49:
50: do_execsql_test 2.2 {
51: SELECT
52: SrcWord, Beginnings.Title
53: FROM
54: (SELECT 'FACTORING' AS SrcWord UNION SELECT 'SWIMMING' AS SrcWord )
55: LEFT JOIN
56: Beginnings
57: WHERE Beginnings.Id= (
58: SELECT BeginningId FROM (
59: SELECT SrcWord, B.Id as BeginningId, B.Title || E.Title As Connected
60: FROM Beginnings B LEFT JOIN Endings E ON B.EndingId=E.EndingId
61: WHERE Connected=SrcWord LIMIT 1
62: )
63: )
64: } {FACTORING FACTOR SWIMMING SWIMM}
65:
66:
67: finish_test
68:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>