From aafc891c9a32bae32aac0af0a2dd8914d93111c7 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Fri, 5 Sep 2014 10:58:54 +0300 Subject: [PATCH] Fixed canonical query test and mqfilter.c bugs --- .../test/canonical_tests/canonizer.c | 38 ++++++++++++------- server/modules/filter/mqfilter.c | 11 ++++-- 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/query_classifier/test/canonical_tests/canonizer.c b/query_classifier/test/canonical_tests/canonizer.c index de2c0f755..b9b17222f 100644 --- a/query_classifier/test/canonical_tests/canonizer.c +++ b/query_classifier/test/canonical_tests/canonizer.c @@ -57,23 +57,32 @@ int main(int argc, char** argv) } read(fdin,buffer,fsz); - tok = strpbrk(buffer,"\n"); - lines = 1; - while((tok = strpbrk(tok + 1,"\n"))){ - lines++; - } - - qbuff = malloc(sizeof(GWBUF*)*lines); - - for(i = 0;i=bsz){ + GWBUF** tmp = calloc(bsz*2,sizeof(GWBUF*)); + if(!tmp){ + printf("Error: Failed to allocate memory."); + return 1; + } + + for(z=0;z 0){ qin = strdup(tok); psize = strlen(qin); @@ -84,7 +93,7 @@ int main(int argc, char** argv) *(qbuff[i]->sbuf->data + 4) = 0x03; memcpy(qbuff[i]->sbuf->data + 5,qin,psize); *(qbuff[i]->sbuf->data + 5 + psize) = 0x00; - tok = strtok(NULL,"\n"); + tok = strtok(NULL,"\n\0"); free(qin); i++; } @@ -92,7 +101,7 @@ int main(int argc, char** argv) fdout = open(argv[2],O_TRUNC|O_CREAT|O_WRONLY,S_IRWXU|S_IXGRP|S_IXOTH); - for(i = 0;itrgtype == TRG_ALL){ + skygw_log_write_flush(LOGFILE_TRACE,"Trigger is TRG_ALL"); + schema_ok = true; + src_ok = true; + obj_ok = true; + goto validate_triggers; + } if(my_instance->trgtype & TRG_SOURCE && my_instance->src_trg){ @@ -1131,9 +1139,6 @@ routeQuery(FILTER *instance, void *session, GWBUF *queue) obj_ok = true; } - if(my_instance->trgtype == TRG_ALL){ - skygw_log_write_flush(LOGFILE_TRACE,"Trigger is TRG_ALL"); - } validate_triggers: