Skip to content

Commit 6836629

Browse files
committed
Fix MySQL 5.7 error
1 parent e9551de commit 6836629

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

go/sql/builder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ func buildRangeInsertQueryTwoColumn(
394394
result = fmt.Sprintf(`
395395
insert /* gh-ost %s.%s */ ignore
396396
into %s.%s (%s)
397-
(%s union all %s union all %s)`,
397+
%s union all %s union all %s`,
398398
databaseName, originalTableName,
399399
databaseName, ghostTableName, mappedSharedColumnsListing,
400400
part1, part2, part3,

go/sql/builder_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,11 @@ func TestBuildRangeInsertQuery(t *testing.T) {
205205
expected := `
206206
insert /* gh-ost mydb.tbl */ ignore
207207
into mydb.ghost (id, name, position)
208-
((select id, name, position from mydb.tbl force index (name_position_uidx) where name = @v1s and position >= @v2s for share nowait)
208+
(select id, name, position from mydb.tbl force index (name_position_uidx) where name = @v1s and position >= @v2s for share nowait)
209209
union all
210210
(select id, name, position from mydb.tbl force index (name_position_uidx) where name > @v1s and name < @v1e for share nowait)
211211
union all
212-
(select id, name, position from mydb.tbl force index (name_position_uidx) where name = @v1e and position <= @v2e for share nowait))`
212+
(select id, name, position from mydb.tbl force index (name_position_uidx) where name = @v1e and position <= @v2e for share nowait)`
213213
require.Equal(t, normalizeQuery(expected), normalizeQuery(query))
214214
require.Equal(t, []interface{}{3, 17, 3, 103, 103, 117}, explodedArgs)
215215
}
@@ -254,11 +254,11 @@ func TestBuildRangeInsertQuery(t *testing.T) {
254254
expected := `
255255
insert /* gh-ost mydb.tbl */ ignore
256256
into mydb.ghost (id, name, position)
257-
((select id, name, position from mydb.tbl force index (name_position_uidx) where name = @v1s and position > @v2s for share nowait)
257+
(select id, name, position from mydb.tbl force index (name_position_uidx) where name = @v1s and position > @v2s for share nowait)
258258
union all
259259
(select id, name, position from mydb.tbl force index (name_position_uidx) where name > @v1s and name < @v1e for share nowait)
260260
union all
261-
(select id, name, position from mydb.tbl force index (name_position_uidx) where name = @v1e and position <= @v2e for share nowait))`
261+
(select id, name, position from mydb.tbl force index (name_position_uidx) where name = @v1e and position <= @v2e for share nowait)`
262262
require.Equal(t, normalizeQuery(expected), normalizeQuery(query))
263263
require.Equal(t, []interface{}{3, 17, 3, 103, 103, 117}, explodedArgs)
264264
}
@@ -276,11 +276,11 @@ func TestBuildRangeInsertQuery(t *testing.T) {
276276
expected := `
277277
insert /* gh-ost mydb.tbl */ ignore
278278
into mydb.ghost (id, name, position)
279-
((select id, name, position from mydb.tbl force index (name_position_uidx) where name = @v1s and position >= @v2s )
279+
(select id, name, position from mydb.tbl force index (name_position_uidx) where name = @v1s and position >= @v2s )
280280
union all
281281
(select id, name, position from mydb.tbl force index (name_position_uidx) where name > @v1s and name < @v1e )
282282
union all
283-
(select id, name, position from mydb.tbl force index (name_position_uidx) where name = @v1e and position <= @v2e ))`
283+
(select id, name, position from mydb.tbl force index (name_position_uidx) where name = @v1e and position <= @v2e )`
284284
require.Equal(t, normalizeQuery(expected), normalizeQuery(query))
285285
require.Equal(t, []interface{}{3, 17, 3, 103, 103, 117}, explodedArgs)
286286
}
@@ -298,11 +298,11 @@ func TestBuildRangeInsertQuery(t *testing.T) {
298298
expected := `
299299
insert /* gh-ost mydb.tbl */ ignore
300300
into mydb.ghost (id, name, position)
301-
((select id, name, position from mydb.tbl force index (name_position_uidx) where name = @v1s and position >= @v2s lock in share mode)
301+
(select id, name, position from mydb.tbl force index (name_position_uidx) where name = @v1s and position >= @v2s lock in share mode)
302302
union all
303303
(select id, name, position from mydb.tbl force index (name_position_uidx) where name > @v1s and name < @v1e lock in share mode)
304304
union all
305-
(select id, name, position from mydb.tbl force index (name_position_uidx) where name = @v1e and position <= @v2e lock in share mode))`
305+
(select id, name, position from mydb.tbl force index (name_position_uidx) where name = @v1e and position <= @v2e lock in share mode)`
306306
require.Equal(t, normalizeQuery(expected), normalizeQuery(query))
307307
require.Equal(t, []interface{}{3, 17, 3, 103, 103, 117}, explodedArgs)
308308
}
@@ -356,11 +356,11 @@ func TestBuildRangeInsertQueryRenameMap(t *testing.T) {
356356
expected := `
357357
insert /* gh-ost mydb.tbl */ ignore
358358
into mydb.ghost (id, name, location)
359-
((select id, name, position from mydb.tbl force index (name_position_uidx) where name = @v1s and position >= @v2s for share nowait)
359+
(select id, name, position from mydb.tbl force index (name_position_uidx) where name = @v1s and position >= @v2s for share nowait)
360360
union all
361361
(select id, name, position from mydb.tbl force index (name_position_uidx) where name > @v1s and name < @v1e for share nowait)
362362
union all
363-
(select id, name, position from mydb.tbl force index (name_position_uidx) where name = @v1e and position <= @v2e for share nowait))`
363+
(select id, name, position from mydb.tbl force index (name_position_uidx) where name = @v1e and position <= @v2e for share nowait)`
364364
require.Equal(t, normalizeQuery(expected), normalizeQuery(query))
365365
require.Equal(t, []interface{}{3, 17, 3, 103, 103, 117}, explodedArgs)
366366
}
@@ -382,11 +382,11 @@ func TestBuildRangeInsertPreparedQuery(t *testing.T) {
382382
expected := `
383383
insert /* gh-ost mydb.tbl */ ignore
384384
into mydb.ghost (id, name, position)
385-
((select id, name, position from mydb.tbl force index (name_position_uidx) where name = ? and position >= ? for share nowait)
385+
(select id, name, position from mydb.tbl force index (name_position_uidx) where name = ? and position >= ? for share nowait)
386386
union all
387387
(select id, name, position from mydb.tbl force index (name_position_uidx) where name > ? and name < ? for share nowait)
388388
union all
389-
(select id, name, position from mydb.tbl force index (name_position_uidx) where name = ? and position <= ? for share nowait))`
389+
(select id, name, position from mydb.tbl force index (name_position_uidx) where name = ? and position <= ? for share nowait)`
390390
require.Equal(t, normalizeQuery(expected), normalizeQuery(query))
391391
require.Equal(t, []interface{}{3, 17, 3, 103, 103, 117}, explodedArgs)
392392
}

0 commit comments

Comments
 (0)