Skip to content

Commit

Permalink
info_schema: fix memtable column flag type (#15944) (#16004)
Browse files Browse the repository at this point in the history
  • Loading branch information
sre-bot authored Apr 2, 2020
1 parent 79db9e3 commit 53bdc3d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
5 changes: 5 additions & 0 deletions executor/infoschema_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -756,4 +756,9 @@ func (s *testInfoschemaTableSuite) TestSequences(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("CREATE SEQUENCE test.seq maxvalue 10000000")
tk.MustQuery("SELECT * FROM information_schema.sequences WHERE sequence_schema='test' AND sequence_name='seq'").Check(testkit.Rows("def test seq 1 1000 0 1 10000000 1 0 1 "))
tk.MustExec("DROP SEQUENCE test.seq")
tk.MustExec("CREATE SEQUENCE test.seq start = -1 minvalue -1 maxvalue 10 increment 1 cache 10")
tk.MustQuery("SELECT * FROM information_schema.sequences WHERE sequence_schema='test' AND sequence_name='seq'").Check(testkit.Rows("def test seq 1 10 0 1 10 -1 0 -1 "))
tk.MustExec("CREATE SEQUENCE test.seq2 start = -9 minvalue -10 maxvalue 10 increment -1 cache 15")
tk.MustQuery("SELECT * FROM information_schema.sequences WHERE sequence_schema='test' AND sequence_name='seq2'").Check(testkit.Rows("def test seq2 1 15 0 -1 10 -10 0 -9 "))
}
8 changes: 3 additions & 5 deletions infoschema/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,19 +214,17 @@ type columnInfo struct {
func buildColumnInfo(col columnInfo) *model.ColumnInfo {
mCharset := charset.CharsetBin
mCollation := charset.CharsetBin
mFlag := mysql.UnsignedFlag
if col.tp == mysql.TypeVarchar || col.tp == mysql.TypeBlob {
mCharset = charset.CharsetUTF8MB4
mCollation = charset.CollationUTF8MB4
mFlag = col.flag
}
fieldType := types.FieldType{
Charset: mCharset,
Collate: mCollation,
Tp: col.tp,
Flen: col.size,
Decimal: col.decimal,
Flag: mFlag,
Flag: col.flag,
}
return &model.ColumnInfo{
Name: model.NewCIStr(col.name),
Expand Down Expand Up @@ -667,15 +665,15 @@ var tableCollationCharacterSetApplicabilityCols = []columnInfo{
}

var tableProcesslistCols = []columnInfo{
{name: "ID", tp: mysql.TypeLonglong, size: 21, flag: mysql.NotNullFlag, deflt: 0},
{name: "ID", tp: mysql.TypeLonglong, size: 21, flag: mysql.NotNullFlag | mysql.UnsignedFlag, deflt: 0},
{name: "USER", tp: mysql.TypeVarchar, size: 16, flag: mysql.NotNullFlag, deflt: ""},
{name: "HOST", tp: mysql.TypeVarchar, size: 64, flag: mysql.NotNullFlag, deflt: ""},
{name: "DB", tp: mysql.TypeVarchar, size: 64},
{name: "COMMAND", tp: mysql.TypeVarchar, size: 16, flag: mysql.NotNullFlag, deflt: ""},
{name: "TIME", tp: mysql.TypeLong, size: 7, flag: mysql.NotNullFlag, deflt: 0},
{name: "STATE", tp: mysql.TypeVarchar, size: 7},
{name: "INFO", tp: mysql.TypeString, size: 512},
{name: "MEM", tp: mysql.TypeLonglong, size: 21},
{name: "MEM", tp: mysql.TypeLonglong, size: 21, flag: mysql.UnsignedFlag},
{name: "TxnStart", tp: mysql.TypeVarchar, size: 64, flag: mysql.NotNullFlag, deflt: ""},
}

Expand Down
6 changes: 3 additions & 3 deletions infoschema/tables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,14 @@ func (s *testTableSuite) TestInfoschemaFieldValue(c *C) {
tk.MustQuery("show create table information_schema.PROCESSLIST").Check(
testkit.Rows("" +
"PROCESSLIST CREATE TABLE `PROCESSLIST` (\n" +
" `ID` bigint(21) unsigned DEFAULT '0',\n" +
" `ID` bigint(21) unsigned NOT NULL DEFAULT '0',\n" +
" `USER` varchar(16) NOT NULL DEFAULT '',\n" +
" `HOST` varchar(64) NOT NULL DEFAULT '',\n" +
" `DB` varchar(64) DEFAULT NULL,\n" +
" `COMMAND` varchar(16) NOT NULL DEFAULT '',\n" +
" `TIME` int(7) unsigned DEFAULT '0',\n" +
" `TIME` int(7) NOT NULL DEFAULT '0',\n" +
" `STATE` varchar(7) DEFAULT NULL,\n" +
" `INFO` binary(512) unsigned DEFAULT NULL,\n" +
" `INFO` binary(512) DEFAULT NULL,\n" +
" `MEM` bigint(21) unsigned DEFAULT NULL,\n" +
" `TxnStart` varchar(64) NOT NULL DEFAULT ''\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"))
Expand Down

0 comments on commit 53bdc3d

Please sign in to comment.