Changeset: 91e672a02d3c for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=91e672a02d3c
Modified Files:
        gdk/gdk_atoms.c
        gdk/gdk_bbp.c
        gdk/gdk_storage.c
        monetdb5/mal/mal_atom.c
        monetdb5/modules/atoms/str.c
        monetdb5/modules/mal/manifold.c
        sql/benchmarks/tpch/LOCKED/Tests/01-22.stable.out
        sql/test/BugTracker-2017/Tests/All
Branch: default
Log Message:

Merge with Jul2017 branch.


diffs (truncated from 309 to 300 lines):

diff --git a/gdk/gdk_atoms.c b/gdk/gdk_atoms.c
--- a/gdk/gdk_atoms.c
+++ b/gdk/gdk_atoms.c
@@ -165,20 +165,25 @@ ATOMallocate(const char *id)
 {
        int t;
 
+       if (strlen(id) >= IDLENGTH) {
+               GDKerror("ATOMallocate: name too long");
+               return int_nil;
+       }
+
        MT_lock_set(&GDKthreadLock);
        t = ATOMindex(id);
-
        if (t < 0) {
                t = -t;
                if (t == GDKatomcnt) {
+                       if (GDKatomcnt == MAXATOMS) {
+                               MT_lock_unset(&GDKthreadLock);
+                               GDKerror("ATOMallocate: too many types");
+                               return int_nil;
+                       }
                        GDKatomcnt++;
                }
-               if (GDKatomcnt == MAXATOMS)
-                       GDKfatal("ATOMallocate: too many types");
-               if (strlen(id) >= IDLENGTH)
-                       GDKfatal("ATOMallocate: name too long");
                memset(BATatoms + t, 0, sizeof(atomDesc));
-               snprintf(BATatoms[t].name, sizeof(BATatoms[t].name), "%s", id);
+               strcpy(BATatoms[t].name, id);
                BATatoms[t].size = sizeof(int);         /* default */
                BATatoms[t].align = sizeof(int);        /* default */
                BATatoms[t].linear = 1;                 /* default */
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -284,7 +284,7 @@ BBPunlock(void)
 }
 
 
-static void
+static gdk_return
 BBPinithash(int j)
 {
        bat i = (bat) ATOMIC_GET(BBPsize, BBPsizeLock);
@@ -293,8 +293,10 @@ BBPinithash(int j)
        for (BBP_mask = 1; (BBP_mask << 1) <= BBPlimit; BBP_mask <<= 1)
                ;
        BBP_hash = (bat *) GDKzalloc(BBP_mask * sizeof(bat));
-       if (BBP_hash == NULL)
-               GDKfatal("BBPinithash: cannot allocate memory\n");
+       if (BBP_hash == NULL) {
+               GDKerror("BBPinithash: cannot allocate memory\n");
+               return GDK_FAIL;
+       }
        BBP_mask--;
 
        while (--i > 0) {
@@ -311,6 +313,7 @@ BBPinithash(int j)
                                j = 0;
                }
        }
+       return GDK_SUCCEED;
 }
 
 int
@@ -360,7 +363,8 @@ BBPextend(int idx, int buildhash)
                BBP_hash = NULL;
                for (i = 0; i <= BBP_THREADMASK; i++)
                        BBP_free(i) = 0;
-               BBPinithash(idx);
+               if (BBPinithash(idx) != GDK_SUCCEED)
+                       return GDK_FAIL;
        }
        return GDK_SUCCEED;
 }
@@ -1402,7 +1406,8 @@ BBPinit(void)
        BBPreadEntries(fp, bbpversion);
        fclose(fp);
 
-       BBPinithash(0);
+       if (BBPinithash(0) != GDK_SUCCEED)
+               GDKfatal("BBPinit: BBPinithash failed");
 
        /* will call BBPrecover if needed */
        if (BBPprepare(FALSE) != GDK_SUCCEED)
