Changeset: 87a67db276da for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=87a67db276da
Modified Files:
        clients/mapiclient/stethoscope.c
        configure.ag
        monetdb5/mal/mal_interpreter.c
        monetdb5/mal/mal_listing.c
        monetdb5/mal/mal_profiler.c
        monetdb5/mal/mal_scenario.c
        monetdb5/mal/mal_session.c
        monetdb5/modules/kernel/batmmath.c
        monetdb5/modules/kernel/mmath.c
        monetdb5/optimizer/opt_dataflow.c
        sql/common/sql_mem.c
        sql/include/sql_mem.h
        sql/server/rel_dump.c
        sql/server/rel_optimizer.c
        sql/server/rel_schema.c
        sql/server/rel_semantic.c
        tools/merovingian/daemon/Makefile.ag
Branch: default
Log Message:

Merge with Jul2017 branch.


diffs (truncated from 667 to 300 lines):

diff --git a/clients/mapiclient/stethoscope.c b/clients/mapiclient/stethoscope.c
--- a/clients/mapiclient/stethoscope.c
+++ b/clients/mapiclient/stethoscope.c
@@ -425,9 +425,9 @@ main(int argc, char **argv)
                                printf("%s", response);
                if(json) {
                        if(trace != NULL) {
-                               fprintf(trace, "%s", response);
+                               fprintf(trace, "%s", response + len);
                        } else {
-                               printf("%s", response);
+                               printf("%s", response + len);
                                fflush(stdout);
                        }
                }
