--- a/dbd/postgresql/connection.c Sat Jun 13 08:55:44 2009 +0000 +++ b/dbd/postgresql/connection.c Tue Sep 01 13:15:02 2009 +0000 @@ -257,6 +257,17 @@ return 0; } +/* + * __tostring + */ +static int connection_tostring(lua_State *L) { + connection_t *conn = (connection_t *)luaL_checkudata(L, 1, DBD_POSTGRESQL_CONNECTION); + + lua_pushfstring(L, "%s: %p", DBD_POSTGRESQL_CONNECTION, conn); + + return 1; +} + int dbd_postgresql_connection(lua_State *L) { static const luaL_Reg connection_methods[] = { {"autocommit", connection_autocommit}, @@ -282,6 +293,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_POSTGRESQL_CONNECTION, connection_class_methods); return 1;