Replace skygw_ type prefix with qc_.

- skygw_query_type_t renamed to qc_query_type_t.
- skygw_query_op_t renamed to qc_query_op_t.
This commit is contained in:
Johan Wikman
2016-01-11 11:22:38 +02:00
parent 2f42246880
commit 23a7562d3a
7 changed files with 73 additions and 76 deletions

View File

@ -66,7 +66,7 @@
static THD* get_or_create_thd_for_parsing(MYSQL* mysql, char* query_str); static THD* get_or_create_thd_for_parsing(MYSQL* mysql, char* query_str);
static unsigned long set_client_flags(MYSQL* mysql); static unsigned long set_client_flags(MYSQL* mysql);
static bool create_parse_tree(THD* thd); static bool create_parse_tree(THD* thd);
static skygw_query_type_t resolve_query_type(THD* thd); static qc_query_type_t resolve_query_type(THD* thd);
static bool skygw_stmt_causes_implicit_commit(LEX* lex, int* autocommit_stmt); static bool skygw_stmt_causes_implicit_commit(LEX* lex, int* autocommit_stmt);
static int is_autocommit_stmt(LEX* lex); static int is_autocommit_stmt(LEX* lex);
@ -108,10 +108,10 @@ bool ensure_query_is_parsed(GWBUF* query)
* *
* @return query type * @return query type
*/ */
skygw_query_type_t qc_get_type(GWBUF* querybuf) qc_query_type_t qc_get_type(GWBUF* querybuf)
{ {
MYSQL* mysql; MYSQL* mysql;
skygw_query_type_t qtype = QUERY_TYPE_UNKNOWN; qc_query_type_t qtype = QUERY_TYPE_UNKNOWN;
bool succp; bool succp;
ss_info_dassert(querybuf != NULL, ("querybuf is NULL")); ss_info_dassert(querybuf != NULL, ("querybuf is NULL"));
@ -416,9 +416,9 @@ return_here:
* the resulting type may be different. * the resulting type may be different.
* *
*/ */
static skygw_query_type_t resolve_query_type(THD* thd) static qc_query_type_t resolve_query_type(THD* thd)
{ {
skygw_query_type_t qtype = QUERY_TYPE_UNKNOWN; qc_query_type_t qtype = QUERY_TYPE_UNKNOWN;
u_int32_t type = QUERY_TYPE_UNKNOWN; u_int32_t type = QUERY_TYPE_UNKNOWN;
int set_autocommit_stmt = -1; /*< -1 no, 0 disable, 1 enable */ int set_autocommit_stmt = -1; /*< -1 no, 0 disable, 1 enable */
LEX* lex; LEX* lex;
@ -826,7 +826,7 @@ static skygw_query_type_t resolve_query_type(THD* thd)
} /**< if */ } /**< if */
return_qtype: return_qtype:
qtype = (skygw_query_type_t) type; qtype = (qc_query_type_t) type;
return qtype; return qtype;
} }
@ -1641,11 +1641,11 @@ static void parsing_info_set_plain_str(void* ptr, char* str)
* *
* @return string representing the query type value * @return string representing the query type value
*/ */
char* qc_get_qtype_str(skygw_query_type_t qtype) char* qc_get_qtype_str(qc_query_type_t qtype)
{ {
int t1 = (int) qtype; int t1 = (int) qtype;
int t2 = 1; int t2 = 1;
skygw_query_type_t t = QUERY_TYPE_UNKNOWN; qc_query_type_t t = QUERY_TYPE_UNKNOWN;
char* qtype_str = NULL; char* qtype_str = NULL;
/** /**
@ -1656,7 +1656,7 @@ char* qc_get_qtype_str(skygw_query_type_t qtype)
{ {
if (t1 & t2) if (t1 & t2)
{ {
t = (skygw_query_type_t) t2; t = (qc_query_type_t) t2;
if (qtype_str == NULL) if (qtype_str == NULL)
{ {
@ -1751,9 +1751,9 @@ retblock:
return databases; return databases;
} }
skygw_query_op_t qc_get_operation(GWBUF* querybuf) qc_query_op_t qc_get_operation(GWBUF* querybuf)
{ {
skygw_query_op_t operation = QUERY_OP_UNDEFINED; qc_query_op_t operation = QUERY_OP_UNDEFINED;
if (querybuf) if (querybuf)
{ {

View File

@ -61,7 +61,7 @@ typedef enum
QUERY_TYPE_READ_TMP_TABLE = 0x100000, /*< Read temporary table:master (could be any) */ QUERY_TYPE_READ_TMP_TABLE = 0x100000, /*< Read temporary table:master (could be any) */
QUERY_TYPE_SHOW_DATABASES = 0x200000, /*< Show list of databases */ QUERY_TYPE_SHOW_DATABASES = 0x200000, /*< Show list of databases */
QUERY_TYPE_SHOW_TABLES = 0x400000 /*< Show list of tables */ QUERY_TYPE_SHOW_TABLES = 0x400000 /*< Show list of tables */
} skygw_query_type_t; } qc_query_type_t;
typedef enum typedef enum
{ {
@ -79,7 +79,7 @@ typedef enum
QUERY_OP_DROP_INDEX = (1 << 10), QUERY_OP_DROP_INDEX = (1 << 10),
QUERY_OP_CHANGE_DB = (1 << 11), QUERY_OP_CHANGE_DB = (1 << 11),
QUERY_OP_LOAD = (1 << 12) QUERY_OP_LOAD = (1 << 12)
} skygw_query_op_t; } qc_query_op_t;
typedef struct parsing_info_st typedef struct parsing_info_st
{ {
@ -101,8 +101,8 @@ typedef struct parsing_info_st
* Create THD and use it for creating parse tree. Examine parse tree and * Create THD and use it for creating parse tree. Examine parse tree and
* classify the query. * classify the query.
*/ */
skygw_query_type_t qc_get_type(GWBUF* querybuf); qc_query_type_t qc_get_type(GWBUF* querybuf);
skygw_query_op_t qc_get_operation(GWBUF* querybuf); qc_query_op_t qc_get_operation(GWBUF* querybuf);
#if defined(NOT_USED) #if defined(NOT_USED)
char* qc_get_stmtname(GWBUF* buf); char* qc_get_stmtname(GWBUF* buf);
@ -114,7 +114,7 @@ bool qc_is_real_query(GWBUF* querybuf);
char** qc_get_table_names(GWBUF* querybuf, int* tblsize, bool fullnames); char** qc_get_table_names(GWBUF* querybuf, int* tblsize, bool fullnames);
char* qc_get_canonical(GWBUF* querybuf); char* qc_get_canonical(GWBUF* querybuf);
bool qc_query_has_clause(GWBUF* buf); bool qc_query_has_clause(GWBUF* buf);
char* qc_get_qtype_str(skygw_query_type_t qtype); char* qc_get_qtype_str(qc_query_type_t qtype);
char* qc_get_affected_fields(GWBUF* buf); char* qc_get_affected_fields(GWBUF* buf);
char** qc_get_database_names(GWBUF* querybuf, int* size); char** qc_get_database_names(GWBUF* querybuf, int* size);

View File

@ -108,7 +108,7 @@ int main(int argc, char** argv)
memmove(strbuff,tok + 1, strsz - qlen); memmove(strbuff,tok + 1, strsz - qlen);
strsz -= qlen; strsz -= qlen;
memset(strbuff + strsz,0,buffsz - strsz); memset(strbuff + strsz,0,buffsz - strsz);
skygw_query_type_t type = qc_get_type(buff); qc_query_type_t type = qc_get_type(buff);
char qtypestr[64]; char qtypestr[64];
char expbuff[256]; char expbuff[256];
int expos = 0; int expos = 0;

View File

@ -195,7 +195,7 @@ typedef struct rule_t
void* data; /*< Actual implementation of the rule */ void* data; /*< Actual implementation of the rule */
char* name; /*< Name of the rule */ char* name; /*< Name of the rule */
ruletype_t type; /*< Type of the rule */ ruletype_t type; /*< Type of the rule */
skygw_query_op_t on_queries; /*< Types of queries to inspect */ qc_query_op_t on_queries; /*< Types of queries to inspect */
bool allow; /*< Allow or deny the query if this rule matches */ bool allow; /*< Allow or deny the query if this rule matches */
int times_matched; /*< Number of times this rule has been matched */ int times_matched; /*< Number of times this rule has been matched */
TIMERANGE* active; /*< List of times when this rule is active */ TIMERANGE* active; /*< List of times when this rule is active */
@ -1595,7 +1595,7 @@ bool rule_matches(FW_INSTANCE* my_instance,
unsigned char* memptr = (unsigned char*) queue->start; unsigned char* memptr = (unsigned char*) queue->start;
bool is_sql, is_real, matches; bool is_sql, is_real, matches;
skygw_query_op_t optype = QUERY_OP_UNDEFINED; qc_query_op_t optype = QUERY_OP_UNDEFINED;
STRLINK* strln = NULL; STRLINK* strln = NULL;
QUERYSPEED* queryspeed = NULL; QUERYSPEED* queryspeed = NULL;
QUERYSPEED* rule_qs = NULL; QUERYSPEED* rule_qs = NULL;

View File

@ -103,26 +103,26 @@ static backend_ref_t* get_bref_from_dcb(ROUTER_CLIENT_SES* rses, DCB* dcb);
static DCB* rses_get_client_dcb(ROUTER_CLIENT_SES* rses); static DCB* rses_get_client_dcb(ROUTER_CLIENT_SES* rses);
static route_target_t get_route_target ( static route_target_t get_route_target (
skygw_query_type_t qtype, qc_query_type_t qtype,
bool trx_active, bool trx_active,
bool load_active, bool load_active,
target_t use_sql_variables_in, target_t use_sql_variables_in,
HINT* hint); HINT* hint);
static backend_ref_t* check_candidate_bref( static backend_ref_t* check_candidate_bref(
backend_ref_t* candidate_bref, backend_ref_t* candidate_bref,
backend_ref_t* new_bref, backend_ref_t* new_bref,
select_criteria_t sc); select_criteria_t sc);
static skygw_query_type_t is_read_tmp_table( static qc_query_type_t is_read_tmp_table(
ROUTER_CLIENT_SES* router_cli_ses, ROUTER_CLIENT_SES* router_cli_ses,
GWBUF* querybuf, GWBUF* querybuf,
skygw_query_type_t type); qc_query_type_t type);
static void check_create_tmp_table( static void check_create_tmp_table(
ROUTER_CLIENT_SES* router_cli_ses, ROUTER_CLIENT_SES* router_cli_ses,
GWBUF* querybuf, GWBUF* querybuf,
skygw_query_type_t type); qc_query_type_t type);
static bool route_single_stmt( static bool route_single_stmt(
ROUTER_INSTANCE* inst, ROUTER_INSTANCE* inst,
@ -276,7 +276,7 @@ static bool route_session_write(
GWBUF* querybuf, GWBUF* querybuf,
ROUTER_INSTANCE* inst, ROUTER_INSTANCE* inst,
unsigned char packet_type, unsigned char packet_type,
skygw_query_type_t qtype); qc_query_type_t qtype);
static void refreshInstance( static void refreshInstance(
ROUTER_INSTANCE* router, ROUTER_INSTANCE* router,
@ -1370,11 +1370,11 @@ static backend_ref_t* check_candidate_bref(
* if the query would otherwise be routed to slave. * if the query would otherwise be routed to slave.
*/ */
static route_target_t get_route_target ( static route_target_t get_route_target (
skygw_query_type_t qtype, qc_query_type_t qtype,
bool trx_active, bool trx_active,
bool load_active, bool load_active,
target_t use_sql_variables_in, target_t use_sql_variables_in,
HINT* hint) HINT* hint)
{ {
route_target_t target = TARGET_UNDEFINED; route_target_t target = TARGET_UNDEFINED;
/** /**
@ -1559,7 +1559,7 @@ static route_target_t get_route_target (
void check_drop_tmp_table( void check_drop_tmp_table(
ROUTER_CLIENT_SES* router_cli_ses, ROUTER_CLIENT_SES* router_cli_ses,
GWBUF* querybuf, GWBUF* querybuf,
skygw_query_type_t type) qc_query_type_t type)
{ {
int tsize = 0, klen = 0,i; int tsize = 0, klen = 0,i;
@ -1644,10 +1644,10 @@ void check_drop_tmp_table(
* @param type The type of the query resolved so far * @param type The type of the query resolved so far
* @return The type of the query * @return The type of the query
*/ */
static skygw_query_type_t is_read_tmp_table( static qc_query_type_t is_read_tmp_table(
ROUTER_CLIENT_SES* router_cli_ses, ROUTER_CLIENT_SES* router_cli_ses,
GWBUF* querybuf, GWBUF* querybuf,
skygw_query_type_t type) qc_query_type_t type)
{ {
bool target_tmp_table = false; bool target_tmp_table = false;
@ -1657,9 +1657,9 @@ static skygw_query_type_t is_read_tmp_table(
char hkey[MYSQL_DATABASE_MAXLEN+MYSQL_TABLE_MAXLEN+2]; char hkey[MYSQL_DATABASE_MAXLEN+MYSQL_TABLE_MAXLEN+2];
MYSQL_session* data; MYSQL_session* data;
DCB* master_dcb = NULL; DCB* master_dcb = NULL;
skygw_query_type_t qtype = type; qc_query_type_t qtype = type;
rses_property_t* rses_prop_tmp; rses_property_t* rses_prop_tmp;
if(router_cli_ses == NULL || querybuf == NULL) if(router_cli_ses == NULL || querybuf == NULL)
{ {
@ -1752,7 +1752,7 @@ static skygw_query_type_t is_read_tmp_table(
static void check_create_tmp_table( static void check_create_tmp_table(
ROUTER_CLIENT_SES* router_cli_ses, ROUTER_CLIENT_SES* router_cli_ses,
GWBUF* querybuf, GWBUF* querybuf,
skygw_query_type_t type) qc_query_type_t type)
{ {
if (!QUERY_IS_TYPE(type, QUERY_TYPE_CREATE_TMP_TABLE)) if (!QUERY_IS_TYPE(type, QUERY_TYPE_CREATE_TMP_TABLE))
{ {
@ -2075,7 +2075,7 @@ static bool route_single_stmt(
ROUTER_CLIENT_SES* rses, ROUTER_CLIENT_SES* rses,
GWBUF* querybuf) GWBUF* querybuf)
{ {
skygw_query_type_t qtype = QUERY_TYPE_UNKNOWN; qc_query_type_t qtype = QUERY_TYPE_UNKNOWN;
mysql_server_cmd_t packet_type = MYSQL_COM_UNDEFINED; mysql_server_cmd_t packet_type = MYSQL_COM_UNDEFINED;
uint8_t* packet; uint8_t* packet;
size_t packet_len; size_t packet_len;
@ -2195,7 +2195,7 @@ static bool route_single_stmt(
*/ */
if (!rses->rses_load_active) if (!rses->rses_load_active)
{ {
skygw_query_op_t queryop = qc_get_operation(querybuf); qc_query_op_t queryop = qc_get_operation(querybuf);
if (queryop == QUERY_OP_LOAD) if (queryop == QUERY_OP_LOAD)
{ {
rses->rses_load_active = true; rses->rses_load_active = true;
@ -4341,7 +4341,7 @@ static bool route_session_write(
GWBUF* querybuf, GWBUF* querybuf,
ROUTER_INSTANCE* inst, ROUTER_INSTANCE* inst,
unsigned char packet_type, unsigned char packet_type,
skygw_query_type_t qtype) qc_query_type_t qtype)
{ {
bool succp; bool succp;
rses_property_t* prop; rses_property_t* prop;

View File

@ -95,9 +95,9 @@ static int router_get_servercount(ROUTER_INSTANCE* router);
static backend_ref_t* get_bref_from_dcb(ROUTER_CLIENT_SES* rses, DCB* dcb); static backend_ref_t* get_bref_from_dcb(ROUTER_CLIENT_SES* rses, DCB* dcb);
static route_target_t get_shard_route_target ( static route_target_t get_shard_route_target (
skygw_query_type_t qtype, qc_query_type_t qtype,
bool trx_active, bool trx_active,
HINT* hint); HINT* hint);
static int getCapabilities (); static int getCapabilities ();
@ -192,7 +192,7 @@ static bool route_session_write(
GWBUF* querybuf, GWBUF* querybuf,
ROUTER_INSTANCE* inst, ROUTER_INSTANCE* inst,
unsigned char packet_type, unsigned char packet_type,
skygw_query_type_t qtype); qc_query_type_t qtype);
static void bref_clear_state(backend_ref_t* bref, bref_state_t state); static void bref_clear_state(backend_ref_t* bref, bref_state_t state);
static void bref_set_state(backend_ref_t* bref, bref_state_t state); static void bref_set_state(backend_ref_t* bref, bref_state_t state);
@ -515,7 +515,7 @@ int gen_databaselist(ROUTER_INSTANCE* inst, ROUTER_CLIENT_SES* session)
* @param buffer Query to inspect * @param buffer Query to inspect
* @return Name of the backend or NULL if the query contains no known databases. * @return Name of the backend or NULL if the query contains no known databases.
*/ */
char* get_shard_target_name(ROUTER_INSTANCE* router, ROUTER_CLIENT_SES* client, GWBUF* buffer,skygw_query_type_t qtype) char* get_shard_target_name(ROUTER_INSTANCE* router, ROUTER_CLIENT_SES* client, GWBUF* buffer,qc_query_type_t qtype)
{ {
int sz = 0,i,j; int sz = 0,i,j;
char** dbnms = NULL; char** dbnms = NULL;
@ -1481,9 +1481,9 @@ return_succp:
* if the query would otherwise be routed to slave. * if the query would otherwise be routed to slave.
*/ */
static route_target_t get_shard_route_target ( static route_target_t get_shard_route_target (
skygw_query_type_t qtype, qc_query_type_t qtype,
bool trx_active, /*< !!! turha ? */ bool trx_active, /*< !!! turha ? */
HINT* hint) /*< !!! turha ? */ HINT* hint) /*< !!! turha ? */
{ {
route_target_t target = TARGET_UNDEFINED; route_target_t target = TARGET_UNDEFINED;
@ -1520,11 +1520,10 @@ static route_target_t get_shard_route_target (
* @param querybuf GWBUF containing the query * @param querybuf GWBUF containing the query
* @param type The type of the query resolved so far * @param type The type of the query resolved so far
*/ */
void check_drop_tmp_table( void check_drop_tmp_table(ROUTER* instance,
ROUTER* instance, void* router_session,
void* router_session, GWBUF* querybuf,
GWBUF* querybuf, qc_query_type_t type)
skygw_query_type_t type)
{ {
int tsize = 0, klen = 0,i; int tsize = 0, klen = 0,i;
@ -1575,11 +1574,10 @@ ROUTER* instance,
* @param type The type of the query resolved so far * @param type The type of the query resolved so far
* @return The type of the query * @return The type of the query
*/ */
skygw_query_type_t is_read_tmp_table( qc_query_type_t is_read_tmp_table(ROUTER* instance,
ROUTER* instance, void* router_session,
void* router_session, GWBUF* querybuf,
GWBUF* querybuf, qc_query_type_t type)
skygw_query_type_t type)
{ {
bool target_tmp_table = false; bool target_tmp_table = false;
@ -1588,7 +1586,7 @@ ROUTER* instance,
char *hkey,*dbname; char *hkey,*dbname;
ROUTER_CLIENT_SES* router_cli_ses = (ROUTER_CLIENT_SES *)router_session; ROUTER_CLIENT_SES* router_cli_ses = (ROUTER_CLIENT_SES *)router_session;
skygw_query_type_t qtype = type; qc_query_type_t qtype = type;
rses_property_t* rses_prop_tmp; rses_property_t* rses_prop_tmp;
rses_prop_tmp = router_cli_ses->rses_properties[RSES_PROP_TYPE_TMPTABLES]; rses_prop_tmp = router_cli_ses->rses_properties[RSES_PROP_TYPE_TMPTABLES];
@ -1654,11 +1652,10 @@ ROUTER* instance,
* @param querybuf GWBUF containing the query * @param querybuf GWBUF containing the query
* @param type The type of the query resolved so far * @param type The type of the query resolved so far
*/ */
void check_create_tmp_table( void check_create_tmp_table(ROUTER* instance,
ROUTER* instance, void* router_session,
void* router_session, GWBUF* querybuf,
GWBUF* querybuf, qc_query_type_t type)
skygw_query_type_t type)
{ {
int klen = 0; int klen = 0;
@ -1866,7 +1863,7 @@ static int routeQuery(
void* router_session, void* router_session,
GWBUF* qbuf) GWBUF* qbuf)
{ {
skygw_query_type_t qtype = QUERY_TYPE_UNKNOWN; qc_query_type_t qtype = QUERY_TYPE_UNKNOWN;
mysql_server_cmd_t packet_type; mysql_server_cmd_t packet_type;
uint8_t* packet; uint8_t* packet;
int i,ret = 0; int i,ret = 0;
@ -2066,7 +2063,7 @@ static int routeQuery(
* all of them. * all of them.
*/ */
skygw_query_op_t op = qc_get_operation(querybuf); qc_query_op_t op = qc_get_operation(querybuf);
if (packet_type == MYSQL_COM_INIT_DB || if (packet_type == MYSQL_COM_INIT_DB ||
op == QUERY_OP_CHANGE_DB) op == QUERY_OP_CHANGE_DB)
@ -3748,7 +3745,7 @@ static bool route_session_write(
GWBUF* querybuf, GWBUF* querybuf,
ROUTER_INSTANCE* inst, ROUTER_INSTANCE* inst,
unsigned char packet_type, unsigned char packet_type,
skygw_query_type_t qtype) qc_query_type_t qtype)
{ {
bool succp = false; bool succp = false;
rses_property_t* prop; rses_property_t* prop;

View File

@ -112,7 +112,7 @@ static int router_get_servercount(ROUTER_INSTANCE* router);
static route_target_t get_shard_route_target( static route_target_t get_shard_route_target(
skygw_query_type_t qtype, qc_query_type_t qtype,
bool trx_active, bool trx_active,
HINT* hint); HINT* hint);
@ -197,7 +197,7 @@ static bool route_session_write(
GWBUF* querybuf, GWBUF* querybuf,
ROUTER_INSTANCE* inst, ROUTER_INSTANCE* inst,
unsigned char packet_type, unsigned char packet_type,
skygw_query_type_t qtype); qc_query_type_t qtype);
static void refreshInstance( static void refreshInstance(
ROUTER_INSTANCE* router, ROUTER_INSTANCE* router,
@ -438,7 +438,7 @@ gen_subsvc_dblist(ROUTER_INSTANCE* inst, ROUTER_CLIENT_SES* session)
* @return Name of the backend or NULL if the query contains no known databases. * @return Name of the backend or NULL if the query contains no known databases.
*/ */
char* char*
get_shard_target_name(ROUTER_INSTANCE* router, ROUTER_CLIENT_SES* client, GWBUF* buffer, skygw_query_type_t qtype) get_shard_target_name(ROUTER_INSTANCE* router, ROUTER_CLIENT_SES* client, GWBUF* buffer, qc_query_type_t qtype)
{ {
HASHTABLE* ht = client->dbhash; HASHTABLE* ht = client->dbhash;
int sz = 0, i, j; int sz = 0, i, j;
@ -1275,7 +1275,7 @@ freeSession(
* if the query would otherwise be routed to slave. * if the query would otherwise be routed to slave.
*/ */
static route_target_t static route_target_t
get_shard_route_target(skygw_query_type_t qtype, get_shard_route_target(qc_query_type_t qtype,
bool trx_active, /*< !!! turha ? */ bool trx_active, /*< !!! turha ? */
HINT* hint) /*< !!! turha ? */ HINT* hint) /*< !!! turha ? */
{ {
@ -1483,7 +1483,7 @@ routeQuery(ROUTER* instance,
void* router_session, void* router_session,
GWBUF* querybuf) GWBUF* querybuf)
{ {
skygw_query_type_t qtype = QUERY_TYPE_UNKNOWN; qc_query_type_t qtype = QUERY_TYPE_UNKNOWN;
mysql_server_cmd_t packet_type; mysql_server_cmd_t packet_type;
uint8_t* packet; uint8_t* packet;
int i,ret = 1; int i,ret = 1;
@ -2524,7 +2524,7 @@ route_session_write(
GWBUF* querybuf, GWBUF* querybuf,
ROUTER_INSTANCE* inst, ROUTER_INSTANCE* inst,
unsigned char packet_type, unsigned char packet_type,
skygw_query_type_t qtype) qc_query_type_t qtype)
{ {
bool succp; bool succp;
rses_property_t* prop; rses_property_t* prop;