Re: [sqlite] How make atomic? Was: Sqlite as a FIFO buffer?

2009-05-18 Thread Allen Fowler
> Thank you. > > I missed the EXCLUSIVE clause in the docs comes with the newbie > territory, > i guess. > > So to confirm, would something like this work? > > Tables: > task_log => (id, task_data, time_stamp) > task_fifo = > (id, fk_task_log) > task_status_log => (id, fk_task_log,

Re: [sqlite] How make atomic? Was: Sqlite as a FIFO buffer?

2009-05-18 Thread Allen Fowler
> Wrap the above two statements in: > > 0) BEGIN EXCLUSIVE > ... > 3) COMMIT > > 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

Re: [sqlite] How make atomic? Was: Sqlite as a FIFO buffer?

2009-05-18 Thread Doug Currie
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

Re: [sqlite] How make atomic? Was: Sqlite as a FIFO buffer?

2009-05-18 Thread Allen Fowler
> Have you considered using a more generic message queuing program? > Wikipedia has a good page about it: > > http://en.wikipedia.org/wiki/Message_queue > > There is even a standardised protocol - AMQP: > > http://en.wikipedia.org/wiki/Advanced_Message_Queuing_Protocol > > You could

Re: [sqlite] How make atomic? Was: Sqlite as a FIFO buffer?

2009-05-18 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Have you considered using a more generic message queuing program? Wikipedia has a good page about it: http://en.wikipedia.org/wiki/Message_queue There is even a standardised protocol - AMQP:

[sqlite] How make atomic? Was: Sqlite as a FIFO buffer?

2009-05-18 Thread Allen Fowler
> >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!