From 03422a0d61549fe9d6d489caf04ae3fc8b68800e Mon Sep 17 00:00:00 2001 From: AilinKid <314806019@qq.com> Date: Wed, 1 Apr 2020 13:17:13 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix=20memtable=20column=20type=EF=BC=88use?= =?UTF-8?q?=20user=20define=20type)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- executor/infoschema_reader_test.go | 5 +++++ infoschema/tables.go | 4 +--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/executor/infoschema_reader_test.go b/executor/infoschema_reader_test.go index d7b0f04d54083..c8d7d5f8ad744 100644 --- a/executor/infoschema_reader_test.go +++ b/executor/infoschema_reader_test.go @@ -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 ")) } diff --git a/infoschema/tables.go b/infoschema/tables.go index e3cd5ef7008f2..300449ddec365 100644 --- a/infoschema/tables.go +++ b/infoschema/tables.go @@ -215,11 +215,9 @@ 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, @@ -227,7 +225,7 @@ func buildColumnInfo(col columnInfo) *model.ColumnInfo { Tp: col.tp, Flen: col.size, Decimal: col.decimal, - Flag: mFlag, + Flag: col.flag, } return &model.ColumnInfo{ Name: model.NewCIStr(col.name), From 1b39ca102c0c1a1ee075de83664e1d05b109b158 Mon Sep 17 00:00:00 2001 From: AilinKid <314806019@qq.com> Date: Wed, 1 Apr 2020 13:58:06 +0800 Subject: [PATCH 2/3] fix processlist unsigned --- infoschema/tables.go | 4 ++-- infoschema/tables_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/infoschema/tables.go b/infoschema/tables.go index 300449ddec365..89d1f5d41d043 100644 --- a/infoschema/tables.go +++ b/infoschema/tables.go @@ -666,7 +666,7 @@ 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}, @@ -674,7 +674,7 @@ var tableProcesslistCols = []columnInfo{ {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: ""}, } diff --git a/infoschema/tables_test.go b/infoschema/tables_test.go index 309be9fd5341f..0a13e3ca8a8db 100644 --- a/infoschema/tables_test.go +++ b/infoschema/tables_test.go @@ -278,9 +278,9 @@ func (s *testTableSuite) TestInfoschemaFieldValue(c *C) { " `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) 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")) From 84e4449fd325d8879ced76a66e91ccc677c0f021 Mon Sep 17 00:00:00 2001 From: AilinKid <314806019@qq.com> Date: Wed, 1 Apr 2020 14:05:36 +0800 Subject: [PATCH 3/3] . --- infoschema/tables_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/infoschema/tables_test.go b/infoschema/tables_test.go index 0a13e3ca8a8db..eab1932ff562c 100644 --- a/infoschema/tables_test.go +++ b/infoschema/tables_test.go @@ -273,12 +273,12 @@ 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) DEFAULT '0',\n" + + " `TIME` int(7) NOT NULL DEFAULT '0',\n" + " `STATE` varchar(7) DEFAULT NULL,\n" + " `INFO` binary(512) DEFAULT NULL,\n" + " `MEM` bigint(21) unsigned DEFAULT NULL,\n" +