Skip to content

Commit

Permalink
This is an automated cherry-pick of pingcap#39142
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
  • Loading branch information
hawkingrei authored and ti-chi-bot committed Nov 28, 2022
1 parent 6b02a5d commit 9d33806
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
22 changes: 21 additions & 1 deletion executor/infoschema_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,28 @@ 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 <nil> <nil> 10 0 <nil> <nil> <nil> bit(10) unsigned select,insert,update,references "))
"def test t bit 1 b'100' YES bit <nil> <nil> 10 0 <nil> <nil> <nil> bit(10) select,insert,update,references "))
tk.MustExec("drop table if exists t")
<<<<<<< HEAD
=======

tk.MustExec("set time_zone='+08:00'")
tk.MustExec("drop table if exists t")
tk.MustExec("create table t (b timestamp(3) NOT NULL DEFAULT '1970-01-01 08:00:01.000')")
tk.MustQuery("select column_default from information_schema.columns where TABLE_NAME='t' and TABLE_SCHEMA='test';").Check(testkit.Rows("1970-01-01 08:00:01.000"))
tk.MustExec("set time_zone='+04:00'")
tk.MustQuery("select column_default from information_schema.columns where TABLE_NAME='t' and TABLE_SCHEMA='test';").Check(testkit.Rows("1970-01-01 04:00:01.000"))
tk.MustExec("set time_zone=default")

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)"))
>>>>>>> 3765abbd43 (infoschema: fix bit, year column metadata is not compatible with mysql (#39142))
}

func TestEngines(t *testing.T) {
Expand Down
4 changes: 3 additions & 1 deletion parser/types/field_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,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
Expand Down

0 comments on commit 9d33806

Please sign in to comment.