Skip to content

Commit

Permalink
Merge pull request #4681 from tinyspeck/vtexplain-support-escaped-tab…
Browse files Browse the repository at this point in the history
…le-names

vtexplain: properly use sqlparser.String to quote reserved table names
  • Loading branch information
sougou authored Feb 27, 2019
2 parents 8316f8f + 69f128d commit f5638ab
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions go/vt/vtexplain/vtexplain_vttablet.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ func initTabletEnvironment(ddls []*sqlparser.DDL, opts *Options) error {
}

for i, ddl := range ddls {
table := ddl.Table.Name.String()
table := sqlparser.String(ddl.Table.Name)
schemaQueries[mysql.BaseShowTablesForTable(table)] = &sqltypes.Result{
Fields: mysql.BaseShowTablesFields,
RowsAffected: 1,
Expand Down Expand Up @@ -511,9 +511,10 @@ func (t *explainTablet) HandleQuery(c *mysql.Conn, query string, callback func(*
return callback(&sqltypes.Result{})
}

colTypeMap := tableColumns[table.String()]
if colTypeMap == nil && table.String() != "dual" {
return fmt.Errorf("unable to resolve table name %s", table.String())
tableName := sqlparser.String(table)
colTypeMap := tableColumns[tableName]
if colTypeMap == nil && tableName != "dual" {
return fmt.Errorf("unable to resolve table name %s", tableName)
}

colNames := make([]string, 0, 4)
Expand Down

0 comments on commit f5638ab

Please sign in to comment.