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 ddl_jobs table query column's type (#42536) #42583

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 8 additions & 0 deletions infoschema/infoschema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,14 @@ func TestIndexComment(t *testing.T) {
tk.MustQuery("SELECT index_comment,char_length(index_comment),COLUMN_NAME FROM information_schema.statistics WHERE table_name='t1' ORDER BY index_comment;").Check(testkit.Rows(" 0 c2", "i1 comment 10 c1"))
}

func TestIssue42400(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustQuery("show create table information_schema.ddl_jobs").CheckContain("`QUERY` text")
tk.MustQuery("select length(query) from information_schema.ddl_jobs;") // No error
}

func TestInfoSchemaRenameTable(t *testing.T) {
store := testkit.CreateMockStore(t)

Expand Down
2 changes: 1 addition & 1 deletion infoschema/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,7 @@ var tableDDLJobsCols = []columnInfo{
{name: "START_TIME", tp: mysql.TypeDatetime, size: 19},
{name: "END_TIME", tp: mysql.TypeDatetime, size: 19},
{name: "STATE", tp: mysql.TypeVarchar, size: 64},
{name: "QUERY", tp: mysql.TypeVarchar, size: 64},
{name: "QUERY", tp: mysql.TypeBlob, size: types.UnspecifiedLength},
}

var tableSequencesCols = []columnInfo{
Expand Down
21 changes: 21 additions & 0 deletions testkit/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,24 @@ func (res *Result) CheckAt(cols []int, expected [][]interface{}) {
need := fmt.Sprintf("%s", expected)
res.require.Equal(need, got, res.comment)
}

// CheckContain checks whether the result contains the expected string
func (res *Result) CheckContain(expected string) {
var result strings.Builder
for i, row := range res.rows {
if i > 0 {
result.WriteString("\n")
}
for j, colValue := range row {
if j > 0 {
result.WriteString(" ")
}
result.WriteString(colValue)
if strings.Contains(colValue, expected) {
return
}
}
}
comment := fmt.Sprintf("the result doesn't contain the exepected %s\n%s", expected, result.String())
res.require.Equal(true, false, comment)
}