MCPcopy Create free account
hub / github.com/MariaDB/server / validate_comment_length

Function validate_comment_length

sql/sql_table.cc:4174–4211  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

4172 @retval false On Success
4173*/
4174bool 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/*

Callers 5

write_db_optFunction · 0.85
mysql_create_frm_imageFunction · 0.85
build_frm_imageFunction · 0.85
pack_headerFunction · 0.85

Calls 5

Well_formed_prefixClass · 0.85
my_errorFunction · 0.85
push_warning_printfFunction · 0.85
is_strict_modeMethod · 0.80
lengthMethod · 0.45

Tested by

no test coverage detected