Skip to content

Commit 8a54c70

Browse files
committed
Added pk for history table
1 parent 58f7db7 commit 8a54c70

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

tpcc_common.lua

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ sysbench.cmdline.options = {
4949
{"Number of tables", 1},
5050
use_fk =
5151
{"Use foreign keys", 1},
52+
force_pk =
53+
{"Force using auto-inc PK on history table", 0},
5254
trx_level =
5355
{"Transaction isolation level (RC, RR or SER)", "RR"},
5456
enable_purge =
@@ -237,19 +239,25 @@ function create_tables(drv, con, table_num)
237239
con:query(query)
238240

239241
-- HISTORY TABLE
240-
242+
local hist_auto_inc=""
243+
local hist_pk=""
244+
if sysbench.opt.force_pk == 1 then
245+
hist_auto_inc="id int NOT NULL AUTO_INCREMENT,"
246+
hist_pk=",PRIMARY KEY(id)"
247+
end
241248
query = string.format([[
242249
create table IF NOT EXISTS history%d (
250+
%s
243251
h_c_id int,
244252
h_c_d_id ]] .. tinyint_type .. [[,
245253
h_c_w_id smallint,
246254
h_d_id ]] .. tinyint_type .. [[,
247255
h_w_id smallint,
248256
h_date ]] .. datetime_type .. [[,
249257
h_amount decimal(6,2),
250-
h_data varchar(24)
258+
h_data varchar(24) %s
251259
) %s %s]],
252-
table_num, engine_def, extra_table_options)
260+
table_num, hist_auto_inc, hist_pk, engine_def, extra_table_options)
253261

254262
con:query(query)
255263

0 commit comments

Comments
 (0)