Changeset: 389bfe0a3f59 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=389bfe0a3f59
Modified Files:
        clients/mapiclient/dotmonetdb.c
        clients/mapiclient/mclient.c
        common/stream/stream.c
        monetdb5/extras/rapi/rapi.c
        monetdb5/mal/mal_listing.c
        monetdb5/mal/mal_type.c
        monetdb5/modules/atoms/inet.c
        monetdb5/modules/atoms/json.c
        monetdb5/modules/kernel/algebra.c
        monetdb5/modules/mal/clients.c
        monetdb5/modules/mal/sysmon.c
        monetdb5/modules/mal/tablet.c
        sql/backends/monet5/generator/generator.c
        sql/backends/monet5/vaults/shp/shp.c
        sql/server/rel_optimizer.c
        sql/server/rel_psm.c
        sql/test/Dump/Tests/dump.stable.out
        sql/test/pg_regress/Tests/float8.stable.out
        sql/test/testdb-upgrade-chain/Tests/dump.stable.out.Windows
        sql/test/testdb-upgrade/Tests/dump.stable.out.Windows
        sql/test/testdb/Tests/testdb-dump.stable.out.Windows
Branch: Jul2017
Log Message:

Merge with Dec2016 branch.


diffs (truncated from 615 to 300 lines):

