Changeset: e84d8d8dba20 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e84d8d8dba20 Modified Files: monetdb5/mal/mal_profiler.c sql/backends/monet5/sql_execute.c Branch: default Log Message:
Properly check for trace directory diffs (75 lines): diff --git a/monetdb5/mal/mal_profiler.c b/monetdb5/mal/mal_profiler.c --- a/monetdb5/mal/mal_profiler.c +++ b/monetdb5/mal/mal_profiler.c @@ -585,18 +585,21 @@ str startTrace(str path) { char buf[FILENAME_MAX]; + struct stat sb; if( path && eventstream == NULL){ // create a file to keep the events, unless we // already have a profiler stream MT_lock_set(&mal_profileLock ); if(eventstream == NULL && offlinestore ==0){ - snprintf(buf,FILENAME_MAX,"%s%c%s",GDKgetenv("gdk_dbname"), DIR_SEP, path); - if(mkdir(buf,0755) < 0) { - MT_lock_unset(&mal_profileLock ); - throw(MAL,"profiler.startTrace", SQLSTATE(42000) "Failed to create directory %s", buf); + snprintf(buf,FILENAME_MAX,"%s%c%s",GDKgetenv("gdk_dbpath"), DIR_SEP, path); + if (stat(buf, &sb) < 0) { //create directory only when it does not exist + if (mkdir(buf, 0755) < 0) { + MT_lock_unset(&mal_profileLock); + throw(MAL, "profiler.startTrace", SQLSTATE(42000) "Failed to create directory %s", buf); + } } - snprintf(buf,FILENAME_MAX,"%s%c%s%ctrace_%d",GDKgetenv("gdk_dbname"), DIR_SEP, path,DIR_SEP,tracecounter++ % MAXTRACEFILES); + snprintf(buf,FILENAME_MAX,"%s%c%s%ctrace_%d",GDKgetenv("gdk_dbpath"), DIR_SEP, path,DIR_SEP,tracecounter++ % MAXTRACEFILES); if((eventstream = open_wastream(buf)) == NULL) { MT_lock_unset(&mal_profileLock ); throw(MAL,"profiler.startTrace", SQLSTATE(HY001) MAL_MALLOC_FAIL); diff --git a/sql/backends/monet5/sql_execute.c b/sql/backends/monet5/sql_execute.c --- a/sql/backends/monet5/sql_execute.c +++ b/sql/backends/monet5/sql_execute.c @@ -67,14 +67,16 @@ * and creates a secondary result set upon termination * of the query. */ -static void +static str SQLsetTrace(Client cntxt, MalBlkPtr mb) { InstrPtr q, resultset; InstrPtr tbls, cols, types, clen, scale; + str msg = MAL_SUCCEED; int k; - startTrace("sql_traces"); + if((msg = startTrace("sql_traces")) != MAL_SUCCEED) + return msg; clearTrace(); for(k= mb->stop-1; k>0; k--) @@ -183,6 +185,8 @@ SQLsetTrace(Client cntxt, MalBlkPtr mb) pushInstruction(mb,resultset); pushEndInstruction(mb); chkTypes(cntxt->usermodule, mb, TRUE); + + return msg; } /* @@ -362,9 +366,10 @@ SQLrun(Client c, backend *be, mvc *m) msg = runMALDebugger(c, mb); } else { if( m->emod & mod_trace){ - SQLsetTrace(c,mb); - msg = runMAL(c, mb, 0, 0); - stopTrace(0); + if((msg = SQLsetTrace(c,mb)) == MAL_SUCCEED) { + msg = runMAL(c, mb, 0, 0); + stopTrace(0); + } } else { msg = runMAL(c, mb, 0, 0); } _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list