Parse the specified system variables list. @Note In case of invalid entry a warning is raised per invalid entry. This is done in order to handle 'potentially' valid system variables from uninstalled plugins which might get installed in future. @param thd [IN] The thd handle. @param var_list [IN] System variable list. @param throw_error [IN] bool whe
| 146 | false Success |
| 147 | */ |
| 148 | bool Session_sysvars_tracker::vars_list::parse_var_list(THD *thd, |
| 149 | LEX_STRING var_list, |
| 150 | bool throw_error, |
| 151 | CHARSET_INFO *char_set) |
| 152 | { |
| 153 | const char separator= ','; |
| 154 | char *token, *lasts= NULL; |
| 155 | size_t rest= var_list.length; |
| 156 | |
| 157 | if (!var_list.str || var_list.length == 0) |
| 158 | return false; |
| 159 | |
| 160 | if(!strcmp(var_list.str, "*")) |
| 161 | { |
| 162 | track_all= true; |
| 163 | return false; |
| 164 | } |
| 165 | |
| 166 | token= var_list.str; |
| 167 | |
| 168 | track_all= false; |
| 169 | mysql_prlock_rdlock(&LOCK_system_variables_hash); |
| 170 | for (;;) |
| 171 | { |
| 172 | sys_var *svar; |
| 173 | LEX_CSTRING var; |
| 174 | |
| 175 | lasts= (char *) memchr(token, separator, rest); |
| 176 | |
| 177 | var.str= token; |
| 178 | if (lasts) |
| 179 | { |
| 180 | var.length= (lasts - token); |
| 181 | rest-= var.length + 1; |
| 182 | } |
| 183 | else |
| 184 | var.length= rest; |
| 185 | |
| 186 | /* Remove leading/trailing whitespace. */ |
| 187 | trim_whitespace(char_set, &var); |
| 188 | |
| 189 | if(!strcmp(var.str, "*")) |
| 190 | { |
| 191 | track_all= true; |
| 192 | } |
| 193 | else if ((svar= find_sys_var(thd, var.str, var.length, throw_error, |
| 194 | /*hash_already_locked=*/true))) |
| 195 | { |
| 196 | if (insert(svar) == TRUE) |
| 197 | return true; |
| 198 | } |
| 199 | else if (throw_error && thd) |
| 200 | { |
| 201 | push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, |
| 202 | ER_WRONG_VALUE_FOR_VAR, |
| 203 | "%.*s is not a valid system variable and will " |
| 204 | "be ignored.", (int)var.length, token); |
| 205 | } |
no test coverage detected