Skip to content

Commit

Permalink
Merge pull request #2763 from nbrane/remove-outdated-azure-sql-fix
Browse files Browse the repository at this point in the history
Remove GetAzureCompactScript from SqlDataProvider
  • Loading branch information
mtrutledge committed May 7, 2019
2 parents 6413f50 + 94a2b26 commit 9899bd3
Showing 1 changed file with 3 additions and 36 deletions.
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

0 comments on commit 9899bd3

Please sign in to comment.