Skip to content

Commit

Permalink
resolve conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
likzn committed Jun 1, 2022
1 parent 0d1c93f commit d07a65a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 35 deletions.
12 changes: 3 additions & 9 deletions executor/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -1468,17 +1468,11 @@ func (e *ShowExec) fetchShowCreatePlacementPolicy() error {
func (e *ShowExec) fetchShowCollation() error {
var (
fieldPatternsLike collate.WildcardPattern
FieldFilterEnable bool
fieldFilter string
)
if e.Extractor != nil {
extractor := (e.Extractor).(*plannercore.ShowCollationExtractor)
if extractor.FieldPatterns != "" {
fieldPatternsLike = collate.GetCollatorByID(collate.CollationName2ID(mysql.UTF8MB4DefaultCollation)).Pattern()
fieldPatternsLike.Compile(extractor.FieldPatterns, byte('\\'))
}
FieldFilterEnable = extractor.Field != ""
fieldFilter = extractor.Field
fieldPatternsLike = e.Extractor.FieldPatternLike()
fieldFilter = e.Extractor.Field()
}

collations := collate.GetSupportedCollations()
Expand All @@ -1487,7 +1481,7 @@ func (e *ShowExec) fetchShowCollation() error {
if v.IsDefault {
isDefault = "Yes"
}
if FieldFilterEnable && strings.ToLower(v.Name) != fieldFilter {
if fieldFilter != "" && strings.ToLower(v.Name) != fieldFilter {
continue
} else if fieldPatternsLike != nil && !fieldPatternsLike.DoMatch(v.Name) {
continue
Expand Down
2 changes: 1 addition & 1 deletion planner/core/planbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -2933,7 +2933,7 @@ func (b *PlanBuilder) buildShow(ctx context.Context, show *ast.ShowStmt) (Plan,
isSequence := false

switch show.Tp {
case ast.ShowDatabases, ast.ShowVariables, ast.ShowTables, ast.ShowColumns, ast.ShowTableStatus:
case ast.ShowDatabases, ast.ShowVariables, ast.ShowTables, ast.ShowColumns, ast.ShowTableStatus, ast.ShowCollation:
if (show.Tp == ast.ShowTables || show.Tp == ast.ShowTableStatus) && p.DBName == "" {
return nil, ErrNoDB
}
Expand Down
31 changes: 6 additions & 25 deletions planner/core/show_predicate_extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ import (
)

const (
fieldKey = "field"
tableKey = "table"
databaseKey = "database"
fieldKey = "field"
tableKey = "table"
databaseKey = "database"
collationKey = "collation"
)

var (
Expand Down Expand Up @@ -104,6 +105,8 @@ func (e *ShowBaseExtractor) explainInfo() string {
key = tableKey
case ast.ShowDatabases:
key = databaseKey
case ast.ShowCollation:
key = collationKey
}

r := new(bytes.Buffer)
Expand Down Expand Up @@ -137,25 +140,3 @@ func (e *ShowBaseExtractor) FieldPatternLike() collate.WildcardPattern {
fieldPatternsLike.Compile(e.fieldPattern, byte('\\'))
return fieldPatternsLike
}

// ShowCollationExtractor is used to extract some predicates of collations.
type ShowCollationExtractor struct {
ShowBaseExtractor
}

func (e *ShowCollationExtractor) explainInfo() string {
r := new(bytes.Buffer)
if len(e.Field) > 0 {
r.WriteString(fmt.Sprintf("collation:[%s], ", e.Field))
}
if len(e.FieldPatterns) > 0 {
r.WriteString(fmt.Sprintf("collation_pattern:[%s], ", e.FieldPatterns))
}

// remove the last ", " in the message info
s := r.String()
if len(s) > 2 {
return s[:len(s)-2]
}
return s
}

0 comments on commit d07a65a

Please sign in to comment.