On Tue Nov 28, 2017 at 03:30:54PM +0000, David Raymond wrote:
> With an integer primary key, not just any primary key. Probably
> something to do with the deterministic flag as well. Looks like in
> checking if it's gonna be a good integer for a rowid it calls it
> twice. Below you can see where random() gets called twice, so what
> the before trigger inserts into another table is different than what
> gets put into the original table. If you have a deterministic
> function like abs() it just calls it once, or if you have a
> non-integer-primary-key table it just calls it once.
> 
> 
> sqlite> create table d (id integer primary key);
> 
> sqlite> create table d2 (id int primary key);
> 
> sqlite> create table t (tableName text, id int);
> 
> sqlite> create trigger bi_d before insert on d begin insert into t values 
> ('d', new.id); end;
> 
> sqlite> create trigger bi_d2 before insert on d2 begin insert into t values 
> ('d2', new.id); end;
> 
> sqlite> insert into d values (random());
> 
> sqlite> insert into d2 values (random());
> 
> sqlite> select * from t;
> tableName|id
> d|-5810358455625904630
> d2|-3456845157187719103
> 
> sqlite> select * from d;
> id
> 6606271909038536929
> 
> sqlite> select * from d2;
> id
> -3456845157187719103

That looks like a good test case to me. This is certainly a regression
as earlier versions of SQLite don't show the same behaviour.

SQLite developers, do you recognise this thread as an issue? I've seen
other topics come and go and be fixed in the meantime, but no statement
on this one.

-- 
Mark Lawrence
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to