diff --git a/clients/mapiclient/dotmonetdb.c b/clients/mapiclient/dotmonetdb.c
--- a/clients/mapiclient/dotmonetdb.c
+++ b/clients/mapiclient/dotmonetdb.c
@@ -97,8 +97,7 @@ parse_dotmonetdb(char **user, char **pas
                        } else if (strcmp(buf, "language") == 0) {
                                /* make sure we don't set garbage */
                                if (strcmp(q, "sql") != 0 &&
-                                   strcmp(q, "mal") != 0 &&
-                                   strcmp(q, "jaql") != 0) {
+                                   strcmp(q, "mal") != 0) {
                                        fprintf(stderr, "%s:%d: unsupported "
                                                "language: %s\n",
                                                cfile, line, q);
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -1158,7 +1158,10 @@ TESTrenderer(MapiHdl hdl)
                                   strcmp(tp, "dbl") == 0) {
                                char buf[32];
                                int j;
-                               double v = strtod(s, NULL);
+                               double v;
+                               if (strcmp(s, "-0") == 0) /* normalize -0 */
+                                       s = "0";
+                               v = strtod(s, NULL);
                                for (j = 4; j < 11; j++) {
                                        snprintf(buf, sizeof(buf), "%.*g", j, 
v);
                                        if (v == strtod(buf, NULL))
@@ -1168,10 +1171,13 @@ TESTrenderer(MapiHdl hdl)
                        } else if (strcmp(tp, "real") == 0) {
                                char buf[32];
                                int j;
+                               float v;
+                               if (strcmp(s, "-0") == 0) /* normalize -0 */
+                                       s = "0";
 #ifdef HAVE_STRTOF
-                               float v = strtof(s, NULL);
+                               v = strtof(s, NULL);
 #else
-                               float v = (float) strtod(s, NULL);
+                               v = (float) strtod(s, NULL);
 #endif
                                for (j = 4; j < 6; j++) {
                                        snprintf(buf, sizeof(buf), "%.*g", j, 
v);
diff --git a/common/stream/stream.c b/common/stream/stream.c
--- a/common/stream/stream.c
+++ b/common/stream/stream.c
@@ -2971,7 +2971,11 @@ file_rastream(FILE *fp, const char *name
                        s->isutf8 = 1;
                        return s;
                }
-               file_fsetpos(s, pos);
+               if (file_fsetpos(s, pos) < 0) {
+                       /* unlikely: we couldn't seek the file back */
+                       destroy(s);
+                       return NULL;
+               }
        }
 #ifdef _MSC_VER
        if (_fileno(fp) == 0 && _isatty(0)) {
diff --git a/monetdb5/extras/rapi/rapi.c b/monetdb5/extras/rapi/rapi.c
--- a/monetdb5/extras/rapi/rapi.c
+++ b/monetdb5/extras/rapi/rapi.c
@@ -490,10 +490,12 @@ void* RAPIloopback(void *query) {
                        retlist = PROTECT(allocVector(VECSXP, ncols));
                        names = PROTECT(NEW_STRING(ncols));
                        for (i = 0; i < ncols; i++) {
-                               if (!(varvalue = 
bat_to_sexp(BATdescriptor(output->cols[i].b)))) {
+                               BAT *b = BATdescriptor(output->cols[i].b);
+                               if (b == NULL || !(varvalue = bat_to_sexp(b))) {
                                        UNPROTECT(i + 3);
                                        return ScalarString(RSTR("Conversion 
error"));
                                }
+                               BBPunfix(b->batCacheid);
                                SET_STRING_ELT(names, i, 
RSTR(output->cols[i].name));
                                SET_VECTOR_ELT(retlist, i, varvalue);
                        }
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
@@ -70,14 +70,20 @@ renderTerm(MalBlkPtr mb, MalStkPtr stk, 
                } else if( stk)
                        val = &stk->stk[varid];
 
-               VALformat(&cv, val);
-               if (len + strlen(cv) >= maxlen)
-                       buf= GDKrealloc(buf, maxlen =len + strlen(cv) + BUFSIZ);
-
-               if( buf == 0){
+               if (VALformat(&cv, val) <= 0) {
+                       GDKfree(buf);
                        GDKerror("renderTerm:Failed to allocate");
                        return NULL;
                }
+               if (len + strlen(cv) >= maxlen) {
+                       char *nbuf = GDKrealloc(buf, maxlen =len + strlen(cv) + 
BUFSIZ);
+                       if (nbuf == NULL) {
+                               GDKfree(buf);
+                               GDKerror("renderTerm:Failed to allocate");
+                               return NULL;
+                       }
+                       buf = nbuf;
+               }
 
                if( strcmp(cv,"nil") == 0){
                        strcat(buf+len,cv);
@@ -93,7 +99,7 @@ renderTerm(MalBlkPtr mb, MalStkPtr stk, 
                        }
                        strcat(buf+len,cv);
                        len += strlen(buf+len);
-                       if( cv) GDKfree(cv);
+                       GDKfree(cv);
 
                        if( closequote ){
                                strcat(buf+len,"\"");
@@ -116,6 +122,11 @@ renderTerm(MalBlkPtr mb, MalStkPtr stk, 
                strcat(buf + len,":");
                len++;
                tpe = getTypeName(getVarType(mb, varid));
+               if (tpe == NULL) {
+                       GDKfree(buf);
+                       GDKerror("renderTerm:Failed to allocate");
+                       return NULL;
+               }
                len += snprintf(buf+len,maxlen-len,"%s",tpe);
                GDKfree(tpe);
        }
diff --git a/monetdb5/mal/mal_type.c b/monetdb5/mal/mal_type.c
--- a/monetdb5/mal/mal_type.c
+++ b/monetdb5/mal/mal_type.c
@@ -34,30 +34,24 @@
 str
 getTypeName(malType tpe)
 {
-       char buf[PATHLENGTH], *s;
-       size_t l = PATHLENGTH;
+       char buf[PATHLENGTH];
        int k;
 
        if (tpe == TYPE_any)
                return GDKstrdup("any");
        if (isaBatType(tpe)) {
-               snprintf(buf, l, "bat[");
-               l -= strlen(buf);
-               s = buf + strlen(buf);
                k = getTypeIndex(tpe);
                if (k)
-                       snprintf(s, l, ":any%c%d]",TMPMARKER,  k);
+                       snprintf(buf, sizeof(buf), "bat[:any%c%d]",TMPMARKER,  
k);
                else if (getBatType(tpe) == TYPE_any)
-                       snprintf(s, l, ":any]");
+                       snprintf(buf, sizeof(buf), "bat[:any]");
                else
-                       snprintf(s, l, ":%s]", ATOMname(getBatType(tpe)));
+                       snprintf(buf, sizeof(buf), "bat[:%s]", 
ATOMname(getBatType(tpe)));
                return GDKstrdup(buf);
        }
        if (isAnyExpression(tpe)) {
-               strncpy(buf, "any", 4);
-               if (isAnyExpression(tpe))
-                       snprintf(buf + 3, PATHLENGTH - 3, "%c%d",
-                                       TMPMARKER, getTypeIndex(tpe));
+               snprintf(buf, sizeof(buf), "any%c%d",
+                                TMPMARKER, getTypeIndex(tpe));
                return GDKstrdup(buf);
        }
        return GDKstrdup(ATOMname(tpe));
diff --git a/monetdb5/modules/atoms/inet.c b/monetdb5/modules/atoms/inet.c
--- a/monetdb5/modules/atoms/inet.c
+++ b/monetdb5/modules/atoms/inet.c
@@ -122,7 +122,8 @@ INETfromString(const char *src, int *len
                *retval = GDKzalloc(sizeof(inet));
                if( *retval == NULL){
                        GDKerror("INETfromString "MAL_MALLOC_FAIL);
-                       goto error;
+                       *len = 0;
+                       return 0;
                }
        } else {
                memset(*retval, 0, sizeof(inet));
diff --git a/monetdb5/modules/atoms/json.c b/monetdb5/modules/atoms/json.c
--- a/monetdb5/modules/atoms/json.c
+++ b/monetdb5/modules/atoms/json.c
@@ -1771,8 +1771,7 @@ JSONrenderarray(Client cntxt, MalBlkPtr 
        cnt = BATcount(bl[pci->retc + 1]);
        result = GDKmalloc(lim = BUFSIZ);
        if( result == NULL) {
-               JSONfreeArgumentlist(bl, pci);
-               throw(MAL,"json.renderArray",MAL_MALLOC_FAIL);
+               goto memfail;
        }
        result[0] = '[';
        result[1] = 0;
@@ -1789,6 +1788,7 @@ JSONrenderarray(Client cntxt, MalBlkPtr 
                        lim = cnt * l <= lim ? cnt * l : lim + BUFSIZ;
                result2 = GDKrealloc(result, lim);
                if (result2 == NULL) {
+                       GDKfree(row);
                        goto memfail;
                }
                result = result2;
diff --git a/monetdb5/modules/kernel/algebra.c 
b/monetdb5/modules/kernel/algebra.c
--- a/monetdb5/modules/kernel/algebra.c
+++ b/monetdb5/modules/kernel/algebra.c
@@ -906,12 +906,7 @@ doALGfetch(ptr ret, BAT *b, BUN pos)
                *(ptr*) ret = _dst;
        } else {
                int _s = ATOMsize(ATOMtype(b->ttype));
-               if (ATOMvarsized(b->ttype)) {
-                       ret = GDKmalloc(_s);
-                       if( ret == NULL)
-                               throw(MAL,"doAlgFetch",MAL_MALLOC_FAIL);
-                       memcpy(*(ptr*) ret, BUNtvar(bi, pos), _s);
-               } else if (b->ttype == TYPE_void) {
+               if (b->ttype == TYPE_void) {
                        *(oid*) ret = b->tseqbase;
                        if (b->tseqbase != oid_nil)
                                *(oid*)ret += pos;
diff --git a/monetdb5/modules/mal/clients.c b/monetdb5/modules/mal/clients.c
--- a/monetdb5/modules/mal/clients.c
+++ b/monetdb5/modules/mal/clients.c
@@ -636,7 +636,7 @@ CLTsessions(Client cntxt, MalBlkPtr mb, 
        last = COLnew(0, TYPE_timestamp, 0, TRANSIENT);
        qtimeout = COLnew(0, TYPE_lng, 0, TRANSIENT);
        active = COLnew(0, TYPE_bit, 0, TRANSIENT);
-       if ( user == NULL || login == NULL || stimeout == NULL || qtimeout == 
NULL || active == NULL){
+       if ( user == NULL || login == NULL || stimeout == NULL || last == NULL 
|| qtimeout == NULL || active == NULL){
                if ( user) BBPunfix(user->batCacheid);
                if ( login) BBPunfix(login->batCacheid);
                if ( stimeout) BBPunfix(stimeout->batCacheid);
diff --git a/monetdb5/modules/mal/sysmon.c b/monetdb5/modules/mal/sysmon.c
--- a/monetdb5/modules/mal/sysmon.c
+++ b/monetdb5/modules/mal/sysmon.c
@@ -45,7 +45,7 @@ SYSMONqueue(Client cntxt, MalBlkPtr mb, 
        activity = COLnew(0, TYPE_str, 256, TRANSIENT);
        oids = COLnew(0, TYPE_oid, 256, TRANSIENT);
        query = COLnew(0, TYPE_str, 256, TRANSIENT);
-       if ( tag == NULL || query == NULL || started == NULL || estimate == 
NULL || progress == NULL || activity == NULL || oids == NULL){
+       if ( tag == NULL || user == NULL || query == NULL || started == NULL || 
estimate == NULL || progress == NULL || activity == NULL || oids == NULL){
                if (tag) BBPunfix(tag->batCacheid);
                if (user) BBPunfix(user->batCacheid);
                if (query) BBPunfix(query->batCacheid);
diff --git a/monetdb5/modules/mal/tablet.c b/monetdb5/modules/mal/tablet.c
--- a/monetdb5/modules/mal/tablet.c
+++ b/monetdb5/modules/mal/tablet.c
@@ -355,12 +355,12 @@ output_line(char **buf, int *len, char *
                                }
                                if (fill + l + f->seplen >= *len) {
                                        /* extend the buffer */
-                                       *buf = GDKrealloc(*buf, fill + l + 
f->seplen + BUFSIZ);
-                                       if( buf == NULL)
-                                               return -1;
+                                       char *nbuf;
+                                       nbuf = GDKrealloc(*buf, fill + l + 
f->seplen + BUFSIZ);
+                                       if( nbuf == NULL)
+                                               return -1; /* *buf freed by 
caller */
+                                       *buf = nbuf;
                                        *len = fill + l + f->seplen + BUFSIZ;
-                                       if (*buf == NULL)
-                                               return -1;
                                }
                                strncpy(*buf + fill, p, l);
                                fill += l;
@@ -397,12 +397,12 @@ output_line_dense(char **buf, int *len, 
                        }
                        if (fill + l + f->seplen >= *len) {
                                /* extend the buffer */
-                               *buf = GDKrealloc(*buf, fill + l + f->seplen + 
BUFSIZ);
-                               if( buf == NULL)
-                                       return 0;
+                               char *nbuf;
+                               nbuf = GDKrealloc(*buf, fill + l + f->seplen + 
BUFSIZ);
+                               if( nbuf == NULL)
+                                       return -1;      /* *buf freed by caller 
*/
+                               *buf = nbuf;
                                *len = fill + l + f->seplen + BUFSIZ;
-                               if (*buf == NULL)
-                                       return -1;
                        }
                        strncpy(*buf + fill, p, l);
                        fill += l;
@@ -722,7 +722,7 @@ tablet_error(READERtask *task, lng row, 
                        task->as->error = createException(MAL, "sql.copy_from", 
MAL_MALLOC_FAIL);
                        task->besteffort = 0;
                }
-               if (row != lng_nil)
+               if (row != lng_nil && task->rowerror)
                        task->rowerror[row]++;
 #ifdef _DEBUG_TABLET_
                mnstr_printf(GDKout, "#tablet_error: " LLFMT ",%d:%s:%s\n",
diff --git a/sql/backends/monet5/generator/generator.c 
b/sql/backends/monet5/generator/generator.c
--- a/sql/backends/monet5/generator/generator.c
+++ b/sql/backends/monet5/generator/generator.c
@@ -829,11 +829,11 @@ str VLTgenerator_projection(Client cntxt
                s = f<l? (TPE) 1: (TPE)-1;\
        else s = * getArgReference_##TPE(stk, p, 3); \
        incr = s > 0;\
-       v = (TPE*) Tloc(bl,0);\
+       v = (TPE*) Tloc(b,0);\
        if ( s == 0 || (f> l && s>0) || (f<l && s < 0))\
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to