tech rant: mysql
Sep. 2nd, 2008 02:14 pmI would like to give a serious clue-by-four beating to whoever thought it was a good idea to implement last_insert_id() many versions before adding transactions to MySQL. In a transactional context, it's a possibly useful function, though I prefer specifying what I want the last ID from, a la PG's currval. Outside of one? Dangerously unreliable, a concept one or more of my predecessors completely failed to grasp.
[end rant]
[end rant]
no subject
Date: 2008-09-03 04:59 pm (UTC)no subject
Date: 2008-09-03 05:04 pm (UTC)no subject
Date: 2008-09-03 06:30 pm (UTC)no subject
Date: 2008-09-03 06:32 pm (UTC)no subject
Date: 2008-09-04 08:18 am (UTC)How are you getting burned by last_insert_id ()? I'm using it in my code, and to the best of my knowledge I'm not getting burned by it.
no subject
Date: 2008-09-04 02:55 pm (UTC)Due to the non-transactional nature of the interactions in the current system, occasionally another insert happens between the insert and the last_insert_id call, and last_insert_id will return an id from another table altogether.
It's not common, but it is possible.
Also, certain people in the past of this codebase wrote overly clever functions which have been annoying to convert to Postgres.
no subject
Date: 2008-09-04 11:02 pm (UTC)Happily, I took a look at my code, and it turns out I'm not using that call after all. :-)