Documentation Home
MySQL 5.6 リファレンスマニュアル
Download this Manual
PDF (US Ltr) - 26.8Mb
PDF (A4) - 26.9Mb
HTML Download (TGZ) - 7.1Mb
HTML Download (Zip) - 7.2Mb mysql_thread_init()

my_bool mysql_thread_init(void)


この関数は、スレッド固有変数を初期化するために、作成された各スレッド内の早期に呼び出す必要があります。ただし、必ずしもそれを明示的に呼び出す必要がないことがあります。mysql_thread_init()my_init() によって自動的に呼び出され、それ自体も mysql_init()mysql_library_init()mysql_server_init()、および mysql_connect() によって自動的に呼び出されます。それらの関数のいずれかを呼び出すと、mysql_thread_init() が自動的に呼び出されます。



User Comments
User comments in this section are, as the name implies, provided by MySQL users. The MySQL documentation team is not responsible for, nor do they endorse, any of the information provided here.
  Posted by Gordon Eldest on August 5, 2012
mysql_thread_init() did crash on my machine, did investigate as mysql_init() is doing it for me.

MORE IMPORTANT remember that:

1) A new thread NEED a SPECIFIC new MYSQL* handle.
So need a call mysql_init() WITHIN your new thread.
(libmysql work badly with exotic error if you use MYSQL* handle from another thread)

Also check
if (!mysql_thread_safe()) {
m_strErrorMessage = "Thread Safe OFF: ";
ASSERT(0); // Major problem: libmysqlcompiled ThreadSafe?

2) you NEED EXPLICTELY to call mysql_thread_end() !!
Do it once you release mysql_close(MYSQL*..)
Or you will get Handle leak !!
(which is as bad as memory leak!)

So no bugs but if multithread carefully read API doc

For reference our destructor of our generci MySqL handler object.

if (m_poMySQLHandle && m_bConnection ){ // Did we use it?
mysql_close(m_poMySQLHandle) ;
mysql_thread_end(); //or 3 Handle leak!
if (--s_ref==0){ // incremented in ::Connect