On Tuesday 08 August 2006 08:58, John Buckman wrote:
> Interesting that you use ns_atclose, why not use the default
> mechanism, which is registered with ns_db ? Like so:
>
> static Ns_DbProc dbProcs[] = {
> {DbFn_ServerInit, DbServerInit},
> {DbFn_Name, DbName},
> {DbFn_DbType, DbDbType},
> {DbFn_OpenDb, DbOpenDb},
> {DbFn_CloseDb, DbCloseDb},
> {DbFn_DML, DbDML},
> {DbFn_GetRow, DbGetRow},
> {DbFn_Flush, DbFlush},
> {DbFn_Cancel, DbCancel},
> {DbFn_Exec, DbExec},
> {DbFn_BindRow, DbBindRow},
> {DbFn_ResetHandle,DbResetHandle},
> {0, NULL}
> };
>
> or is it just the case that you're not using ns_db at all, and wrote
> your own?
>
I do use these APIs, it is just how I get to them that is different.
Essentially I use a wrapper api which simplifies handle/transaction
use/reuse/release. When a thread starts up it will have no db handles. Once
one is used, it can be reused. If the thread needs a second handle, it can
grab one without first releasing the ones it has. So the thread ends up with
only as many handles as it needed. If an error occurs certain db drivers will
keep a transaction alive.
After looking at my code, it appears that db handles are released when a
connection closes. But in the C code, if a transaction isn't committed or
rolled back, the database is still holding it open. When you reuse the handle
there will be problems. So my ns_atclose fixes any transactions, but handles
are automatically released from the thread.
This page shows three database queries, all using the same handle:
http://rmadilo.com/m2/servers/rmadilo/pages/remodel/req-detail.tcl
So my database API is similar to the OACS db_ api, however it is
much-much-much simpler, doesn't use catch for transactions, allows you to
nest arbitrary transactions (or to run transactions concurrently).
All queries pass through ns_db execute and the return value is easy to test to
figure out the result, so you never, ever have to catch ns_db 1row, ns_db
0or1row or ns_db select.
tom jackson
--
AOLserver - http://www.aolserver.com/
To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]>
with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject:
field of your email blank.