diff --git a/ddl/serial_test.go b/ddl/serial_test.go index baef8c38df4ed..1cc6af5310371 100644 --- a/ddl/serial_test.go +++ b/ddl/serial_test.go @@ -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) { diff --git a/errors.toml b/errors.toml index cd2bdd0b89abc..b81be32953a96 100644 --- a/errors.toml +++ b/errors.toml @@ -741,6 +741,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 diff --git a/executor/ddl.go b/executor/ddl.go index d168f4f8a25de..7658d08136174 100644 --- a/executor/ddl.go +++ b/executor/ddl.go @@ -862,20 +862,23 @@ 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 + } + for _, tb := range s.TableLocks { if _, ok := e.getLocalTemporaryTable(tb.Table.Schema, tb.Table.Name); ok { return ddl.ErrUnsupportedLocalTempTableDDL.GenWithStackByArgs("LOCK TABLES") } } - if !config.TableLockEnabled() { - 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() diff --git a/executor/errors.go b/executor/errors.go index ca19ecba51373..0cd0912eaf7f9 100644 --- a/executor/errors.go +++ b/executor/errors.go @@ -60,6 +60,13 @@ var ( ErrCTEMaxRecursionDepth = dbterror.ClassExecutor.NewStd(mysql.ErrCTEMaxRecursionDepth) ErrDataInConsistentExtraIndex = dbterror.ClassExecutor.NewStd(mysql.ErrDataInConsistentExtraIndex) ErrDataInConsistentMisMatchIndex = dbterror.ClassExecutor.NewStd(mysql.ErrDataInConsistentMisMatchIndex) +<<<<<<< HEAD +======= + ErrNotSupportedWithSem = dbterror.ClassOptimizer.NewStd(mysql.ErrNotSupportedWithSem) + ErrPluginIsNotLoaded = dbterror.ClassExecutor.NewStd(mysql.ErrPluginIsNotLoaded) + ErrSetPasswordAuthPlugin = dbterror.ClassExecutor.NewStd(mysql.ErrSetPasswordAuthPlugin) + 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)) +>>>>>>> dcbfda914... ddl, executor: add warning log for lock/unlock tables (#29301) 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))