Format query classifier modules
Formatted query classifier modules with Astyle.
This commit is contained in:
@ -1297,7 +1297,7 @@ int32_t qc_mysql_get_table_names(GWBUF* querybuf, int32_t fullnames, char*** tab
|
||||
{
|
||||
if (i >= currtblsz)
|
||||
{
|
||||
tmp = (char**) malloc(sizeof (char*)*(currtblsz * 2 + 1));
|
||||
tmp = (char**) malloc(sizeof (char*) * (currtblsz * 2 + 1));
|
||||
|
||||
if (tmp)
|
||||
{
|
||||
@ -1616,7 +1616,7 @@ int32_t qc_mysql_get_database_names(GWBUF* querybuf, char*** databasesp, int* si
|
||||
if (i >= currsz)
|
||||
{
|
||||
tmp = (char**) realloc(databases,
|
||||
sizeof (char*)*(currsz * 2 + 1));
|
||||
sizeof (char*) * (currsz * 2 + 1));
|
||||
|
||||
if (tmp == NULL)
|
||||
{
|
||||
@ -2609,7 +2609,8 @@ const int IDX_DATADIR = 2;
|
||||
const int IDX_LANGUAGE = 3;
|
||||
const int N_OPTIONS = (sizeof(server_options) / sizeof(server_options[0])) - 1;
|
||||
|
||||
const char* server_groups[] = {
|
||||
const char* server_groups[] =
|
||||
{
|
||||
"embedded",
|
||||
"server",
|
||||
"server",
|
||||
@ -2720,8 +2721,8 @@ void qc_mysql_thread_end(void)
|
||||
extern "C"
|
||||
{
|
||||
|
||||
MXS_MODULE* MXS_CREATE_MODULE()
|
||||
{
|
||||
MXS_MODULE* MXS_CREATE_MODULE()
|
||||
{
|
||||
static QUERY_CLASSIFIER qc =
|
||||
{
|
||||
qc_mysql_setup,
|
||||
@ -2762,6 +2763,6 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
};
|
||||
|
||||
return &info;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -49,8 +49,8 @@ int main(int argc, char** argv)
|
||||
qc_setup("qc_sqlite", NULL);
|
||||
qc_process_init();
|
||||
|
||||
infile = fopen(argv[1],"rb");
|
||||
outfile = fopen(argv[2],"wb");
|
||||
infile = fopen(argv[1], "rb");
|
||||
outfile = fopen(argv[2], "wb");
|
||||
|
||||
if (infile == NULL || outfile == NULL)
|
||||
{
|
||||
|
@ -12,7 +12,8 @@
|
||||
static char datadir[1024] = "";
|
||||
static char mysqldir[1024] = "";
|
||||
|
||||
static char* server_options[] = {
|
||||
static char* server_options[] =
|
||||
{
|
||||
"MariaDB Corporation MaxScale",
|
||||
"--datadir=",
|
||||
"--default-storage-engine=myisam",
|
||||
@ -21,7 +22,8 @@ static char* server_options[] = {
|
||||
|
||||
const int num_elements = (sizeof(server_options) / sizeof(char *)) - 1;
|
||||
|
||||
static char* server_groups[] = {
|
||||
static char* server_groups[] =
|
||||
{
|
||||
"embedded",
|
||||
"server",
|
||||
"server",
|
||||
@ -38,7 +40,8 @@ static void slcursor_add_case(
|
||||
|
||||
typedef struct query_test_st query_test_t;
|
||||
|
||||
struct query_test_st {
|
||||
struct query_test_st
|
||||
{
|
||||
skygw_chk_t qt_chk_top;
|
||||
const char* qt_query_str;
|
||||
skygw_query_type_t qt_query_type;
|
||||
@ -352,19 +355,24 @@ int main(int argc, char** argv)
|
||||
*/
|
||||
workingdir = getenv("PWD");
|
||||
|
||||
if (workingdir == NULL) {
|
||||
if (workingdir == NULL)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Failed to resolve the working directory, $PWD is not "
|
||||
"set.\n");
|
||||
ss_dassert(workingdir != NULL);
|
||||
} else if (access(workingdir, R_OK) != 0) {
|
||||
}
|
||||
else if (access(workingdir, R_OK) != 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"Failed to access the working directory due %d, %s\n",
|
||||
errno,
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
ss_dassert(false);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
char** so = server_options;
|
||||
snprintf(datadir, 1023, "%s/data", workingdir);
|
||||
mkdir(datadir, 0777);
|
||||
@ -372,7 +380,8 @@ int main(int argc, char** argv)
|
||||
|
||||
while (strncmp(*so++, "--datadir=", 10) != 0) ;
|
||||
|
||||
if (*so == NULL) {
|
||||
if (*so == NULL)
|
||||
{
|
||||
fprintf(stderr, "Failed to find datadir option.\n");
|
||||
ss_dassert(*so != NULL);
|
||||
}
|
||||
@ -383,7 +392,8 @@ int main(int argc, char** argv)
|
||||
}
|
||||
failp = mysql_library_init(num_elements, server_options, server_groups);
|
||||
|
||||
if (failp) {
|
||||
if (failp)
|
||||
{
|
||||
MYSQL* mysql = mysql_init(NULL);
|
||||
ss_dassert(mysql != NULL);
|
||||
fprintf(stderr,
|
||||
@ -402,7 +412,8 @@ int main(int argc, char** argv)
|
||||
*/
|
||||
succp = slcursor_move_to_begin(c);
|
||||
|
||||
while(succp) {
|
||||
while (succp)
|
||||
{
|
||||
qtest = slcursor_get_case(c);
|
||||
qtest->qt_result_type =
|
||||
skygw_query_classifier_get_type(qtest->qt_query_str, f,
|
||||
@ -416,17 +427,21 @@ int main(int argc, char** argv)
|
||||
succp = slcursor_move_to_begin(c);
|
||||
fprintf(stderr, "\nScanning through the results :\n\n");
|
||||
|
||||
while(succp) {
|
||||
while (succp)
|
||||
{
|
||||
qtest = slcursor_get_case(c);
|
||||
|
||||
if (!query_test_types_match(qtest)) {
|
||||
if (!query_test_types_match(qtest))
|
||||
{
|
||||
nfail += 1;
|
||||
ss_dfprintf(stderr,
|
||||
"* Failed: \"%s\" -> %s (Expected %s)\n",
|
||||
query_test_get_querystr(qtest),
|
||||
STRQTYPE(query_test_get_result_type(qtest)),
|
||||
STRQTYPE(query_test_get_query_type(qtest)));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
nsucc += 1;
|
||||
ss_dfprintf(stderr,
|
||||
"Succeed\t: \"%s\" -> %s\n",
|
||||
@ -438,7 +453,7 @@ int main(int argc, char** argv)
|
||||
fprintf(stderr,
|
||||
"------------------------------------------\n"
|
||||
"Tests in total %d, SUCCEED %d, FAILED %d\n",
|
||||
nsucc+nfail,
|
||||
nsucc + nfail,
|
||||
nsucc,
|
||||
nfail);
|
||||
|
||||
@ -449,7 +464,8 @@ int main(int argc, char** argv)
|
||||
succp = slcursor_move_to_begin(c);
|
||||
mysql = mysql_init(NULL);
|
||||
|
||||
if (mysql == NULL) {
|
||||
if (mysql == NULL)
|
||||
{
|
||||
fprintf(stderr, "mysql_init failed\n");
|
||||
ss_dassert(mysql != NULL);
|
||||
}
|
||||
@ -469,7 +485,8 @@ int main(int argc, char** argv)
|
||||
NULL,
|
||||
CLIENT_MULTI_STATEMENTS);
|
||||
|
||||
if (mysql == NULL) {
|
||||
if (mysql == NULL)
|
||||
{
|
||||
fprintf(stderr, "mysql_real_connect failed\n");
|
||||
ss_dassert(mysql != NULL);
|
||||
}
|
||||
@ -477,10 +494,12 @@ int main(int argc, char** argv)
|
||||
fprintf(stderr,
|
||||
"\nRe-execution of selected cases in Embedded server :\n\n");
|
||||
|
||||
while(succp) {
|
||||
while (succp)
|
||||
{
|
||||
qtest = slcursor_get_case(c);
|
||||
|
||||
if (query_test_exec_also_in_server(qtest)) {
|
||||
if (query_test_exec_also_in_server(qtest))
|
||||
{
|
||||
MYSQL_RES* results;
|
||||
MYSQL_ROW record;
|
||||
const char* query_str;
|
||||
@ -488,22 +507,28 @@ int main(int argc, char** argv)
|
||||
query_str = query_test_get_querystr(qtest);
|
||||
failp = mysql_query(mysql, query_str);
|
||||
|
||||
if (failp) {
|
||||
if (failp)
|
||||
{
|
||||
ss_dfprintf(stderr,
|
||||
"* Failed: \"%s\" -> %d : %s\n",
|
||||
query_str,
|
||||
mysql_errno(mysql),
|
||||
mysql_error(mysql));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
ss_dfprintf(stderr,
|
||||
"Succeed\t: \"%s\"\n",
|
||||
query_str);
|
||||
results = mysql_store_result(mysql);
|
||||
|
||||
if (results != NULL) {
|
||||
if (results != NULL)
|
||||
{
|
||||
|
||||
while((record = mysql_fetch_row(results))) {
|
||||
while(record != NULL && *record != NULL) {
|
||||
while ((record = mysql_fetch_row(results)))
|
||||
{
|
||||
while (record != NULL && *record != NULL)
|
||||
{
|
||||
ss_dfprintf(stderr, "%s ", *record);
|
||||
record++;
|
||||
}
|
||||
|
Reference in New Issue
Block a user