1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-13414 Fix the SP code to avoid excessive use of strlen

This commit is contained in:
Alexander Barkov
2017-07-31 17:34:59 +04:00
parent 716898755a
commit 4937474f86
12 changed files with 281 additions and 256 deletions

View File

@ -7475,4 +7475,34 @@ void AUTHID::copy(MEM_ROOT *mem_root, const LEX_CSTRING *user_name,
}
/*
Set from a string in 'user@host' format.
This method resebmles parse_user(),
but does not need temporary buffers.
*/
void AUTHID::parse(const char *str, size_t length)
{
const char *p= strrchr(str, '@');
if (!p)
{
user.str= str;
user.length= length;
host= null_clex_str;
}
else
{
user.str= str;
user.length= (size_t) (p - str);
host.str= p + 1;
host.length= (size_t) (length - user.length - 1);
if (user.length && !host.length)
host= host_not_specified; // 'user@' -> 'user@%'
}
if (user.length > USERNAME_LENGTH)
user.length= USERNAME_LENGTH;
if (host.length > HOSTNAME_LENGTH)
host.length= HOSTNAME_LENGTH;
}
#endif /* !defined(MYSQL_CLIENT) */