diff --git a/expression/integration_test.go b/expression/integration_test.go index 4e1d1d3466717..81777a965d8ca 100755 --- a/expression/integration_test.go +++ b/expression/integration_test.go @@ -6980,6 +6980,19 @@ func (s *testIntegrationSerialSuite) TestIssue19045(c *C) { tk.MustQuery(`select ( SELECT t1.a FROM t1, t2 WHERE t1.b = t2.a AND t2.b = '03' AND t1.c = a.a) invode from t a ;`).Check(testkit.Rows("a011", "a011")) } +func (s *testIntegrationSerialSuite) TestIssue19383(c *C) { + tk := testkit.NewTestKit(c, s.store) + tk.MustExec("use test") + tk.MustExec("DROP TABLE IF EXISTS t1") + tk.MustExec("CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY)") + tk.MustExec("INSERT INTO t1 VALUES (1),(2),(3)") + _, err := tk.Exec("SELECT * FROM t1 LOCK IN SHARE MODE") + message := `function LOCK IN SHARE MODE has only noop implementation in tidb now, use tidb_enable_noop_functions to enable these functions` + c.Assert(strings.Contains(err.Error(), message), IsTrue) + tk.MustExec("SET tidb_enable_noop_functions=1") + tk.MustExec("SELECT * FROM t1 LOCK IN SHARE MODE") +} + func (s *testIntegrationSerialSuite) TestIssue19315(c *C) { tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test") diff --git a/planner/core/logical_plan_builder.go b/planner/core/logical_plan_builder.go index 0bef4438aedbe..5c3a3bc7fbbeb 100644 --- a/planner/core/logical_plan_builder.go +++ b/planner/core/logical_plan_builder.go @@ -2503,7 +2503,7 @@ func (b *PlanBuilder) buildSelect(ctx context.Context, sel *ast.SelectStmt) (p L // table hints are only visible in the current SELECT statement. b.popTableHints() }() - + enableNoopFuncs := b.ctx.GetSessionVars().EnableNoopFuncs if sel.SelectStmtOpts != nil { origin := b.inStraightJoin b.inStraightJoin = sel.SelectStmtOpts.StraightJoin @@ -2572,6 +2572,10 @@ func (b *PlanBuilder) buildSelect(ctx context.Context, sel *ast.SelectStmt) (p L } if sel.LockTp != ast.SelectLockNone { + if sel.LockTp == ast.SelectLockInShareMode && !enableNoopFuncs { + err = expression.ErrFunctionsNoopImpl.GenWithStackByArgs("LOCK IN SHARE MODE") + return nil, err + } p = b.buildSelectLock(p, sel.LockTp) } b.handleHelper.popMap()