in reply to Re: Sharing DBI handle per each thread
in thread Sharing DBI handle per each thread
However, the internal pointer data within the handles will refer to the DBI and drivers in the original interpreter. Using those handles in the new interpreter thread is not safe, so the DBI detects this and croaks on any method call using handles that don't belong to the current thread (except for DESTROY).
Because of this (possibly temporary) restriction, newly created threads must make their own connctions to the database. Handles can't be shared across threads.
But BEWARE, some underlying database APIs (the code the DBD driver uses to talk to the database, often supplied by the database vendor) are not thread safe. If it's not thread safe, then allowing more than one thread to enter the code at the same time may cause subtle/serious problems. In some cases allowing more than one thread to enter the code, even if not at the same time, can cause problems. You have been warned.
Can't really be much plainer can it!
|
|---|