Changeset: 73ed25c8f7c0 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=73ed25c8f7c0
Modified Files:
        clients/Tests/MAL-signatures.stable.out
        clients/Tests/MAL-signatures.stable.out.int128
        clients/Tests/exports.stable.out
        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/blob.c
        monetdb5/modules/atoms/blob.h
        monetdb5/modules/atoms/inet.c
        monetdb5/modules/atoms/json.c
        monetdb5/modules/kernel/algebra.c
        monetdb5/modules/kernel/bat5.c
        monetdb5/modules/mal/clients.c
        monetdb5/modules/mal/sysmon.c
        monetdb5/modules/mal/tablet.c
        monetdb5/optimizer/opt_reorder.c
        sql/backends/monet5/generator/generator.c
        sql/backends/monet5/sql.c
        sql/backends/monet5/sql.mal
        sql/backends/monet5/sql_cast.c
        sql/backends/monet5/vaults/shp/shp.c
        sql/common/sql_types.c
        sql/server/rel_optimizer.c
        sql/server/rel_psm.c
        sql/server/rel_updates.c
        sql/storage/store.c
        
sql/test/BugTracker-2017/Tests/wrong_aggregation_count.Bug-6257.stable.out
        sql/test/Dump/Tests/dump.stable.out
        sql/test/Tests/systemfunctions.stable.out
        sql/test/Tests/systemfunctions.stable.out.int128
        sql/test/emptydb-upgrade-chain-hge/Tests/check.stable.out.int128
        sql/test/emptydb-upgrade-chain/Tests/check.stable.out
        sql/test/emptydb-upgrade-chain/Tests/check.stable.out.32bit
        sql/test/emptydb-upgrade-chain/Tests/check.stable.out.int128
        sql/test/emptydb-upgrade-hge/Tests/check.stable.out.int128
        sql/test/emptydb-upgrade/Tests/check.stable.out
        sql/test/emptydb-upgrade/Tests/check.stable.out.32bit
        sql/test/emptydb-upgrade/Tests/check.stable.out.int128
        sql/test/emptydb/Tests/check.stable.out
        sql/test/emptydb/Tests/check.stable.out.32bit
        sql/test/emptydb/Tests/check.stable.out.int128
        sql/test/leaks/Tests/check1.stable.out
        sql/test/leaks/Tests/check1.stable.out.int128
        sql/test/leaks/Tests/check2.stable.out
        sql/test/leaks/Tests/check2.stable.out.int128
        sql/test/leaks/Tests/check3.stable.out
        sql/test/leaks/Tests/check3.stable.out.int128
        sql/test/leaks/Tests/check4.stable.out
        sql/test/leaks/Tests/check4.stable.out.int128
        sql/test/leaks/Tests/check5.stable.out
        sql/test/leaks/Tests/check5.stable.out.int128
        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: default
Log Message:

Merge with Jul2017 branch.


diffs (truncated from 2725 to 300 lines):

diff --git a/clients/Tests/MAL-signatures.stable.out 
b/clients/Tests/MAL-signatures.stable.out
--- a/clients/Tests/MAL-signatures.stable.out
+++ b/clients/Tests/MAL-signatures.stable.out
@@ -8298,7 +8298,7 @@ Ready.
 [ "sql",       "bind_idxbat",  "pattern sql.bind_idxbat(mvc:int, schema:str, 
table:str, index:str, access:int, part_nr:int, nr_parts:int):bat[:any_1] ",     
  "mvc_bind_idxbat_wrap;",        "Bind the 'schema.table.index' BAT with 
