Guest User

Untitled

a guest
Nov 18th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. BEGIN;
  2. SELECT stuff ... FOR UPDATE;
  3. fetches `stuff` and prevents (via a lock) other connections from messing with row(s).
  4. work with `stuff`.
  5. UPDATE the rows SELECTed (or a subset of them)
  6. COMMIT;
  7.  
  8. (autocommit=1)
  9. UPDATE Queue... WHERE ... LIMIT... -- Grab row for self
  10. SELECT ... WHERE ... -- Make sure I got it, and fetch id
  11. if got it -- Perhaps someone else got it
  12. then
  13. BEGIN;
  14. work on application things
  15. COMMIT;
  16. endif
  17. DELETE FROM Queue WHERE ... -- remove from queue
Add Comment
Please, Sign In to add comment