• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# 2008 July 4
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# Specifically, it tests that bug #3201 has been fixed.
13#
14# $Id: tkt3201.test,v 1.3 2008/07/12 14:52:21 drh Exp $
15
16set testdir [file dirname $argv0]
17source $testdir/tester.tcl
18
19do_test tkt3201-1 {
20  execsql {
21    CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT);
22    INSERT INTO t1 VALUES(1, 'one');
23    INSERT INTO t1 VALUES(2, 'two');
24  }
25} {}
26
27do_test tkt3201-2 {
28  execsql {
29    SELECT l.a, r.a FROM t1 AS l, t1 AS r WHERE l.a < r.a;
30  }
31} {1 2}
32
33do_test tkt3201-3 {
34  execsql {
35    CREATE TABLE t2(a INTEGER PRIMARY KEY, b TEXT);
36    INSERT INTO t2 VALUES(2, 'two');
37  }
38  execsql {
39    SELECT l.a, r.a FROM t1 AS l, t2 AS r WHERE l.a < r.a;
40  }
41} {1 2}
42
43do_test tkt3201-4 {
44  execsql {
45    DELETE FROM t1 WHERE a = 2;
46  }
47  execsql {
48    SELECT l.a, r.a FROM t1 AS l, t2 AS r WHERE l.a < r.a;
49  }
50} {1 2}
51
52do_test tkt3201-5 {
53  execsql {
54    DELETE FROM t1 WHERE a = 2;
55  }
56  execsql {
57    SELECT t1.a, t1.b, t2.a, t2.b FROM t1, t2;
58  }
59} {1 one 2 two}
60
61do_test tkt3201-6 {
62  execsql {
63    CREATE TABLE t3(c INTEGER PRIMARY KEY, d TEXT);
64    INSERT INTO t3 VALUES(2, 'two');
65  }
66  execsql { SELECT a, b, c, d FROM t1, t3 }
67} {1 one 2 two}
68
69do_test tkt3201-7 {
70  execsql { SELECT a, b, c, d FROM t1, t3 WHERE a < c }
71} {1 one 2 two}
72
73# Ticket [efc02f977919]
74#
75ifcapable trigger {
76  do_test tkt3201-4.0 {
77    db eval {
78     CREATE TABLE t4(x);
79     CREATE TABLE t4_log(x);
80     CREATE TRIGGER r4_1 AFTER INSERT ON t4 WHEN new.x=1 BEGIN
81       INSERT INTO t4_log(x) VALUES(new.x);
82     END;
83     CREATE TRIGGER r4_2 AFTER INSERT ON t4 WHEN new.x=2 BEGIN
84       INSERT INTO t4_log(x) VALUES(new.x);
85     END;
86     CREATE TRIGGER r4_3 AFTER INSERT ON t4 WHEN new.x=3 BEGIN
87       INSERT INTO t4_log(x) VALUES(new.x);
88     END;
89     CREATE TRIGGER r4_4 AFTER INSERT ON t4 WHEN new.x=4 BEGIN
90       INSERT INTO t4_log(x) VALUES(new.x);
91     END;
92     INSERT INTO t4 VALUES(1);
93     INSERT INTO t4 VALUES(2);
94     INSERT INTO t4 VALUES(3);
95     INSERT INTO t4 VALUES(4);
96     SELECT * FROM t4_log;
97    }
98  } {1 2 3 4}
99}
100
101
102
103
104
105finish_test
106