I'm confused by manual's tutorial for threading. I don't believe I need any of the thread-safe measures, because while the worker thread is running, the main thread doesn't make any MySQL calls. So the only issue I should be facing is getting the connection to work in a different thread, and not worry about synchronization. This is the code I have for my worker thread:
verify(mysql_library_init(-1, NULL, NULL) == 0);
verify(mysql_thread_init() == 0);
Both of these calls return 0, but when I try to make a query, after a long pause, I sometimes get the error "Query was empty" which it isn't, and sometimes "Lost connection to MySQL server during query". What's going on?
The manual seems to imply that mysql_library_init() doesn't need to be called, because it is called by mysql_init(). Nevertheless, the manual (http://dev.mysql.com/doc/refman/4.1/en/threaded-clients.html) recommends it be called anyway for multithreading, even though it also recommends that the thing be called before thread creation. Including winds up being the same as the omitting it, because the result is the same.