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:
VilhoRaatikka
2014-12-07 00:34:23 +02:00
parent 94b6fc8ff1
commit 68fc849c6e
4 changed files with 329 additions and 681 deletions

View File

@ -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;
}

View File

@ -75,15 +75,16 @@ struct router_instance;
typedef enum {
TARGET_UNDEFINED = 0x00,
TARGET_SINGLE = 0x01,
TARGET_ALL = 0x02
TARGET_MASTER = 0x01,
TARGET_SLAVE = 0x02,
TARGET_NAMED_SERVER = 0x04,
TARGET_ALL = 0x08,
TARGET_RLAG_MAX = 0x10
} route_target_t;
#define TARGET_IS_MASTER(t) (t & TARGET_MASTER)
#define TARGET_IS_SLAVE(t) (t & TARGET_SLAVE)
#define TARGET_IS_NAMED_SERVER(t) (t & TARGET_NAMED_SERVER)
#define TARGET_IS_ALL(t) (t & TARGET_ALL)
#define TARGET_IS_RLAG_MAX(t) (t & TARGET_RLAG_MAX)
typedef struct rses_property_st rses_property_t;
typedef struct router_client_session ROUTER_CLIENT_SES;
@ -97,24 +98,6 @@ typedef enum rses_property_type_t {
RSES_PROP_TYPE_COUNT=RSES_PROP_TYPE_LAST+1
} rses_property_type_t;
/**
* This criteria is used when backends are chosen for a router session's use.
* Backend servers are sorted to ascending order according to the criteria
* and top N are chosen.
*/
typedef enum select_criteria {
UNDEFINED_CRITERIA=0,
LEAST_GLOBAL_CONNECTIONS, /*< all connections established by MaxScale */
LEAST_ROUTER_CONNECTIONS, /*< connections established by this router */
LEAST_BEHIND_MASTER,
LEAST_CURRENT_OPERATIONS,
DEFAULT_CRITERIA=LEAST_CURRENT_OPERATIONS,
LAST_CRITERIA /*< not used except for an index */
} select_criteria_t;
/** default values for rwsplit configuration parameters */
#define CONFIG_MAX_SLAVE_CONN 1
#define CONFIG_MAX_SLAVE_RLAG -1 /*< not used */
@ -229,11 +212,9 @@ typedef struct backend_ref_st {
} backend_ref_t;
typedef struct rwsplit_config_st {
typedef struct dbshard_config_st {
int rw_max_slave_conn_percent;
int rw_max_slave_conn_count;
select_criteria_t rw_slave_select_criteria;
int rw_max_slave_replication_lag;
target_t rw_use_sql_variables_in;
} rwsplit_config_t;

File diff suppressed because it is too large Load Diff

View File

@ -3220,8 +3220,6 @@ static bool select_connect_backend_servers(
atomic_add(&backend_ref[i].bref_backend->backend_conn_count, -1);
}
}
master_connected = false;
slaves_connected = 0;
}
return_succp: