@@ -26,7 +26,7 @@ func (mysqld *Mysqld) GetSchema(dbName string, tables, excludeTables []string, i
26
26
sd := & tabletmanagerdatapb.SchemaDefinition {}
27
27
28
28
// get the database creation command
29
- qr , fetchErr := mysqld .FetchSuperQuery (ctx , "SHOW CREATE DATABASE IF NOT EXISTS " + dbName )
29
+ qr , fetchErr := mysqld .FetchSuperQuery (ctx , fmt . Sprintf ( "SHOW CREATE DATABASE IF NOT EXISTS `%s`" , dbName ) )
30
30
if fetchErr != nil {
31
31
return nil , fetchErr
32
32
}
@@ -72,7 +72,7 @@ func (mysqld *Mysqld) GetSchema(dbName string, tables, excludeTables []string, i
72
72
}
73
73
}
74
74
75
- qr , fetchErr := mysqld .FetchSuperQuery (ctx , "SHOW CREATE TABLE " + dbName + "." + tableName )
75
+ qr , fetchErr := mysqld .FetchSuperQuery (ctx , fmt . Sprintf ( "SHOW CREATE TABLE `%s`.`%s`" , dbName , tableName ) )
76
76
if fetchErr != nil {
77
77
return nil , fetchErr
78
78
}
@@ -138,7 +138,7 @@ func (mysqld *Mysqld) GetColumns(dbName, table string) ([]string, error) {
138
138
return nil , err
139
139
}
140
140
defer conn .Recycle ()
141
- qr , err := conn .ExecuteFetch (fmt .Sprintf ("select * from %v.%v where 1=0" , dbName , table ), 0 , true )
141
+ qr , err := conn .ExecuteFetch (fmt .Sprintf ("SELECT * FROM `%s`.`%s` WHERE 1=0" , dbName , table ), 0 , true )
142
142
if err != nil {
143
143
return nil , err
144
144
}
@@ -157,7 +157,7 @@ func (mysqld *Mysqld) GetPrimaryKeyColumns(dbName, table string) ([]string, erro
157
157
return nil , err
158
158
}
159
159
defer conn .Recycle ()
160
- qr , err := conn .ExecuteFetch (fmt .Sprintf ("show index from %v.%v " , dbName , table ), 100 , true )
160
+ qr , err := conn .ExecuteFetch (fmt .Sprintf ("SHOW INDEX FROM `%v`.`%v` " , dbName , table ), 100 , true )
161
161
if err != nil {
162
162
return nil , err
163
163
}
@@ -309,7 +309,7 @@ func (mysqld *Mysqld) ApplySchemaChange(dbName string, change *tmutils.SchemaCha
309
309
}
310
310
311
311
// add a 'use XXX' in front of the SQL
312
- sql = "USE " + dbName + " ;\n " + sql
312
+ sql = fmt . Sprintf ( "USE `%s` ;\n %s" , dbName , sql )
313
313
314
314
// execute the schema change using an external mysql process
315
315
// (to benefit from the extra commands in mysql cli)
0 commit comments