On 9/8/06, Philippe Poelvoorde <[EMAIL PROTECTED]> wrote:
2006/9/8, Andrew W. Nosenko <[EMAIL PROTECTED]>:
> Sorry, but documentation on the MySQL C API say nothing about many
> interesting questions.
>
> The one of them: is it safe (or unsafe) to use non-MT client library
> (libmysqlclient.*, as opposite to the MT-aware libmysqlclient_r.*) for
> the multithreading programs in case when every parallel mysql
> connection (MYSQL*) lives in the own thread, is not shared between
> threads and doesn't migrates between threads.  Just born in the own
> thread, lives in the same own thread and dies in the own thread?  Of
> course, queries (select/insert/delete/..., both using "plain old"
> mysql_real_query() and prepared prepared statements, using
> transactions and not) may be executed in the one and the same time in
> the different threads.
>
> Second question: the same as first but for case when connections may
> migrate between threads -- born in the one thread, used in the second,
> dies in third... but anyway at the one time the one connection is used
> by the only one thread.  At the next time it may be another but,
> again, only one thread.

Well the only precaution you need for MT program regarding mysql
client lib, is to do a mysql_thread_init() and mysql_thread_end(); and
yes you should do it for every thread.
do you have a special requirement to use libmysql instead of
libmysql_r ?

The necessity to call these functions is very inconvenient if creating
and/or shutdown of threads is out of your control.

Call mysql_thread_begin() at the start of every function and
mysql_thread_end() before return?...  Yes, I can, but it efficiently
just removes the sense of the thread-private variables and slows down
the process.  Moreover, first that does mysql_thread_init() on the
POSIX systems is locking of the global mutex.  For what?  Why do not
do it _after_ pthread_getspecific() (on the POSIX systems, of course)?

Therefore I expect increasing of the speed and decreasing of the
complexity by declining the use of libmysqlclient_r.

I would guess there is some global variables or system
calls that might fails with the non-MT version.

I guess something like that also.  And this guess is the reason of the
my question.  I don't want to guess...  I want to know :-)

--
Andrew W. Nosenko <[EMAIL PROTECTED]>

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to