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

Method init

sql/item_strfunc.cc:1692–1714  ·  view source on GitHub ↗

@note USER() is replicated correctly if binlog_format=ROW or (as of BUG#28086) binlog_format=MIXED, but is incorrectly replicated to '' if binlog_format=STATEMENT. */

Source from the content-addressed store, hash-verified

1690 if binlog_format=STATEMENT.
1691*/
1692bool Item_func_user::init(const char *user, const char *host)
1693{
1694 DBUG_ASSERT(fixed == 1);
1695
1696 // For system threads (e.g. replication SQL thread) user may be empty
1697 if (user)
1698 {
1699 const CHARSET_INFO *cs= str_value.charset();
1700 size_t res_length= (strlen(user)+strlen(host)+2) * cs->mbmaxlen;
1701
1702 if (str_value.alloc((uint) res_length))
1703 {
1704 null_value=1;
1705 return TRUE;
1706 }
1707
1708 res_length=cs->cset->snprintf(cs, (char*)str_value.ptr(), (uint) res_length,
1709 "%s@%s", user, host);
1710 str_value.length((uint) res_length);
1711 str_value.mark_as_const();
1712 }
1713 return FALSE;
1714}
1715
1716/**
1717 If alpha, map input letter to soundex code.

Callers 1

seedMethod · 0.45

Calls 5

mark_as_constMethod · 0.80
charsetMethod · 0.45
allocMethod · 0.45
ptrMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected