check comment length of table, column, index and partition If comment length is more than the standard length truncate it and store the comment length upto the standard comment length size @param thd Thread handle @param[in,out] comment Comment @param max_len Maximum allowed comment length @param err_code Error message
| 4172 | @retval false On Success |
| 4173 | */ |
| 4174 | bool validate_comment_length(THD *thd, LEX_CSTRING *comment, size_t max_len, |
| 4175 | uint err_code, const char *name) |
| 4176 | { |
| 4177 | DBUG_ENTER("validate_comment_length"); |
| 4178 | if (comment->length == 0) |
| 4179 | DBUG_RETURN(false); |
| 4180 | |
| 4181 | size_t tmp_len= |
| 4182 | Well_formed_prefix(system_charset_info, *comment, max_len).length(); |
| 4183 | if (tmp_len < comment->length) |
| 4184 | { |
| 4185 | if (comment->length <= max_len) |
| 4186 | { |
| 4187 | if (thd->is_strict_mode()) |
| 4188 | { |
| 4189 | my_error(ER_INVALID_CHARACTER_STRING, MYF(0), |
| 4190 | system_charset_info->cs_name.str, comment->str); |
| 4191 | DBUG_RETURN(true); |
| 4192 | } |
| 4193 | push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, |
| 4194 | ER_INVALID_CHARACTER_STRING, |
| 4195 | ER_THD(thd, ER_INVALID_CHARACTER_STRING), |
| 4196 | system_charset_info->cs_name.str, comment->str); |
| 4197 | comment->length= tmp_len; |
| 4198 | DBUG_RETURN(false); |
| 4199 | } |
| 4200 | if (thd->is_strict_mode()) |
| 4201 | { |
| 4202 | my_error(err_code, MYF(0), name, static_cast<ulong>(max_len)); |
| 4203 | DBUG_RETURN(true); |
| 4204 | } |
| 4205 | push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, err_code, |
| 4206 | ER_THD(thd, err_code), name, |
| 4207 | static_cast<ulong>(max_len)); |
| 4208 | comment->length= tmp_len; |
| 4209 | } |
| 4210 | DBUG_RETURN(false); |
| 4211 | } |
| 4212 | |
| 4213 | |
| 4214 | /* |
no test coverage detected