Skip to content

Commit

Permalink
cherry-pick PR 13283 to 1.1-dev: Lock original table during create in…
Browse files Browse the repository at this point in the history
…dex (#13351)

Cherry-pick `Create Index` lock

Approved by: @nnsgmsone, @sukki37
  • Loading branch information
arjunsk authored Dec 11, 2023
1 parent 9585c1d commit 20f2847
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pkg/sql/compile/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,20 @@ func (s *Scope) CreateTempTable(c *Compile) error {

func (s *Scope) CreateIndex(c *Compile) error {
qry := s.Plan.GetDdl().GetCreateIndex()

{
// lockMoTable will lock Table mo_catalog.mo_tables
// for the row with db_name=dbName & table_name = tblName。
dbName := c.db
if qry.GetDatabase() != "" {
dbName = qry.GetDatabase()
}
tblName := qry.GetTableDef().GetName()
if err := lockMoTable(c, dbName, tblName, lock.LockMode_Exclusive); err != nil {
return err
}
}

d, err := c.e.Database(c.ctx, qry.Database, c.proc.TxnOperator)
if err != nil {
return err
Expand Down

0 comments on commit 20f2847

Please sign in to comment.