Skip to content

Commit

Permalink
ddl, executor: add warning log for lock/unlock tables (#29301) (#29439)
Browse files Browse the repository at this point in the history
close #28967
  • Loading branch information
ti-srebot authored May 31, 2022
1 parent ab1f4b0 commit ec172fe
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ddl/serial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,10 @@ func (s *testSerialSuite) TestTableLocksEnable(c *C) {
})

tk.MustExec("lock tables t1 write")
tk.MustQuery("SHOW WARNINGS").Check(testkit.Rows("Warning 1235 LOCK TABLES is not supported. To enable this experimental feature, set 'enable-table-lock' in the configuration file."))
checkTableLock(c, tk.Se, "test", "t1", model.TableLockNone)
tk.MustExec("unlock tables")
tk.MustQuery("SHOW WARNINGS").Check(testkit.Rows("Warning 1235 UNLOCK TABLES is not supported. To enable this experimental feature, set 'enable-table-lock' in the configuration file."))
}

func (s *testSerialDBSuite) TestAutoRandomOnTemporaryTable(c *C) {
Expand Down
5 changes: 5 additions & 0 deletions errors.toml
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,11 @@ error = '''
Incorrect usage of %s and %s
'''

["executor:1235"]
error = '''
%-.32s is not supported. To enable this experimental feature, set '%-.32s' in the configuration file.
'''

["executor:1242"]
error = '''
Subquery returns more than 1 row
Expand Down
3 changes: 3 additions & 0 deletions executor/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -612,13 +612,16 @@ func (e *DDLExec) executeFlashbackTable(s *ast.FlashBackTableStmt) error {

func (e *DDLExec) executeLockTables(s *ast.LockTablesStmt) error {
if !config.TableLockEnabled() {
e.ctx.GetSessionVars().StmtCtx.AppendWarning(ErrFuncNotEnabled.GenWithStackByArgs("LOCK TABLES", "enable-table-lock"))
return nil
}

return domain.GetDomain(e.ctx).DDL().LockTables(e.ctx, s)
}

func (e *DDLExec) executeUnlockTables(_ *ast.UnlockTablesStmt) error {
if !config.TableLockEnabled() {
e.ctx.GetSessionVars().StmtCtx.AppendWarning(ErrFuncNotEnabled.GenWithStackByArgs("UNLOCK TABLES", "enable-table-lock"))
return nil
}
lockedTables := e.ctx.GetAllTableLocks()
Expand Down
1 change: 1 addition & 0 deletions executor/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ var (
ErrCTEMaxRecursionDepth = dbterror.ClassExecutor.NewStd(mysql.ErrCTEMaxRecursionDepth)
ErrDataInConsistentExtraIndex = dbterror.ClassExecutor.NewStd(mysql.ErrDataInConsistentExtraIndex)
ErrDataInConsistentMisMatchIndex = dbterror.ClassExecutor.NewStd(mysql.ErrDataInConsistentMisMatchIndex)
ErrFuncNotEnabled = dbterror.ClassExecutor.NewStdErr(mysql.ErrNotSupportedYet, parser_mysql.Message("%-.32s is not supported. To enable this experimental feature, set '%-.32s' in the configuration file.", nil))

errUnsupportedFlashbackTmpTable = dbterror.ClassDDL.NewStdErr(mysql.ErrUnsupportedDDLOperation, parser_mysql.Message("Recover/flashback table is not supported on temporary tables", nil))
errTruncateWrongInsertValue = dbterror.ClassTable.NewStdErr(mysql.ErrTruncatedWrongValue, parser_mysql.Message("Incorrect %-.32s value: '%-.128s' for column '%.192s' at row %d", nil))
Expand Down

0 comments on commit ec172fe

Please sign in to comment.