MySQL: Check for case-sensitivity

This commit is contained in:
Sebastiaan Janssen
2013-02-25 13:14:26 -01:00
parent 7498b2f994
commit f3621aa743
5 changed files with 45 additions and 3 deletions

View File

@@ -385,10 +385,24 @@ namespace Umbraco.Core
{
LogHelper.Info<DatabaseContext>("Database configuration status: Started");
string message;
var database = new UmbracoDatabase(_connectionString, ProviderName);
if (SyntaxConfig.SqlSyntaxProvider.SupportsCaseInsensitiveQueries(database) == false)
{
message = "<p>&nbsp;</p><p>The database you're trying to use does not support case insensitive queries. <br />We currently do not support these types of databases.</p>" +
"<p>You can fix this by changing the following two settings in your my.ini file in your MySQL installation directory:</p>" +
"<pre>lower_case_table_names=1\nlower_case_file_system=1</pre><br />" +
"<p>Note: Make sure to check with your hosting provider if they support case insensitive queries as well.</p>" +
"<p>For more technical information on case sensitivity in MySQL, have a look at " +
"<a href='http://dev.mysql.com/doc/refman/5.0/en/identifier-case-sensitivity.html'>the documentation on the subject</a></p>";
return new Result { Message = message, Success = false, Percentage = "15" };
}
var schemaResult = ValidateDatabaseSchema();
var installedVersion = schemaResult.DetermineInstalledVersion();
string message;
//If Configuration Status is empty and the determined version is "empty" its a new install - otherwise upgrade the existing
if (string.IsNullOrEmpty(GlobalSettings.ConfigurationStatus) && installedVersion.Equals(new Version(0, 0, 0)))
@@ -424,7 +438,7 @@ namespace Umbraco.Core
{
Message =
"The database configuration failed with the following message: " + ex.Message +
"\n Please check log file for addtional information (can be found in '/App_Data/Logs/UmbracoTraceLog.txt')",
"\n Please check log file for additional information (can be found in '/App_Data/Logs/UmbracoTraceLog.txt')",
Success = false,
Percentage = "90"
};

View File

@@ -48,6 +48,7 @@ namespace Umbraco.Core.Persistence.SqlSyntax
string FormatTableRename(string oldName, string newName);
bool SupportsClustered();
bool SupportsIdentityInsert();
bool? SupportsCaseInsensitiveQueries(Database db);
IEnumerable<string> GetTablesInSchema(Database db);
IEnumerable<ColumnInfo> GetColumnsInSchema(Database db);
IEnumerable<Tuple<string, string>> GetConstraintsPerTable(Database db);

View File

@@ -309,5 +309,27 @@ namespace Umbraco.Core.Persistence.SqlSyntax
public override string DropIndex { get { return "DROP INDEX {0} ON {1}"; } }
public override string RenameColumn { get { return "ALTER TABLE {0} CHANGE {1} {2}"; } }
public override bool? SupportsCaseInsensitiveQueries(Database db)
{
bool? supportsCaseInsensitiveQueries;
try
{
db.OpenSharedConnection();
var lowerCaseFileSystem = db.Fetch<int>("SELECT @@Global.lower_case_file_system");
var lowerCaseTableNames = db.Fetch<int>("SELECT @@Global.lower_case_table_names");
supportsCaseInsensitiveQueries = lowerCaseFileSystem.First() == 1 && lowerCaseTableNames.First() == 0;
}
finally
{
db.CloseSharedConnection();
}
// Could return null, which means testing failed,
// add message to check with their hosting provider
return supportsCaseInsensitiveQueries;
}
}
}

View File

@@ -151,6 +151,11 @@ namespace Umbraco.Core.Persistence.SqlSyntax
return "NVARCHAR";
}
public virtual bool? SupportsCaseInsensitiveQueries(Database db)
{
return true;
}
public virtual IEnumerable<string> GetTablesInSchema(Database db)
{
return new List<string>();

View File

@@ -31,7 +31,7 @@ function updateProgressBar(percent) {
function updateStatusMessage(message, error) {
if (message != null && message != undefined) {
jQuery(".loader > strong").text(message);
jQuery(".loader > strong").append(message);
}
if (error != undefined) {