Fix some built-in database methods error-checking bugs