MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / validate_comment_length

Function validate_comment_length

sql/sql_table.cc:1567–1596  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1565*/
1566
1567bool validate_comment_length(THD *thd, const char *comment_str,
1568 size_t *comment_len, uint max_len,
1569 uint err_code, const char *comment_name)
1570{
1571 int length= 0;
1572 DBUG_ENTER("validate_comment_length");
1573 uint tmp_len= system_charset_info->cset->charpos(system_charset_info,
1574 comment_str,
1575 comment_str +
1576 *comment_len,
1577 max_len);
1578 if (tmp_len < *comment_len)
1579 {
1580 if (thd->is_strict_mode())
1581 {
1582 my_error(err_code, MYF(0),
1583 comment_name, static_cast<ulong>(max_len));
1584 DBUG_RETURN(true);
1585 }
1586 char warn_buff[MYSQL_ERRMSG_SIZE];
1587 length= my_snprintf(warn_buff, sizeof(warn_buff), ER(err_code),
1588 comment_name, static_cast<ulong>(max_len));
1589 /* do not push duplicate warnings */
1590 if (!thd->get_stmt_da()->has_sql_condition(warn_buff, length))
1591 push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
1592 err_code, warn_buff);
1593 *comment_len= tmp_len;
1594 }
1595 DBUG_RETURN(false);
1596}
1597
1598/*
1599 Extend long VARCHAR fields to blob & prepare field if it's a blob

Callers

nothing calls this directly

Calls 7

my_errorFunction · 0.85
my_snprintfFunction · 0.85
push_warningFunction · 0.85
charposMethod · 0.80
is_strict_modeMethod · 0.80
get_stmt_daMethod · 0.80
has_sql_conditionMethod · 0.45

Tested by

no test coverage detected