tags:

views:

66

answers:

1

Hi! 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.

+2  A: 

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.

idstam
Ops, so i'm screwed, I can't set a lock there :/
Manuel Abeledo