Bram, I don't think there is a solid workaround of the form you suggest. The last_insert_rowid() you're getting is for the segment in the internal segdir table, and is unrelated to the rowid of the overall virtual table.
What you should be able to do is to call last_insert_rowid() IMMEDIATELY after your insert statement. By "immediately", I mean before calling COMMIT or END, or running a SELECT against the fts table, any of which can cause updates to the underlying tables. UPDATE and DELETE are included in the list of statements which can change things. -scott On Tue, May 20, 2008 at 2:03 PM, Bram de Jong <[EMAIL PROTECTED]> wrote: > Hello, > > On Tue, May 20, 2008 at 10:26 PM, D. Richard Hipp <[EMAIL PROTECTED]> wrote: >> So it is not at all clear to me whether this behavior is a bug or a >> feature. SQLite is doing what the documentation says it ought to do. >> The question is, should the specification of what SQLite ought to do >> change in order to be less surprising to programmers? And if so, what >> would that new specification be? > > I wouldn't mind having to call another function, or call it at a > different time/location, > but if you do an insert, there needs to be *some* way to get the id it > just used. :-) > > Considering triggers: if triggers would have had the side-effect of > changing the insert-id, you could still get > the "original" insert-id inside the trigger (which would be hard to > externalize, but still, you could get your > hands on it. If the insert is done in a place you have no control > over, you're completely out of luck. > > As a workaround for now, how is the insert ID generally created > (considering a single-threaded app)? > > select max(id) + 1 from table? > > - bram > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users