blob: c3e2a2bc92bdd87adb23edc48032b3aeacc3ca40 [file] [log] [blame]
danielk1977fdd8e5b2008-09-06 14:19:11 +00001# 2008 September 1
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 implements regression tests for SQLite library. The
13# focus of this file is testing the fix for ticket #3357.
14#
drhdda70fe2009-06-05 17:09:11 +000015# $Id: tkt3357.test,v 1.2 2009/06/05 17:09:12 drh Exp $
danielk1977fdd8e5b2008-09-06 14:19:11 +000016
17set testdir [file dirname $argv0]
18source $testdir/tester.tcl
19
20do_test tkt3357-1.1 {
21 execsql {
22 create table a(id integer primary key, b_id integer, myvalue varchar);
23 create table b(id integer primary key, bvalue varchar);
24 insert into a(b_id, myvalue) values(1,'Test');
25 insert into a(b_id, myvalue) values(1,'Test2');
26 insert into a(b_id, myvalue) values(1,'Test3');
27 insert into b(bvalue) values('btest');
28 }
29} {}
30
31do_test tkt3357-1.2 {
32 execsql {
33 SELECT cc.id, cc.b_id, cc.myvalue, dd.bvalue
34 FROM (
35 SELECT DISTINCT a.id, a.b_id, a.myvalue FROM a
36 INNER JOIN b ON a.b_id = b.id WHERE b.bvalue = 'btest'
37 ) cc
38 LEFT OUTER JOIN b dd ON cc.b_id = dd.id
39 }
40} {1 1 Test btest 2 1 Test2 btest 3 1 Test3 btest}
41
42do_test tkt3357-1.3 {
43 execsql {
44 SELECT cc.id, cc.b_id, cc.myvalue
45 FROM (
46 SELECT a.id, a.b_id, a.myvalue
47 FROM a, b WHERE a.b_id = b.id
48 ) cc
49 LEFT OUTER JOIN b dd ON cc.b_id = dd.id
50 }
51} {1 1 Test 2 1 Test2 3 1 Test3}
52
53do_test tkt3357-1.4 {
54 execsql {
55 SELECT cc.id, cc.b_id, cc.myvalue
56 FROM (
57 SELECT DISTINCT a.id, a.b_id, a.myvalue
58 FROM a, b WHERE a.b_id = b.id
59 ) cc
60 LEFT OUTER JOIN b dd ON cc.b_id = dd.id
61 }
62} {1 1 Test 2 1 Test2 3 1 Test3}
63
64finish_test