开发者

Is mysql_insert_id thread safe?

I'm using MySQL C API to build a db c开发者_Go百科lient 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