Re-write select_random*.lua benchmarks to the new SQL API.
This commit is contained in:
@ -489,14 +489,15 @@ int mysql_drv_disconnect(db_conn_t *sb_conn)
|
||||
|
||||
int mysql_drv_prepare(db_stmt_t *stmt, const char *query, size_t len)
|
||||
{
|
||||
db_mysql_conn_t *db_mysql_con = (db_mysql_conn_t *) stmt->connection->ptr;
|
||||
MYSQL *con = db_mysql_con->mysql;
|
||||
MYSQL_STMT *mystmt;
|
||||
unsigned int rc;
|
||||
|
||||
if (args.dry_run)
|
||||
return 0;
|
||||
|
||||
db_mysql_conn_t *db_mysql_con = (db_mysql_conn_t *) stmt->connection->ptr;
|
||||
MYSQL *con = db_mysql_con->mysql;
|
||||
|
||||
if (con == NULL)
|
||||
return 1;
|
||||
|
||||
@ -557,8 +558,6 @@ int mysql_drv_prepare(db_stmt_t *stmt, const char *query, size_t len)
|
||||
|
||||
int mysql_drv_bind_param(db_stmt_t *stmt, db_bind_t *params, size_t len)
|
||||
{
|
||||
db_mysql_conn_t *db_mysql_con = (db_mysql_conn_t *) stmt->connection->ptr;
|
||||
MYSQL *con = db_mysql_con->mysql;
|
||||
MYSQL_BIND *bind;
|
||||
unsigned int i;
|
||||
my_bool rc;
|
||||
@ -567,6 +566,9 @@ int mysql_drv_bind_param(db_stmt_t *stmt, db_bind_t *params, size_t len)
|
||||
if (args.dry_run)
|
||||
return 0;
|
||||
|
||||
db_mysql_conn_t *db_mysql_con = (db_mysql_conn_t *) stmt->connection->ptr;
|
||||
MYSQL *con = db_mysql_con->mysql;
|
||||
|
||||
if (con == NULL)
|
||||
return 1;
|
||||
|
||||
@ -629,12 +631,16 @@ int mysql_drv_bind_param(db_stmt_t *stmt, db_bind_t *params, size_t len)
|
||||
|
||||
int mysql_drv_bind_result(db_stmt_t *stmt, db_bind_t *params, size_t len)
|
||||
{
|
||||
db_mysql_conn_t *db_mysql_con =(db_mysql_conn_t *) stmt->connection->ptr;
|
||||
MYSQL *con = db_mysql_con->mysql;
|
||||
MYSQL_BIND *bind;
|
||||
unsigned int i;
|
||||
my_bool rc;
|
||||
|
||||
if (args.dry_run)
|
||||
return 0;
|
||||
|
||||
db_mysql_conn_t *db_mysql_con =(db_mysql_conn_t *) stmt->connection->ptr;
|
||||
MYSQL *con = db_mysql_con->mysql;
|
||||
|
||||
if (con == NULL || stmt->ptr == NULL)
|
||||
return 1;
|
||||
|
||||
@ -924,6 +930,9 @@ int mysql_drv_fetch(db_result_t *rs)
|
||||
/* NYI */
|
||||
(void)rs; /* unused */
|
||||
|
||||
if (args.dry_run)
|
||||
return DB_ERROR_NONE;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -934,6 +943,9 @@ int mysql_drv_fetch(db_result_t *rs)
|
||||
|
||||
int mysql_drv_fetch_row(db_result_t *rs, db_row_t *row)
|
||||
{
|
||||
if (args.dry_run)
|
||||
return DB_ERROR_NONE;
|
||||
|
||||
db_mysql_conn_t *db_mysql_con = (db_mysql_conn_t *) rs->connection->ptr;
|
||||
row->ptr = mysql_fetch_row(rs->ptr);
|
||||
DEBUG("mysql_fetch_row(%p) = %p", rs->ptr, row->ptr);
|
||||
|
||||
59
sysbench/lua/select_random_points.lua
Normal file
59
sysbench/lua/select_random_points.lua
Normal file
@ -0,0 +1,59 @@
|
||||
-- This test is designed for testing MariaDB's key_cache_segments for MyISAM,
|
||||
-- and should work with other storage engines as well.
|
||||
--
|
||||
-- For details about key_cache_segments please refer to:
|
||||
-- http://kb.askmonty.org/v/segmented-key-cache
|
||||
--
|
||||
|
||||
-- Override oltp_tables_count, this test only supports a single table
|
||||
oltp_tables_count = 1
|
||||
|
||||
pathtest = string.match(test, "(.*/)")
|
||||
|
||||
if pathtest then
|
||||
dofile(pathtest .. "oltp_common.lua")
|
||||
else
|
||||
require("oltp_common")
|
||||
end
|
||||
|
||||
function thread_init()
|
||||
set_vars_points()
|
||||
|
||||
drv = sysbench.sql.driver()
|
||||
con = drv:connect()
|
||||
|
||||
local points = string.rep("?, ", random_points - 1) .. "?"
|
||||
|
||||
stmt = con:prepare(string.format([[
|
||||
SELECT id, k, c, pad
|
||||
FROM sbtest1
|
||||
WHERE k IN (%s)
|
||||
]], points))
|
||||
|
||||
params = {}
|
||||
for j = 1,random_points do
|
||||
params[j] = stmt:bind_create(sysbench.sql.type.INT)
|
||||
end
|
||||
|
||||
stmt:bind_param(unpack(params))
|
||||
|
||||
rlen = oltp_table_size / num_threads
|
||||
end
|
||||
|
||||
function event(thread_id)
|
||||
-- To prevent overlapping of our range queries we need to partition the whole
|
||||
-- table into num_threads segments and then make each thread work with its
|
||||
-- own segment.
|
||||
for i = 1,random_points do
|
||||
local rmin = rlen * thread_id
|
||||
local rmax = rmin + rlen
|
||||
params[i]:set(sb_rand(rmin, rmax))
|
||||
end
|
||||
|
||||
stmt:execute()
|
||||
end
|
||||
|
||||
function set_vars_points()
|
||||
set_vars()
|
||||
random_points = random_points or 10
|
||||
end
|
||||
62
sysbench/lua/select_random_ranges.lua
Normal file
62
sysbench/lua/select_random_ranges.lua
Normal file
@ -0,0 +1,62 @@
|
||||
-- This test is designed for testing MariaDB's key_cache_segments for MyISAM,
|
||||
-- and should work with other storage engines as well.
|
||||
--
|
||||
-- For details about key_cache_segments please refer to:
|
||||
-- http://kb.askmonty.org/v/segmented-key-cache
|
||||
--
|
||||
|
||||
-- Override oltp_tables_count, this test only supports a single table
|
||||
oltp_tables_count = 1
|
||||
|
||||
pathtest = string.match(test, "(.*/)")
|
||||
|
||||
if pathtest then
|
||||
dofile(pathtest .. "oltp_common.lua")
|
||||
else
|
||||
require("oltp_common")
|
||||
end
|
||||
|
||||
function thread_init()
|
||||
set_vars_ranges()
|
||||
|
||||
drv = sysbench.sql.driver()
|
||||
con = drv:connect()
|
||||
|
||||
local ranges = string.rep("k BETWEEN ? AND ? OR ", number_of_ranges - 1) ..
|
||||
"k BETWEEN ? AND ?"
|
||||
|
||||
stmt = con:prepare(string.format([[
|
||||
SELECT count(k)
|
||||
FROM sbtest1
|
||||
WHERE %s]], ranges))
|
||||
|
||||
params = {}
|
||||
for j = 1, number_of_ranges*2 do
|
||||
params[j] = stmt:bind_create(sysbench.sql.type.INT)
|
||||
end
|
||||
|
||||
stmt:bind_param(unpack(params))
|
||||
|
||||
rlen = oltp_table_size / num_threads
|
||||
end
|
||||
|
||||
function event(thread_id)
|
||||
-- To prevent overlapping of our range queries we need to partition the whole
|
||||
-- table into num_threads segments and then make each thread work with its
|
||||
-- own segment.
|
||||
for i = 1, number_of_ranges*2, 2 do
|
||||
local rmin = rlen * thread_id
|
||||
local rmax = rmin + rlen
|
||||
local val = sb_rand(rmin, rmax)
|
||||
params[i]:set(val)
|
||||
params[i+1]:set(val + delta)
|
||||
end
|
||||
|
||||
stmt:execute()
|
||||
end
|
||||
|
||||
function set_vars_ranges()
|
||||
set_vars()
|
||||
number_of_ranges = number_of_ranges or 10
|
||||
delta = random_ranges_delta or 5
|
||||
end
|
||||
@ -52,7 +52,7 @@ select_random_*.lua + MySQL tests
|
||||
write: 0
|
||||
other: 0
|
||||
total: 100
|
||||
transactions: 0 (0.00 per sec.)
|
||||
transactions: 100 (* per sec.) (glob)
|
||||
queries: 100 (* per sec.) (glob)
|
||||
ignored errors: 0 (0.00 per sec.)
|
||||
reconnects: 0 (0.00 per sec.)
|
||||
@ -122,7 +122,7 @@ select_random_*.lua + MySQL tests
|
||||
write: 0
|
||||
other: 0
|
||||
total: 100
|
||||
transactions: 0 (0.00 per sec.)
|
||||
transactions: 100 (* per sec.) (glob)
|
||||
queries: 100 (* per sec.) (glob)
|
||||
ignored errors: 0 (0.00 per sec.)
|
||||
reconnects: 0 (0.00 per sec.)
|
||||
@ -53,7 +53,7 @@ select_random_*.lua + PostgreSQL tests
|
||||
write: 0
|
||||
other: 0
|
||||
total: 100
|
||||
transactions: 0 (0.00 per sec.)
|
||||
transactions: 100 (* per sec.) (glob)
|
||||
queries: 100 (* per sec.) (glob)
|
||||
ignored errors: 0 (0.00 per sec.)
|
||||
reconnects: 0 (0.00 per sec.)
|
||||
@ -124,7 +124,7 @@ select_random_*.lua + PostgreSQL tests
|
||||
write: 0
|
||||
other: 0
|
||||
total: 100
|
||||
transactions: 0 (0.00 per sec.)
|
||||
transactions: 100 (* per sec.) (glob)
|
||||
queries: 100 (* per sec.) (glob)
|
||||
ignored errors: 0 (0.00 per sec.)
|
||||
reconnects: 0 (0.00 per sec.)
|
||||
Reference in New Issue
Block a user