lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Thank you,
I am using ls_odbc.c which uses a totally different
scheme to ls_pg.c. I am testing in Win32 and trying to
implement on IBM DB2.
I think I have sorted some of my problems by moving some
of the code from ls_pg.c to ls_odbc.c. The malloc of env
handles in ls_odbc was a leak.

> lua_pushusertag(L, conn, env->conn_tag);
> cursor->conn = lua_ref(L, 1);
> /* gc method closes handle, does  lua_unref(L, cursor->conn);
> and presumably relies on gc to clean up the cursor userdata */
> See the  code above?  The reference ensures  that the  connection object
> will not be GCed before the cursor object is GCed. Is this not working?
it works. However, I am not sure about the ODBC equivalent.

My bug, (which is hard to cause and harder to debug) occurs
after lots of selects and I get an "invalid SQL handle" reported
from DB2. It would seem that the handle (stmt handle) has been
closed. I presume that the gc has closed it. Methinks that the
gc is being invoked during the fetch loop.

Also, Can you explain the code in ls_pg.c that reads

 /* Change tag. Otherwise we will create another userdata when we push it.
    lua_settag(L, edata->env_tag);
    lua_pop(L, 1);

Thanks again