Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove GetAzureCompactScript from SqlDataProvider #2763

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 3 additions & 36 deletions DNN Platform/Library/Data/SqlDataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ public sealed class SqlDataProvider : DataProvider

private const string ScriptDelimiter = "(?<=(?:[^\\w]+|^))GO(?=(?: |\\t)*?(?:\\r?\\n|$))";

private static readonly Regex ScriptWithRegex = new Regex("WITH\\s*\\([\\s\\S]*?((PAD_INDEX|ALLOW_ROW_LOCKS|ALLOW_PAGE_LOCKS)\\s*=\\s*(ON|OFF))+[\\s\\S]*?\\)",
RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Compiled);
private static readonly Regex ScriptOnPrimaryRegex = new Regex("(TEXTIMAGE_)*ON\\s*\\[\\s*PRIMARY\\s*\\]", RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Compiled);

#endregion

#region Public Properties
Expand Down Expand Up @@ -110,30 +106,16 @@ private string ExecuteScriptInternal(string connectionString, string script, int
// script dynamic substitution
sql = DataUtil.ReplaceTokens(sql);

//Clean up some SQL Azure incompatabilities
var query = GetAzureCompactScript(sql);

if (query != sql)
{
var props = new LogProperties { new LogDetailInfo("SQL Script Modified", query) };

EventLogController.Instance.AddLog(props,
PortalController.Instance.GetCurrentPortalSettings(),
UserController.Instance.GetCurrentUserInfo().UserID,
EventLogController.EventLogType.HOST_ALERT.ToString(),
true);
}

try
{
Logger.Trace("Executing SQL Script " + query);
Logger.Trace("Executing SQL Script " + sql);

_dbConnectionProvider.ExecuteNonQuery(connectionString, CommandType.Text, timeoutSec, query);
_dbConnectionProvider.ExecuteNonQuery(connectionString, CommandType.Text, timeoutSec, sql);
}
catch (SqlException objException)
{
Logger.Error(objException);
exceptions += objException + Environment.NewLine + Environment.NewLine + query + Environment.NewLine + Environment.NewLine;
exceptions += objException + Environment.NewLine + Environment.NewLine + sql + Environment.NewLine + Environment.NewLine;
}
}
}
Expand Down Expand Up @@ -282,21 +264,6 @@ private string ExecuteUpgradedConnectionQuery(string sql)
return exceptions;
}

private static string GetAzureCompactScript(string script)
{
if (ScriptWithRegex.IsMatch(script))
{
script = ScriptWithRegex.Replace(script, string.Empty);
}

if (ScriptOnPrimaryRegex.IsMatch(script))
{
script = ScriptOnPrimaryRegex.Replace(script, string.Empty);
}

return script;
}

#endregion

#region Abstract Methods
Expand Down