| OLD | NEW |
| 1 # 2009 December 29 | 1 # 2009 December 29 |
| 2 # | 2 # |
| 3 # The author disclaims copyright to this source code. In place of | 3 # The author disclaims copyright to this source code. In place of |
| 4 # a legal notice', here is a blessing: | 4 # a legal notice', here is a blessing: |
| 5 # | 5 # |
| 6 # May you do good and not evil. | 6 # May you do good and not evil. |
| 7 # May you find forgiveness for yourself and forgive others. | 7 # May you find forgiveness for yourself and forgive others. |
| 8 # May you share freely, never taking more than you give. | 8 # May you share freely, never taking more than you give. |
| 9 # | 9 # |
| 10 #*********************************************************************** | 10 #*********************************************************************** |
| 11 # | 11 # |
| 12 # Verify that when columns named "rowid", "oid", and "_rowid_" appear | 12 # Verify that when columns named "rowid", "oid", and "_rowid_" appear |
| 13 # in a table as ordinary columns (not as the INTEGER PRIMARY KEY) then | 13 # in a table as ordinary columns (not as the INTEGER PRIMARY KEY) then |
| 14 # the use of these columns in triggers will refer to the column and not | 14 # the use of these columns in triggers will refer to the column and not |
| 15 # to the actual ROWID. Ticket [34d2ae1c6d08b5271ba5e5592936d4a1d913ffe3] | 15 # to the actual ROWID. Ticket [34d2ae1c6d08b5271ba5e5592936d4a1d913ffe3] |
| 16 # | 16 # |
| 17 # Also, verify that triggers created like this: |
| 18 # |
| 19 # CREATE TRIGGER attached.trig AFTER INSERT ON attached.tab ... |
| 20 # |
| 21 # can be reparsed as a main database. Ticket [d6ddba6706353915ceedc56b4e3] |
| 22 # |
| 17 | 23 |
| 18 set testdir [file dirname $argv0] | 24 set testdir [file dirname $argv0] |
| 19 source $testdir/tester.tcl | 25 source $testdir/tester.tcl |
| 20 ifcapable {!trigger} { | 26 ifcapable {!trigger} { |
| 21 finish_test | 27 finish_test |
| 22 return | 28 return |
| 23 } | 29 } |
| 24 | 30 |
| 25 # Triggers on tables where the table has ordinary columns named | 31 # Triggers on tables where the table has ordinary columns named |
| 26 # rowid, oid, and _rowid_. | 32 # rowid, oid, and _rowid_. |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 CREATE TRIGGER temp.r301 AFTER INSERT ON t300 BEGIN | 170 CREATE TRIGGER temp.r301 AFTER INSERT ON t300 BEGIN |
| 165 INSERT INTO t301 VALUES(20000 + new.x); | 171 INSERT INTO t301 VALUES(20000 + new.x); |
| 166 END; | 172 END; |
| 167 INSERT INTO main.t300 VALUES(3); | 173 INSERT INTO main.t300 VALUES(3); |
| 168 INSERT INTO temp.t300 VALUES(4); | 174 INSERT INTO temp.t300 VALUES(4); |
| 169 SELECT * FROM t301; | 175 SELECT * FROM t301; |
| 170 } | 176 } |
| 171 } {10003 20004} | 177 } {10003 20004} |
| 172 | 178 |
| 173 | 179 |
| 180 ############################################################################# |
| 181 # |
| 182 # Ticket [d6ddba6706353915ceedc56b4e3e72ecb4d77ba4] |
| 183 # |
| 184 # The following syntax really should not be allowed: |
| 185 # |
| 186 # CREATE TRIGGER xyz.trig BEFORE UPDATE ON xyz.tab BEGIN ... |
| 187 # |
| 188 # But a long-standing bug does allow it. And the "xyz.tab" slips into |
| 189 # the sqlite_master table. We cannot fix the bug simply by disallowing |
| 190 # "xyz.tab" since that could break legacy applications. We have to |
| 191 # fix the system so that the "xyz." on "xyz.tab" is ignored. |
| 192 # Verify that this is the case. |
| 193 # |
| 194 do_test triggerD-4.1 { |
| 195 db close |
| 196 forcedelete test.db test2.db |
| 197 sqlite3 db test.db |
| 198 db eval { |
| 199 CREATE TABLE t1(x); |
| 200 ATTACH 'test2.db' AS db2; |
| 201 CREATE TABLE db2.t2(y); |
| 202 CREATE TABLE db2.log(z); |
| 203 CREATE TRIGGER db2.trig AFTER INSERT ON db2.t2 BEGIN |
| 204 INSERT INTO log(z) VALUES(new.y); |
| 205 END; |
| 206 INSERT INTO t2 VALUES(123); |
| 207 SELECT * FROM log; |
| 208 } |
| 209 } {123} |
| 210 do_test triggerD-4.2 { |
| 211 sqlite3 db2 test2.db |
| 212 db2 eval { |
| 213 INSERT INTO t2 VALUES(234); |
| 214 SELECT * FROM log; |
| 215 } |
| 216 } {123 234} |
| 217 db2 close |
| 218 |
| 174 finish_test | 219 finish_test |
| OLD | NEW |