# HG changeset patch # User Sebastien Jodogne # Date 1542636368 -3600 # Node ID 412e303368472426e319baaa5cabb8bf639166b6 # Parent 318c1ccb787c01dc582f62b28a889022d04afd70 allowing dollars and underscores in MySQL database identifiers diff -r 318c1ccb787c -r 412e30336847 Framework/MySQL/MySQLDatabase.cpp --- a/Framework/MySQL/MySQLDatabase.cpp Sun Oct 28 12:29:22 2018 +0100 +++ b/Framework/MySQL/MySQLDatabase.cpp Mon Nov 19 15:06:08 2018 +0100 @@ -328,7 +328,7 @@ throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); } - if (!IsAlphanumericString(name)) + if (!IsValidDatabaseIdentifier(name)) { throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); } @@ -360,7 +360,7 @@ throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); } - if (!IsAlphanumericString(name)) + if (!IsValidDatabaseIdentifier(name)) { throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); } @@ -480,11 +480,14 @@ } - bool MySQLDatabase::IsAlphanumericString(const std::string& s) + bool MySQLDatabase::IsValidDatabaseIdentifier(const std::string& s) { for (size_t i = 0; i < s.length(); i++) { - if (!isalnum(s[i])) + // https://dev.mysql.com/doc/refman/8.0/en/identifiers.html + if (!isalnum(s[i]) && + s[i] != '$' && + s[i] != '_') { return false; } diff -r 318c1ccb787c -r 412e30336847 Framework/MySQL/MySQLDatabase.h --- a/Framework/MySQL/MySQLDatabase.h Sun Oct 28 12:29:22 2018 +0100 +++ b/Framework/MySQL/MySQLDatabase.h Mon Nov 19 15:06:08 2018 +0100 @@ -92,6 +92,6 @@ static void GlobalFinalization(); - static bool IsAlphanumericString(const std::string& s); + static bool IsValidDatabaseIdentifier(const std::string& s); }; } diff -r 318c1ccb787c -r 412e30336847 MySQL/NEWS --- a/MySQL/NEWS Sun Oct 28 12:29:22 2018 +0100 +++ b/MySQL/NEWS Mon Nov 19 15:06:08 2018 +0100 @@ -1,6 +1,8 @@ Pending changes in the mainline =============================== +* Characters "$" and "_" are allowed in MySQL database identifiers + Release 1.1 (2018-07-18) ======================== diff -r 318c1ccb787c -r 412e30336847 MySQL/Plugins/MySQLIndex.cpp --- a/MySQL/Plugins/MySQLIndex.cpp Sun Oct 28 12:29:22 2018 +0100 +++ b/MySQL/Plugins/MySQLIndex.cpp Mon Nov 19 15:06:08 2018 +0100 @@ -56,7 +56,7 @@ throw Orthanc::OrthancException(Orthanc::ErrorCode_Plugin); } - if (!MySQLDatabase::IsAlphanumericString(parameters_.GetDatabase())) + if (!MySQLDatabase::IsValidDatabaseIdentifier(parameters_.GetDatabase())) { throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); }