diff --git a/configure.ag b/configure.ag
--- a/configure.ag
+++ b/configure.ag
@@ -738,8 +738,12 @@ AS_VAR_IF([enable_sanitizer], [no], [], 
                        AS_VAR_IF([enable_sanitizer], [yes],
                                [MCHECK_ADD_FLAG([-fsanitize=address])],
                                [MCHECK_ADD_FLAG([-fsanitize=$enable_sanitizer])
-                               AS_VAR_IF([enable_sanitizer], [thread],
+                                AS_VAR_IF([enable_sanitizer], [thread],
                                        [X_CFLAGS="$X_CFLAGS 
-DNO_ATOMIC_INSTRUCTIONS"])])
+                       AS_CASE([$X_CFLAGS],
+                               [*-fsanitize=*],
+                               [],
+                               [AC_MSG_ERROR([--enable-sanitizer not supported 
by this compiler])])
                        MCHECK_ADD_FLAG([-fno-omit-frame-pointer])],
                [AC_MSG_ERROR([--enable-sanitizer only supported with GCC])])])
 
diff --git a/monetdb5/mal/mal_interpreter.c b/monetdb5/mal/mal_interpreter.c
--- a/monetdb5/mal/mal_interpreter.c
+++ b/monetdb5/mal/mal_interpreter.c
@@ -592,7 +592,7 @@ str runMALsequence(Client cntxt, MalBlkP
                 * garbage collected are identified. In the post-execution
                 * phase they are removed.
                 */
-               for (i = 0; i < pci->retc; i++)
+               for (i = 0; i < pci->retc; i++) 
                        backup[i] = stk->stk[getArg(pci, i)];
 
                if (garbageControl(pci)) {
diff --git a/monetdb5/mal/mal_listing.c b/monetdb5/mal/mal_listing.c
--- a/monetdb5/mal/mal_listing.c
+++ b/monetdb5/mal/mal_listing.c
@@ -412,8 +412,9 @@ shortRenderingTerm(MalBlkPtr mb, MalStkP
        ValRecord *val;
        char *cv =0;
        int varid = getArg(p,idx);
+       size_t len = BUFSIZ;
 
-       s= GDKmalloc(BUFSIZ);
+       s= GDKmalloc(len);
        if( s == NULL)
                return NULL;
        *s = 0;
@@ -421,7 +422,17 @@ shortRenderingTerm(MalBlkPtr mb, MalStkP
        if( isVarConstant(mb,varid) ){
                val =&getVarConstant(mb, varid);
                VALformat(&cv, val);
-               snprintf(s,BUFSIZ,"%s",cv);
+               if (strlen(cv) >= len) {
+                       char *nbuf;
+                       len = strlen(cv);
+                       nbuf = GDKrealloc(s, len + 1);
+                       if (nbuf == NULL) {
+                               GDKfree(s);
+                               return NULL;
+                       }
+                       s = nbuf;
+               }
+               snprintf(s,len + 1,"%s",cv);
        } else {
                val = &stk->stk[varid];
                VALformat(&cv, val);
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
@@ -280,7 +280,7 @@ renderProfilerEvent(MalBlkPtr mb, MalStk
 #else
                logadd("\"prereq\":%s]%s", prereq, prettify);
 #endif
-               
+
 /* EXAMPLE MAL statement argument decomposition
  * The eventparser may assume this layout for ease of parsing
 {
@@ -306,14 +306,14 @@ This information can be used to determin
 
                                if( j == pci->retc ){
                                        logadd("],%s\"arg\":[",prettify);
-                               } 
+                               }
                                logadd("{");
                                logadd("\"index\":\"%d\",%s", j,pret);
                                logadd("\"name\":\"%s\",%s", getVarName(mb, 
getArg(pci,j)), pret);
                                if( getVarSTC(mb,getArg(pci,j))){
                                        InstrPtr stc = getInstrPtr(mb, 
getVarSTC(mb,getArg(pci,j)));
                                        if(stc && 
strcmp(getModuleId(stc),"sql") ==0  && strncmp(getFunctionId(stc),"bind",4)==0)
-                                               
logadd("\"alias\":\"%s.%s.%s\",%s", 
+                                               
logadd("\"alias\":\"%s.%s.%s\",%s",
                                                        getVarConstant(mb, 
getArg(stc,stc->retc +1)).val.sval,
                                                        getVarConstant(mb, 
getArg(stc,stc->retc +2)).val.sval,
                                                        getVarConstant(mb, 
getArg(stc,stc->retc +3)).val.sval, pret);
@@ -335,16 +335,16 @@ This information can be used to determin
                                                } else
                                                        
logadd("\"kind\":\"%s\",%s", ( d->batPersistence == PERSISTENT ? 
"persistent":"transient"), pret);
                                                total += cnt * d->twidth;
-                                               total += heapinfo(d->tvheap, 
d->batCacheid); 
-                                               total += hashinfo(d->thash, 
d->batCacheid); 
+                                               total += heapinfo(d->tvheap, 
d->batCacheid);
+                                               total += hashinfo(d->thash, 
d->batCacheid);
                                                total += IMPSimprintsize(d);
                                                BBPunfix(d->batCacheid);
-                                       } 
+                                       }
                                        logadd("\"bid\":\"%d\",%s", bid,pret);
                                        
logadd("\"count\":\""BUNFMT"\",%s",cnt,pret);
                                        logadd("\"size\":" LLFMT",%s", 
total,pret);
                                } else{
-                                       char *truncated;
+                                       char *truncated = NULL;
                                        tname = getTypeName(tpe);
                                        logadd("\"type\":\"%s\",%s", 
tname,pret);
                                        cv = 0;
@@ -355,7 +355,11 @@ This information can be used to determin
                                                GDKfree(stmtq);
                                                stmtq = truncated;
                                        }
-                                       logadd("\"value\":\"%s\",%s", 
stmtq,pret);
+                                       if (stmtq == NULL) {
+                                               
logadd("\"value\":\"(null)\",%s", pret);
+                                       } else {
+                                               logadd("\"value\":\"%s\",%s", 
stmtq, pret);
+                                       }
                                        GDKfree(cv);
                                        GDKfree(stmtq);
                                }
diff --git a/monetdb5/mal/mal_scenario.c b/monetdb5/mal/mal_scenario.c
--- a/monetdb5/mal/mal_scenario.c
+++ b/monetdb5/mal/mal_scenario.c
@@ -468,6 +468,7 @@ resetScenario(Client c)
        c->oldscenario = 0;
 }
 
+/*
 void
 exitScenario(Client c)
 {
@@ -480,6 +481,19 @@ exitScenario(Client c)
                (*scen->exitSystemCmd) (c);
        c->scenario = NULL;
 }
+*/
+
+void
+exitScenario(Client c)
+{
+       int i;
+       Scenario scen = scenarioRec;
+
+       for (i = 0; i < MAXSCEN && scen->name; i++, scen++) {
+               if (scen->exitSystemCmd)
+                       (*scen->exitSystemCmd)(c);
+       }
+}
 
 /*
  * The building blocks of scenarios are routines obeying a strict
diff --git a/monetdb5/mal/mal_session.c b/monetdb5/mal/mal_session.c
--- a/monetdb5/mal/mal_session.c
+++ b/monetdb5/mal/mal_session.c
@@ -488,13 +488,8 @@ MSserveClient(void *dummy)
                assert(0);
        }
 
-       if (c->mode > FINISHCLIENT) {
-               if (isAdministrator(c) /* && moreClients(0)==0 */) {
-                       if (c->scenario) {
-                               exitScenario(c);
-                       }
-               }
-       }
+       if (c->mode == FINISHCLIENT && isAdministrator(c))
+               exitScenario(c);
        if (!isAdministrator(c))
                MCcloseClient(c);
        if (c->nspace && strcmp(c->nspace->name, "user") == 0) {
diff --git a/monetdb5/modules/kernel/batmmath.c 
b/monetdb5/modules/kernel/batmmath.c
--- a/monetdb5/modules/kernel/batmmath.c
+++ b/monetdb5/modules/kernel/batmmath.c
@@ -23,6 +23,9 @@
 #else
 #define feclearexcept(x)
 #define fetestexcept(x)                0
+#define FE_INVALID                     0
+#define FE_DIVBYZERO           0
+#define FE_OVERFLOW                    0
 #endif
 
 #define voidresultBAT(X1,X2)                                                   
                \
@@ -43,6 +46,8 @@ str CMDscience_bat_##TYPE##_##FUNC(bat *
 {                                                                              
                                                        \
        BAT *b, *bn;                                                            
                                        \
        TYPE *o, *p, *q;                                                        
                                        \
+       int e = 0, ex = 0;                                                      
                                        \
+                                                                               
                                                        \
        if ((b = BATdescriptor(*bid)) == NULL) {                                
                \
                throw(MAL, #TYPE, RUNTIME_OBJECT_MISSING);                      
                \
        }                                                                       
                                                        \
@@ -60,13 +65,20 @@ str CMDscience_bat_##TYPE##_##FUNC(bat *
                for (; p < q; o++, p++)                                         
                                \
                        *o = *p == TYPE##_nil ? TYPE##_nil : FUNC##SUFF(*p);    
\
        }                                                                       
                                                        \
-       if (errno != 0 ||                                                       
                                        \
-               fetestexcept(FE_INVALID | FE_DIVBYZERO |                        
                \
-                                        FE_OVERFLOW | FE_UNDERFLOW) != 0) {    
                \
-               int e = errno;                                                  
                                        \
+       if ((e = errno) != 0 ||                                                 
                                \
+               (ex = fetestexcept(FE_INVALID | FE_DIVBYZERO |                  
        \
+                                                  FE_OVERFLOW)) != 0) {        
                                \
+               const char *err;                                                
                                        \
                BBPunfix(bn->batCacheid);                                       
                                \
-               throw(MAL, "batmmath." #FUNC, "Math exception: %s",             
        \
-                         strerror(e));                                         
                                        \
+               if (e) {                                                        
                                                \
+                       err = strerror(e);                                      
                                        \
+               } else if (ex & FE_DIVBYZERO)                                   
                        \
+                       err = "Divide by zero";                                 
                                \
+               else if (ex & FE_OVERFLOW)                                      
                                \
+                       err = "Overflow";                                       
                                        \
+               else                                                            
                                                \
+                       err = "Invalid result";                                 
                                \
+               throw(MAL, "batmmath." #FUNC, "Math exception: %s", err);       
\
        }                                                                       
                                                        \
        BATsetcount(bn, BATcount(b));                                           
                        \
        bn->tsorted = 0;                                                        
                                        \
@@ -85,6 +97,7 @@ str CMDscience_bat_cst_##FUNC##_##TYPE(b
 {                                                                              
                                                                \
        BAT *b, *bn;                                                            
                                                \
        TYPE *o, *p, *q;                                                        
                                                \
+       int e = 0, ex = 0;                                                      
                                                \
                                                                                
                                                                \
        if ((b = BATdescriptor(*bid)) == NULL) {                                
                        \
                throw(MAL, #TYPE, RUNTIME_OBJECT_MISSING);                      
                        \
@@ -103,13 +116,20 @@ str CMDscience_bat_cst_##FUNC##_##TYPE(b
                for (; p < q; o++, p++)                                         
                                        \
                        *o = *p == TYPE##_nil ? TYPE##_nil : FUNC##SUFF(*p, 
*d);        \
        }                                                                       
                                                                \
-       if (errno != 0 ||                                                       
                                                \
-               fetestexcept(FE_INVALID | FE_DIVBYZERO |                        
                        \
-                                        FE_OVERFLOW | FE_UNDERFLOW) != 0) {    
                        \
-               int e = errno;                                                  
                                                \
+       if ((e = errno) != 0 ||                                                 
                                        \
+               (ex = fetestexcept(FE_INVALID | FE_DIVBYZERO |                  
                \
+                                                  FE_OVERFLOW)) != 0) {        
                                        \
+               const char *err;                                                
                                                \
                BBPunfix(bn->batCacheid);                                       
                                        \
-               throw(MAL, "batmmath." #FUNC, "Math exception: %s",             
                \
-                         strerror(e));                                         
                                                \
+               if (e) {                                                        
                                                        \
+                       err = strerror(e);                                      
                                                \
+               } else if (ex & FE_DIVBYZERO)                                   
                                \
+                       err = "Divide by zero";                                 
                                        \
+               else if (ex & FE_OVERFLOW)                                      
                                        \
+                       err = "Overflow";                                       
                                                \
+               else                                                            
                                                        \
+                       err = "Invalid result";                                 
                                        \
+               throw(MAL, "batmmath." #FUNC, "Math exception: %s", err);       
        \
        }                                                                       
                                                                \
        BATsetcount(bn, BATcount(b));                                           
                                \
        bn->tsorted = 0;                                                        
                                                \
@@ -127,6 +147,7 @@ str CMDscience_cst_bat_##FUNC##_##TYPE(b
 {                                                                              
                                                                \
        BAT *b, *bn;                                                            
                                                \
        TYPE *o, *p, *q;                                                        
                                                \
+       int e = 0, ex = 0;                                                      
                                                \
                                                                                
                                                                \
        if ((b = BATdescriptor(*bid)) == NULL) {                                
                        \
                throw(MAL, #TYPE, RUNTIME_OBJECT_MISSING);                      
                        \
@@ -145,13 +166,20 @@ str CMDscience_cst_bat_##FUNC##_##TYPE(b
                for (; p < q; o++, p++)                                         
                                        \
                        *o = *p == TYPE##_nil ? TYPE##_nil : FUNC##SUFF(*d, 
*p);        \
        }                                                                       
                                                                \
-       if (errno != 0 ||                                                       
                                                \
-               fetestexcept(FE_INVALID | FE_DIVBYZERO |                        
                        \
-                                        FE_OVERFLOW | FE_UNDERFLOW) != 0) {    
                        \
-               int e = errno;                                                  
                                                \
+       if ((e = errno) != 0 ||                                                 
                                        \
+               (ex = fetestexcept(FE_INVALID | FE_DIVBYZERO |                  
                \
+                                                  FE_OVERFLOW)) != 0) {        
                                        \
+               const char *err;                                                
                                                \
                BBPunfix(bn->batCacheid);                                       
                                        \
-               throw(MAL, "batmmath." #FUNC, "Math exception: %s",             
                \
-                         strerror(e));                                         
                                                \
+               if (e) {                                                        
                                                        \
+                       err = strerror(e);                                      
                                                \
+               } else if (ex & FE_DIVBYZERO)                                   
                                \
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to