diff --git a/src/lua/oltp_common.lua b/src/lua/oltp_common.lua index 989fa03..29dec28 100644 --- a/src/lua/oltp_common.lua +++ b/src/lua/oltp_common.lua @@ -198,8 +198,10 @@ CREATE TABLE sbtest%d( con:query(query) - print(string.format("Inserting %d records into 'sbtest%d'", - sysbench.opt.table_size, table_num)) + if (sysbench.opt.table_size > 0) then + print(string.format("Inserting %d records into 'sbtest%d'", + sysbench.opt.table_size, table_num)) + end if sysbench.opt.auto_inc then query = "INSERT INTO sbtest" .. table_num .. "(k, c, pad) VALUES" diff --git a/src/lua/oltp_insert.lua b/src/lua/oltp_insert.lua index 62a5573..5cddf8c 100755 --- a/src/lua/oltp_insert.lua +++ b/src/lua/oltp_insert.lua @@ -21,6 +21,20 @@ require("oltp_common") +sysbench.cmdline.commands.prepare = { + function () + if (not sysbench.opt.auto_inc) then + -- Create empty tables on prepare when --auto-inc is off, since IDs + -- generated on prepare may collide later with values generated by + -- sysbench.rand.unique() + sysbench.opt.table_size=0 + end + + cmd_prepare() + end, + sysbench.cmdline.PARALLEL_PREPARE +} + function prepare_statements() -- We do not use prepared statements here, but oltp_common.sh expects this -- function to be defined diff --git a/tests/t/script_oltp_insert_mysql.t b/tests/t/script_oltp_insert_mysql.t index 549c817..068753d 100644 --- a/tests/t/script_oltp_insert_mysql.t +++ b/tests/t/script_oltp_insert_mysql.t @@ -196,6 +196,5 @@ oltp_insert.lua + MySQL tests Dropping table 'sbtest1'... # Test --auto-inc=off Creating table 'sbtest1'... - Inserting 10000 records into 'sbtest1' Creating a secondary index on 'sbtest1'... Dropping table 'sbtest1'... diff --git a/tests/t/script_oltp_insert_pgsql.t b/tests/t/script_oltp_insert_pgsql.t index 18b4c5b..827d9ca 100644 --- a/tests/t/script_oltp_insert_pgsql.t +++ b/tests/t/script_oltp_insert_pgsql.t @@ -198,6 +198,5 @@ oltp_insert.lua + PostgreSQL tests Dropping table 'sbtest1'... # Test --auto-inc=off Creating table 'sbtest1'... - Inserting 10000 records into 'sbtest1' Creating a secondary index on 'sbtest1'... Dropping table 'sbtest1'...