Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Added test cases for the multi-way USING and NATURAL JOIN fix. Ticket [f74beaabde]. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
0b34ab25624ae4b6c5fa7775328ff0e6 |
User & Date: | drh 2009-12-09 18:22:26.000 |
Context
2009-12-09
| ||
21:43 | Restore the incorrect legacy ON INSERT syntax to the parser as a no-op. That way, older databases that actually use this meaningless syntax will still be readable. (check-in: 54b955c36b user: drh tags: trunk) | |
18:22 | Added test cases for the multi-way USING and NATURAL JOIN fix. Ticket [f74beaabde]. (check-in: 0b34ab2562 user: drh tags: trunk) | |
17:36 | The USING clause and NATURAL JOIN look at all tables to the left when searching for a match, not just the one table to the immediate left. Tables further to the left are preferred. Fix for ticket [f74beaabde]. Still need to add test cases to complete the ticket. (check-in: b558e96f0a user: drh tags: trunk) | |
Changes
Added test/join6.test.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | # 2009 December 9 # # 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. # # This file implements tests for N-way joins (N>2) which make # use of USING or NATURAL JOIN. For such joins, the USING and # NATURAL JOIN processing needs to search all tables to the left # of the join looking for a match. See ticket [f74beaabde] # for additional information. # set testdir [file dirname $argv0] source $testdir/tester.tcl # The problem as initially reported on the mailing list: # do_test join6-1.1 { execsql { CREATE TABLE t1(a); CREATE TABLE t2(a); CREATE TABLE t3(a,b); INSERT INTO t1 VALUES(1); INSERT INTO t3 VALUES(1,2); SELECT * FROM t1 LEFT JOIN t2 USING(a) LEFT JOIN t3 USING(a); } } {1 2} do_test join6-1.2 { execsql { SELECT t1.a, t3.b FROM t1 LEFT JOIN t2 ON t1.a=t2.a LEFT JOIN t3 ON t2.a=t3.a; } } {1 {}} do_test join6-1.3 { execsql { SELECT t1.a, t3.b FROM t1 LEFT JOIN t2 ON t1.a=t2.a LEFT JOIN t3 ON t1.a=t3.a; } } {1 2} do_test join6-2.1 { execsql { DROP TABLE t1; DROP TABLE t2; DROP TABLE t3; CREATE TABLE t1(x,y); CREATE TABLE t2(y,z); CREATE TABLE t3(x,z); INSERT INTO t1 VALUES(1,2); INSERT INTO t1 VALUES(3,4); INSERT INTO t2 VALUES(2,3); INSERT INTO t2 VALUES(4,5); INSERT INTO t3 VALUES(1,3); INSERT INTO t3 VALUES(3,5); SELECT * FROM t1 JOIN t2 USING (y) JOIN t3 USING(x); } } {1 2 3 3 3 4 5 5} do_test join6-2.2 { execsql { SELECT * FROM t1 NATURAL JOIN t2 NATURAL JOIN t3; } } {1 2 3 3 4 5} do_test join6-3.1 { execsql { DROP TABLE t1; DROP TABLE t2; DROP TABLE t3; CREATE TABLE t1(a,x,y); INSERT INTO t1 VALUES(1,91,92); INSERT INTO t1 VALUES(2,93,94); CREATE TABLE t2(b,y,z); INSERT INTO t2 VALUES(3,92,93); INSERT INTO t2 VALUES(4,94,95); CREATE TABLE t3(c,x,z); INSERT INTO t3 VALUES(5,91,93); INSERT INTO t3 VALUES(6,99,95); SELECT * FROM t1 NATURAL JOIN t2 NATURAL JOIN t3; } } {1 91 92 3 93 5} do_test join6-3.2 { execsql { SELECT * FROM t1 JOIN t2 NATURAL JOIN t3; } } {1 91 92 3 92 93 5} do_test join6-3.3 { execsql { SELECT * FROM t1 JOIN t2 USING(y) NATURAL JOIN t3; } } {1 91 92 3 93 5} do_test join6-3.4 { execsql { SELECT * FROM t1 NATURAL JOIN t2 JOIN t3 USING(x,z); } } {1 91 92 3 93 5} do_test join6-3.5 { execsql { SELECT * FROM t1 NATURAL JOIN t2 JOIN t3 USING(x); } } {1 91 92 3 93 5 93} do_test join6-3.6 { execsql { SELECT * FROM t1 NATURAL JOIN t2 JOIN t3 USING(z); } } {1 91 92 3 93 5 91 2 93 94 4 95 6 99} do_test join6-4.1 { execsql { SELECT * FROM (SELECT 1 AS a, 91 AS x, 92 AS y UNION SELECT 2, 93, 94) NATURAL JOIN t2 NATURAL JOIN t3 } } {1 91 92 3 93 5} do_test join6-4.2 { execsql { SELECT * FROM t1 NATURAL JOIN (SELECT 3 AS b, 92 AS y, 93 AS z UNION SELECT 4, 94, 95) NATURAL JOIN t3 } } {1 91 92 3 93 5} do_test join6-4.3 { execsql { SELECT * FROM t1 NATURAL JOIN t2 NATURAL JOIN (SELECT 5 AS c, 91 AS x, 93 AS z UNION SELECT 6, 99, 95) } } {1 91 92 3 93 5} finish_test |