Quote:
Originally Posted by InformixWilli
You want your own last inserted row and not the last one in general?
|
no, i'm talking about a
race condition
user one adds a row, it gets assigned id 52
user two adds a row, it gets assigned id 53
user one does his SELECT MAX, and gets 53 (wrong!!)
user two does his SELECT MAX, and gets 53 (right!! a coincidence!!)
see
tocttou
there are two options: use transaction locking, or find a different method
hint: requerying with a candidate key is lock-free and guaranteed safe against race conditions