Skip to content

Commit f6015c1

Browse files
authored
Merge branch 'master' into fix-hot-regions
2 parents 0bdc394 + d83ee8c commit f6015c1

25 files changed

+2041
-1388
lines changed

cmd/ddltest/main_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ func TestMain(m *testing.M) {
3737
goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"),
3838
goleak.IgnoreTopFunction("internal/poll.runtime_pollWait"),
3939
goleak.IgnoreTopFunction("net/http.(*persistConn).writeLoop"),
40+
goleak.IgnoreTopFunction("github.com/go-sql-driver/mysql.(*mysqlConn).startWatcher.func1"),
41+
goleak.IgnoreTopFunction("database/sql.(*DB).connectionOpener"),
4042
}
4143
goleak.VerifyTestMain(m, opts...)
4244
}

ddl/ddl_api.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,7 @@ func columnDefToCol(ctx sessionctx.Context, offset int, colDef *ast.ColumnDef, o
774774
hasNullFlag = true
775775
case ast.ColumnOptionAutoIncrement:
776776
col.Flag |= mysql.AutoIncrementFlag
777+
col.Flag |= mysql.NotNullFlag
777778
case ast.ColumnOptionPrimaryKey:
778779
// Check PriKeyFlag first to avoid extra duplicate constraints.
779780
if col.Flag&mysql.PriKeyFlag == 0 {

ddl/serial_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,6 +1652,7 @@ func (s *testIntegrationSuite7) TestInvisibleIndex(c *C) {
16521652
// Implicit primary key cannot be invisible index
16531653
// Create a implicit primary key
16541654
tk.MustGetErrCode("create table t2(a int not null, unique (a) invisible)", errno.ErrPKIndexCantBeInvisible)
1655+
tk.MustGetErrCode("create table t2(a int auto_increment, unique key (a) invisible);", errno.ErrPKIndexCantBeInvisible)
16551656
// Column `a` become implicit primary key after DDL statement on itself
16561657
tk.MustExec("create table t2(a int not null)")
16571658
tk.MustGetErrCode("alter table t2 add unique (a) invisible", errno.ErrPKIndexCantBeInvisible)

executor/adapter.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,13 +1022,12 @@ func (a *ExecStmt) LogSlowQuery(txnTS uint64, succ bool, hasMoreResults bool) {
10221022
if _, ok := a.StmtNode.(*ast.CommitStmt); ok {
10231023
slowItems.PrevStmt = sessVars.PrevStmt.String()
10241024
}
1025+
slowLog := sessVars.SlowLogFormat(slowItems)
10251026
if trace.IsEnabled() {
1026-
trace.Log(a.GoCtx, "details", sessVars.SlowLogFormat(slowItems))
1027+
trace.Log(a.GoCtx, "details", slowLog)
10271028
}
1028-
if costTime < threshold {
1029-
logutil.SlowQueryLogger.Debug(sessVars.SlowLogFormat(slowItems))
1030-
} else {
1031-
logutil.SlowQueryLogger.Warn(sessVars.SlowLogFormat(slowItems))
1029+
logutil.SlowQueryLogger.Warn(slowLog)
1030+
if costTime >= threshold {
10321031
if sessVars.InRestrictedSQL {
10331032
totalQueryProcHistogramInternal.Observe(costTime.Seconds())
10341033
totalCopProcHistogramInternal.Observe(execDetail.TimeDetail.ProcessTime.Seconds())

executor/ddl_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,7 +1205,7 @@ func (s *testSuite6) TestMaxHandleAddIndex(c *C) {
12051205
tk.MustExec("admin check table t1")
12061206
}
12071207

1208-
func (s *testSuite6) TestSetDDLReorgWorkerCnt(c *C) {
1208+
func (s *testSerialSuite) TestSetDDLReorgWorkerCnt(c *C) {
12091209
tk := testkit.NewTestKit(c, s.store)
12101210
tk.MustExec("use test")
12111211
err := ddlutil.LoadDDLReorgVars(context.Background(), tk.Se)
@@ -1244,7 +1244,7 @@ func (s *testSuite6) TestSetDDLReorgWorkerCnt(c *C) {
12441244
tk.MustQuery("select @@global.tidb_ddl_reorg_worker_cnt").Check(testkit.Rows("256"))
12451245
}
12461246

1247-
func (s *testSuite6) TestSetDDLReorgBatchSize(c *C) {
1247+
func (s *testSerialSuite) TestSetDDLReorgBatchSize(c *C) {
12481248
tk := testkit.NewTestKit(c, s.store)
12491249
tk.MustExec("use test")
12501250
err := ddlutil.LoadDDLReorgVars(context.Background(), tk.Se)

executor/partition_table_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"time"
2222

2323
. "github.com/pingcap/check"
24+
"github.com/pingcap/tidb/domain"
2425
"github.com/pingcap/tidb/infoschema"
2526
"github.com/pingcap/tidb/parser/model"
2627
"github.com/pingcap/tidb/sessionctx/variable"
@@ -1726,6 +1727,36 @@ func (s *partitionTableSuite) TestAddDropPartitions(c *C) {
17261727
tk.MustPartition(`select * from t where a < 20`, "p1,p2,p3").Sort().Check(testkit.Rows("12", "15", "7"))
17271728
}
17281729

1730+
func (s *partitionTableSuite) TestMPPQueryExplainInfo(c *C) {
1731+
if israce.RaceEnabled {
1732+
c.Skip("exhaustive types test, skip race test")
1733+
}
1734+
1735+
tk := testkit.NewTestKitWithInit(c, s.store)
1736+
tk.MustExec("create database tiflash_partition_test")
1737+
tk.MustExec("use tiflash_partition_test")
1738+
tk.MustExec("set @@tidb_partition_prune_mode = 'dynamic'")
1739+
1740+
tk.MustExec(`create table t(a int) partition by range(a) (
1741+
partition p0 values less than (5),
1742+
partition p1 values less than (10),
1743+
partition p2 values less than (15))`)
1744+
tb := testGetTableByName(c, tk.Se, "tiflash_partition_test", "t")
1745+
for _, partition := range tb.Meta().GetPartitionInfo().Definitions {
1746+
err := domain.GetDomain(tk.Se).DDL().UpdateTableReplicaInfo(tk.Se, partition.ID, true)
1747+
c.Assert(err, IsNil)
1748+
}
1749+
err := domain.GetDomain(tk.Se).DDL().UpdateTableReplicaInfo(tk.Se, tb.Meta().ID, true)
1750+
c.Assert(err, IsNil)
1751+
tk.MustExec(`insert into t values (2), (7), (12)`)
1752+
tk.MustExec("set tidb_enforce_mpp=1")
1753+
tk.MustPartition(`select * from t where a < 3`, "p0").Sort().Check(testkit.Rows("2"))
1754+
tk.MustPartition(`select * from t where a < 8`, "p0,p1").Sort().Check(testkit.Rows("2", "7"))
1755+
tk.MustPartition(`select * from t where a < 20`, "all").Sort().Check(testkit.Rows("12", "2", "7"))
1756+
tk.MustPartition(`select * from t where a < 5 union all select * from t where a > 10`, "p0").Sort().Check(testkit.Rows("12", "2"))
1757+
tk.MustPartition(`select * from t where a < 5 union all select * from t where a > 10`, "p2").Sort().Check(testkit.Rows("12", "2"))
1758+
}
1759+
17291760
func (s *partitionTableSuite) PartitionPruningInTransaction(c *C) {
17301761
if israce.RaceEnabled {
17311762
c.Skip("exhaustive types test, skip race test")

expression/builtin_info.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ func (b *builtinCurrentUserSig) evalString(row chunk.Row) (string, bool, error)
190190
if data == nil || data.User == nil {
191191
return "", true, errors.Errorf("Missing session variable when eval builtin")
192192
}
193-
return data.User.AuthIdentityString(), false, nil
193+
return data.User.String(), false, nil
194194
}
195195

196196
type currentRoleFunctionClass struct {
@@ -278,8 +278,7 @@ func (b *builtinUserSig) evalString(row chunk.Row) (string, bool, error) {
278278
if data == nil || data.User == nil {
279279
return "", true, errors.Errorf("Missing session variable when eval builtin")
280280
}
281-
282-
return data.User.String(), false, nil
281+
return data.User.LoginString(), false, nil
283282
}
284283

285284
type connectionIDFunctionClass struct {

expression/builtin_info_vec.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func (b *builtinCurrentUserSig) vecEvalString(input *chunk.Chunk, result *chunk.
114114
return errors.Errorf("Missing session variable when eval builtin")
115115
}
116116
for i := 0; i < n; i++ {
117-
result.AppendString(data.User.AuthIdentityString())
117+
result.AppendString(data.User.String())
118118
}
119119
return nil
120120
}
@@ -168,7 +168,7 @@ func (b *builtinUserSig) vecEvalString(input *chunk.Chunk, result *chunk.Column)
168168

169169
result.ReserveString(n)
170170
for i := 0; i < n; i++ {
171-
result.AppendString(data.User.String())
171+
result.AppendString(data.User.LoginString())
172172
}
173173
return nil
174174
}

expression/constant_propagation_test.go

Lines changed: 15 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,41 +15,20 @@
1515
package expression_test
1616

1717
import (
18-
. "github.com/pingcap/check"
19-
"github.com/pingcap/tidb/domain"
20-
"github.com/pingcap/tidb/kv"
21-
"github.com/pingcap/tidb/sessionctx"
22-
"github.com/pingcap/tidb/util/mock"
23-
"github.com/pingcap/tidb/util/testkit"
24-
"github.com/pingcap/tidb/util/testutil"
25-
)
18+
"testing"
2619

27-
var _ = Suite(&testSuite{})
20+
"github.com/pingcap/tidb/expression"
21+
"github.com/pingcap/tidb/testkit"
22+
"github.com/pingcap/tidb/testkit/testdata"
23+
)
2824

29-
type testSuite struct {
30-
store kv.Storage
31-
dom *domain.Domain
32-
ctx sessionctx.Context
33-
testData testutil.TestData
34-
}
25+
func TestOuterJoinPropConst(t *testing.T) {
26+
t.Parallel()
3527

36-
func (s *testSuite) SetUpSuite(c *C) {
37-
var err error
38-
s.store, s.dom, err = newStoreWithBootstrap()
39-
c.Assert(err, IsNil)
40-
s.ctx = mock.NewContext()
41-
s.testData, err = testutil.LoadTestSuiteData("testdata", "expression_suite")
42-
c.Assert(err, IsNil)
43-
}
28+
store, clean := testkit.CreateMockStore(t)
29+
defer clean()
4430

45-
func (s *testSuite) TearDownSuite(c *C) {
46-
c.Assert(s.testData.GenerateOutputIfNeeded(), IsNil)
47-
s.dom.Close()
48-
s.store.Close()
49-
}
50-
51-
func (s *testSuite) TestOuterJoinPropConst(c *C) {
52-
tk := testkit.NewTestKit(c, s.store)
31+
tk := testkit.NewTestKit(t, store)
5332
tk.MustExec("use test")
5433
tk.MustExec("drop table if exists t1, t2;")
5534
tk.MustExec("create table t1(id bigint primary key, a int, b int);")
@@ -60,11 +39,13 @@ func (s *testSuite) TestOuterJoinPropConst(c *C) {
6039
SQL string
6140
Result []string
6241
}
63-
s.testData.GetTestCases(c, &input, &output)
42+
43+
expressionSuiteData := expression.GetExpressionSuiteData()
44+
expressionSuiteData.GetTestCases(t, &input, &output)
6445
for i, tt := range input {
65-
s.testData.OnRecord(func() {
46+
testdata.OnRecord(func() {
6647
output[i].SQL = tt
67-
output[i].Result = s.testData.ConvertRowsToStrings(tk.MustQuery(tt).Rows())
48+
output[i].Result = testdata.ConvertRowsToStrings(tk.MustQuery(tt).Rows())
6849
})
6950
tk.MustQuery(tt).Check(testkit.Rows(output[i].Result...))
7051
}

0 commit comments

Comments
 (0)