Adding test to check whether the setautocommit method is return a boolean. Correcting drivers MySQL, Oracle, Postgres and SQLite

This commit is contained in:
tomas 2007-03-09 14:56:20 +00:00
parent d29054b8b3
commit e00c33c287
5 changed files with 17 additions and 12 deletions

View File

@ -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 <assert.h>
@ -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;
}

View File

@ -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 <assert.h>
@ -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;
}

View File

@ -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 <assert.h>
@ -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;
}

View File

@ -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 <stdio.h>
@ -429,7 +429,8 @@ static int conn_setautocommit(lua_State *L)
lua_error(L);
}
}
return 0;
lua_pushboolean(L, 1);
return 1;
}

View File

@ -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