Merge branch '2.3' into develop
This commit is contained in:
@ -1853,58 +1853,82 @@ int32_t qc_mysql_get_database_names(GWBUF* querybuf, char*** databasesp, int* si
|
|||||||
goto retblock;
|
goto retblock;
|
||||||
}
|
}
|
||||||
|
|
||||||
lex->current_select = lex->all_selects_list;
|
if (lex->sql_command == SQLCOM_CHANGE_DB)
|
||||||
|
|
||||||
while (lex->current_select)
|
|
||||||
{
|
{
|
||||||
tbl = lex->current_select->table_list.first;
|
if (lex->select_lex.db)
|
||||||
|
|
||||||
while (tbl)
|
|
||||||
{
|
{
|
||||||
if (lex->sql_command == SQLCOM_SHOW_FIELDS)
|
if (i >= currsz)
|
||||||
{
|
{
|
||||||
// If we are describing, we want the actual table, not the information_schema.
|
tmp = (char**) realloc(databases,
|
||||||
if (tbl->schema_select_lex)
|
sizeof(char*) * (currsz * 2 + 1));
|
||||||
|
|
||||||
|
if (tmp == NULL)
|
||||||
{
|
{
|
||||||
tbl = tbl->schema_select_lex->table_list.first;
|
goto retblock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
databases = tmp;
|
||||||
|
currsz = currsz * 2 + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The database is sometimes an empty string. So as not to return
|
databases[i++] = strdup(lex->select_lex.db);
|
||||||
// an array of empty strings, we need to check for that possibility.
|
}
|
||||||
if ((strcmp(tbl->db, "skygw_virtual") != 0) && (*tbl->db != 0))
|
}
|
||||||
{
|
else
|
||||||
if (i >= currsz)
|
{
|
||||||
{
|
lex->current_select = lex->all_selects_list;
|
||||||
tmp = (char**) realloc(databases,
|
|
||||||
sizeof(char*) * (currsz * 2 + 1));
|
|
||||||
|
|
||||||
if (tmp == NULL)
|
while (lex->current_select)
|
||||||
|
{
|
||||||
|
tbl = lex->current_select->table_list.first;
|
||||||
|
|
||||||
|
while (tbl)
|
||||||
|
{
|
||||||
|
if (lex->sql_command == SQLCOM_SHOW_FIELDS)
|
||||||
|
{
|
||||||
|
// If we are describing, we want the actual table, not the information_schema.
|
||||||
|
if (tbl->schema_select_lex)
|
||||||
{
|
{
|
||||||
goto retblock;
|
tbl = tbl->schema_select_lex->table_list.first;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The database is sometimes an empty string. So as not to return
|
||||||
|
// an array of empty strings, we need to check for that possibility.
|
||||||
|
if ((strcmp(tbl->db, "skygw_virtual") != 0) && (*tbl->db != 0))
|
||||||
|
{
|
||||||
|
if (i >= currsz)
|
||||||
|
{
|
||||||
|
tmp = (char**) realloc(databases,
|
||||||
|
sizeof(char*) * (currsz * 2 + 1));
|
||||||
|
|
||||||
|
if (tmp == NULL)
|
||||||
|
{
|
||||||
|
goto retblock;
|
||||||
|
}
|
||||||
|
|
||||||
|
databases = tmp;
|
||||||
|
currsz = currsz * 2 + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
databases = tmp;
|
int j = 0;
|
||||||
currsz = currsz * 2 + 1;
|
|
||||||
|
while ((j < i) && (strcmp(tbl->db, databases[j]) != 0))
|
||||||
|
{
|
||||||
|
++j;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (j == i) // Not found
|
||||||
|
{
|
||||||
|
databases[i++] = strdup(tbl->db);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int j = 0;
|
tbl = tbl->next_local;
|
||||||
|
|
||||||
while ((j < i) && (strcmp(tbl->db, databases[j]) != 0))
|
|
||||||
{
|
|
||||||
++j;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (j == i) // Not found
|
|
||||||
{
|
|
||||||
databases[i++] = strdup(tbl->db);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tbl = tbl->next_local;
|
lex->current_select = lex->current_select->next_select_in_list();
|
||||||
}
|
}
|
||||||
|
|
||||||
lex->current_select = lex->current_select->next_select_in_list();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
retblock:
|
retblock:
|
||||||
|
@ -3046,6 +3046,13 @@ public:
|
|||||||
m_status = QC_QUERY_PARSED;
|
m_status = QC_QUERY_PARSED;
|
||||||
m_type_mask = QUERY_TYPE_SESSION_WRITE;
|
m_type_mask = QUERY_TYPE_SESSION_WRITE;
|
||||||
m_operation = QUERY_OP_CHANGE_DB;
|
m_operation = QUERY_OP_CHANGE_DB;
|
||||||
|
|
||||||
|
if (should_collect(QC_COLLECT_DATABASES))
|
||||||
|
{
|
||||||
|
char* zCopy = MXS_STRNDUP_A(pToken->z, pToken->n);
|
||||||
|
|
||||||
|
m_database_names.push_back(zCopy);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_type_mask(uint32_t type_mask)
|
void set_type_mask(uint32_t type_mask)
|
||||||
|
Reference in New Issue
Block a user