Format query classifier modules

Formatted query classifier modules with Astyle.
This commit is contained in:
Markus Mäkelä
2017-01-17 13:51:57 +02:00
parent a48be9badf
commit 3d92263cb3
4 changed files with 519 additions and 493 deletions

View File

@ -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",

View File

@ -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",
@ -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++;
}