access kind:\n\t0 - base table\n\t1 - inserts\n\t2 - updates"   ]
 [ "sql",       "clear_table",  "pattern sql.clear_table(sname:str, 
tname:str):lng ",   "mvc_clear_table_wrap;",        "Clear the table 
sname.tname."  ]
 [ "sql",       "commit",       "pattern sql.commit():void ",   "SQLcommit;",   
"Trigger the commit operation for a MAL block"  ]
-[ "sql",       "copy_from",    "pattern sql.copy_from(t:ptr, sep:str, 
rsep:str, ssep:str, ns:str, fname:str, nr:lng, offset:lng, locked:int, 
best:int):bat[:any]... ", "mvc_import_table_wrap;",       "Import a table from 
bstream s with the \n\tgiven tuple and seperators (sep/rsep)"      ]
+[ "sql",       "copy_from",    "pattern sql.copy_from(t:ptr, sep:str, 
rsep:str, ssep:str, ns:str, fname:str, nr:lng, offset:lng, locked:int, 
best:int, fwf:str):bat[:any]... ",        "mvc_import_table_wrap;",       
"Import a table from bstream s with the \n\tgiven tuple and seperators 
(sep/rsep)"      ]
 [ "sql",       "copy_rejects", "pattern sql.copy_rejects() (rowid:bat[:lng], 
fldid:bat[:int], msg:bat[:str], inp:bat[:str]) ", "COPYrejects;", ""      ]
 [ "sql",       "copy_rejects_clear",   "pattern sql.copy_rejects_clear():void 
",       "COPYrejects_clear;",   ""      ]
 [ "sql",       "create_func_upgrade_oct2014",  "pattern 
sql.create_func_upgrade_oct2014(sname:str, f:str):int ",       
"UPGcreate_func;",      "Create the function described by f, needed for the 
Oct2014 upgrade"    ]
diff --git a/clients/Tests/MAL-signatures.stable.out.int128 
b/clients/Tests/MAL-signatures.stable.out.int128
--- a/clients/Tests/MAL-signatures.stable.out.int128
+++ b/clients/Tests/MAL-signatures.stable.out.int128
@@ -10660,7 +10660,7 @@ Ready.
 [ "sql",       "bind_idxbat",  "pattern sql.bind_idxbat(mvc:int, schema:str, 
table:str, index:str, access:int, part_nr:int, nr_parts:int):bat[:any_1] ",     
  "mvc_bind_idxbat_wrap;",        "Bind the 'schema.table.index' BAT with 
access kind:\n\t0 - base table\n\t1 - inserts\n\t2 - updates"   ]
 [ "sql",       "clear_table",  "pattern sql.clear_table(sname:str, 
tname:str):lng ",   "mvc_clear_table_wrap;",        "Clear the table 
sname.tname."  ]
 [ "sql",       "commit",       "pattern sql.commit():void ",   "SQLcommit;",   
"Trigger the commit operation for a MAL block"  ]
-[ "sql",       "copy_from",    "pattern sql.copy_from(t:ptr, sep:str, 
rsep:str, ssep:str, ns:str, fname:str, nr:lng, offset:lng, locked:int, 
best:int):bat[:any]... ", "mvc_import_table_wrap;",       "Import a table from 
bstream s with the \n\tgiven tuple and seperators (sep/rsep)"      ]
+[ "sql",       "copy_from",    "pattern sql.copy_from(t:ptr, sep:str, 
rsep:str, ssep:str, ns:str, fname:str, nr:lng, offset:lng, locked:int, 
best:int, fwf:str):bat[:any]... ",        "mvc_import_table_wrap;",       
"Import a table from bstream s with the \n\tgiven tuple and seperators 
(sep/rsep)"      ]
 [ "sql",       "copy_rejects", "pattern sql.copy_rejects() (rowid:bat[:lng], 
fldid:bat[:int], msg:bat[:str], inp:bat[:str]) ", "COPYrejects;", ""      ]
 [ "sql",       "copy_rejects_clear",   "pattern sql.copy_rejects_clear():void 
",       "COPYrejects_clear;",   ""      ]
 [ "sql",       "create_func_upgrade_oct2014",  "pattern 
sql.create_func_upgrade_oct2014(sname:str, f:str):int ",       
"UPGcreate_func;",      "Create the function described by f, needed for the 
Oct2014 upgrade"    ]
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -1703,7 +1703,7 @@ str SERVERstop(void *ret);
 str SERVERsuspend(void *ret);
 str SERVERtrace(void *ret, int *mid, int *flag);
 int SQLBLOBfromstr(char *instr, int *l, blob **val);
-int SQLBLOBtostr(str *tostr, int *l, blob *pin);
+int SQLBLOBtostr(str *tostr, int *l, const blob *pin);
 BUN SQLload_file(Client cntxt, Tablet *as, bstream *b, stream *out, char 
*csep, char *rsep, char quote, lng skip, lng maxrow, int best);
 str STRBytes(int *res, const str *arg1);
 str STRConcat(str *res, const str *val1, const str *val2);
@@ -2515,8 +2515,6 @@ str sortRef;
 str sortReverseRef;
 str soundex_impl(str *res, str *Name);
 str sqlRef;
-int sqlblob_fromstr(char *instr, int *l, blob **val);
-int sqlblob_tostr(str *tostr, int *l, const blob *p);
 str sqlcatalogRef;
 str startProfiler(void);
 str startRef;
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/blob.c b/monetdb5/modules/atoms/blob.c
--- a/monetdb5/modules/atoms/blob.c
+++ b/monetdb5/modules/atoms/blob.c
@@ -46,8 +46,6 @@ mal_export var_t BLOBput(Heap *h, var_t 
 mal_export void BLOBdel(Heap *h, var_t *index);
 mal_export int BLOBlength(blob *p);
 mal_export void BLOBheap(Heap *heap, size_t capacity);
-mal_export int SQLBLOBfromstr(char *instr, int *l, blob **val);
-mal_export int SQLBLOBtostr(str *tostr, int *l, blob *pin);
 mal_export str BLOBtoblob(blob **retval, str *s);
 mal_export str BLOBfromblob(str *retval, blob **b);
 mal_export str BLOBfromidx(str *retval, blob **binp, int *index);
@@ -79,22 +77,39 @@ blobsize(size_t nitems)
        return (var_t) (offsetof(blob, data) + nitems);
 }
 
-static var_t
-blob_put(Heap *h, var_t *bun, blob *val)
-{
-       char *base = NULL;
+static blob nullval = {
+       ~(size_t) 0
+};
 
-       *bun = HEAP_malloc(h, blobsize(val->nitems));
-       base = h->base;
-       if (*bun) {
-               memcpy(&base[*bun], (char *) val, blobsize(val->nitems));
-               h->dirty = 1;
+static char hexit[] = "0123456789ABCDEF";
+
+static str
+fromblob_idx(str *retval, blob *b, int *idx)
+{
+       str s, p = b->data + *idx;
+       str r, q = b->data + b->nitems;
+
+       for (r = p; r < q; r++) {
+               if (*r == 0)
+                       break;
        }
-       return *bun;
+       *retval = s = (str) GDKmalloc(1 + r - p);
+       if( *retval == NULL)
+               throw(MAL, "blob.tostring", MAL_MALLOC_FAIL);
+       for (; p < r; p++, s++)
+               *s = *p;
+       *s = 0;
+       return MAL_SUCCEED;
 }
 
-static int
-blob_cmp(blob *l, blob *r)
+/*
+ * @- Wrapping section
+ * This section contains the wrappers to re-use the implementation
+ * section of the blob modules from MonetDB 4.3
+ * @-
+ */
+int
+BLOBcmp(blob *l, blob *r)
 {
        size_t len = l->nitems;
 
@@ -107,29 +122,29 @@ blob_cmp(blob *l, blob *r)
        return memcmp(l->data, r->data, len);
 }
 
-static void
-blob_del(Heap *h, var_t *idx)
+void
+BLOBdel(Heap *h, var_t *idx)
 {
        HEAP_free(h, *idx);
 }
 
-static BUN
-blob_hash(blob *b)
+BUN
+BLOBhash(blob *b)
 {
        return (BUN) b->nitems;
 }
 
-static blob *
-blob_null(void)
+blob *
+BLOBnull(void)
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to