SQLite

View Ticket
Login
Ticket Hash: 0d676cd6e67b2a8d7e97b46a89537c51325524ee
Title: Triggers: new/old.oid is interpreted as the IPK, even if there is another column "oid"
Status: Closed Type: Code_Defect
Severity: Important Priority: Immediate
Subsystem: Code_Generator Resolution: Duplicate
Last Modified: 2009-12-30 12:42:11
Version Found In: 3.6.18
Description:
Within a trigger body, a reference to new.oid is always interpreted as a reference to the rowid. However, if there is an explicitly declared column named "oid", then "new.oid" should refer to the explicit column. Example:

<verbatim>
SQLite version 3.6.21
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> CREATE TABLE foo(k INTEGER PRIMARY KEY, oid INTEGER);
sqlite> CREATE TABLE log(a, b);
sqlite> 
sqlite> CREATE TRIGGER tr1 AFTER INSERT ON foo BEGIN
   ...>   INSERT INTO log VALUES(new.k, new.oid);
   ...> END;
sqlite> INSERT INTO foo VALUES(100, 200);
sqlite> SELECT a, b FROM log;
100|100
</verbatim>

The result of the above SELECT should be "100|200".

<hr><i>dan added on 2009-12-30 07:41:28:</i><br>
Dup of [34d2ae1c6d].