Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

infoschema: fix bit, year column metadata is not compatible with mysql #39142

Merged
merged 4 commits into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions executor/infoschema_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -866,3 +866,12 @@ func TestNullColumns(t *testing.T) {
tk.MustQuery("select * from information_schema.columns where TABLE_SCHEMA = 'test' and TABLE_NAME = 'v_test';").
Check(testkit.Rows("def test v_test type 1 <nil> YES binary 0 0 <nil> <nil> <nil> <nil> <nil> binary(0) select,insert,update,references "))
}

func TestIssue25472(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
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)"))
}
4 changes: 3 additions & 1 deletion parser/types/field_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down