Ok, I've narrowed down the problem.

I'm calling Ns_TclAllocateInterp() from a callback in SQLite. I want to
write SQLite functions using Tcl, which should be pretty easy.

The problem is that I do not know the Tcl_Interp that called 'ns_db
select'. Things get complicated when current thread has no connection
(otherwise I can get an interp using Ns_ConnGetInterp()).

Anyway, the problem is that Ns_TclDeAllocateInterp() does cleaning up,
which also happens to delete all connection handles and local variables.

Here's an example:

test8008:nscp 1> set h [ns_db gethandle sqlite];
set s [ns_db select $h "SELECT 1"];
while {[ns_db getrow $h $s]} {}
ns_set free $s

test8008:nscp 2> set h [ns_db gethandle sqlite];
set s [ns_db select $h "SELECT NOW()"];
while {[ns_db getrow $h $s]} {}
ns_set free $s
could not allocate 1 handle from pool "sqlite"

So the real question is do I always have to call Ns_TclDeAllocateInterp?
From the 3.4.2 sources it seems that it only does some cleaning up, so
there shouldn't be any problems and there aren't any refcount checks.

--
WK


-- AOLserver - http://www.aolserver.com/ To Remove yourself from this list: http://www.aolserver.com/listserv.html List information and options: http://listserv.aol.com/

Reply via email to