dbd/oracle/statement.c

changeset 32
03ed0ca09837
parent 31
999ef93f0dbc
--- a/dbd/oracle/statement.c	Sat Jun 13 08:55:44 2009 +0000
+++ b/dbd/oracle/statement.c	Tue Sep 01 13:15:02 2009 +0000
@@ -475,6 +475,17 @@
     return 0;
 }
 
+/*
+ * __tostring
+ */
+static int statement_tostring(lua_State *L) {
+    statement_t *statement = (statement_t *)luaL_checkudata(L, 1, DBD_ORACLE_STATEMENT);
+
+    lua_pushfstring(L, "%s: %p", DBD_ORACLE_STATEMENT, statement);
+
+    return 1;
+}
+
 int dbd_oracle_statement_create(lua_State *L, connection_t *conn, const char *sql_query) { 
     int rc;
     statement_t *statement = NULL;
@@ -528,6 +539,9 @@
     lua_pushcfunction(L, statement_gc);
     lua_setfield(L, -2, "__gc");
 
+    lua_pushcfunction(L, statement_tostring);
+    lua_setfield(L, -2, "__tostring");
+
     luaL_register(L, DBD_ORACLE_STATEMENT, statement_class_methods);
 
     return 1;    

mercurial