Skip to content

Commit

Permalink
Added pk for history table
Browse files Browse the repository at this point in the history
  • Loading branch information
vadimtk committed May 22, 2018
1 parent 58f7db7 commit 8a54c70
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions tpcc_common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ sysbench.cmdline.options = {
{"Number of tables", 1},
use_fk =
{"Use foreign keys", 1},
force_pk =
{"Force using auto-inc PK on history table", 0},
trx_level =
{"Transaction isolation level (RC, RR or SER)", "RR"},
enable_purge =
Expand Down Expand Up @@ -237,19 +239,25 @@ function create_tables(drv, con, table_num)
con:query(query)

-- HISTORY TABLE

local hist_auto_inc=""
local hist_pk=""
if sysbench.opt.force_pk == 1 then
hist_auto_inc="id int NOT NULL AUTO_INCREMENT,"
hist_pk=",PRIMARY KEY(id)"
end
query = string.format([[
create table IF NOT EXISTS history%d (
%s
h_c_id int,
h_c_d_id ]] .. tinyint_type .. [[,
h_c_w_id smallint,
h_d_id ]] .. tinyint_type .. [[,
h_w_id smallint,
h_date ]] .. datetime_type .. [[,
h_amount decimal(6,2),
h_data varchar(24)
h_data varchar(24) %s
) %s %s]],
table_num, engine_def, extra_table_options)
table_num, hist_auto_inc, hist_pk, engine_def, extra_table_options)

con:query(query)

Expand Down

0 comments on commit 8a54c70

Please sign in to comment.