http://www.perlmonks.org?node_id=1193869


in reply to Re^2: SELECT LAST_INSERT_ID does not work
in thread SELECT LAST_INSERT_ID does not work

It cannot guarantee it was not overwritten, but it can guarantee what was inserted by that statement.

If a trigger runs as a result of the select, the insert will not finish until the trigger is finished, so the next statement should be accurate. (I am assuming noone is trying to specifically avoid detection with some fancy logic in the trigger.)