Compare commits
2 Commits
master
...
no-lock-in
Author | SHA1 | Date | |
---|---|---|---|
|
97da64be8f | ||
|
19e00e5ddc |
@ -214,18 +214,14 @@ func BuildRangeInsertQuery(databaseName, originalTableName, ghostTableName strin
|
|||||||
return "", explodedArgs, err
|
return "", explodedArgs, err
|
||||||
}
|
}
|
||||||
explodedArgs = append(explodedArgs, rangeExplodedArgs...)
|
explodedArgs = append(explodedArgs, rangeExplodedArgs...)
|
||||||
transactionalClause := ""
|
|
||||||
if transactionalTable {
|
|
||||||
transactionalClause = "lock in share mode"
|
|
||||||
}
|
|
||||||
result = fmt.Sprintf(`
|
result = fmt.Sprintf(`
|
||||||
insert /* gh-ost %s.%s */ ignore into %s.%s (%s)
|
insert /* gh-ost %s.%s */ ignore into %s.%s (%s)
|
||||||
(select %s from %s.%s force index (%s)
|
(select %s from %s.%s force index (%s)
|
||||||
where (%s and %s) %s
|
where (%s and %s)
|
||||||
)
|
)
|
||||||
`, databaseName, originalTableName, databaseName, ghostTableName, mappedSharedColumnsListing,
|
`, databaseName, originalTableName, databaseName, ghostTableName, mappedSharedColumnsListing,
|
||||||
sharedColumnsListing, databaseName, originalTableName, uniqueKey,
|
sharedColumnsListing, databaseName, originalTableName, uniqueKey,
|
||||||
rangeStartComparison, rangeEndComparison, transactionalClause)
|
rangeStartComparison, rangeEndComparison)
|
||||||
return result, explodedArgs, nil
|
return result, explodedArgs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,7 +267,7 @@ func TestBuildRangeInsertPreparedQuery(t *testing.T) {
|
|||||||
insert /* gh-ost mydb.tbl */ ignore into mydb.ghost (id, name, position)
|
insert /* gh-ost mydb.tbl */ ignore into mydb.ghost (id, name, position)
|
||||||
(select id, name, position from mydb.tbl force index (name_position_uidx)
|
(select id, name, position from mydb.tbl force index (name_position_uidx)
|
||||||
where (((name > ?) or (((name = ?)) AND (position > ?)) or ((name = ?) and (position = ?))) and ((name < ?) or (((name = ?)) AND (position < ?)) or ((name = ?) and (position = ?))))
|
where (((name > ?) or (((name = ?)) AND (position > ?)) or ((name = ?) and (position = ?))) and ((name < ?) or (((name = ?)) AND (position < ?)) or ((name = ?) and (position = ?))))
|
||||||
lock in share mode )
|
)
|
||||||
`
|
`
|
||||||
test.S(t).ExpectEquals(normalizeQuery(query), normalizeQuery(expected))
|
test.S(t).ExpectEquals(normalizeQuery(query), normalizeQuery(expected))
|
||||||
test.S(t).ExpectTrue(reflect.DeepEqual(explodedArgs, []interface{}{3, 3, 17, 3, 17, 103, 103, 117, 103, 117}))
|
test.S(t).ExpectTrue(reflect.DeepEqual(explodedArgs, []interface{}{3, 3, 17, 3, 17, 103, 103, 117, 103, 117}))
|
||||||
|
Loading…
Reference in New Issue
Block a user