2011/3/30 Jonathan Wakely <mysql@stripped>:
> On 30 March 2011 14:03, KiberGus wrote:
>> Today I've stucked in quite a veird bug. My application was written according to
>> was called before grabbing connection from connection pool.
>> thread_start was called before mysql_init on a first call. As a result
>> pthread_getspecific() was called with an unallocated pthread key as an
>> argument. This bug is especially hard to find because thread key has 0
>> value by default and would recieve 0 value on first call to
>> pthread_key_create. So you would never notice this if you don't use
>> thread specific pointers anywhere else beside mysql.
>> But i have used libmysql which uses it too.
> Isn't this a bug in mysql_thread_init, as calling that is all that
> Connection::thread_start does?
MySQL documentation does not warn much about allowed order of calls.
But ducumentation for my_init
However, my_init() is automatically called by mysql_init(),
mysql_library_init(), mysql_server_init(), and mysql_connect(). If you
ensure that your program invokes one of those functions before any
other MySQL calls, there is no need to invoke my_init() explicitly.
I tend to interpret it as a requirement that application MUST start
it's work with library with call to mysql_init(),
mysql_library_init(), mysql_server_init(), mysql_connect() or
my_init(). And then it is documented feature of mysql library and bug
is in mysql++ rather than in mysql_thread_init.