query_classifier.cc

resolve_query_type, traverse through the list of items of thd->free_list, identify functions and reason query type according to the function type. This phase can only increase the restrictiviness level of the query.

query_classifier.h
        Added new query type QUERY_TYPE_LOCAL_READ, for functions that can be executed in Maxscale. This type is the least restrict
ive query type. It is not used currently.

testmain.c
	Added a few test cases and fixed expected return values for query type tests.

readwritesplit.c
	polish

skygw_debug.h
	Added string macro for Item types.
This commit is contained in:
vraatikka
2013-10-25 11:55:45 +03:00
parent 241a0a6175
commit f32cfe8546
5 changed files with 240 additions and 30 deletions

View File

@ -28,8 +28,6 @@ static char* server_groups[] = {
NULL
};
static void slcursor_add_case(
slist_cursor_t* c,
void* data)
@ -132,6 +130,47 @@ int main(int argc, char** argv)
ss_dfprintf(stderr, ">> testmain\n");
c = slist_init();
/** Test some functions */
q = "SELECT MY_UDF('Hello')";
slcursor_add_case(
c,
query_test_init(q, QUERY_TYPE_WRITE, false, true));
/** This could be QUERY_TYPE_LOCAL_READ */
q = "SELECT repeat('a', 1024)";
slcursor_add_case(
c,
query_test_init(q, QUERY_TYPE_READ, false, true));
/** This could be QUERY_TYPE_LOCAL_READ */
q = "SELECT soundex('Hello')";
slcursor_add_case(
c,
query_test_init(q, QUERY_TYPE_READ, false, true));
q = "SELECT ssoundexx('Hello')";
slcursor_add_case(
c,
query_test_init(q, QUERY_TYPE_WRITE, false, true));
/** This could be QUERY_TYPE_LOCAL_READ */
q = "SELECT now()";
slcursor_add_case(
c,
query_test_init(q, QUERY_TYPE_READ, false, true));
/** This could be QUERY_TYPE_LOCAL_READ */
q = "SELECT rand()";
slcursor_add_case(
c,
query_test_init(q, QUERY_TYPE_READ, false, true));
q = "SELECT rand(234), MY_UDF('Hello'), soundex('Hello')";
slcursor_add_case(
c,
query_test_init(q, QUERY_TYPE_WRITE, false, true));
/** Read-only SELECTs */
q = "SELECT user from mysql.user";
slcursor_add_case(
@ -196,24 +235,8 @@ int main(int argc, char** argv)
"select * from table3";
slcursor_add_case(
c,
query_test_init(q, QUERY_TYPE_SESSION_WRITE, false, true));
/** Functions */
q = "SELECT NOW()";
slcursor_add_case(
c,
query_test_init(q, QUERY_TYPE_READ, false, false));
q = "SELECT SOUNDEX('Hello')";
slcursor_add_case(
c,
query_test_init(q, QUERY_TYPE_READ, false, false));
q = "SELECT MY_UDF('Hello')";
slcursor_add_case(
c,
query_test_init(q, QUERY_TYPE_READ, false, true));
query_test_init(q, QUERY_TYPE_READ, false, true));
/** RENAME TABLEs */
q = "RENAME TABLE T1 to T2";
slcursor_add_case(