@@ -199,41 +199,15 @@ func (this *Applier) ValidateOrDropExistingTables() error {
199
199
// It is safer to attempt the change than try and parse the DDL, since
200
200
// there might be specifics about the table which make it not possible to apply instantly.
201
201
func (this * Applier ) AttemptInstantDDL () error {
202
-
203
202
query := fmt .Sprintf (`ALTER /* gh-ost */ TABLE %s.%s %s, ALGORITHM=INSTANT` ,
204
203
sql .EscapeName (this .migrationContext .DatabaseName ),
205
204
sql .EscapeName (this .migrationContext .OriginalTableName ),
206
205
this .migrationContext .AlterStatementOptions ,
207
206
)
208
- this .migrationContext .Log .Infof ("INSTANT DDL Query is: %s" , query )
209
-
210
- err := func () error {
211
- tx , err := this .db .Begin ()
212
- if err != nil {
213
- return err
214
- }
215
- defer tx .Rollback ()
216
-
217
- sessionQuery := fmt .Sprintf (`SET SESSION time_zone = '%s'` , this .migrationContext .ApplierTimeZone )
218
- sessionQuery = fmt .Sprintf ("%s, %s" , sessionQuery , this .generateSqlModeQuery ())
219
-
220
- if _ , err := tx .Exec (sessionQuery ); err != nil {
221
- return err
222
- }
223
- if _ , err := tx .Exec (query ); err != nil {
224
- this .migrationContext .Log .Infof ("INSTANT DDL failed: %s" , err )
225
- return err
226
- }
227
- if err := tx .Commit (); err != nil {
228
- // Neither SET SESSION nor ALTER are really transactional, so strictly speaking
229
- // there's no need to commit; but let's do this the legit way anyway.
230
- return err
231
- }
232
- return nil
233
- }()
234
-
207
+ this .migrationContext .Log .Infof ("INSTANT DDL query is: %s" , query )
208
+ // We don't need a trx, because for instant DDL the SQL mode doesn't matter.
209
+ _ , err := this .db .Exec (query )
235
210
return err
236
-
237
211
}
238
212
239
213
// CreateGhostTable creates the ghost table on the applier host
0 commit comments