Fix GH-250: mysql_table_options is not supported in oltp tests
OLTP scripts now support --create-table-options, which can be used to pass extra SQL to CREATE TABLE statements executed on 'prepare'. Ref. GH-252.
This commit is contained in:
@ -59,6 +59,8 @@ sysbench.cmdline.options = {
|
||||
{"Use AUTO_INCREMENT column as Primary Key (for MySQL), " ..
|
||||
"or its alternatives in other DBMS. When disabled, use " ..
|
||||
"client-generated IDs", true},
|
||||
create_table_options =
|
||||
{"Extra CREATE TABLE options", ""},
|
||||
skip_trx =
|
||||
{"Don't start explicit transactions and execute all queries " ..
|
||||
"in the AUTOCOMMIT mode", false},
|
||||
@ -169,7 +171,6 @@ function create_table(drv, con, table_num)
|
||||
id_def = "INTEGER NOT NULL"
|
||||
end
|
||||
engine_def = "/*! ENGINE = " .. sysbench.opt.mysql_storage_engine .. " */"
|
||||
extra_table_options = mysql_table_options or ""
|
||||
elseif drv:name() == "pgsql"
|
||||
then
|
||||
if not sysbench.opt.auto_inc then
|
||||
@ -193,7 +194,8 @@ CREATE TABLE sbtest%d(
|
||||
pad CHAR(60) DEFAULT '' NOT NULL,
|
||||
%s (id)
|
||||
) %s %s]],
|
||||
table_num, id_def, id_index_def, engine_def, extra_table_options)
|
||||
table_num, id_def, id_index_def, engine_def,
|
||||
sysbench.opt.create_table_options)
|
||||
|
||||
con:query(query)
|
||||
|
||||
|
||||
23
tests/t/script_oltp_general_mysql.t
Normal file
23
tests/t/script_oltp_general_mysql.t
Normal file
@ -0,0 +1,23 @@
|
||||
$ . $SBTEST_INCDIR/mysql_common.sh
|
||||
$ SB_EXTRA_ARGS=${SB_EXTRA_ARGS:-}
|
||||
$ ARGS="oltp_read_write ${DB_DRIVER_ARGS} --verbosity=1 ${SB_EXTRA_ARGS}"
|
||||
|
||||
$ sysbench $ARGS --create-table-options="COMMENT='foo'" prepare
|
||||
Creating table 'sbtest1'...
|
||||
Inserting 10000 records into 'sbtest1'
|
||||
Creating a secondary index on 'sbtest1'...
|
||||
|
||||
$ db_show_table sbtest1
|
||||
*************************** 1. row ***************************
|
||||
sbtest1
|
||||
CREATE TABLE `sbtest1` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`k` int(11) NOT NULL DEFAULT '0',
|
||||
`c` char(120) NOT NULL DEFAULT '',
|
||||
`pad` char(60) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `k_1` (`k`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COMMENT='foo'
|
||||
|
||||
$ sysbench $ARGS --create-table-options="COMMENT='foo'" cleanup
|
||||
Dropping table 'sbtest1'...
|
||||
@ -8,6 +8,7 @@ OLTP usage information test
|
||||
oltp_read_write.lua options:
|
||||
--auto_inc[=on|off] Use AUTO_INCREMENT column as Primary Key (for MySQL), or its alternatives in other DBMS. When disabled, use client-generated IDs [on]
|
||||
--create_secondary[=on|off] Create a secondary index in addition to the PRIMARY KEY [on]
|
||||
--create_table_options=STRING Extra CREATE TABLE options []
|
||||
--delete_inserts=N Number of DELETE/INSERT combinations per transaction [1]
|
||||
--distinct_ranges=N Number of SELECT DISTINCT queries per transaction [1]
|
||||
--index_updates=N Number of UPDATE index queries per transaction [1]
|
||||
|
||||
Reference in New Issue
Block a user