I'm using MySQL C API to build a db client application, and i need to get the last autoincremented value in a INSERT statement, so mysql_insert_id does.
But this client is multithreaded and a piece of code like this:
mysql_query(conn, query_string); value = mysql_insert_id(conn);
I don't know what will it return, this query autogenerated id or something else. Any clues?
Thanks in advance.
According to the documentation mysql_insert_id will return an id of the last successful insert on the current connection.
So if you use the same connection for several threads it will not be thread safe.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With