/ Check-in [de54dad8]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add some extra tests for the recent trigger compilation optimization. (CVS 4653)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: de54dad800f0b62740ad4ebb3780464b44eb6dff
User & Date: danielk1977 2008-01-02 04:41:25
Context
2008-01-02
11:50
Take advantage of the fact that b-tree cursors need not be closed while other cursors modify their tables to simplify trigger program generation code. (CVS 4654) check-in: f1966a8a user: danielk1977 tags: trunk
04:41
Add some extra tests for the recent trigger compilation optimization. (CVS 4653) check-in: de54dad8 user: danielk1977 tags: trunk
00:34
Begin setting a foundation on which to convert the VM from a stack-based to a register-based machine. Everything is still mostly stack based with this check-in. This change merely begins adding infrastructure to support a register-based architecture. (CVS 4652) check-in: 051ec01f user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to test/trigger9.test.

45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
..
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
..
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
..
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
...
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
...
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146















































































147
    INSERT INTO t1 VALUES('2', randstr(10000,10000), '4');
    INSERT INTO t1 VALUES('3', randstr(10000,10000), '6');
    CREATE TABLE t2(x);
  }
} {}

do_test trigger9-1.2.1 {
  sqlite3 db test.db
  execsql {
    BEGIN;
      CREATE TRIGGER trig1 BEFORE DELETE ON t1 BEGIN
        INSERT INTO t2 VALUES(old.rowid);
      END;
      DELETE FROM t1;
      SELECT * FROM t2;
................................................................................
} {1 2 3}
do_test trigger9-1.2.3 {
  has_rowdata {DELETE FROM t1}
} 0
do_test trigger9-1.2.4 { execsql { ROLLBACK } } {}

do_test trigger9-1.3.1 {
  sqlite3 db test.db
  execsql {
    BEGIN;
      CREATE TRIGGER trig1 BEFORE DELETE ON t1 BEGIN
        INSERT INTO t2 VALUES(old.x);
      END;
      DELETE FROM t1;
      SELECT * FROM t2;
................................................................................
} {1 2 3}
do_test trigger9-1.3.2 {
  has_rowdata {DELETE FROM t1}
} 1
do_test trigger9-1.3.3 { execsql { ROLLBACK } } {}

do_test trigger9-1.4.1 {
  sqlite3 db test.db
  execsql {
    BEGIN;
      CREATE TRIGGER trig1 BEFORE DELETE ON t1 WHEN old.x='1' BEGIN
        INSERT INTO t2 VALUES(old.rowid);
      END;
      DELETE FROM t1;
      SELECT * FROM t2;
................................................................................
} {1}
do_test trigger9-1.4.2 {
  has_rowdata {DELETE FROM t1}
} 1
do_test trigger9-1.4.3 { execsql { ROLLBACK } } {}

do_test trigger9-1.5.1 {
  sqlite3 db test.db
  execsql {
    BEGIN;
      CREATE TRIGGER trig1 BEFORE UPDATE ON t1 BEGIN
        INSERT INTO t2 VALUES(old.rowid);
      END;
      UPDATE t1 SET y = '';
      SELECT * FROM t2;
................................................................................
} {1 2 3}
do_test trigger9-1.5.2 {
  has_rowdata {UPDATE t1 SET y = ''}
} 0
do_test trigger9-1.5.3 { execsql { ROLLBACK } } {}

do_test trigger9-1.6.1 {
  sqlite3 db test.db
  execsql {
    BEGIN;
      CREATE TRIGGER trig1 BEFORE UPDATE ON t1 BEGIN
        INSERT INTO t2 VALUES(old.x);
      END;
      UPDATE t1 SET y = '';
      SELECT * FROM t2;
................................................................................
} {1 2 3}
do_test trigger9-1.6.2 {
  has_rowdata {UPDATE t1 SET y = ''}
} 1
do_test trigger9-1.6.3 { execsql { ROLLBACK } } {}

do_test trigger9-1.7.1 {
  sqlite3 db test.db
  execsql {
    BEGIN;
      CREATE TRIGGER trig1 BEFORE UPDATE ON t1 WHEN old.x>='2' BEGIN
        INSERT INTO t2 VALUES(old.x);
      END;
      UPDATE t1 SET y = '';
      SELECT * FROM t2;
  }
} {2 3}
do_test trigger9-1.7.2 {
  has_rowdata {UPDATE t1 SET y = ''}
} 1
do_test trigger9-1.7.3 { execsql { ROLLBACK } } {}
















































































finish_test







<







 







<







 







<







 







<







 







<







 







<














>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

45
46
47
48
49
50
51

52
53
54
55
56
57
58
..
60
61
62
63
64
65
66

67
68
69
70
71
72
73
..
75
76
77
78
79
80
81

82
83
84
85
86
87
88
..
90
91
92
93
94
95
96

97
98
99
100
101
102
103
...
105
106
107
108
109
110
111

112
113
114
115
116
117
118
...
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
    INSERT INTO t1 VALUES('2', randstr(10000,10000), '4');
    INSERT INTO t1 VALUES('3', randstr(10000,10000), '6');
    CREATE TABLE t2(x);
  }
} {}

do_test trigger9-1.2.1 {

  execsql {
    BEGIN;
      CREATE TRIGGER trig1 BEFORE DELETE ON t1 BEGIN
        INSERT INTO t2 VALUES(old.rowid);
      END;
      DELETE FROM t1;
      SELECT * FROM t2;
................................................................................
} {1 2 3}
do_test trigger9-1.2.3 {
  has_rowdata {DELETE FROM t1}
} 0
do_test trigger9-1.2.4 { execsql { ROLLBACK } } {}

do_test trigger9-1.3.1 {

  execsql {
    BEGIN;
      CREATE TRIGGER trig1 BEFORE DELETE ON t1 BEGIN
        INSERT INTO t2 VALUES(old.x);
      END;
      DELETE FROM t1;
      SELECT * FROM t2;
................................................................................
} {1 2 3}
do_test trigger9-1.3.2 {
  has_rowdata {DELETE FROM t1}
} 1
do_test trigger9-1.3.3 { execsql { ROLLBACK } } {}

do_test trigger9-1.4.1 {

  execsql {
    BEGIN;
      CREATE TRIGGER trig1 BEFORE DELETE ON t1 WHEN old.x='1' BEGIN
        INSERT INTO t2 VALUES(old.rowid);
      END;
      DELETE FROM t1;
      SELECT * FROM t2;
................................................................................
} {1}
do_test trigger9-1.4.2 {
  has_rowdata {DELETE FROM t1}
} 1
do_test trigger9-1.4.3 { execsql { ROLLBACK } } {}

do_test trigger9-1.5.1 {

  execsql {
    BEGIN;
      CREATE TRIGGER trig1 BEFORE UPDATE ON t1 BEGIN
        INSERT INTO t2 VALUES(old.rowid);
      END;
      UPDATE t1 SET y = '';
      SELECT * FROM t2;
................................................................................
} {1 2 3}
do_test trigger9-1.5.2 {
  has_rowdata {UPDATE t1 SET y = ''}
} 0
do_test trigger9-1.5.3 { execsql { ROLLBACK } } {}

do_test trigger9-1.6.1 {

  execsql {
    BEGIN;
      CREATE TRIGGER trig1 BEFORE UPDATE ON t1 BEGIN
        INSERT INTO t2 VALUES(old.x);
      END;
      UPDATE t1 SET y = '';
      SELECT * FROM t2;
................................................................................
} {1 2 3}
do_test trigger9-1.6.2 {
  has_rowdata {UPDATE t1 SET y = ''}
} 1
do_test trigger9-1.6.3 { execsql { ROLLBACK } } {}

do_test trigger9-1.7.1 {

  execsql {
    BEGIN;
      CREATE TRIGGER trig1 BEFORE UPDATE ON t1 WHEN old.x>='2' BEGIN
        INSERT INTO t2 VALUES(old.x);
      END;
      UPDATE t1 SET y = '';
      SELECT * FROM t2;
  }
} {2 3}
do_test trigger9-1.7.2 {
  has_rowdata {UPDATE t1 SET y = ''}
} 1
do_test trigger9-1.7.3 { execsql { ROLLBACK } } {}

do_test trigger9-3.1 {
  execsql {
    CREATE TABLE t3(a, b);
    INSERT INTO t3 VALUES(1, 'one');
    INSERT INTO t3 VALUES(2, 'two');
    INSERT INTO t3 VALUES(3, 'three');
  }
} {}
do_test trigger9-3.2 {
  execsql {
    BEGIN;
      CREATE VIEW v1 AS SELECT * FROM t3;
      CREATE TRIGGER trig1 INSTEAD OF UPDATE ON v1 BEGIN
        INSERT INTO t2 VALUES(old.a);
      END;
      UPDATE v1 SET b = 'hello';
      SELECT * FROM t2;
    ROLLBACK;
  }
} {1 2 3}
do_test trigger9-3.3 {
  # In this test the 'c' column of the view is not required by
  # the INSTEAD OF trigger, but the expression is reused internally as
  # part of the view's WHERE clause. Check that this does not cause
  # a problem.
  #
  execsql {
    BEGIN;
      CREATE VIEW v1 AS SELECT a, b AS c FROM t3 WHERE c > 'one';
      CREATE TRIGGER trig1 INSTEAD OF UPDATE ON v1 BEGIN
        INSERT INTO t2 VALUES(old.a);
      END;
      UPDATE v1 SET c = 'hello';
      SELECT * FROM t2;
    ROLLBACK;
  }
} {2 3}
do_test trigger9-3.4 {
  execsql {
    BEGIN;
      INSERT INTO t3 VALUES(3, 'three');
      INSERT INTO t3 VALUES(3, 'four');
      CREATE VIEW v1 AS SELECT DISTINCT a, b FROM t3;
      CREATE TRIGGER trig1 INSTEAD OF UPDATE ON v1 BEGIN
        INSERT INTO t2 VALUES(old.a);
      END;
      UPDATE v1 SET b = 'hello';
      SELECT * FROM t2;
    ROLLBACK;
  }
} {1 2 3 3}
do_test trigger9-3.5 {
  execsql {
    BEGIN;
      INSERT INTO t3 VALUES(1, 'uno');
      CREATE VIEW v1 AS SELECT a, b FROM t3 EXCEPT SELECT 1, 'one';
      CREATE TRIGGER trig1 INSTEAD OF UPDATE ON v1 BEGIN
        INSERT INTO t2 VALUES(old.a);
      END;
      UPDATE v1 SET b = 'hello';
      SELECT * FROM t2;
    ROLLBACK;
  }
} {1 2 3}
do_test trigger9-3.6 {
  execsql {
    BEGIN;
      INSERT INTO t3 VALUES(1, 'zero');
      CREATE VIEW v1 AS 
        SELECT sum(a) AS a, max(b) AS b FROM t3 GROUP BY t3.a HAVING b>'two';
      CREATE TRIGGER trig1 INSTEAD OF UPDATE ON v1 BEGIN
        INSERT INTO t2 VALUES(old.a);
      END;
      UPDATE v1 SET b = 'hello';
      SELECT * FROM t2;
    ROLLBACK;
  }
} {2}

finish_test