Skip to content

Commit

Permalink
add sp_flush_CT_internal_table_on_demand for CT
Browse files Browse the repository at this point in the history
  • Loading branch information
Mimetis committed Aug 30, 2024
1 parent 2cee9c7 commit 1ba0e75
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public SqlChangeTrackingSyncAdapter(SyncTable tableDescription, ScopeInfo scopeI
{
DbCommandType.UpdateMetadata => (this.BuildUpdateMetadataCommand(), false),
DbCommandType.SelectRow => (this.BuildSelectRowCommand(), false),
DbCommandType.DeleteMetadata => (null, false),
DbCommandType.DeleteMetadata => (this.BuildDeleteMetadataCommand(), false),
DbCommandType.Reset => (this.CreateResetCommand(), false),
DbCommandType.UpdateUntrackedRows => (this.BuildUpdateUntrackedRowsCommand(), false),
_ => base.GetCommand(context, commandType, filter),
Expand All @@ -43,6 +43,13 @@ private SqlCommand BuildUpdateMetadataCommand()
return c;
}

private SqlCommand BuildDeleteMetadataCommand()
{
var sqlCommand = new SqlCommand();
sqlCommand.CommandText = $"EXEC sys.sp_flush_CT_internal_table_on_demand;";
return sqlCommand;
}

private SqlCommand BuildSelectRowCommand()
{
var sqlCommand = new SqlCommand();
Expand Down Expand Up @@ -106,9 +113,7 @@ private SqlCommand CreateResetCommand()
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine($"SET @sync_row_count = 0;");
stringBuilder.AppendLine();
stringBuilder.AppendLine($"DELETE FROM {this.SqlObjectNames.TableQuotedFullName};");
stringBuilder.AppendLine();
stringBuilder.AppendLine(string.Concat("SET @sync_row_count = @@ROWCOUNT;"));

return new SqlCommand(stringBuilder.ToString());
Expand Down

0 comments on commit 1ba0e75

Please sign in to comment.