Skip to content

Commit 046fd4f

Browse files
Null not nilti-srebot
authored andcommitted
cherry pick pingcap#19506 to release-4.0
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
1 parent 2411352 commit 046fd4f

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

expression/integration_test.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6971,6 +6971,43 @@ func (s *testIntegrationSerialSuite) TestIssue19045(c *C) {
69716971
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"))
69726972
}
69736973

6974+
<<<<<<< HEAD
6975+
=======
6976+
func (s *testIntegrationSerialSuite) TestIssue19116(c *C) {
6977+
collate.SetNewCollationEnabledForTest(true)
6978+
defer collate.SetNewCollationEnabledForTest(false)
6979+
6980+
tk := testkit.NewTestKit(c, s.store)
6981+
tk.MustExec("set names utf8mb4 collate utf8mb4_general_ci;")
6982+
tk.MustQuery("select collation(concat(1 collate `binary`));").Check(testkit.Rows("binary"))
6983+
tk.MustQuery("select coercibility(concat(1 collate `binary`));").Check(testkit.Rows("0"))
6984+
tk.MustQuery("select collation(concat(NULL,NULL));").Check(testkit.Rows("binary"))
6985+
tk.MustQuery("select coercibility(concat(NULL,NULL));").Check(testkit.Rows("6"))
6986+
tk.MustQuery("select collation(concat(1,1));").Check(testkit.Rows("utf8mb4_general_ci"))
6987+
tk.MustQuery("select coercibility(concat(1,1));").Check(testkit.Rows("4"))
6988+
tk.MustQuery("select collation(1);").Check(testkit.Rows("binary"))
6989+
tk.MustQuery("select coercibility(1);").Check(testkit.Rows("5"))
6990+
tk.MustQuery("select coercibility(1=1);").Check(testkit.Rows("5"))
6991+
}
6992+
6993+
func (s *testIntegrationSerialSuite) TestIssue14448and19383(c *C) {
6994+
tk := testkit.NewTestKit(c, s.store)
6995+
tk.MustExec("use test")
6996+
tk.MustExec("DROP TABLE IF EXISTS t1")
6997+
tk.MustExec("CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY)")
6998+
tk.MustExec("INSERT INTO t1 VALUES (1),(2),(3)")
6999+
_, err := tk.Exec("SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1")
7000+
message := `function SQL_CALC_FOUND_ROWS has only noop implementation in tidb now, use tidb_enable_noop_functions to enable these functions`
7001+
c.Assert(strings.Contains(err.Error(), message), IsTrue)
7002+
_, err = tk.Exec("SELECT * FROM t1 LOCK IN SHARE MODE")
7003+
message = `function LOCK IN SHARE MODE has only noop implementation in tidb now, use tidb_enable_noop_functions to enable these functions`
7004+
c.Assert(strings.Contains(err.Error(), message), IsTrue)
7005+
tk.MustExec("SET tidb_enable_noop_functions=1")
7006+
tk.MustExec("SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1")
7007+
tk.MustExec("SELECT * FROM t1 LOCK IN SHARE MODE")
7008+
}
7009+
7010+
>>>>>>> 9876de896... planner: disable SQL_CALC_FOUND_ROWS/LOCK IN SHARE MODE by default (#19506)
69747011
func (s *testIntegrationSerialSuite) TestIssue19315(c *C) {
69757012
tk := testkit.NewTestKit(c, s.store)
69767013
tk.MustExec("use test")

planner/core/logical_plan_builder.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2503,8 +2503,12 @@ func (b *PlanBuilder) buildSelect(ctx context.Context, sel *ast.SelectStmt) (p L
25032503
// table hints are only visible in the current SELECT statement.
25042504
b.popTableHints()
25052505
}()
2506-
2506+
enableNoopFuncs := b.ctx.GetSessionVars().EnableNoopFuncs
25072507
if sel.SelectStmtOpts != nil {
2508+
if sel.SelectStmtOpts.CalcFoundRows && !enableNoopFuncs {
2509+
err = expression.ErrFunctionsNoopImpl.GenWithStackByArgs("SQL_CALC_FOUND_ROWS")
2510+
return nil, err
2511+
}
25082512
origin := b.inStraightJoin
25092513
b.inStraightJoin = sel.SelectStmtOpts.StraightJoin
25102514
defer func() { b.inStraightJoin = origin }()
@@ -2570,9 +2574,18 @@ func (b *PlanBuilder) buildSelect(ctx context.Context, sel *ast.SelectStmt) (p L
25702574
return nil, err
25712575
}
25722576
}
2577+
<<<<<<< HEAD
25732578

25742579
if sel.LockTp != ast.SelectLockNone {
25752580
p = b.buildSelectLock(p, sel.LockTp)
2581+
=======
2582+
if sel.LockInfo != nil && sel.LockInfo.LockType != ast.SelectLockNone {
2583+
if sel.LockInfo.LockType == ast.SelectLockInShareMode && !enableNoopFuncs {
2584+
err = expression.ErrFunctionsNoopImpl.GenWithStackByArgs("LOCK IN SHARE MODE")
2585+
return nil, err
2586+
}
2587+
p = b.buildSelectLock(p, sel.LockInfo)
2588+
>>>>>>> 9876de896... planner: disable SQL_CALC_FOUND_ROWS/LOCK IN SHARE MODE by default (#19506)
25762589
}
25772590
b.handleHelper.popMap()
25782591
b.handleHelper.pushMap(nil)

0 commit comments

Comments
 (0)