--- a/dbd/db2/connection.c Sat Jun 13 08:55:44 2009 +0000 +++ b/dbd/db2/connection.c Tue Sep 01 13:15:02 2009 +0000 @@ -230,6 +230,17 @@ return 0; } +/* + * __tostring + */ +static int connection_tostring(lua_State *L) { + connection_t *conn = (connection_t *)luaL_checkudata(L, 1, DBD_DB2_CONNECTION); + + lua_pushfstring(L, "%s: %p", DBD_DB2_CONNECTION, conn); + + return 1; +} + int dbd_db2_connection(lua_State *L) { static const luaL_Reg connection_methods[] = { {"autocommit", connection_autocommit}, @@ -255,6 +266,9 @@ lua_pushcfunction(L, connection_gc); lua_setfield(L, -2, "__gc"); + lua_pushcfunction(L, connection_tostring); + lua_setfield(L, -2, "__tostring"); + luaL_register(L, DBD_DB2_CONNECTION, connection_class_methods); return 1;