Return NULL only if there is an error code on the DB handle
Return zero (0) when there is no last key
Alter insert_id test to match changes for DB-4698