Otis wrote:
Fetches aren't done in an implicit transaction, i.e.: if you don't start a transaction, there's no transaction started. If you want to fetch them in one transaction, you have to start one, and make sure you use innodb on mysql otherwise you won't get any transaction at all (besides the fact that mysql and transactions are still not that big friends).
That answers my question, many thanks!
Otis wrote:
The scenario you described is possible and you can't prevent it. The thing is: the delete can also happen right AFTER you've fetched the data. The data in the db is then different from what you have in memory.
Considering it is a web application, locking is not an option. Saving data will have to rely on some sort of optimistic concurrency control. That's OK with me.
Yet I still have to be careful and ensure that the data is read consistently. Either by wrapping fetches in a transaction, or by... don't know yet.
And just to make things clear: recursive Saves are done in an implicit transaction, aren't they?