diff --git a/Documentation/Changelog.md b/Documentation/Changelog.md index e8037428e..1309cbb4c 100644 --- a/Documentation/Changelog.md +++ b/Documentation/Changelog.md @@ -3,6 +3,7 @@ ## MariaDB MaxScale 2.4 * Names starting with `@@` are reserved for use by MaxScale. +* Names can no longer contain whitespace. For more details, please refer to: diff --git a/Documentation/Getting-Started/Configuration-Guide.md b/Documentation/Getting-Started/Configuration-Guide.md index d6c1fc1b0..d8775014f 100644 --- a/Documentation/Getting-Started/Configuration-Guide.md +++ b/Documentation/Getting-Started/Configuration-Guide.md @@ -244,6 +244,11 @@ not supported. some_parameter=123 ``` +### Names + +Section names may not contain whitespace and must not start with the characters +`@@`, but otherwise there are no restrictions. + ### Special Parameter Types #### Sizes diff --git a/Documentation/Release-Notes/MaxScale-2.4.0-Release-Notes.md b/Documentation/Release-Notes/MaxScale-2.4.0-Release-Notes.md index 68e094ba0..022a1c206 100644 --- a/Documentation/Release-Notes/MaxScale-2.4.0-Release-Notes.md +++ b/Documentation/Release-Notes/MaxScale-2.4.0-Release-Notes.md @@ -16,6 +16,9 @@ Section and object names starting with `@@` are now reserved for use by MaxScale itself. If any such names are encountered in configuration files, then MaxScale will not start. +Whitespace in section names that was deprecated in 2.2 will now be +rejected and cause the startup of MaxScale to fail. + ## Dropped Features ## New Features diff --git a/Documentation/Upgrading/Upgrading-To-MaxScale-2.4.md b/Documentation/Upgrading/Upgrading-To-MaxScale-2.4.md index 26d3308ce..4cb6bcb20 100644 --- a/Documentation/Upgrading/Upgrading-To-MaxScale-2.4.md +++ b/Documentation/Upgrading/Upgrading-To-MaxScale-2.4.md @@ -22,3 +22,25 @@ Those files are: * The main configuration file; typically `/etc/maxscale.cnf`. * All nested configuration files; typically `/etc/maxscale.cnf.d/*`. * All dynamic configuration files; typically `/var/lib/maxscale/maxscale.cnd.d/*`. + +Further, whitespace in section names that was deprecated in MaxScale 2.2 +will now be rejected, which will cause the startup of MaxScale to fail. + +To prevent that, section names like +``` +[My Server] +... + +[My Service] +... +servers=My Server +``` +must be changed, for instance, to +``` +[MyServer] +... + +[MyService] +... +servers=MyServer +``` diff --git a/maxscale-system-test/cnf/maxscale.cnf.template.no_spaces_in_section_names b/maxscale-system-test/cnf/maxscale.cnf.template.no_spaces_in_section_names new file mode 100644 index 000000000..54e642eb2 --- /dev/null +++ b/maxscale-system-test/cnf/maxscale.cnf.template.no_spaces_in_section_names @@ -0,0 +1,57 @@ +[maxscale] +threads=###threads### + +[server 1] +type=server +address=###node_server_IP_1### +port=###node_server_port_1### +protocol=MySQLBackend + +[server 2] +type=server +address=###node_server_IP_2### +port=###node_server_port_2### +protocol=MySQLBackend + +[server 3] +type=server +address=###node_server_IP_3### +port=###node_server_port_3### +protocol=MySQLBackend + +[server 4] +type=server +address=###node_server_IP_4### +port=###node_server_port_4### +protocol=MySQLBackend + +[MySQL Monitor] +type=monitor +module=mysqlmon +servers=server 1,server 2,server 3,server 4 +user=maxskysql +password=skysql +monitor_interval=1000 + +[RW Split Router] +type=service +router=readwritesplit +servers=server 1,server 2,server 3,server 4 +user=maxskysql +password=skysql + +[RW Split Listener] +type=listener +service=RW Split Router +protocol=MySQLClient +port=4006 + +[CLI] +type=service +router=cli + +[CLI Listener] +type=listener +service=CLI +protocol=maxscaled +socket=default diff --git a/maxscale-system-test/config_test.cpp b/maxscale-system-test/config_test.cpp index 5a3f39de8..53bc9f754 100644 --- a/maxscale-system-test/config_test.cpp +++ b/maxscale-system-test/config_test.cpp @@ -24,6 +24,7 @@ const char* bad_configs[] = // passwd is still supported // "old_passwd", "no_use_of_reserved_names", + "no_spaces_in_section_names", NULL }; diff --git a/server/core/config.cc b/server/core/config.cc index a31c6b6f7..f7c253f20 100644 --- a/server/core/config.cc +++ b/server/core/config.cc @@ -616,34 +616,9 @@ CONFIG_CONTEXT* config_context_create(const char* section) return ctx; } -/** A set that holds all the section names that contain whitespace */ -static std::set warned_whitespace; - -static void fix_section_name(char* section) -{ - for (char* s = section; *s; s++) - { - if (isspace(*s)) - { - if (warned_whitespace.find(section) == warned_whitespace.end()) - { - warned_whitespace.insert(section); - MXS_WARNING("Whitespace in object names is deprecated, " - "converting to hyphens: %s", - section); - } - break; - } - } - - fix_object_name(section); -} - void fix_object_name(char* name) { - squeeze_whitespace(name); mxb::trim(name); - replace_whitespace(name); } void fix_object_name(std::string& name) @@ -747,12 +722,8 @@ static int ini_handler(void* userdata, const char* section, const char* name, co return 0; } - char fixed_section[strlen(section) + 1]; - strcpy(fixed_section, section); - fix_section_name(fixed_section); - string reason; - if (!config_is_valid_name(fixed_section, &reason)) + if (!config_is_valid_name(section, &reason)) { /* A set that holds all the section names that are invalid. As the configuration file * is parsed multiple times, we need to do this to prevent the same complaint from @@ -773,14 +744,14 @@ static int ini_handler(void* userdata, const char* section, const char* name, co * add the parameters to that object. If not create * a new object. */ - while (ptr && strcmp(ptr->object, fixed_section) != 0) + while (ptr && strcmp(ptr->object, section) != 0) { ptr = ptr->next; } if (!ptr) { - if ((ptr = config_context_create(fixed_section)) == NULL) + if ((ptr = config_context_create(section)) == NULL) { return 0; }