From 9867b3220a1a636adc153ceb1b9ef5b68ad2990c Mon Sep 17 00:00:00 2001 From: crazycs520 Date: Wed, 1 Feb 2023 17:58:30 +0800 Subject: [PATCH 1/2] br: disable foreign key check when br create table Signed-off-by: crazycs520 --- br/pkg/gluetidb/glue.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/br/pkg/gluetidb/glue.go b/br/pkg/gluetidb/glue.go index 06af5615ff451..abe239f7723dc 100644 --- a/br/pkg/gluetidb/glue.go +++ b/br/pkg/gluetidb/glue.go @@ -288,6 +288,8 @@ func (gs *tidbSession) CreateTable(ctx context.Context, dbName model.CIStr, tabl return errors.Trace(err) } gs.se.SetValue(sessionctx.QueryString, query) + // Disable foreign key check when batch create tables. + gs.se.GetSessionVars().ForeignKeyChecks = false // Clone() does not clone partitions yet :( table = table.Clone() if table.Partition != nil { From 3f708ef2bcbd48a089a814ee676e3847d0e6f89e Mon Sep 17 00:00:00 2001 From: crazycs520 Date: Wed, 1 Feb 2023 18:07:54 +0800 Subject: [PATCH 2/2] tiny fix Signed-off-by: crazycs520 --- executor/brie.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/executor/brie.go b/executor/brie.go index 608cfd6336b52..96896c0eb0119 100644 --- a/executor/brie.go +++ b/executor/brie.go @@ -524,6 +524,8 @@ func (gs *tidbGlueSession) CreateTable(ctx context.Context, dbName model.CIStr, return err } gs.se.SetValue(sessionctx.QueryString, result.String()) + // Disable foreign key check when batch create tables. + gs.se.GetSessionVars().ForeignKeyChecks = false // Clone() does not clone partitions yet :( table = table.Clone()