Changeset: f688685972ab for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f688685972ab
Modified Files:
        clients/Tests/exports.stable.out
        gdk/gdk_atoms.c
        gdk/gdk_group.c
        monetdb5/extras/mal_optimizer_template/opt_sql_append.c
        monetdb5/mal/mal_listing.c
        monetdb5/mal/mal_profiler.c
        monetdb5/modules/kernel/algebra.c
        monetdb5/modules/kernel/algebra.h
        monetdb5/modules/kernel/algebra.mal
        monetdb5/optimizer/Tests/CMexample.stable.out
        monetdb5/optimizer/Tests/inlineCst.stable.out
        monetdb5/optimizer/Tests/inlineIfthen.stable.out
        monetdb5/optimizer/opt_coercion.c
        monetdb5/optimizer/opt_commonTerms.c
        monetdb5/optimizer/opt_costModel.c
        monetdb5/optimizer/opt_joinpath.c
        monetdb5/optimizer/opt_macro.c
        monetdb5/optimizer/opt_matpack.c
        monetdb5/optimizer/opt_mergetable.c
        monetdb5/optimizer/opt_multiplex.c
        monetdb5/optimizer/opt_prelude.c
        monetdb5/optimizer/opt_prelude.h
        monetdb5/optimizer/opt_support.c
        monetdb5/optimizer/opt_support.h
        monetdb5/optimizer/opt_wrapper.c
        monetdb5/tests/BugTracker/Tests/algebra_project.Bug-3045.mal
        monetdb5/tests/BugTracker/Tests/algebra_project.Bug-3045.stable.out
        sql/backends/monet5/sql_optimizer.c
        
sql/test/BugTracker-2010/Tests/group-by_ordered_column.Bug-2564.stable.out.32bit
        tools/merovingian/daemon/client.c
Branch: newstorage
Log Message:

merge with default


