Clean up bits and pieces, removed some unnecessary checks.

This commit is contained in:
VilhoRaatikka
2015-01-14 14:11:19 +02:00
parent df2297aa6c
commit b3824a1eaf
4 changed files with 31 additions and 27 deletions

View File

@ -1210,6 +1210,8 @@ bool is_drop_table_query(GWBUF* querybuf)
lex->sql_command == SQLCOM_DROP_TABLE); lex->sql_command == SQLCOM_DROP_TABLE);
} }
inline void add_str(char** buf, int* buflen, int* bufsize, char* str) inline void add_str(char** buf, int* buflen, int* bufsize, char* str)
{ {
int isize = strlen(str) + 1; int isize = strlen(str) + 1;
@ -1542,7 +1544,7 @@ static void parsing_info_set_plain_str(
* @return string representing the query type value * @return string representing the query type value
*/ */
char* skygw_get_qtype_str( char* skygw_get_qtype_str(
skygw_query_type_t qtype) skygw_query_type_t qtype)
{ {
int t1 = (int)qtype; int t1 = (int)qtype;
int t2 = 1; int t2 = 1;
@ -1554,29 +1556,31 @@ char* skygw_get_qtype_str(
* t1 is completely cleared. * t1 is completely cleared.
*/ */
while (t1 != 0) while (t1 != 0)
{
if (t1&t2)
{ {
if (t1&t2) t = (skygw_query_type_t)t2;
{
t = (skygw_query_type_t)t2;
if (qtype_str == NULL) if (qtype_str == NULL)
{ {
qtype_str = strdup(STRQTYPE(t)); qtype_str = strdup(STRQTYPE(t));
} }
else else
{ {
size_t len = strlen(STRQTYPE(t)); size_t len = strlen(STRQTYPE(t));
/** reallocate space for delimiter, new string and termination */ /** reallocate space for delimiter, new string and termination */
qtype_str = (char *)realloc(qtype_str, strlen(qtype_str)+1+len+1); qtype_str = (char *)realloc(qtype_str, strlen(qtype_str)+1+len+1);
snprintf(qtype_str+strlen(qtype_str), 1+len+1, "|%s", STRQTYPE(t)); snprintf(qtype_str+strlen(qtype_str), 1+len+1, "|%s", STRQTYPE(t));
} }
/** Remove found value from t1 */ /** Remove found value from t1 */
t1 &= ~t2; t1 &= ~t2;
}
t2 <<= 1;
} }
t2 <<= 1;
}
return qtype_str; return qtype_str;
} }
skygw_query_op_t query_classifier_get_operation(GWBUF* querybuf) skygw_query_op_t query_classifier_get_operation(GWBUF* querybuf)
{ {
LEX* lex = get_lex(querybuf); LEX* lex = get_lex(querybuf);

View File

@ -3611,7 +3611,7 @@ static GWBUF* sescmd_cursor_process_replies(
bref_clear_state(bref, BREF_WAITING_RESULT); bref_clear_state(bref, BREF_WAITING_RESULT);
} }
/** Response is in the buffer and it will be sent to client. */ /** Response is in the buffer and it will be sent to client. */
else if (replybuf != NULL) else
{ {
/** Mark the rest session commands as replied */ /** Mark the rest session commands as replied */
scmd->my_sescmd_is_replied = true; scmd->my_sescmd_is_replied = true;