Hi,
Hi, I'm having some issues with last_insert_rowid starting with 3.17
Basically it seems to be returning the row inserted by a trigger,
instead of the explicitly inserted row.
As far as I understand, this contradicts the last_insert_rowid()
documentation.
I wrote a small test case to demonstrate the issue:
chouquette@nibbler cat /tmp/test.sql
CREATE TABLE IF NOT EXISTS Foo(
id_foo INTEGER PRIMARY KEY AUTOINCREMENT,
bar TEXT
);
CREATE VIRTUAL TABLE IF NOT EXISTS FooFts
USING FTS4(bar);
CREATE TRIGGER IF NOT EXISTS insert_fts
AFTER INSERT ON Foo
WHEN new.bar IS NOT NULL
BEGIN
INSERT INTO FooFts(rowid, bar) VALUES(new.id_foo, new.bar);
END;
BEGIN;
INSERT INTO Foo(id_foo) VALUES(NULL);
SELECT last_insert_rowid();
INSERT INTO Foo(id_foo) VALUES(NULL);
SELECT last_insert_rowid();
COMMIT;
SELECT last_insert_rowid();
BEGIN;
INSERT INTO Foo(id_foo, bar) VALUES(NULL, "otter");
COMMIT;
SELECT last_insert_rowid();
SELECT * FROM sqlite_sequence;
chouquette@nibbler ./sqlite3 --version
3.16.2 2017-01-06 16:32:41 a65a62893ca8319e89e48b8a38cf8a59c69a8209
chouquette@nibbler ./sqlite3 < /tmp/test.sql
1
2
2
3
Foo|3
chouquette@nibbler ~/dev/prefix/bin/sqlite3 --version
3.17.0 2017-02-13 16:02:40 ada05cfa86ad7f5645450ac7a2a21c9aa6e57d2c
chouquette@nibbler ~/dev/prefix/bin/sqlite3 < /tmp/test.sql
1
2
2
1
Foo|3
Has the behavior changed without being documented (or did I miss the
change?), or is this indeed a bug?
Thanks a lot in advance,
Regards,
--
Hugo Beauzée-Luyssen
[email protected]
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users