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

fix some column values of information_schema.columns table #1029

Merged
merged 6 commits into from
May 24, 2022
Merged
Changes from 1 commit
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
19 changes: 11 additions & 8 deletions sql/information_schema/columns_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,18 @@ func columnsRowIter(ctx *sql.Context, cat sql.Catalog, columnNameToDefault map[s
ordinalPos uint64
colDefault interface{}
charMaxLen interface{}
colType string
columnKey string
colType = strings.ToLower(c.Type.String())
)

ordinalPos = uint64(i + 1)
if c.Nullable {
nullable = "YES"
} else {
nullable = "NO"
jennifersp marked this conversation as resolved.
Show resolved Hide resolved
}
dataType = strings.ToLower(c.Type.String())

dataType = colType
jennifersp marked this conversation as resolved.
Show resolved Hide resolved
if sql.IsText(c.Type) {
charName = sql.Collation_Default.CharacterSet().String()
collName = sql.Collation_Default.String()
Expand All @@ -183,16 +187,15 @@ func columnsRowIter(ctx *sql.Context, cat sql.Catalog, columnNameToDefault map[s
}
dataType = strings.TrimSuffix(dataType, fmt.Sprintf("(%v)", charMaxLen))
}
ordinalPos = uint64(i + 1)

fullColumnName := db.Name() + "." + t.Name() + "." + c.Name
colDefault = trimColumnDefaultOutput(columnNameToDefault[fullColumnName])
colType = strings.ToLower(c.Type.String())
if c.Type == sql.Boolean {
colType = colType + "(1)"
}
columnKey := ""
// PK is checked here first because there are PKs from table implementations that don't implement sql.IndexedTable

fullColumnName := db.Name() + "." + t.Name() + "." + c.Name
colDefault = trimColumnDefaultOutput(columnNameToDefault[fullColumnName])

// Check column PK here first because there are PKs from table implementations that don't implement sql.IndexedTable
if c.PrimaryKey {
columnKey = "PRI"
} else if val, ok := columnKeyMap[c.Name]; ok {
Expand Down