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.
13 # This file is a verification that the bugs identified in ticket
14 # #3527 have been fixed.
16 # $Id: tkt3527.test,v 1.1 2008/12/08 13:42:36 drh Exp $
18 set testdir [file dirname $argv0]
19 source $testdir/tester.tcl
28 CREATE TABLE Element (
29 Code INTEGER PRIMARY KEY,
34 CodeOr INTEGER NOT NULL,
35 Code INTEGER NOT NULL,
36 PRIMARY KEY(CodeOr,Code)
39 CREATE TABLE ElemAnd (
45 PRIMARY KEY(CodeAnd,Code)
48 INSERT INTO Element VALUES(1,'Elem1');
49 INSERT INTO Element VALUES(2,'Elem2');
50 INSERT INTO Element VALUES(3,'Elem3');
51 INSERT INTO Element VALUES(4,'Elem4');
52 INSERT INTO Element VALUES(5,'Elem5');
53 INSERT INTO ElemOr Values(3,4);
54 INSERT INTO ElemOr Values(3,5);
55 INSERT INTO ElemAnd VALUES(1,3,'a','b','c');
56 INSERT INTO ElemAnd VALUES(1,2,'x','y','z');
58 CREATE VIEW ElemView1 AS
60 CAST(Element.Code AS VARCHAR(50)) AS ElemId,
61 Element.Code AS ElemCode,
62 Element.Name AS ElemName,
63 ElemAnd.Code AS InnerCode,
64 ElemAnd.Attr1 AS Attr1,
65 ElemAnd.Attr2 AS Attr2,
66 ElemAnd.Attr3 AS Attr3,
69 FROM Element JOIN ElemAnd ON ElemAnd.CodeAnd=Element.Code
70 WHERE ElemAnd.CodeAnd NOT IN (SELECT CodeOr FROM ElemOr)
73 CAST(ElemOr.CodeOr AS VARCHAR(50)) AS ElemId,
74 Element.Code AS ElemCode,
75 Element.Name AS ElemName,
76 ElemOr.Code AS InnerCode,
82 FROM ElemOr JOIN Element ON Element.Code=ElemOr.CodeOr
83 ORDER BY ElemId, InnerCode;
85 CREATE VIEW ElemView2 AS
99 Element.ElemId || '.' || InnerElem.ElemId AS ElemId,
108 FROM ElemView1 AS Element
109 JOIN ElemView1 AS InnerElem
110 ON Element.Level=0 AND Element.InnerCode=InnerElem.ElemCode
111 ORDER BY ElemId, InnerCode;
113 SELECT * FROM ElemView1;
115 } {1 1 Elem1 2 x y z 0 0 1 1 Elem1 3 a b c 0 0 3 3 Elem3 4 {} {} {} 0 1 3 3 Elem3 5 {} {} {} 0 1}
117 do_test tkt3527-1.2 {
119 SELECT * FROM ElemView2;
121 } {1 1 Elem1 2 x y z 0 0 1 1 Elem1 3 a b c 0 0 1.3 3 Elem3 4 {} {} {} 1 1 1.3 3 Elem3 5 {} {} {} 1 1 3 3 Elem3 4 {} {} {} 0 1 3 3 Elem3 5 {} {} {} 0 1}