2006-01-10 18:31:50 +00:00
|
|
|
---------------------------------------------------------------------
|
|
|
|
-- MySQL specific tests and configurations.
|
|
|
|
---------------------------------------------------------------------
|
|
|
|
|
2006-01-23 20:13:25 +00:00
|
|
|
QUERYING_STRING_TYPE_NAME = "binary(65535)"
|
|
|
|
|
2018-12-03 16:25:04 -02:00
|
|
|
---------------------------------------------------------------------
|
|
|
|
-- 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
|
|
|
|
|
2006-01-25 20:28:30 +00:00
|
|
|
table.insert (CUR_METHODS, "numrows")
|
|
|
|
table.insert (EXTENSIONS, numrows)
|
2018-12-03 16:25:04 -02:00
|
|
|
table.insert (CUR_METHODS, "seek")
|
|
|
|
table.insert (EXTENSIONS, seek)
|
2015-11-30 10:21:19 -02:00
|
|
|
table.insert (CONN_METHODS, "escape")
|
|
|
|
table.insert (EXTENSIONS, escape)
|
2006-01-25 20:28:30 +00:00
|
|
|
|
2006-01-10 18:31:50 +00:00
|
|
|
---------------------------------------------------------------------
|
|
|
|
-- Build SQL command to create the test table.
|
|
|
|
---------------------------------------------------------------------
|
|
|
|
local _define_table = define_table
|
|
|
|
function define_table (n)
|
2017-02-23 14:41:35 -03:00
|
|
|
return _define_table(n) .. " ENGINE = InnoDB;"
|
2006-01-10 18:31:50 +00:00
|
|
|
end
|
|
|
|
|
2006-01-10 18:34:54 +00:00
|
|
|
---------------------------------------------------------------------
|
|
|
|
-- MySQL versions 4.0.x do not implement rollback.
|
|
|
|
---------------------------------------------------------------------
|
|
|
|
local _rollback = rollback
|
|
|
|
function rollback ()
|
|
|
|
if luasql._MYSQLVERSION and string.sub(luasql._MYSQLVERSION, 1, 3) == "4.0" then
|
|
|
|
io.write("skipping rollback test (mysql version 4.0.x)")
|
|
|
|
return
|
|
|
|
else
|
|
|
|
_rollback ()
|
|
|
|
end
|
|
|
|
end
|