diffs (truncated from 1286 to 300 lines):

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
@@ -764,8 +764,6 @@ str ALGmaxany(ptr result, const bat *bid
 str ALGminany(ptr result, const bat *bid);
 str ALGouterjoin(bat *result, const bat *lid, const bat *rid);
 str ALGouterjoinestimate(bat *result, const bat *lid, const bat *rid, const 
lng *estimate);
-str ALGprojectNIL(bat *ret, const bat *bid);
-str ALGprojecthead(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
 str ALGprojecttail(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
 str ALGrangejoin(bat *result, const bat *lid, const bat *rlid, const bat 
*rhid, const bit *li, const bit *hi);
 str ALGrangejoin2(bat *l, bat *r, const bat *lid, const bat *rlid, const bat 
*rhid, const bit *li, const bit *hi);
diff --git a/gdk/gdk_atoms.c b/gdk/gdk_atoms.c
--- a/gdk/gdk_atoms.c
+++ b/gdk/gdk_atoms.c
@@ -583,56 +583,47 @@ numFromStr(const char *src, int *len, vo
        int sz = ATOMsize(tp);
 #ifdef HAVE_HGE
        hge base = 0;
-       hge maxdiv10 = 0;       /* max value / 10 */
+       const hge maxdiv10 = GDK_hge_max / 10;
 #else
        lng base = 0;
-       lng maxdiv10 = 0;       /* max value / 10 */
+       const lng maxdiv10 = LL_CONSTANT(922337203685477580); /*7*/
 #endif
-       int maxmod10 = 7;       /* max value % 10 */
-       int sign = 1;
+       const int maxmod10 = 7; /* max value % 10 */
+       int sign;
 
        atommem(void, sz);
        while (GDKisspace(*p))
                p++;
-       memcpy(*dst, ATOMnilptr(tp), sz);
-       if (p[0] == 'n' && p[1] == 'i' && p[2] == 'l') {
-               p += 3;
-               return (int) (p - src);
-       }
-       if (*p == '-') {
+       switch (*p) {
+       case 'n':
+               memcpy(*dst, ATOMnilptr(tp), sz);
+               if (p[1] == 'i' && p[2] == 'l') {
+                       p += 3;
+                       return (int) (p - src);
+               }
+               /* not a number */
+               return 0;
+       case '-':
                sign = -1;
                p++;
-       } else if (*p == '+') {
+               break;
+       case '+':
                p++;
+               /* fall through */
+       default:
+               sign = 1;
+               break;
        }
        if (!num10(*p)) {
                /* not a number */
+               memcpy(*dst, ATOMnilptr(tp), sz);
                return 0;
        }
-       switch (sz) {
-       case 1:
-               maxdiv10 = 12/*7*/;
-               break;
-       case 2:
-               maxdiv10 = 3276/*7*/;
-               break;
-       case 4:
-               maxdiv10 = 214748364/*7*/;
-               break;
-       case 8:
-               maxdiv10 = LL_CONSTANT(922337203685477580)/*7*/;
-               break;
-#ifdef HAVE_HGE
-       case 16:
-               maxdiv10 = GDK_hge_max / 10;
-               //         17014118346046923173168730371588410572/*7*/;
-               break;
-#endif
-       }
        do {
                if (base > maxdiv10 ||
                    (base == maxdiv10 && base10(*p) > maxmod10)) {
                        /* overflow */
+                       memcpy(*dst, ATOMnilptr(tp), sz);
                        return 0;
                }
                base = 10 * base + base10(*p);
@@ -642,21 +633,39 @@ numFromStr(const char *src, int *len, vo
        switch (sz) {
        case 1: {
                bte **dstbte = (bte **) dst;
+               if (base <= GDK_bte_min || base > GDK_bte_max) {
+                       **dstbte = bte_nil;
+                       return 0;
+               }
                **dstbte = (bte) base;
                break;
        }
        case 2: {
                sht **dstsht = (sht **) dst;
+               if (base <= GDK_sht_min || base > GDK_sht_max) {
+                       **dstsht = sht_nil;
+                       return 0;
+               }
                **dstsht = (sht) base;
                break;
        }
        case 4: {
                int **dstint = (int **) dst;
+               if (base <= GDK_int_min || base > GDK_int_max) {
+                       **dstint = int_nil;
+                       return 0;
+               }
                **dstint = (int) base;
                break;
        }
        case 8: {
                lng **dstlng = (lng **) dst;
+#ifdef HAVE_HGE
+               if (base <= GDK_lng_min || base > GDK_lng_max) {
+                       **dstlng = lng_nil;
+                       return 0;
+               }
+#endif
                **dstlng = (lng) base;
                if (p[0] == 'L' && p[1] == 'L')
                        p += 2;
diff --git a/gdk/gdk_group.c b/gdk/gdk_group.c
--- a/gdk/gdk_group.c
+++ b/gdk/gdk_group.c
@@ -551,6 +551,27 @@ BATgroup_internal(BAT **groups, BAT **ex
        /* figure out if we can use the storage type also for
         * comparing values */
        t = ATOMbasetype(b->ttype);
+       /* for strings we can use the offset instead of the actual
+        * string values if we know that the strings in the string
+        * heap are unique */
+       if (t == TYPE_str && GDK_ELIMDOUBLES(b->T->vheap)) {
+               switch (b->T->width) {
+               case 1:
+                       t = TYPE_bte;
+                       break;
+               case 2:
+                       t = TYPE_sht;
+                       break;
+#if SIZEOF_VAR_T == 8
+               case 4:
+                       t = TYPE_int;
+                       break;
+#endif
+               default:
+                       t = TYPE_var;
+                       break;
+               }
+       }
 
        if (((b->tsorted || b->trevsorted) &&
             (g == NULL || g->tsorted || g->trevsorted)) ||
@@ -682,7 +703,7 @@ BATgroup_internal(BAT **groups, BAT **ex
                }
 
                GDKfree(pgrp);
-       } else if (g == NULL && ATOMbasetype(b->ttype) == TYPE_bte) {
+       } else if (g == NULL && t == TYPE_bte) {
                /* byte-sized values, use 256 entry array to keep
                 * track of doled out group ids; note that we can't
                 * possibly have more than 256 groups, so the group id
@@ -708,7 +729,7 @@ BATgroup_internal(BAT **groups, BAT **ex
                                cnts[v]++;
                }
                GDKfree(bgrps);
-       } else if (g == NULL && ATOMbasetype(b->ttype) == TYPE_sht) {
+       } else if (g == NULL && t == TYPE_sht) {
                /* short-sized values, use 65536 entry array to keep
                 * track of doled out group ids; note that we can't
                 * possibly have more than 65536 groups, so the group
diff --git a/monetdb5/extras/mal_optimizer_template/opt_sql_append.c 
b/monetdb5/extras/mal_optimizer_template/opt_sql_append.c
--- a/monetdb5/extras/mal_optimizer_template/opt_sql_append.c
+++ b/monetdb5/extras/mal_optimizer_template/opt_sql_append.c
@@ -292,7 +292,7 @@ str OPTsql_append(Client cntxt, MalBlkPt
                return MAL_SUCCEED;
        }
        actions= OPTsql_appendImplementation(cntxt, mb,stk,p);
-       msg= optimizerCheck(cntxt, mb, "optimizer.sql_append", actions, 
t=(GDKusec() - clk),OPT_CHECK_ALL);
+       msg= optimizerCheck(cntxt, mb, "optimizer.sql_append", actions, 
t=(GDKusec() - clk));
        OPTDEBUGsql_append {
                mnstr_printf(cntxt->fdout,"=FINISHED sql_append %d\n",actions);
                printFunction(cntxt->fdout,mb,0,LIST_MAL_ALL );
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
@@ -119,7 +119,7 @@ renderTerm(MalBlkPtr mb, MalStkPtr stk, 
        }
 
        // show the properties when required 
-       if (flg & LIST_MAL_PROPS){
+       if ( (flg & LIST_MAL_PROPS) && (idx < p->retc || getInstrPtr(mb,0) == 
p)) {
                pstring = varGetPropStr(mb,varid);
                if( pstring)
                        snprintf(buf+len,maxlen-len,"%s",pstring);
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
@@ -231,7 +231,7 @@ offlineProfilerEvent(MalBlkPtr mb, MalSt
                // TODO Obfusate instructions unless administrator calls for it.
                
                /* generate actual call statement */
-               stmt = instruction2str(mb, stk, pci, LIST_MAL_CALL);
+               stmt = instruction2str(mb, stk, pci, LIST_MAL_ALL);
                c = stmt;
 
                while (c && *c && isspace((int)*c))
@@ -702,7 +702,7 @@ cachedProfilerEvent(MalBlkPtr mb, MalStk
        snprintf(ctm + 19, 6, ".%03d", (int)(clock.tv_usec / 1000));
 
        /* generate actual call statement */
-       stmt = instruction2str(mb, stk, pci, LIST_MAL_CALL);
+       stmt = instruction2str(mb, stk, pci, LIST_MAL_ALL);
        c = stmt;
 
        while (c && *c && (isspace((int)*c) || *c == '!'))
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
@@ -1792,55 +1792,6 @@ ALGfind(oid *ret, const bat *bid, ptr va
        return msg;
 }
 
-str
-ALGprojectNIL(bat *ret, const bat *bid)
-{
-    BAT *b, *bn;
-
-    if ((b = BATdescriptor(*bid)) == NULL) {
-        throw(MAL, "algebra.project", RUNTIME_OBJECT_MISSING);
-    }
-
-    bn = BATconst(b, TYPE_void, (ptr) &oid_nil, TRANSIENT);
-    if (bn) {
-        *ret = bn->batCacheid;
-        BBPkeepref(bn->batCacheid);
-               BBPunfix(b->batCacheid);
-        return MAL_SUCCEED;
-    }
-    BBPunfix(b->batCacheid);
-    throw(MAL, "algebra.project", MAL_MALLOC_FAIL);
-}
-
-/*
- * The constant versions are typed by the parser
- */
-str
-ALGprojecthead(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
-{
-       bat *ret = getArgReference_bat(stk, pci, 0);
-       const ValRecord *v = &stk->stk[getArg(pci, 1)];
-       bat bid = * getArgReference_bat(stk, pci, 2);
-       BAT *b, *bn;
-
-       (void) cntxt;
-       (void) mb;
-       if ((b = BATdescriptor(bid)) == NULL)
-               throw(MAL, "algebra.project", RUNTIME_OBJECT_MISSING);
-       b = BATmirror(b);
-       bn = BATconst(b, v->vtype, VALptr(v), TRANSIENT);
-       if (bn == NULL) {
-               *ret = bat_nil;
-               throw(MAL, "algebra.project", MAL_MALLOC_FAIL);
-       }
-       bn = BATmirror(bn);
-       if (!(bn->batDirty&2))
-               BATsetaccess(bn, BAT_READ);
-       *ret= bn->batCacheid;
-       BBPkeepref(bn->batCacheid);
-       BBPunfix(b->batCacheid);
-       return MAL_SUCCEED;
-}
 
 str
 ALGprojecttail(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
@@ -1852,6 +1803,8 @@ ALGprojecttail(Client cntxt, MalBlkPtr m
 
        (void) cntxt;
        (void) mb;
+       if( isaBatType(getArgType(mb,pci,2)) )
+               throw(MAL,"algebra.project","Scalar value expected");
        if ((b = BATdescriptor(bid)) == NULL)
                throw(MAL, "algebra.project", RUNTIME_OBJECT_MISSING);
        bn = BATconst(b, v->vtype, VALptr(v), TRANSIENT);
diff --git a/monetdb5/modules/kernel/algebra.h 
b/monetdb5/modules/kernel/algebra.h
--- a/monetdb5/modules/kernel/algebra.h
+++ b/monetdb5/modules/kernel/algebra.h
@@ -115,11 +115,7 @@ algebra_export str ALGsubslice_wrd(bat *
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to