What is difference between libmysqlclient.a and libmysqlclient_r.a?
Asked Answered
F

4

8

Which should I use to link for mysqlclient library? What is the difference between them? I can't seem to find the answer. Thanks.

Finding answered 20/12, 2010 at 3:9 Comment(0)
E
6

libmysqlclient_r.a is thread-safe

Enyo answered 20/12, 2010 at 3:13 Comment(1)
This answer is incomplete. Does libmyqslclient.a have nasty internal global state that's not properly protected by mutexes? Or does it just not allow you to use the same database connection object simultaneously from multiple threads? This is a huge difference. If it's the former, any library code must use the _r version to avoid conflicting with other libraries that might or might not be used by the caller. If it's the latter, only programs which want to access the same database connection from multiple threads need to use the _r version.Hawthorn
H
11

Newer versions of the MySQL client distributions do not include the "_r" version. Some may have a symbolic link from libmyqslclient_r.a to libmyqslclient.a

Hwahwan answered 30/8, 2011 at 11:19 Comment(2)
@confirmed mysql Ver 14.14 Distrib 5.5.44Identity
Quote: "The libmysqlclient client library is now built as a thread-safe library. The libmysqlclient_r client library is still present for compatibility, but is just a symbolic link to libmysqlclient.", see Changelog for msyql 5.5Zonate
E
6

libmysqlclient_r.a is thread-safe

Enyo answered 20/12, 2010 at 3:13 Comment(1)
This answer is incomplete. Does libmyqslclient.a have nasty internal global state that's not properly protected by mutexes? Or does it just not allow you to use the same database connection object simultaneously from multiple threads? This is a huge difference. If it's the former, any library code must use the _r version to avoid conflicting with other libraries that might or might not be used by the caller. If it's the latter, only programs which want to access the same database connection from multiple threads need to use the _r version.Hawthorn
A
5

libmysqlclient_r.a is "re-entrant". https://en.wikipedia.org/wiki/Reentrant_%28subroutine%29 But as Garret pointed out, there is no difference in newer versions (both are re-entrant).

Amidst answered 26/10, 2011 at 21:39 Comment(0)
D
3

libmysqlclient_r is guaranteed to be thread-safe per connection. However, MySQL documentations prior to MySQL 5.5 are vague on whether multi-threaded applications can link to libmysqlclient as long as there are no simultaneous access on a single MySQL connection handle.

Base on experience though, I used libmysqlclient for applications that processes 100-400 queries per second and have been running for 5 years. I've yet to encounter any issues.

Delphinedelphinia answered 11/7, 2012 at 10:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.