diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 0a271dab40efb..28a4c97651a12 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -56,6 +56,7 @@ #include "sql_audit.h" #include "password.h" #include "scope.h" +#include #include "sql_plugin_compat.h" #include "wsrep_mysqld.h" @@ -9419,7 +9420,7 @@ static void add_user_parameters(THD *thd, String *result, ACL_USER* acl_user, } } -static const char *command_array[]= +static constexpr const char *command_array[]= { "SELECT", "INSERT", "UPDATE", "DELETE", "CREATE", "DROP", "RELOAD", "SHUTDOWN", "PROCESS","FILE", "GRANT", "REFERENCES", "INDEX", @@ -9432,23 +9433,18 @@ static const char *command_array[]= "BINLOG REPLAY", "SLAVE MONITOR", "SHOW CREATE ROUTINE" }; -static uint command_lengths[]= -{ - 6, 6, 6, 6, 6, 4, 6, - 8, 7, 4, 5, 10, 5, - 5, 14, 5, 23, - 11, 7, 17, 14, - 11, 9, 14, 13, - 11, 5, 7, 17, 14, - 8, 15, 16, 15, - 23, 24, 12, - 13, 13, 19 -}; +static constexpr auto command_lengths= []() constexpr { + std::array lengths{}; + for (size_t i= 0; i < lengths.size(); i++) + lengths[i]= static_cast( + std::char_traits::length(command_array[i])); + return lengths; +}(); static_assert(array_elements(command_array) == PRIVILEGE_T_MAX_BIT + 1, "The definition of command_array does not match privilege_t"); -static_assert(array_elements(command_lengths) == PRIVILEGE_T_MAX_BIT + 1, +static_assert(command_lengths.size() == PRIVILEGE_T_MAX_BIT + 1, "The definition of command_lengths does not match privilege_t");