You have to call open & close in the same thread, and in each thread if
needed.

" The returned sqlite3* can only be used in the same thread in which it was
created. It is an error to call
sqlite3_open<http://www.sqlite.org/capi3ref.html#sqlite3_open>()
in one thread then pass the resulting database handle off to another thread
to use. This restriction is due to goofy design decisions (bugs?) in the way
some threading implementations interact with file locks."

<http://www.sqlite.org/capi3ref.html#sqlite3_open>

Hope this help

Ludovic

On 3/21/06, Ralf Junker <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
> I am using SQLite compiled with SQLITE_ENABLE_MEMORY_MANAGEMENT on Win32.
>
> I execute the following psydocode, all with same DB handle:
>
> * In application's main thread: sqlite3_open
> * Create a new thread
> * In new thread: sqlite3_close
>
> This creates an access violation in pager.c, lines 2065 to 2076:
>
> #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
>   /* Remove the pager from the linked list of pagers starting at
>   ** ThreadData.pPager if memory-management is enabled.
>   */
>   if( pPager==pTsd->pPager ){
>     pTsd->pPager = pPager->pNext;
>   }else{
>     Pager *pTmp;
>     for(pTmp = pTsd->pPager; pTmp->pNext!=pPager; pTmp=pTmp->pNext);
>     pTmp->pNext = pPager->pNext;
>   }
> #endif
>
> While I understand from the FAQ that it might be problematic to use more
> than one thread with SQLITE_ENABLE_MEMORY_MANAGEMENT, I wonder if SQLite
> should cause an AV in this case?
>
> I even found that other SQL instructions, like INSERT, work fine when
> called from the 2nd thread.
>
> Could anybody help, please?
>
> Thanks & regards,
>
> Ralf
>
>

Reply via email to