MXS-1575: Fix CREATE TABLE processing

The CREATE TABLE processing failed to identify the explicit database names
that were generated by mysqldump.
This commit is contained in:
Markus Mäkelä
2018-01-05 10:37:43 +02:00
parent c64fd4f39f
commit ce1c45828a

View File

@ -421,28 +421,33 @@ static bool get_database_name(const char* sql, char* dest)
if (ptr)
{
ptr--;
while (*ptr == '`' || isspace(*ptr))
while (ptr >= sql && (*ptr == '`' || isspace(*ptr)))
{
ptr--;
}
while (*ptr != '`' && *ptr != '.' && !isspace(*ptr))
while (ptr >= sql && *ptr != '`' && *ptr != '.' && !isspace(*ptr))
{
ptr--;
}
if (*ptr == '.')
while (ptr >= sql && (*ptr == '`' || isspace(*ptr)))
{
ptr--;
}
if (ptr >= sql && *ptr == '.')
{
// The query defines an explicit database
while (*ptr == '`' || *ptr == '.' || isspace(*ptr))
while (ptr >= sql && (*ptr == '`' || *ptr == '.' || isspace(*ptr)))
{
ptr--;
}
const char* end = ptr + 1;
while (*ptr != '`' && *ptr != '.' && !isspace(*ptr))
while (ptr >= sql && *ptr != '`' && *ptr != '.' && !isspace(*ptr))
{
ptr--;
}