From ad756d875a1a6ba88a139725a5af83afd3ac260d Mon Sep 17 00:00:00 2001 From: Jay Janssen Date: Fri, 16 Sep 2022 12:23:45 -0400 Subject: [PATCH] add skip_existing_tables flag --- src/lua/oltp_common.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/lua/oltp_common.lua b/src/lua/oltp_common.lua index fdc5c83ed..0c3e56e44 100644 --- a/src/lua/oltp_common.lua +++ b/src/lua/oltp_common.lua @@ -68,6 +68,9 @@ sysbench.cmdline.options = { {"Use a secondary index in place of the PRIMARY KEY", false}, create_secondary = {"Create a secondary index in addition to the PRIMARY KEY", true}, + skip_existing_tables = + {"If a table already exists during prepare, " .. + "skip and assume it has enough rows", true}, reconnect = {"Reconnect after every N events. The default (0) is to not reconnect", 0}, @@ -160,6 +163,14 @@ function create_table(drv, con, table_num) local extra_table_options = "" local query + if sysbench.opt.skip_existing_tables then + rs = con:query("SHOW TABLE STATUS like 'sbtest" .. table_num .. "'") + if rs.nrows >= 1 then + print(string.format("Skipping create table 'sbtest%d'...", table_num)) + return + end + end + if sysbench.opt.secondary then id_index_def = "KEY xid" else