Skip to content

Commit

Permalink
br: disable foreign key check when br create table (#40951)
Browse files Browse the repository at this point in the history
close #40952
  • Loading branch information
crazycs520 committed Feb 1, 2023
1 parent 95f4d0d commit 34516a3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions br/pkg/gluetidb/glue.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions executor/brie.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 34516a3

Please sign in to comment.