diff --git a/infoschema/infoschema_test.go b/infoschema/infoschema_test.go index 601a01163450b..e6ba40d3839a8 100644 --- a/infoschema/infoschema_test.go +++ b/infoschema/infoschema_test.go @@ -665,6 +665,15 @@ 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, clean := testkit.CreateMockStore(t) + defer clean() + 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, clean := testkit.CreateMockStore(t) defer clean() diff --git a/infoschema/tables.go b/infoschema/tables.go index 66f3c48d83eb6..2955e186e1c9d 100644 --- a/infoschema/tables.go +++ b/infoschema/tables.go @@ -1169,7 +1169,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{ diff --git a/testkit/result.go b/testkit/result.go index 30fa7a53d2a2f..004fae930c304 100644 --- a/testkit/result.go +++ b/testkit/result.go @@ -117,3 +117,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) +}