Hi!

>>>>> "Michael" == Michael Chang <[EMAIL PROTECTED]> writes:

>> For example, have you called mysql_thread_init() before calling
>> mysql_real_connect() in all your threads ?

Michael> However, to my understanding, mysql_thread_init() is not needed if
Michael> only one database connection is used, and that database connection
Michael> is established when the program starts, before any threads have been
Michael> created.

Sorry, but this in not true.

You have to call mysql_thread_init() for each thread that is not
calling mysql_real_connect()

This is needed to setup some thread local variables MySQL needs to
make things threadsafe.

Michael>  That is, if you call mysql_real_connect() at the top
Michael> of main(), for example, and you let the connection persist for the
Michael> lifetime of the program, then mysql_thread_init() is not necessary,

It is necessary

Michael> and the only thing that you must worry about is to make sure that
Michael> critical sections (like between mysql_real_query() and 
Michael> mysql_store_result()) are sandwiched in-between a mutex lock.

Michael> If the above is incorrect, please let me know.

Please read the manual section about how to make a thread safe
client. This explains in detail what you have to do!


Regards,
Monty

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to