Skip to content

Commit

Permalink
Merge pull request #2 from planetscale/fix-FOREIGN_KEY_CHECKS
Browse files Browse the repository at this point in the history
set `foreign_key_checks` to `1` if `use_fk=1`
  • Loading branch information
frouioui authored Jan 31, 2024
2 parents d4a8ffe + 3ea7b5e commit 1d67d31
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tpcc_common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,10 @@ function db_connection_init()

set_isolation_level(drv,con)

if drv:name() == "mysql" then
con:query("SET FOREIGN_KEY_CHECKS=0")
if drv:name() == "mysql" then
if sysbench.opt.use_fk == 0 then
con:query("SET FOREIGN_KEY_CHECKS=0")
end
con:query("SET autocommit=0")
end

Expand Down Expand Up @@ -642,6 +644,9 @@ function cleanup()

local drv,con = db_connection_init()

if sysbench.opt.use_fk == 1 then
con:query("SET FOREIGN_KEY_CHECKS=0")
end
for i = 1, sysbench.opt.tables do
print(string.format("Dropping tables '%d'...", i))
con:query("DROP TABLE IF EXISTS history" .. i )
Expand All @@ -654,6 +659,9 @@ function cleanup()
con:query("DROP TABLE IF EXISTS item" .. i )
con:query("DROP TABLE IF EXISTS warehouse" .. i )
end
if sysbench.opt.use_fk == 1 then
con:query("SET FOREIGN_KEY_CHECKS=1")
end
end

function Lastname(num)
Expand Down

0 comments on commit 1d67d31

Please sign in to comment.