Changeset: 469d39f8f798 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=469d39f8f798 Added Files: sql/test/BugTracker-2015/Tests/apply_merge_distinct.Bug-3760.sql sql/test/BugTracker-2015/Tests/apply_merge_distinct.Bug-3760.stable.err sql/test/BugTracker-2015/Tests/apply_merge_distinct.Bug-3760.stable.out sql/test/BugTracker-2015/Tests/cardinality.Bug-3761.sql sql/test/BugTracker-2015/Tests/cardinality.Bug-3761.stable.err sql/test/BugTracker-2015/Tests/cardinality.Bug-3761.stable.out sql/test/BugTracker-2015/Tests/cast_on_groupby_col_crash.Bug-3769.sql sql/test/BugTracker-2015/Tests/cast_on_groupby_col_crash.Bug-3769.stable.err sql/test/BugTracker-2015/Tests/cast_on_groupby_col_crash.Bug-3769.stable.out sql/test/BugTracker-2015/Tests/sessions_crash.Bug-3759.sql sql/test/BugTracker-2015/Tests/sessions_crash.Bug-3759.stable.err sql/test/BugTracker-2015/Tests/sessions_crash.Bug-3759.stable.out sql/test/BugTracker-2015/Tests/set_default_role.Bug-3364.sql sql/test/BugTracker-2015/Tests/set_default_role.Bug-3364.stable.err sql/test/BugTracker-2015/Tests/set_default_role.Bug-3364.stable.out sql/test/BugTracker-2015/Tests/useless_casts.Bug-3756.sql sql/test/BugTracker-2015/Tests/useless_casts.Bug-3756.stable.err sql/test/BugTracker-2015/Tests/useless_casts.Bug-3756.stable.out sql/test/Users/Tests/grantPrivilegesNonDefaultRole.Bug-3365.SQL.py sql/test/Users/Tests/grantPrivilegesNonDefaultRole.Bug-3365.stable.err sql/test/Users/Tests/grantPrivilegesNonDefaultRole.Bug-3365.stable.out Modified Files: clients/mapiclient/eventparser.c clients/mapiclient/eventparser.h clients/mapiclient/tachograph.c clients/mapiclient/tomograph.c debian/changelog gdk/gdk_atoms.c gdk/gdk_bat.c gdk/gdk_bbp.c gdk/gdk_logger.c gdk/gdk_select.c monetdb5/mal/mal_interpreter.c monetdb5/mal/mal_parser.c monetdb5/mal/mal_profiler.c monetdb5/modules/mal/clients.c monetdb5/modules/mal/mal_io.c sql/include/sql_relation.h sql/server/rel_exp.c sql/server/rel_exp.h sql/server/rel_optimizer.c sql/server/rel_schema.c sql/server/rel_select.c sql/server/sql_privileges.c sql/test/BugDay_2005-11-09_2.9.3/Tests/grant_public.SF-1114580.stable.err sql/test/BugTracker-2009/Tests/count_bug.SF-2604583.stable.out.int128 sql/test/BugTracker-2012/Tests/scalar_subquery_with_alias.Bug-3093.stable.out sql/test/BugTracker-2015/Tests/All sql/test/BugTracker-2015/Tests/assertHead.Bug-3706.stable.out sql/test/Users/Tests/All sql/test/Users/Tests/dropManyUsers.Bug-3764.stable.err sql/test/Users/Tests/dropManyUsers.Bug-3764.stable.out sql/test/Users/Tests/grantAndRevokeUserLogedIN.Bug-3476.stable.err sql/test/Users/Tests/grantAndRevokeUserLogedIN.Bug-3476.stable.out sql/test/Users/Tests/grantMonetdb.SQL.py sql/test/Users/Tests/grantRevokeAndGrantAgain.Bug-3765.SQL.py sql/test/Users/Tests/grantRevokeAndGrantAgain.Bug-3765.stable.err sql/test/Users/Tests/grantRevokeAndGrantAgain.Bug-3765.stable.out sql/test/Users/Tests/test_privs2_p2.stable.err sql/test/remote/Tests/ssbm.SQL.py tools/mserver/mserver5.c Branch: embedded Log Message:
merge with default diffs (truncated from 5811 to 300 lines): diff --git a/clients/mapiclient/eventparser.c b/clients/mapiclient/eventparser.c --- a/clients/mapiclient/eventparser.c +++ b/clients/mapiclient/eventparser.c @@ -6,7 +6,7 @@ * Copyright 2008-2015 MonetDB B.V. */ -/* (c) M Kersten, S Manegold */ +/* (c) M Kersten */ #include "eventparser.h" @@ -50,29 +50,31 @@ clearArguments(void) } char * -stripQuotes(char *currentquery) -{ char *q, *c, *qry; - q = qry = (char *) malloc(strlen(currentquery) * 2); - if( q == NULL){ - fprintf(stderr,"Could not allocate query buffer of size "SZFMT"\n", strlen(currentquery) * 2); - exit(-1); - } - for (c= currentquery; *c; ){ - if ( strncmp(c,"\\\\t",3) == 0){ - *q++ = '\t'; - c+=3; - } else - if ( strncmp(c,"\\\\n",3) == 0){ - *q++ = '\n'; - c+=3; - } else if ( strncmp(c,"\\\"",2) == 0){ - *q++= '"'; - c+=2; - } else if ( strncmp(c,"\\\\",2) == 0){ - c+= 2; - } else *q++ = *c++; - } - *q =0; +stripQuotes(const char *currentquery) +{ + const char *c; + char *q, *qry; + q = qry = (char *) malloc(strlen(currentquery) * 2); + if( q == NULL){ + fprintf(stderr,"Could not allocate query buffer of size "SZFMT"\n", strlen(currentquery) * 2); + exit(-1); + } + for (c= currentquery; *c; ){ + if ( strncmp(c,"\\\\t",3) == 0){ + *q++ = '\t'; + c+=3; + } else + if ( strncmp(c,"\\\\n",3) == 0){ + *q++ = '\n'; + c+=3; + } else if ( strncmp(c,"\\\"",2) == 0){ + *q++= '"'; + c+=2; + } else if ( strncmp(c,"\\\\",2) == 0){ + c+= 2; + } else *q++ = *c++; + } + *q =0; return qry; } @@ -210,7 +212,7 @@ parseArguments(char *call, int m) int eventparser(char *row, EventRecord *ev) { - char *c, *cc, *v =0; + char *c, *cc, *v =0,*w; struct tm stm; malargc = 0; @@ -228,7 +230,7 @@ eventparser(char *row, EventRecord *ev) /* scan event record number */ c = row+1; - if (c == 0) + if (*c == 0) return -2; ev->eventnr = atoi(c + 1); @@ -250,6 +252,8 @@ eventparser(char *row, EventRecord *ev) ev->clkticks += usec; } c = strchr(c + 1, '"'); + if (c == NULL) + return -3; if (ev->clkticks < 0) { fprintf(stderr, "parser: read negative value "LLFMT" from\n'%s'\n", ev->clkticks, cc); } @@ -336,8 +340,8 @@ eventparser(char *row, EventRecord *ev) if (*c == 0) return -1; *c = 0; - ev->numa= strdup(numa); - if( ev->num == NULL){ + ev->numa = strdup(numa); + if( ev->numa == NULL){ fprintf(stderr,"Could not allocate numa memory\n"); exit(-1); } @@ -390,13 +394,6 @@ eventparser(char *row, EventRecord *ev) exit(-1); } c= ev->fcn; - if( ev->state == MDB_SYSTEM){ - monetdb_characteristics = strdup(ev->stmt); - if( ev->stmt == NULL){ - fprintf(stderr,"Could not allocate monetdb_characteristics memory\n"); - exit(-1); - } - } else if( *c != '[') { v=c; @@ -429,7 +426,25 @@ eventparser(char *row, EventRecord *ev) if( v) parseArguments(v+3,1); } - if (ev->stmt && (v=strstr(ev->stmt, ";\",\t"))) - *v = 0; + // remove some superflous elements + w = strrchr(ev->stmt, (int) ']'); + if(w && *w == ev->stmt[strlen(ev->stmt)-1]) + *w = 0; + w = strrchr(ev->stmt, (int) '\t'); + if(w && *w == ev->stmt[strlen(ev->stmt)-1]) + *w = 0; + w = strrchr(ev->stmt, (int) ','); + if(w && *w == ev->stmt[strlen(ev->stmt)-1]) + *w = 0; + w = strrchr(ev->stmt, (int) '"'); + if(w && *w == ev->stmt[strlen(ev->stmt)-1]) + *w = 0; + if( ev->state == MDB_SYSTEM){ + monetdb_characteristics = strdup(ev->stmt); + if( monetdb_characteristics == NULL){ + fprintf(stderr,"Could not allocate monetdb_characteristics memory\n"); + exit(-1); + } + } return 0; } diff --git a/clients/mapiclient/eventparser.h b/clients/mapiclient/eventparser.h --- a/clients/mapiclient/eventparser.h +++ b/clients/mapiclient/eventparser.h @@ -6,7 +6,7 @@ * Copyright 2008-2015 MonetDB B.V. */ -/* (c) M Kersten, S Manegold +/* (c) M Kersten * The easiest calling method is something like: * tomograph -d demo --atlast=10 * which connects to the demo database server and @@ -100,5 +100,5 @@ extern char *monetdb_characteristics; extern void clearArguments(void); extern void eventdump(void); extern int eventparser(char *row, EventRecord *ev); -extern char *stripQuotes(char *currentquery); +extern char *stripQuotes(const char *currentquery); #endif /*_EVENT_PARSER_*/ diff --git a/clients/mapiclient/tachograph.c b/clients/mapiclient/tachograph.c --- a/clients/mapiclient/tachograph.c +++ b/clients/mapiclient/tachograph.c @@ -486,7 +486,7 @@ showBar(int level, lng clk, char *stmt) } else if( duration && duration- clk > 0){ rendertime(duration - clk,0); - printf(" %c%s ETC ", (level == 100? '-':' '),stamp); + printf(" %s ETC ", stamp); stamplen= strlen(stamp)+3; } else if( duration && duration- clk < 0){ @@ -539,11 +539,23 @@ initFiles(void) static void progressBarInit(char *qry) { + char *s; fprintf(tachojson,"{ \"tachograph\":0.1,\n"); fprintf(tachojson," \"system\":%s,\n",monetdb_characteristics); fprintf(tachojson," \"qid\":\"%s\",\n",currentfunction?currentfunction:""); - fprintf(tachojson," \"tag\":\"%d\",\n",currenttag); - fprintf(tachojson," \"query\":\"%s\",\n",qry); + fprintf(tachojson," \"tag\":%d,\n",currenttag); + + fprintf(tachojson," \"query\":\""); + for(s = qry; *s; s++) + switch(*s){ + case '\n': fputs("\\n", tachojson); break; + case '\r': fputs("\\r", tachojson); break; + case '\t': fputs("\\t", tachojson); break; + case '\b': fputs("\\b", tachojson); break; + default: fputc((int) *s, tachojson); + } + fprintf(tachojson,"\",\n"); + fprintf(tachojson," \"started\": "LLFMT",\n",starttime); fprintf(tachojson," \"duration\":"LLFMT",\n",duration); fprintf(tachojson," \"instructions\":%d\n",malsize); @@ -555,8 +567,8 @@ static void update(EventRecord *ev) { int progress=0; - int i,j; - char *v; + int i,j,k; + char *v, *s; int uid = 0,qid = 0; char line[BUFSIZ]; char prereq[BUFSIZ]={0}; @@ -684,20 +696,36 @@ update(EventRecord *ev) fprintf(tachojson,"\"time\": "LLFMT",\n",ev->clkticks); fprintf(tachojson,"\"status\": \"start\",\n"); fprintf(tachojson,"\"estimate\": "LLFMT",\n",ev->ticks); - fprintf(tachojson,"\"stmt\": \"%s\",\n",ev->stmt); - fprintf(tachojson,"\"beautystmt\": \"%s\",\n",line); + + fprintf(tachojson," \"stmt\":\""); + for(s = ev->stmt; *s; s++) + switch(*s){ + case '\\': + if( *(s+1) == '\\' ) s++; + default: fputc((int) *s, tachojson); + } + fprintf(tachojson,"\",\n"); + + fprintf(tachojson," \"beautystmt\":\""); + for(s = line; *s; s++) + switch(*s){ + case '\\': + if( *(s+1) == '\\' ) s++; + default: fputc((int) *s, tachojson); + } + fprintf(tachojson,"\",\n"); + // collect all input producing PCs fprintf(tachojson,"\"prereq\":["); - for( i=0; i < malvartop; i++){ + for( k=0, i=0; i < malvartop; i++){ // remove duplicates for(j= ev->pc-1; j>=0;j --){ - //if(debug) - //fprintf(stderr,"locate %s in %s\n",malvariables[i], events[j].stmt); if(events[j].stmt && (v = strstr(events[j].stmt, malvariables[i])) && v < strstr(events[j].stmt,":=")){ - snprintf(number,BUFSIZ,"%d",j); + snprintf(number,BUFSIZ," %d ",j); + //avoid duplicate prerequisites if( strstr(prereq,number) == 0) - snprintf(prereq + strlen(prereq), BUFSIZ-1-strlen(prereq), "%s%d",(i?", ":""), j); - //fprintf(tachojson,"%s%d",(i?", ":""), j); + snprintf(prereq + strlen(prereq), BUFSIZ-1-strlen(prereq), "%s %d ",(k?", ":""), j); + k++; break; } } @@ -726,9 +754,25 @@ update(EventRecord *ev) fprintf(tachojson,"\"time\": "LLFMT",\n",ev->clkticks); fprintf(tachojson,"\"status\": \"done\",\n"); fprintf(tachojson,"\"ticks\": "LLFMT",\n",ev->ticks); - fprintf(tachojson,"\"stmt\": \"%s\",\n",ev->stmt); + fprintf(tachojson,"\"stmt\":\""); + for(s = ev->stmt; *s; s++) + switch(*s){ + case '\\': + if( *(s+1) == '\\' ) s++; + default: fputc((int) *s, tachojson); + } + fprintf(tachojson,"\",\n"); + renderCall(line,BUFSIZ, ev->stmt,1,1); - fprintf(tachojson,"\"beautystmt\": \"%s\"\n",line); + fprintf(tachojson,"\"beautystmt\":\""); + for(s = line; *s; s++) + switch(*s){ + case '\\': + if( *(s+1) == '\\' ) s++; + default: fputc((int) *s, tachojson); + } + fprintf(tachojson,"\"\n"); + fprintf(tachojson,"},\n"); fflush(tachojson); @@ -747,8 +791,6 @@ update(EventRecord *ev) fprintf(tachostmt,LLFMT"\t",ev->tmpspace); fprintf(tachostmt,LLFMT"\t",ev->inblock); fprintf(tachostmt,LLFMT"\t",ev->oublock); - fprintf(tachostmt,"%s\t",ev->stmt); - fprintf(tachostmt, "%s\n",line); free(ev->stmt); progress = (int)(pccount++ / (malsize/100.0)); diff --git a/clients/mapiclient/tomograph.c b/clients/mapiclient/tomograph.c --- a/clients/mapiclient/tomograph.c +++ b/clients/mapiclient/tomograph.c _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list