@@ -283,46 +283,25 @@ func BuildUniqueKeyRangeEndPreparedQueryViaOffset(databaseName, tableName string
283
283
uniqueKeyColumnAscending [i ] = fmt .Sprintf ("%s asc" , uniqueKeyColumnNames [i ])
284
284
}
285
285
}
286
- joinedColumnNames := strings .Join (uniqueKeyColumnNames , ", " )
287
286
result = fmt .Sprintf (`
288
287
select /* gh-ost %s.%s %s */
289
- %s,
290
- (select count(*) from (
291
- select
292
- %s
293
- from
294
- %s.%s
295
- where
296
- %s and %s
297
- limit
298
- %d
299
- ) select_osc_chunk)
300
- from (
301
- select
302
- %s
303
- from
304
- %s.%s
305
- where
306
- %s and %s
307
- limit
308
- %d
309
- ) select_osc_chunk
288
+ %s
289
+ from
290
+ %s.%s
291
+ where
292
+ %s and %s
310
293
order by
311
294
%s
312
295
limit 1
313
296
offset %d` ,
314
297
databaseName , tableName , hint ,
315
- joinedColumnNames , joinedColumnNames ,
316
- databaseName , tableName ,
317
- rangeStartComparison , rangeEndComparison , chunkSize ,
318
- joinedColumnNames ,
298
+ strings .Join (uniqueKeyColumnNames , ", " ),
319
299
databaseName , tableName ,
320
- rangeStartComparison , rangeEndComparison , chunkSize ,
300
+ rangeStartComparison , rangeEndComparison ,
321
301
strings .Join (uniqueKeyColumnAscending , ", " ),
322
302
(chunkSize - 1 ),
323
303
)
324
- // 2x the explodedArgs for the subquery (CTE would be possible but not supported by MySQL 5)
325
- return result , append (explodedArgs , explodedArgs ... ), nil
304
+ return result , explodedArgs , nil
326
305
}
327
306
328
307
func BuildUniqueKeyRangeEndPreparedQueryViaTemptable (databaseName , tableName string , uniqueKeyColumns * ColumnList , rangeStartArgs , rangeEndArgs []interface {}, chunkSize int64 , includeRangeStartValues bool , hint string ) (result string , explodedArgs []interface {}, err error ) {
@@ -360,22 +339,8 @@ func BuildUniqueKeyRangeEndPreparedQueryViaTemptable(databaseName, tableName str
360
339
uniqueKeyColumnDescending [i ] = fmt .Sprintf ("%s desc" , uniqueKeyColumnNames [i ])
361
340
}
362
341
}
363
-
364
- joinedColumnNames := strings .Join (uniqueKeyColumnNames , ", " )
365
342
result = fmt .Sprintf (`
366
- select /* gh-ost %s.%s %s */
367
- %s,
368
- (select count(*) from (
369
- select
370
- %s
371
- from
372
- %s.%s
373
- where
374
- %s and %s
375
- order by
376
- %s
377
- limit %d
378
- ) select_osc_chunk)
343
+ select /* gh-ost %s.%s %s */ %s
379
344
from (
380
345
select
381
346
%s
@@ -390,17 +355,13 @@ func BuildUniqueKeyRangeEndPreparedQueryViaTemptable(databaseName, tableName str
390
355
order by
391
356
%s
392
357
limit 1` ,
393
- databaseName , tableName , hint , joinedColumnNames ,
394
- joinedColumnNames , databaseName , tableName ,
395
- rangeStartComparison , rangeEndComparison ,
396
- strings .Join (uniqueKeyColumnAscending , ", " ), chunkSize ,
397
- joinedColumnNames , databaseName , tableName ,
358
+ databaseName , tableName , hint , strings .Join (uniqueKeyColumnNames , ", " ),
359
+ strings .Join (uniqueKeyColumnNames , ", " ), databaseName , tableName ,
398
360
rangeStartComparison , rangeEndComparison ,
399
361
strings .Join (uniqueKeyColumnAscending , ", " ), chunkSize ,
400
362
strings .Join (uniqueKeyColumnDescending , ", " ),
401
363
)
402
- // 2x the explodedArgs for the subquery (CTE would be possible but not supported by MySQL 5)
403
- return result , append (explodedArgs , explodedArgs ... ), nil
364
+ return result , explodedArgs , nil
404
365
}
405
366
406
367
func BuildUniqueKeyMinValuesPreparedQuery (databaseName , tableName string , uniqueKey * UniqueKey ) (string , error ) {
0 commit comments