>>>>> "Christian" == Christian Mack <Mack@stripped> writes:
Christian> Shane Wegner wrote:
>>
>> Hi,
>>
>> I wrote an application which uses threads and I am planning to add Mysql
>> support. My question is one relating to design and that is when a
>> multithreaded program uses Mysql using the mysqlclient library, is it best
>> to have each thread connect to the Mysql server seperately or is it safe
>> to use a shared handle. The MYSQL_RES and MYSQL_ROW would be local to the
>> thread of corse but can the handle be global? If it can, what will happen
>> when two threads submit a query? Will the second wait until the first
>> completes or should this construct just be avoided?
>>
>> --
>> Shane Wegner: shane@stripped
Christian> Hi Shane
Christian> You have to give each thread its own connection.
Christian> Mysql connections can't handle two concurrent queries.
Christian> If you want to reduce the amount of open connections, you can create a
> connection pool.
Christian> This obviously only will spare some connections as long as not all threads
> are querying at the same time.
Christian> Tschau
Christian> Christian
Hi!
You can use a global handle as long as you ensure that no other thread
calls access the handle until you have called mysql_store_result().
Regards,
Monty