I know that deadlocks occur inevitably when using transactions in Innodb and that they are harmless if they are treated properly by the application code - "just try it again", as the manual says.
So I was wondering - how do you detect deadlocks? Does a deadlock issue some special mysql error number? I am using PHP's mysqli extension if that matters.
Thank you.
Edit: solution found, see comments
http://dev.mysql.com/doc/refman/5.0/en/innodb-error-codes.html
1213 (ER_LOCK_DEADLOCK)
Transaction deadlock. You should rerun the transaction.