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.

Van Nguyen
  • 682
  • 3
  • 11
  • 21

4 Answers4

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

Garett Long
  • 111
  • 1
  • 2
  • 1
    @confirmed mysql Ver 14.14 Distrib 5.5.44 – Jichao Sep 20 '15 at 08:43
  • 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.5](https://dev.mysql.com/doc/relnotes/mysql/5.5/en/news-5-5-0.html) – huch Apr 13 '18 at 11:56
6

libmysqlclient_r.a is thread-safe

Oswald
  • 31,254
  • 3
  • 43
  • 68
  • 7
    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. – R.. GitHub STOP HELPING ICE Dec 20 '10 at 03:38
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).

Krenair
  • 570
  • 5
  • 21
sep332
  • 1,039
  • 2
  • 13
  • 24
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.