Skip to content

Commit

Permalink
Merge pull request Percona-Lab#22 from alexey2k/master
Browse files Browse the repository at this point in the history
Fixes
  • Loading branch information
alexey2k authored May 6, 2020
2 parents 72c5634 + ec5e717 commit a058f40
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions tpcc_common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ function sleep(n)
end

function db_connection_init()
drv = sysbench.sql.driver()
con = drv:connect()
local drv = sysbench.sql.driver()
local con = drv:connect()

set_isolation_level(drv,con)

Expand All @@ -92,7 +92,7 @@ end
-- benefit from executing with --threads > 1 as long as --scale > 1
function cmd_prepare()

drv,con = db_connection_init()
local drv,con = db_connection_init()

-- create tables in parallel table per thread
for i = sysbench.tid % sysbench.opt.threads + 1, sysbench.opt.tables,
Expand All @@ -116,7 +116,7 @@ end
-- benefit from executing with --threads > 1 as long as --scale > 1
function cmd_check()

drv,con = db_connection_init()
local drv,con = db_connection_init()

for i = sysbench.tid % sysbench.opt.threads + 1, sysbench.opt.scale,
sysbench.opt.threads do
Expand Down Expand Up @@ -340,7 +340,7 @@ function create_tables(drv, con, table_num)

query = string.format([[(%d,%d,'%s',%f,'%s')]],
j, i_im_id, i_name:sub(1,24), i_price, i_data:sub(1,50))
con:bulk_insert_next(query)
con:bulk_insert_next(query)

end
con:bulk_insert_done()
Expand All @@ -365,7 +365,6 @@ function create_tables(drv, con, table_num)
con:query("ALTER TABLE stock"..i.." ADD CONSTRAINT fkey_stock_1_"..table_num.." FOREIGN KEY(s_w_id) REFERENCES warehouse"..i.."(w_id)")
con:query("ALTER TABLE stock"..i.." ADD CONSTRAINT fkey_stock_2_"..table_num.." FOREIGN KEY(s_i_id) REFERENCES item"..i.."(i_id)")
end

end


Expand Down Expand Up @@ -408,6 +407,8 @@ function load_tables(drv, con, warehouse_num)
local extra_table_options = ""
local query

con:query("SET autocommit=1")

-- print(string.format("Creating warehouse: %d\n", warehouse_num))

for table_num = 1, sysbench.opt.tables do
Expand All @@ -421,8 +422,8 @@ function load_tables(drv, con, warehouse_num)
warehouse_num, sysbench.rand.string("name-@@@@@"), sysbench.rand.string("street1-@@@@@@@@@@"),
sysbench.rand.string("street2-@@@@@@@@@@"), sysbench.rand.string("city-@@@@@@@@@@"),
sysbench.rand.string("@@"),sysbench.rand.string("zip-#####"),sysbench.rand.uniform_double()*0.2 )
con:bulk_insert_next(query)

con:bulk_insert_next(query)
con:bulk_insert_done()

con:bulk_insert_init("INSERT INTO district" .. table_num ..
Expand All @@ -437,7 +438,7 @@ function load_tables(drv, con, warehouse_num)
con:bulk_insert_next(query)

end
con:bulk_insert_done()
con:bulk_insert_done()

-- CUSTOMER TABLE

Expand Down Expand Up @@ -591,7 +592,7 @@ end

function cleanup()

drv,con = db_connection_init()
local drv,con = db_connection_init()

for i = 1, sysbench.opt.tables do
print(string.format("Dropping tables '%d'...", i))
Expand Down

0 comments on commit a058f40

Please sign in to comment.