diff --git a/gdk/gdk_storage.c b/gdk/gdk_storage.c
--- a/gdk/gdk_storage.c
+++ b/gdk/gdk_storage.c
@@ -798,6 +798,7 @@ BATload_intern(bat bid, int lock)
        /* LOAD bun heap */
        if (b->ttype != TYPE_void) {
                if (HEAPload(&b->theap, nme, "tail", b->batRestricted == 
BAT_READ) != GDK_SUCCEED) {
+                       HEAPfree(&b->theap, 0);
                        return NULL;
                }
                assert(b->theap.size >> b->tshift <= BUN_MAX);
@@ -810,6 +811,7 @@ BATload_intern(bat bid, int lock)
        if (ATOMvarsized(b->ttype)) {
                if (HEAPload(b->tvheap, nme, "theap", b->batRestricted == 
BAT_READ) != GDK_SUCCEED) {
                        HEAPfree(&b->theap, 0);
+                       HEAPfree(b->tvheap, 0);
                        return NULL;
                }
                if (ATOMstorage(b->ttype) == TYPE_str) {
diff --git a/monetdb5/mal/mal_atom.c b/monetdb5/mal/mal_atom.c
--- a/monetdb5/mal/mal_atom.c
+++ b/monetdb5/mal/mal_atom.c
@@ -184,6 +184,10 @@ malAtomDefinition(stream *out, str name,
        if (strlen(name) >= sizeof(BATatoms[0].name))
                return -1;
        i = ATOMallocate(name);
+       if (i == int_nil) {
+               showException(out, TYPE, "atomDefinition", "Could not allocate 
atom '%s'", name);
+               return -1;
+       }
        /* overload atom ? */
        if (tpe) {
                BATatoms[i] = BATatoms[tpe];
diff --git a/monetdb5/modules/atoms/str.c b/monetdb5/modules/atoms/str.c
--- a/monetdb5/modules/atoms/str.c
+++ b/monetdb5/modules/atoms/str.c
@@ -2340,30 +2340,39 @@ STRSubstitute(str *res, const str *arg1,
        int repeat = *g;
        size_t lsrc = src ? strlen(src) : 0;
        size_t ldst = dst ? strlen(dst) : 0;
-       size_t l = s ? strLen(s) : 0;
-       size_t n = l + ldst;
-       str buf, fnd, end;
+       size_t l = strLen(s);
+       size_t n;
+       char *buf;
+       const char *pfnd;
+       char *fnd;
 
+       if (s == NULL || strcmp(s, str_nil) == 0) {
+               if ((*res = GDKstrdup(str_nil)) == NULL)
+                       throw(MAL, "str.substitute", MAL_MALLOC_FAIL);
+               return MAL_SUCCEED;
+       }
+
+       n = l + ldst;
        if (repeat && ldst > lsrc && lsrc) {
                n = (ldst * l) / lsrc;  /* max length */
        }
        buf = *res = GDKmalloc(n);
        if (*res == NULL)
                throw(MAL, "str.substitute", MAL_MALLOC_FAIL);
-       end = buf + l;
-       fnd = buf;
-       strcpy(buf, s ? s : "");
-       if (lsrc == 0)
-               return MAL_SUCCEED;
+
+       pfnd = s;
        do {
-               fnd = strstr(fnd < buf ? buf : fnd, src);
+               fnd = strstr(pfnd, src);
                if (fnd == NULL)
                        break;
-               memmove(fnd + ldst, fnd + lsrc, end - fnd);
-               memcpy(fnd, dst, ldst);
-               end += ldst - lsrc;
-               fnd += ldst;
+               n = fnd - pfnd;
+               strncpy(buf, pfnd, n);
+               buf += n;
+               strncpy(buf, dst, ldst);
+               buf += ldst;
+               pfnd = fnd + lsrc;
        } while (repeat);
+       strcpy(buf, pfnd);
        return MAL_SUCCEED;
 }
 
diff --git a/monetdb5/modules/mal/manifold.c b/monetdb5/modules/mal/manifold.c
--- a/monetdb5/modules/mal/manifold.c
+++ b/monetdb5/modules/mal/manifold.c
@@ -58,10 +58,11 @@ typedef struct{
 #define ManifoldLoop(Type, ...)                                                
                                        \
        do {                                                                    
                                                        \
                Type *v = (Type*) mut->args[0].first;                           
                        \
-               oid oo, olimit = mut->args[mut->fvar].cnt;                      
                        \
-               for( oo= 0; oo < olimit; oo++){                                 
                                \
+               for (;;) {                                                      
                                                        \
                        msg = (*mut->pci->fcn)(v, __VA_ARGS__);                 
                        \
                        if (msg) break;                                         
                                                \
+                       if (++oo == olimit)                                     
                                                \
+                               break;                                          
                                                        \
                        for( i = mut->fvar; i<= mut->lvar; i++) {               
                        \
                                if(ATOMstorage(mut->args[i].type) == TYPE_void 
){               \
                                        args[i] = (void*)  &mut->args[i].o;     
                                \
@@ -104,13 +105,14 @@ typedef struct{
                case TYPE_dbl: ManifoldLoop(dbl,__VA_ARGS__); break;            
        \
                case TYPE_str:                                                  
                                                \
                default: {                                                      
                                                        \
-                       oid oo, olimit = mut->args[mut->fvar].cnt;              
                        \
-                       for( oo= 0; oo < olimit; oo++){                         
                                \
+                       for (;;) {                                              
                                                        \
                                msg = (*mut->pci->fcn)(&y, __VA_ARGS__);        
                        \
                                if (msg)                                        
                                                        \
                                        break;                                  
                                                        \
                                bunfastapp(mut->args[0].b, (void*) y);          
                        \
                                GDKfree(y); y = NULL;                           
                                        \
+                               if (++oo == olimit)                             
                                                \
+                                       break;                                  
                                                        \
                                for( i = mut->fvar; i<= mut->lvar; i++) {       
                        \
                                        if(ATOMstorage(mut->args[i].type) == 
TYPE_void ){       \
                                                args[i] = (void*)  
&mut->args[i].o;                             \
@@ -143,6 +145,10 @@ MANIFOLDjob(MULTItask *mut)
 {      int i;
        char **args;
        str y = NULL, msg= MAL_SUCCEED;
+       oid oo = 0, olimit = mut->args[mut->fvar].cnt;
+
+       if (olimit == 0)
+               return msg;                             /* nothing to do */
 
        args = (char**) GDKzalloc(sizeof(char*) * mut->pci->argc);
        if( args == NULL)
diff --git a/sql/benchmarks/tpch/LOCKED/Tests/01-22.stable.out 
b/sql/benchmarks/tpch/LOCKED/Tests/01-22.stable.out
--- a/sql/benchmarks/tpch/LOCKED/Tests/01-22.stable.out
+++ b/sql/benchmarks/tpch/LOCKED/Tests/01-22.stable.out
@@ -701,31 +701,17 @@ Ready.
 % decimal # type
 % 20 # length
 [ 15.48654     ]
-#select * from optimizer_stats() stats;
-% .stats,      .stats # table_name
-% rewrite,     count # name
-% clob,        int # type
-% 7,   1 # length
-[ "joinidx",   0       ]
-
-# 11:48:06 >  
-# 11:48:06 >  Mtimeout -timeout 60 MapiClient -lsql -umonetdb -Pmonetdb 
--host=localhost --port=35781
-# 11:48:06 >  
 
 % sys.supplier,        sys.supplier,   sys.supplier,   sys.supplier,   
sys.revenue0 # table_name
 % s_suppkey,   s_name, s_address,      s_phone,        total_revenue # name
 % int, char,   varchar,        char,   decimal # type
 % 2,   25,     36,     15,     20 # length
 [ 21,  "Supplier#000000021",   "81CavellcrJ0PQ3CPBID0Z0JwyJm0ka5igEs", 
"12-253-590-5816",      1161099.4636    ]
-% .stats,      .stats # table_name
-% rewrite,     count # name
-% clob,        int # type
-% 7,   1 # length
-[ "joinidx",   0       ]
+#drop view revenue0;
 
-# 00:16:03 >  
-# 00:16:03 >  Mtimeout -timeout 60 mclient -lsql -ftest -i -e --host=alf 
--port=39190  < 
/net/alf.ins.cwi.nl/export/scratch1/niels/rc/MonetDB/sql/src/benchmarks/tpch/LOCKED/16.sql
-# 00:16:03 >  
+# 11:44:39 >  
+# 11:44:39 >  Mtimeout -timeout 60 mclient -lsql -ftest -Eutf-8 -i -e 
--host=/var/tmp/mtest-29401 --port=32058 < 
/net/madrid/export/scratch1/sjoerd/src/MonetDB/candidate/sql/benchmarks/tpch/LOCKED/../16.sql
+# 11:44:39 >  
 
 #select
 #      p_brand,
@@ -1159,30 +1145,16 @@ Ready.
 % decimal # type
 % 20 # length
 [ 22923.0280   ]
-% .stats,      .stats # table_name
-% rewrite,     count # name
-% clob,        int # type
-% 7,   1 # length
-[ "joinidx",   0       ]
-
-# 11:48:06 >  
-# 11:48:06 >  Mtimeout -timeout 60 MapiClient -lsql -umonetdb -Pmonetdb 
--host=localhost --port=35781
-# 11:48:06 >  
 
 % sys.supplier,        sys.supplier # table_name
 % s_name,      s_address # name
 % char,        varchar # type
 % 25,  30 # length
 [ "Supplier#000000013",        "HK71HQyWoqRWOX8GI FpgAifW,2PoH"        ]
-% .stats,      .stats # table_name
-% rewrite,     count # name
-% clob,        int # type
-% 7,   1 # length
-[ "joinidx",   0       ]
 
-# 11:48:06 >  
-# 11:48:06 >  Mtimeout -timeout 60 MapiClient -lsql -umonetdb -Pmonetdb 
--host=localhost --port=35781
-# 11:48:06 >  
+# 11:44:39 >  
+# 11:44:39 >  Mtimeout -timeout 60 mclient -lsql -ftest -Eutf-8 -i -e 
--host=/var/tmp/mtest-29401 --port=32058 < 
/net/madrid/export/scratch1/sjoerd/src/MonetDB/candidate/sql/benchmarks/tpch/LOCKED/../21.sql
+# 11:44:39 >  
 
 #select
 #      s_name,
diff --git a/sql/test/BugTracker-2017/Tests/All 
b/sql/test/BugTracker-2017/Tests/All
--- a/sql/test/BugTracker-2017/Tests/All
+++ b/sql/test/BugTracker-2017/Tests/All
@@ -24,8 +24,8 @@ dce_bug-6177
 crash_on_NULL_ptr.Bug-6130
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to