SQLite

Check-in [953e169e8a]
Login

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

Overview
Comment:Test case for ticket [d6ddba6706353915ceed]
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 953e169e8a7dac05a0b56b4ef5d500ec8399d37f
User & Date: drh 2011-07-01 14:22:04.191
Context
2011-07-02
09:46
Merge experimental changes improving optimization of DISTINCT queries with the trunk. (check-in: 45e581bff7 user: dan tags: trunk)
2011-07-01
18:43
Merge latest trunk changes with experimental branch. (check-in: e56be74eab user: dan tags: experimental)
14:22
Test case for ticket [d6ddba6706353915ceed] (check-in: 953e169e8a user: drh tags: trunk)
13:50
Ignore the database name on the target table when parsing a CREATE TABLE statement out of the sqlite_master table. This is a fix for ticket [d6ddba6706353] that preserves backwards compatibility. (check-in: 009c96ea78 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to test/triggerD.test.
10
11
12
13
14
15
16






17
18
19
20
21
22
23
#***********************************************************************
#
# Verify that when columns named "rowid", "oid", and "_rowid_" appear
# in a table as ordinary columns (not as the INTEGER PRIMARY KEY) then
# the use of these columns in triggers will refer to the column and not
# to the actual ROWID.  Ticket [34d2ae1c6d08b5271ba5e5592936d4a1d913ffe3]
#







set testdir [file dirname $argv0]
source $testdir/tester.tcl
ifcapable {!trigger} {
  finish_test
  return
}







>
>
>
>
>
>







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#***********************************************************************
#
# Verify that when columns named "rowid", "oid", and "_rowid_" appear
# in a table as ordinary columns (not as the INTEGER PRIMARY KEY) then
# the use of these columns in triggers will refer to the column and not
# to the actual ROWID.  Ticket [34d2ae1c6d08b5271ba5e5592936d4a1d913ffe3]
#
# Also, verify that triggers created like this:
#
#    CREATE TRIGGER attached.trig AFTER INSERT ON attached.tab ...
#
# can be reparsed as a main database.  Ticket [d6ddba6706353915ceedc56b4e3]
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl
ifcapable {!trigger} {
  finish_test
  return
}
166
167
168
169
170
171
172
173







































174
    END;
    INSERT INTO main.t300 VALUES(3);
    INSERT INTO temp.t300 VALUES(4);
    SELECT * FROM t301;
  }
} {10003 20004}









































finish_test








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

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
    END;
    INSERT INTO main.t300 VALUES(3);
    INSERT INTO temp.t300 VALUES(4);
    SELECT * FROM t301;
  }
} {10003 20004}


#############################################################################
# 
# Ticket [d6ddba6706353915ceedc56b4e3e72ecb4d77ba4]
#
# The following syntax really should not be allowed:
#
#    CREATE TRIGGER xyz.trig BEFORE UPDATE ON xyz.tab BEGIN ...
#
# But a long-standing bug does allow it.  And the "xyz.tab" slips into
# the sqlite_master table.  We cannot fix the bug simply by disallowing
# "xyz.tab" since that could break legacy applications.  We have to 
# fix the system so that the "xyz." on "xyz.tab" is ignored.
# Verify that this is the case.
#
do_test triggerD-4.1 {
  db close
  file delete -force test.db test2.db
  sqlite3 db test.db
  db eval {
    CREATE TABLE t1(x);
    ATTACH 'test2.db' AS db2;
    CREATE TABLE db2.t2(y);
    CREATE TABLE db2.log(z);
    CREATE TRIGGER db2.trig AFTER INSERT ON db2.t2 BEGIN
      INSERT INTO log(z) VALUES(new.y);
    END;
    INSERT INTO t2 VALUES(123);
    SELECT * FROM log;
  }
} {123}
do_test triggerD-4.2 {
  sqlite3 db2 test2.db
  db2 eval {
    INSERT INTO t2 VALUES(234);
    SELECT * FROM log;
  }
} {123 234}
db2 close

finish_test