query_classifier.cc:cleaned up some intendentions and brackets.
dbshard.h:removed unnecessary code dbshard.c:removed unnecessary code, cleaned up a bit and made some required changes readwritesplit.c:removed two unnecessary variable assignments.
This commit is contained in:
@ -1441,47 +1441,55 @@ char* skygw_get_qtype_str(
|
||||
|
||||
/**
|
||||
* Returns an array of strings of databases that this query uses.
|
||||
* If the database isn't defined in the query, it is assumed that this query only targets the current database.
|
||||
* The value of @p size is set to the number of allocated strings. The caller is responsible for freeing all the allocated memory.
|
||||
* If the database isn't defined in the query, it is assumed that this query
|
||||
* only targets the current database.
|
||||
* The value of @p size is set to the number of allocated strings. The caller is
|
||||
* responsible for freeing all the allocated memory.
|
||||
* @param querybuf GWBUF containing the query
|
||||
* @param size Size of the resulting array
|
||||
* @return A new array of strings containing the database names or NULL if no databases were found.
|
||||
* @return A new array of strings containing the database names or NULL if no
|
||||
* databases were found.
|
||||
*/
|
||||
char** skygw_get_database_names(GWBUF* querybuf,int* size)
|
||||
char** skygw_get_database_names(GWBUF* querybuf,int* size)
|
||||
{
|
||||
LEX* lex;
|
||||
TABLE_LIST* tbl;
|
||||
char **databases = NULL, **tmp = NULL;
|
||||
int currsz = 0,i = 0;
|
||||
int currsz = 0,i = 0;
|
||||
|
||||
if( (lex = get_lex(querybuf)) == NULL)
|
||||
if( (lex = get_lex(querybuf)) == NULL)
|
||||
{
|
||||
goto retblock;
|
||||
}
|
||||
goto retblock;
|
||||
}
|
||||
|
||||
lex->current_select = lex->all_selects_list;
|
||||
|
||||
|
||||
while(lex->current_select){
|
||||
tbl = lex->current_select->join_list->head();
|
||||
while(tbl)
|
||||
while(lex->current_select)
|
||||
{
|
||||
tbl = lex->current_select->join_list->head();
|
||||
while(tbl)
|
||||
{
|
||||
if(strcmp(tbl->db,"skygw_virtual") != 0){
|
||||
if(i>= currsz){
|
||||
tmp = (char**)realloc(databases,sizeof(char*)*(currsz*2 + 1));
|
||||
if(tmp == NULL) goto retblock;
|
||||
if(strcmp(tbl->db,"skygw_virtual") != 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[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:
|
||||
*size = i;
|
||||
return databases;
|
||||
}
|
||||
|
Reference in New Issue
Block a user