Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
11 changes: 11 additions & 0 deletions enginetest/queries/information_schema_queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ var InfoSchemaQueries = []QueryTest{
Query: "SHOW KEYS FROM `columns` FROM `information_schema`;",
Expected: []sql.Row{},
},
{
Query: `SELECT table_schema AS TABLE_CAT,
NULL AS TABLE_SCHEM,
table_name,
CASE WHEN table_type = 'BASE TABLE' THEN
CASE WHEN table_schema = 'mysql' OR table_schema = 'performance_schema' THEN 'SYSTEM TABLE'
ELSE 'TABLE' END
WHEN table_type = 'TEMPORARY' THEN 'LOCAL_TEMPORARY'
ELSE table_type END AS TABLE_TYPE FROM information_schema.tables ORDER BY table_name LIMIT 1;`,
Expected: []sql.Row{{"information_schema", nil, "administrable_role_authorizations", "SYSTEM VIEW"}},
},
{
Query: `SELECT
table_name, index_name, comment, non_unique, GROUP_CONCAT(column_name ORDER BY seq_in_index) AS COLUMNS
Expand Down
10 changes: 9 additions & 1 deletion sql/expression/enum.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,15 @@ func (e *EnumToString) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)
}

enumType := e.Enum.Type().(types.EnumType)
str, _ := enumType.At(int(val.(uint16)))
var str string
Comment thread
elianddb marked this conversation as resolved.
switch v := val.(type) {
case uint16:
str, _ = enumType.At(int(v))
case string:
str = v
default:
return nil, sql.ErrInvalidType.New(val, types.Text)
}
return str, nil
}

Expand Down
6 changes: 3 additions & 3 deletions sql/information_schema/tables_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ var tablesSchema = Schema{
func tablesRowIter(ctx *Context, cat Catalog) (RowIter, error) {
var rows []Row
var (
tableType string
tableType uint16
tableRows uint64
avgRowLength uint64
dataLength uint64
Expand All @@ -82,9 +82,9 @@ func tablesRowIter(ctx *Context, cat Catalog) (RowIter, error) {

for _, db := range databases {
if db.Database.Name() == InformationSchemaDatabaseName {
tableType = "SYSTEM VIEW"
tableType = 3 // SYSTEM_VIEW
} else {
tableType = "BASE TABLE"
tableType = 1 // BASE_TABLE
engine = "InnoDB"
rowFormat = "Dynamic"
}
Expand Down