Which should I use to link for mysqlclient library? What is the difference between them? I can't seem to find the answer. Thanks.
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
libmysqlclient_r.a is thread-safe
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 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).
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.
© 2022 - 2024 — McMap. All rights reserved.
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