Skip to content
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
15 changes: 15 additions & 0 deletions enginetest/queries/information_schema_queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -1717,6 +1717,21 @@ from information_schema.routines where routine_schema = 'mydb' and routine_type
},
},
},
{

Name: "information_schema.tables has table comments",
SetUpScript: []string{
"create table t (i int primary key) comment 'this is a table comment';",
},
Assertions: []ScriptTestAssertion{
{
Query: "select table_comment from information_schema.tables where table_name = 't';",
Expected: []sql.Row{
{"this is a table comment"},
},
},
},
},
}

var SkippedInfoSchemaScripts = []ScriptTest{
Expand Down
7 changes: 6 additions & 1 deletion sql/information_schema/information_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -1822,6 +1822,7 @@ func tablesRowIter(ctx *Context, cat Catalog) (RowIter, error) {
y2k, _, _ := types.Timestamp.Convert("2000-01-01 00:00:00")
err := DBTableIter(ctx, db, func(t Table) (cont bool, err error) {
tableCollation = t.Collation().String()
comment := ""
if db.Name() != InformationSchemaDatabaseName {
if st, ok := t.(StatisticsTable); ok {
tableRows, _, err = st.RowCount(ctx)
Expand Down Expand Up @@ -1856,6 +1857,10 @@ func tablesRowIter(ctx *Context, cat Catalog) (RowIter, error) {
autoInc = nil
}
}

if commentedTable, ok := t.(CommentedTable); ok {
comment = commentedTable.Comment()
}
}

rows = append(rows, Row{
Expand All @@ -1879,7 +1884,7 @@ func tablesRowIter(ctx *Context, cat Catalog) (RowIter, error) {
tableCollation, // table_collation
nil, // checksum
"", // create_options
"", // table_comment
comment, // table_comment
})

return true, nil
Expand Down