diff --git a/src/ls_mysql.c b/src/ls_mysql.c index 0694353..c7ff7df 100644 --- a/src/ls_mysql.c +++ b/src/ls_mysql.c @@ -2,7 +2,7 @@ ** LuaSQL, MySQL driver ** Authors: Eduardo Quintao ** See Copyright Notice in license.html -** $Id: ls_mysql.c,v 1.22 2006/08/22 14:42:59 tomas Exp $ +** $Id: ls_mysql.c,v 1.23 2007/03/09 14:56:20 tomas Exp $ */ #include @@ -426,7 +426,8 @@ static int conn_setautocommit (lua_State *L) { else { mysql_autocommit(conn->my_conn, 0); } - return 0; + lua_pushboolean(L, 1); + return 1; } diff --git a/src/ls_oci8.c b/src/ls_oci8.c index 43a4df6..dd756c2 100644 --- a/src/ls_oci8.c +++ b/src/ls_oci8.c @@ -2,7 +2,7 @@ ** LuaSQL, Oracle driver ** Authors: Tomas Guisasola, Leonardo Godinho ** See Copyright Notice in license.html -** $Id: ls_oci8.c,v 1.26 2006/08/22 14:42:59 tomas Exp $ +** $Id: ls_oci8.c,v 1.27 2007/03/09 14:56:20 tomas Exp $ */ #include @@ -704,7 +704,8 @@ static int conn_setautocommit (lua_State *L) { conn->auto_commit = 0; /* sql_begin(conn);*/ } - return 0; + lua_pushboolean(L, 1); + return 1; } diff --git a/src/ls_postgres.c b/src/ls_postgres.c index 2704c92..7294a84 100644 --- a/src/ls_postgres.c +++ b/src/ls_postgres.c @@ -3,7 +3,7 @@ ** Authors: Pedro Rabinovitch, Roberto Ierusalimschy, Carlos Cassino ** Tomas Guisasola, Eduardo Quintao ** See Copyright Notice in license.html -** $Id: ls_postgres.c,v 1.5 2006/09/18 14:04:56 tomas Exp $ +** $Id: ls_postgres.c,v 1.6 2007/03/09 14:56:20 tomas Exp $ */ #include @@ -397,7 +397,8 @@ static int conn_setautocommit (lua_State *L) { conn->auto_commit = 0; sql_begin(conn); } - return 0; + lua_pushboolean(L, 1); + return 1; } diff --git a/src/ls_sqlite.c b/src/ls_sqlite.c index 95b1000..aabbd9a 100644 --- a/src/ls_sqlite.c +++ b/src/ls_sqlite.c @@ -2,7 +2,7 @@ ** LuaSQL, SQLite driver ** Author: Tiago Dionizio, Eduardo Quintao ** See Copyright Notice in license.html -** $Id: ls_sqlite.c,v 1.9 2006/08/22 14:42:59 tomas Exp $ +** $Id: ls_sqlite.c,v 1.10 2007/03/09 14:56:20 tomas Exp $ */ #include @@ -429,7 +429,8 @@ static int conn_setautocommit(lua_State *L) lua_error(L); } } - return 0; + lua_pushboolean(L, 1); + return 1; } diff --git a/tests/test.lua b/tests/test.lua index 90defd7..4d34d67 100644 --- a/tests/test.lua +++ b/tests/test.lua @@ -359,7 +359,8 @@ end --------------------------------------------------------------------- --------------------------------------------------------------------- function rollback () - CONN:setautocommit (false) -- == begin transaction + -- begin transaction + assert2 (true, CONN:setautocommit (false), "couldn't disable autocommit") -- insert a record and commit the operation. assert2 (1, CONN:execute ("insert into t (f1) values ('a')")) local cur = CUR_OK (CONN:execute ("select count(*) from t")) @@ -400,7 +401,7 @@ function rollback () assert2 (2, tonumber (cur:fetch ()), "Insert failed") assert2 (true, cur:close(), "couldn't close cursor") assert2 (false, cur:close()) - CONN:setautocommit (true) + assert2 (true, CONN:setautocommit (true), "couldn't enable autocommit") -- check resulting table with one record. cur = CUR_OK (CONN:execute ("select count(*) from t")) assert2 (1, tonumber(cur:fetch()), "Rollback failed") @@ -410,7 +411,7 @@ function rollback () -- clean the table. assert2 (1, CONN:execute (sql_erase_table"t")) CONN:commit () - CONN:setautocommit (true) + assert2 (true, CONN:setautocommit (true), "couldn't enable autocommit") -- check resulting table with no records. cur = CUR_OK (CONN:execute ("select count(*) from t")) assert2 (0, tonumber(cur:fetch()), "Rollback failed") @@ -486,8 +487,8 @@ end --------------------------------------------------------------------- --------------------------------------------------------------------- function drop_table () + assert2 (true, CONN:setautocommit(true), "couldn't enable autocommit") -- Postgres retorna 0, enquanto ODBC retorna -1. - CONN:setautocommit(true) assert2 (DROP_TABLE_RETURN_VALUE, CONN:execute ("drop table t")) end