Fixed canonical query test and mqfilter.c bugs

This commit is contained in:
Markus Makela 2014-09-05 10:58:54 +03:00
parent c41a1ffe05
commit aafc891c9a
2 changed files with 32 additions and 17 deletions

View File

@ -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<lines;i++){
qbuff[i] = NULL;
}
i = 0;
int bsz = 4,z=0;
qbuff = calloc(bsz,sizeof(GWBUF*));
tok = strtok(buffer,"\n");
while(tok){
if(i>=bsz){
GWBUF** tmp = calloc(bsz*2,sizeof(GWBUF*));
if(!tmp){
printf("Error: Failed to allocate memory.");
return 1;
}
for(z=0;z<bsz;z++){
tmp[z] = qbuff[z];
}
free(qbuff);
qbuff = tmp;
bsz *= 2;
}
if(strlen(tok) > 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;i<lines;i++){
for(i = 0;i<bsz;i++){
if(qbuff[i]){
parse_query(qbuff[i]);
tok = skygw_get_canonical(qbuff[i]);
@ -102,7 +111,8 @@ int main(int argc, char** argv)
}
}
free(qbuff);
free(buffer);
close(fdin);
close(fdout);

View File

@ -980,6 +980,14 @@ routeQuery(FILTER *instance, void *session, GWBUF *queue)
goto send_downstream;
}
}
if(my_instance->trgtype == 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: