Skip to content

Commit

Permalink
infoschema, sessionctx: add support for mysqldump from 8.0 (pingcap#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
morgo authored and SunRunAway committed Jun 26, 2019
1 parent 5eae9fa commit cf5f42b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
12 changes: 11 additions & 1 deletion expression/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4192,7 +4192,7 @@ func (s *testIntegrationSuite) TestIssue9710(c *C) {
}
}

// for issue #9770
// TestDecimalConvertToTime for issue #9770
func (s *testIntegrationSuite) TestDecimalConvertToTime(c *C) {
tk := testkit.NewTestKit(c, s.store)
defer s.cleanEnv(c)
Expand Down Expand Up @@ -4403,3 +4403,13 @@ func (s *testIntegrationSuite) TestExprPushdownBlacklist(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustQuery(`select * from mysql.expr_pushdown_blacklist`).Check(testkit.Rows())
}

func (s *testIntegrationSuite) TestIssue10804(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustQuery(`SELECT @@information_schema_stats_expiry`).Check(testkit.Rows(`86400`))
tk.MustExec("/*!80000 SET SESSION information_schema_stats_expiry=0 */")
tk.MustQuery(`SELECT @@information_schema_stats_expiry`).Check(testkit.Rows(`0`))
tk.MustQuery(`SELECT @@GLOBAL.information_schema_stats_expiry`).Check(testkit.Rows(`86400`))
tk.MustExec("/*!80000 SET GLOBAL information_schema_stats_expiry=0 */")
tk.MustQuery(`SELECT @@GLOBAL.information_schema_stats_expiry`).Check(testkit.Rows(`0`))
}
9 changes: 9 additions & 0 deletions infoschema/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const (
tableSchemata = "SCHEMATA"
tableTables = "TABLES"
tableColumns = "COLUMNS"
tableColumnStatistics = "COLUMN_STATISTICS"
tableStatistics = "STATISTICS"
tableCharacterSets = "CHARACTER_SETS"
tableCollations = "COLLATIONS"
Expand Down Expand Up @@ -189,6 +190,13 @@ var columnsCols = []columnInfo{
{"GENERATION_EXPRESSION", mysql.TypeBlob, 589779, mysql.NotNullFlag, nil, nil},
}

var columnStatisticsCols = []columnInfo{
{"SCHEMA_NAME", mysql.TypeVarchar, 64, mysql.NotNullFlag, nil, nil},
{"TABLE_NAME", mysql.TypeVarchar, 64, mysql.NotNullFlag, nil, nil},
{"COLUMN_NAME", mysql.TypeVarchar, 64, mysql.NotNullFlag, nil, nil},
{"HISTOGRAM", mysql.TypeJSON, 51, 0, nil, nil},
}

var statisticsCols = []columnInfo{
{"TABLE_CATALOG", mysql.TypeVarchar, 512, 0, nil, nil},
{"TABLE_SCHEMA", mysql.TypeVarchar, 64, 0, nil, nil},
Expand Down Expand Up @@ -1715,6 +1723,7 @@ var tableNameToColumns = map[string][]columnInfo{
tableSchemata: schemataCols,
tableTables: tablesCols,
tableColumns: columnsCols,
tableColumnStatistics: columnStatisticsCols,
tableStatistics: statisticsCols,
tableCharacterSets: charsetCols,
tableCollations: collationsCols,
Expand Down
5 changes: 5 additions & 0 deletions infoschema/tables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,3 +405,8 @@ func (s *testTableSuite) TestForAnalyzeStatus(c *C) {
c.Assert(result.Rows()[1][5], NotNil)
c.Assert(result.Rows()[1][6], Equals, "finished")
}

func (s *testTableSuite) TestColumnStatistics(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustQuery("select * from information_schema.column_statistics").Check(testkit.Rows())
}
1 change: 1 addition & 0 deletions sessionctx/variable/sysvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@ var defaultSysVars = []*SysVar{
{ScopeGlobal, "innodb_online_alter_log_max_size", "134217728"},
{ScopeSession, WarningCount, "0"},
{ScopeSession, ErrorCount, "0"},
{ScopeGlobal | ScopeSession, "information_schema_stats_expiry", "86400"},
/* TiDB specific variables */
{ScopeSession, TiDBSnapshot, ""},
{ScopeSession, TiDBOptAggPushDown, BoolToIntStr(DefOptAggPushDown)},
Expand Down

0 comments on commit cf5f42b

Please sign in to comment.