Permalink
Browse files

fixing closure bug and eliminating duplicate columns hard coded into …

…merge statement
  • Loading branch information...
1 parent 38c764b commit b817eea1c959f517e09137f663d70e7e67f92fde @ssandler ssandler committed Jan 29, 2013
Showing with 4 additions and 3 deletions.
  1. +2 −1 TeslaSQL/Agents/ShardCoordinator.cs
  2. +2 −2 TeslaSQL/DataUtils/MSSQLDataUtils.cs
@@ -138,6 +138,7 @@ public ShardCoordinator(IDataUtils dataUtils, Logger logger)
var actions = new List<Action>();
foreach (var tableDb in tableDBFieldLists) {
var table = tableDb.Key;
+ var dbColumns = tableDb.Value;
var firstDB = tableDb.Value.FirstOrDefault(t => t.Value.Count > 0).Key;
if (firstDB == null) {
logger.Log("No shard has CT changes for table " + table.Name, LogLevel.Debug);
@@ -146,7 +147,7 @@ public ShardCoordinator(IDataUtils dataUtils, Logger logger)
tablesWithChanges.Add(table);
SetFieldList(table, firstDB, batch);
- Action act = () => MergeTable(batch, tableDb.Value, table, firstDB);
+ Action act = () => MergeTable(batch, dbColumns, table, firstDB);
actions.Add(act);
}
logger.Log("Parallel invocation of " + actions.Count + " table merges", LogLevel.Info);
@@ -1025,9 +1025,9 @@ THEN DELETE
USING (SELECT * FROM {1}.dbo.{0}) AS CT
ON ({2})
WHEN MATCHED AND P.SYS_CHANGE_OPERATION = 'D' AND CT.SYS_CHANGE_OPERATION IN ('I', 'U')
- THEN UPDATE SET {3}, P.SYS_CHANGE_OPERATION = CT.SYS_CHANGE_OPERATION, P.SYS_CHANGE_VERSION = CT.SYS_CHANGE_VERSION
+ THEN UPDATE SET {3}
WHEN NOT MATCHED
- THEN INSERT ({4},SYS_CHANGE_VERSION, SYS_CHANGE_OPERATION) VALUES ({5}, CT.SYS_CHANGE_VERSION, CT.SYS_CHANGE_OPERATION);",
+ THEN INSERT ({4}) VALUES ({5});",
table.ToCTName(CTID), sourceDB, table.PkList, mergeList, columnList, insertList);
SqlCommand cmd = new SqlCommand(sql);
SqlNonQuery(destDB, cmd);

0 comments on commit b817eea

Please sign in to comment.