diff --git a/executor/infoschema_reader_test.go b/executor/infoschema_reader_test.go index c55c51031fa24..ed6eed4fb4607 100644 --- a/executor/infoschema_reader_test.go +++ b/executor/infoschema_reader_test.go @@ -151,7 +151,7 @@ func TestColumnsTables(t *testing.T) { tk.MustExec("drop table if exists t") tk.MustExec("create table t (bit bit(10) DEFAULT b'100')") tk.MustQuery("SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't'").Check(testkit.Rows( - "def test t bit 1 b'100' YES bit 10 0 bit(10) unsigned select,insert,update,references ")) + "def test t bit 1 b'100' YES bit 10 0 bit(10) select,insert,update,references ")) tk.MustExec("drop table if exists t") tk.MustExec("set time_zone='+08:00'") @@ -165,6 +165,11 @@ func TestColumnsTables(t *testing.T) { tk.MustExec("drop table if exists t") tk.MustExec("create table t (a bit DEFAULT (rand()))") tk.MustQuery("select column_default from information_schema.columns where TABLE_NAME='t' and TABLE_SCHEMA='test';").Check(testkit.Rows("rand()")) + + tk.MustExec("drop table if exists t") + tk.MustExec("CREATE TABLE t (`COL3` bit(1) NOT NULL,b year) ;") + tk.MustQuery("select column_type from information_schema.columns where TABLE_SCHEMA = 'test' and TABLE_NAME = 't';"). + Check(testkit.Rows("bit(1)", "year(4)")) } func TestEngines(t *testing.T) { diff --git a/parser/types/field_type.go b/parser/types/field_type.go index 6afc445b30c6e..efc1c20d0c18f 100644 --- a/parser/types/field_type.go +++ b/parser/types/field_type.go @@ -392,7 +392,9 @@ func (ft *FieldType) CompactStr() string { // returns a string. func (ft *FieldType) InfoSchemaStr() string { suffix := "" - if mysql.HasUnsignedFlag(ft.flag) { + if mysql.HasUnsignedFlag(ft.flag) && + ft.tp != mysql.TypeBit && + ft.tp != mysql.TypeYear { suffix = " unsigned" } return ft.CompactStr() + suffix