Adding cur:seek() method to MySQL driver.
This commit is contained in:
parent
48d33e4109
commit
acf8e021bf
@ -322,6 +322,17 @@ static int cur_numrows (lua_State *L) {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Seeks to an arbitrary row in a query result set.
|
||||
*/
|
||||
static int cur_seek (lua_State *L) {
|
||||
cur_data *cur = getcursor (L);
|
||||
lua_Integer rownum = luaL_checkinteger (L, 2);
|
||||
mysql_data_seek (cur->my_res, rownum);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Create a new Cursor object and push it on top of the stack.
|
||||
*/
|
||||
@ -592,6 +603,7 @@ static void create_metatables (lua_State *L) {
|
||||
{"getcoltypes", cur_getcoltypes},
|
||||
{"fetch", cur_fetch},
|
||||
{"numrows", cur_numrows},
|
||||
{"seek", cur_seek},
|
||||
{NULL, NULL},
|
||||
};
|
||||
luasql_createmeta (L, LUASQL_ENVIRONMENT_MYSQL, environment_methods);
|
||||
@ -633,7 +645,6 @@ lua_pushliteral (L, MARIADB_CLIENT_VERSION_STR);
|
||||
#else
|
||||
lua_pushliteral (L, MYSQL_SERVER_VERSION);
|
||||
#endif
|
||||
/*lua_pushliteral (L, MYSQL_SERVER_VERSION);*/
|
||||
lua_settable (L, -3);
|
||||
return 1;
|
||||
}
|
||||
|
@ -1,12 +1,34 @@
|
||||
---------------------------------------------------------------------
|
||||
-- MySQL specific tests and configurations.
|
||||
-- $Id: mysql.lua,v 1.4 2006/01/25 20:28:30 tomas Exp $
|
||||
---------------------------------------------------------------------
|
||||
|
||||
QUERYING_STRING_TYPE_NAME = "binary(65535)"
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- Seeks to an arbitrary row in a query result set.
|
||||
---------------------------------------------------------------------
|
||||
function seek ()
|
||||
-- Inserts three rows.
|
||||
assert2 (3, CONN:execute"insert into t (f1) values ('a'), ('b'), ('c')", "could not insert a new record")
|
||||
cur = CUR_OK(CONN:execute"select * from t")
|
||||
assert2('a', cur:fetch())
|
||||
assert2('b', cur:fetch())
|
||||
cur:seek(1)
|
||||
assert2('b', cur:fetch())
|
||||
assert2('c', cur:fetch())
|
||||
cur:seek(1)
|
||||
assert2('b', cur:fetch())
|
||||
assert2('c', cur:fetch())
|
||||
assert2(nil, cur:fetch())
|
||||
cur:close()
|
||||
|
||||
io.write (" seek")
|
||||
end
|
||||
|
||||
table.insert (CUR_METHODS, "numrows")
|
||||
table.insert (EXTENSIONS, numrows)
|
||||
table.insert (CUR_METHODS, "seek")
|
||||
table.insert (EXTENSIONS, seek)
|
||||
table.insert (CONN_METHODS, "escape")
|
||||
table.insert (EXTENSIONS, escape)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user