That definitely does the job. My point is that it is much more complex than a select/update clause in SQL.
Yep, TaskTiger also uses Lua quite extensively ([0]) to ensure atomicity when moving tasks between various stages of processing (queued, active, scheduled, errored).