On May 18, 2009, at 5:32 PM, Allen Fowler wrote: >>> The simple solution would just create a race condition... i think: >>> >>> 1) INSERT INTO status_table FROM SELECT oldest task in queue >>> 2) DELETE oldest task in queue >>> >>> Right? >> >> It might work fine if you wrap it in an exclusive >> transaction. >> > > > "exclusive transaction"? Great! How do I do that? :)
Wrap the above two statements in: 0) BEGIN EXCLUSIVE ... 3) COMMIT > From reading http://www.sqlite.org/lockingv3.html it sounds like > SQLite very rarely will want to gain an exclusive lock. I think, > not even issuing an INSERT will do that until other factors cause it > to flush to disk. The BEGIN EXCLUSIVE above is all you need (and more, a simple BEGIN may be enough). > Can someone with more knowledge of SQLite internals explain the > right way to "atomic"-lly "pop"-off an item from table in SQlite? > (And, in this case, also add it to a 2nd table.) The above sequence of 4 statements is atomic. e _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users