Changeset: 5f7183a36aee for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5f7183a36aee
Modified Files:
        NT/monetdb_config.h.in
        gdk/gdk_calc.c
        gdk/gdk_group.c
        monetdb5/modules/atoms/batxml.c
        sql/backends/monet5/sql_scenario.c
        sql/server/rel_psm.c
        sql/storage/bat/bat_storage.c
        sql/storage/store.c
        testing/Mtest.py.in
        tools/merovingian/client/monetdb.1
Branch: default
Log Message:

Merge with Feb2013 branch.


diffs (truncated from 458 to 300 lines):

diff --git a/NT/monetdb_config.h.in b/NT/monetdb_config.h.in
--- a/NT/monetdb_config.h.in
+++ b/NT/monetdb_config.h.in
@@ -611,6 +611,11 @@
 /* Define to 1 if the system has the type `_Bool'. */
 #define HAVE__BOOL 1
 
+#ifdef _WIN64
+/* Define to 1 if you have the `_mul128' function. */
+#define HAVE__MUL128 1
+#endif
+
 /* Define if you have _sys_siglist */
 /* #undef HAVE__SYS_SIGLIST */
 
diff --git a/gdk/gdk_calc.c b/gdk/gdk_calc.c
--- a/gdk/gdk_calc.c
+++ b/gdk/gdk_calc.c
@@ -3384,6 +3384,48 @@ mul_##TYPE1##_##TYPE2##_##TYPE3(const TY
        return nils;                                                    \
 }
 
+#ifdef HAVE__MUL128
+#include <intrin.h>
+#pragma intrinsic(_mul128)
+
+#define MUL_2TYPE_lng(TYPE1, TYPE2)                                    \
+static BUN                                                             \
+mul_##TYPE1##_##TYPE2##_lng(const TYPE1 *lft, int incr1,               \
+                           const TYPE2 *rgt, int incr2,                \
+                           lng *dst, BUN cnt, BUN start,               \
+                           BUN end, const oid *cand,                   \
+                           const oid *candend, oid candoff,            \
+                           int abort_on_error)                         \
+{                                                                      \
+       BUN i, j, k;                                                    \
+       BUN nils = 0;                                                   \
+       lng clo, chi;                                                   \
+                                                                       \
+       CANDLOOP(dst, k, lng_nil, 0, start);                            \
+       for (i = start * incr1, j = start * incr2, k = start;           \
+            k < end; i += incr1, j += incr2, k++) {                    \
+               CHECKCAND(dst, k, candoff, lng_nil);                    \
+               if (lft[i] == TYPE1##_nil || rgt[j] == TYPE2##_nil) {   \
+                       dst[k] = lng_nil;                               \
+                       nils++;                                         \
+               } else {                                                \
+                       clo = _mul128((lng) lft[i],                     \
+                                     (lng) rgt[j], &chi);              \
+                       if ((chi == 0 && clo >= 0) ||                   \
+                           (chi == -1 && clo < 0 && clo != lng_nil)) { \
+                               dst[k] = clo;                           \
+                       } else {                                        \
+                               if (abort_on_error)                     \
+                                       ON_OVERFLOW(TYPE1, TYPE2, "*"); \
+                               dst[k] = lng_nil;                       \
+                               nils++;                                 \
+                       }                                               \
+               }                                                       \
+       }                                                               \
+       CANDLOOP(dst, k, lng_nil, end, cnt);                            \
+       return nils;                                                    \
+}
+#else
 #define MUL_2TYPE_lng(TYPE1, TYPE2)                                    \
 static BUN                                                             \
 mul_##TYPE1##_##TYPE2##_lng(const TYPE1 *lft, int incr1,               \
@@ -3413,6 +3455,7 @@ mul_##TYPE1##_##TYPE2##_lng(const TYPE1 
        CANDLOOP(dst, k, lng_nil, end, cnt);                            \
        return nils;                                                    \
 }
+#endif
 
 #define MUL_2TYPE_float(TYPE1, TYPE2, TYPE3)                           \
 static BUN                                                             \
diff --git a/gdk/gdk_group.c b/gdk/gdk_group.c
--- a/gdk/gdk_group.c
+++ b/gdk/gdk_group.c
@@ -484,7 +484,6 @@ BATgroup_internal(BAT **groups, BAT **ex
                                assert( HASHgetlink(hs,hb) == HASHnil(hs)
                                       || HASHgetlink(hs,hb) < hb);
                        }
-                               ;
                        if (gc) {
                                for (;
                                     hb != HASHnil(hs) && grps[hb - r] == 
grps[p - r];
diff --git a/monetdb5/modules/atoms/batxml.c b/monetdb5/modules/atoms/batxml.c
--- a/monetdb5/modules/atoms/batxml.c
+++ b/monetdb5/modules/atoms/batxml.c
@@ -1446,6 +1446,13 @@ BATxmlaggr(BAT **bnp, BAT *b, BAT *g, BA
                        }
                }
        }
+       if (g && BATtdense(g)) {
+               /* singleton groups: return group ID's (g's tail) and original
+                * values from b */
+               bn = VIEWcreate(BATmirror(g), b);
+               goto out;
+       }
+
        maxlen = BUFSIZ;
        if ((buf = GDKmalloc(maxlen)) == NULL) {
                err = MAL_MALLOC_FAIL;
diff --git a/sql/backends/monet5/sql_scenario.c 
b/sql/backends/monet5/sql_scenario.c
--- a/sql/backends/monet5/sql_scenario.c
+++ b/sql/backends/monet5/sql_scenario.c
@@ -580,6 +580,45 @@ sql_update_feb2013(Client c)
        return err;             /* usually MAL_SUCCEED */
 }
 
+
+static str
+sql_update_feb2013_sp1(Client c)
+{
+       size_t bufsize = 10240, pos = 0;
+       char *buf = GDKmalloc(bufsize), *err = NULL;
+       char *fullname;
+       FILE *fp = NULL;
+
+       snprintf(buf, bufsize, "createdb%c75_storagemodel", DIR_SEP);
+       if ((fullname = MSP_locate_sqlscript(buf, 1)) != NULL) {
+               fp = fopen(fullname, "r");
+               GDKfree(fullname);
+       }
+
+       /* sys.stddev functions */
+       pos += snprintf(buf+pos, bufsize-pos, "drop filter function 
sys.\"like\"(string, string, string);\n");
+       pos += snprintf(buf+pos, bufsize-pos, "drop filter function 
sys.\"ilike\"(string, string, string);\n");
+       pos += snprintf(buf+pos, bufsize-pos, "create filter function 
sys.\"like\"(val string, pat string, esc string) external name 
algebra.likesubselect;\n");
+       pos += snprintf(buf+pos, bufsize-pos, "create filter function 
sys.\"ilike\"(val string, pat string, esc string) external name 
algebra.ilikesubselect;\n");
+
+       pos += snprintf(buf+pos, bufsize-pos, "drop function sys.storage;\n");
+       if (fp) {
+               pos += fread(buf+pos, 1, bufsize-pos, fp);
+               fclose(fp);
+       }
+
+       pos += snprintf(buf + pos, bufsize-pos, "insert into 
sys.systemfunctions (select f.id from sys.functions f, sys.schemas s where 
f.name in ('like', 'ilike') and f.type = %d and f.schema_id = s.id and s.name = 
'sys');\n", F_FILT);
+       pos += snprintf(buf + pos, bufsize-pos, "insert into 
sys.systemfunctions (select f.id from sys.functions f, sys.schemas s where 
f.name in ('storage', 'columnsize', 'heapsize', 'indexsize', 'storagemodel') 
and f.type = %d and f.schema_id = s.id and s.name = 'sys');\n", F_FUNC);
+       pos += snprintf(buf + pos, bufsize-pos, "insert into 
sys.systemfunctions (select f.id from sys.functions f, sys.schemas s where 
f.name = 'storagemodelinit' and f.type = %d and f.schema_id = s.id and s.name = 
'sys');\n", F_PROC);
+
+       assert(pos < bufsize);
+
+       printf("Running database upgrade commands:\n%s\n", buf);
+       err = SQLstatementIntern(c, &buf, "update", 1, 0);
+       GDKfree(buf);
+       return err;             /* usually MAL_SUCCEED */
+}
+
 str
 SQLinitClient(Client c)
 {
@@ -702,28 +741,36 @@ SQLinitClient(Client c)
                 * exist, we need to update */
                sql_find_subtype(&tp, "clob", 0, 0);
                if (!sql_bind_func3(m->sa, mvc_bind_schema(m,"sys"), "like", 
&tp, &tp, &tp, F_FILT )) {
-                       if ((err = sql_update_dec2011(c, m)) != NULL)
+                       if ((err = sql_update_dec2011(c, m)) != NULL) {
                                fprintf(stderr, "!%s\n", err);
+                               GDKfree(err);
+                       }
                }
                /* if aggregate function sys.median(int) does not
                 * exist, we need to update */
                sql_find_subtype(&tp, "int", 0, 0);
                if (!sql_bind_func(m->sa, mvc_bind_schema(m,"sys"), "median", 
&tp, NULL, F_AGGR )) {
-                       if ((err = sql_update_apr2012(c)) != NULL)
+                       if ((err = sql_update_apr2012(c)) != NULL) {
                                fprintf(stderr, "!%s\n", err);
+                               GDKfree(err);
+                       }
                }
                /* if function sys.optimizers() does not exist, we
                 * need to update */
                if (!sql_bind_func(m->sa, mvc_bind_schema(m,"sys"), 
"optimizers", NULL, NULL, F_FUNC )) {
-                       if ((err = sql_update_apr2012_sp1(c)) != NULL)
+                       if ((err = sql_update_apr2012_sp1(c)) != NULL) {
                                fprintf(stderr, "!%s\n", err);
+                               GDKfree(err);
+                       }
                }
                /* if function sys.alpa(double) does not
                 * exist, we need to update */
                sql_find_subtype(&tp, "double", 0, 0);
                if (!sql_bind_func(m->sa, mvc_bind_schema(m,"sys"), "alpha", 
&tp, &tp, F_FUNC )) {
-                       if ((err = sql_update_jul2012(c)) != NULL)
+                       if ((err = sql_update_jul2012(c)) != NULL) {
                                fprintf(stderr, "!%s\n", err);
+                               GDKfree(err);
+                       }
                }
                /* if function sys.zorder_slice() does exist, we need
                 * to update */
@@ -736,23 +783,37 @@ SQLinitClient(Client c)
                        list_append(l, &tp);
                        if (sql_bind_func_(m->sa, mvc_bind_schema(m,"sys"),
                                           "zorder_slice", l, F_FUNC )) {
-                               if ((err = sql_update_oct2012(c)) != NULL)
+                               if ((err = sql_update_oct2012(c)) != NULL) {
                                        fprintf(stderr, "!%s\n", err);
+                                       GDKfree(err);
+                               }
                        }
                }
                /* if aggregate function sys.stddev(int) does
                 * exist, we need to update */
                sql_find_subtype(&tp, "int", 0, 0);
                if (sql_bind_func(m->sa, mvc_bind_schema(m,"sys"), "stddev", 
&tp, NULL, F_AGGR )) {
-                       if ((err = sql_update_oct2012_sp1(c)) != NULL)
+                       if ((err = sql_update_oct2012_sp1(c)) != NULL) {
                                fprintf(stderr, "!%s\n", err);
+                               GDKfree(err);
+                       }
                }
                /* if aggregate function sys.stddev_samp(int) does not
                 * exist, we need to update */
                sql_find_subtype(&tp, "int", 0, 0);
                if (!sql_bind_func(m->sa, mvc_bind_schema(m,"sys"), 
"stddev_samp", &tp, NULL, F_AGGR )) {
-                       if ((err = sql_update_feb2013(c)) != NULL)
+                       if ((err = sql_update_feb2013(c)) != NULL) {
                                fprintf(stderr, "!%s\n", err);
+                               GDKfree(err);
+                       }
+               }
+               /* if function sys.storagemodel() does not exist, we
+                * need to update */
+               if (!sql_bind_func(m->sa, mvc_bind_schema(m,"sys"), 
"storagemodel", NULL, NULL, F_FUNC )) {
+                       if ((err = sql_update_feb2013_sp1(c)) != NULL) {
+                               fprintf(stderr, "!%s\n", err);
+                               GDKfree(err);
+                       }
                }
        }
        fflush(stdout);
diff --git a/sql/server/rel_psm.c b/sql/server/rel_psm.c
--- a/sql/server/rel_psm.c
+++ b/sql/server/rel_psm.c
@@ -893,7 +893,7 @@ rel_drop_func(mvc *sql, dlist *qname, dl
                } else {
                        return sql_error(sql, 02, "DROP %s%s: no such %s%s 
'%s'", KF, F, kf, f, name);
                }
-       } else if ((is_func && !func->res.type) || 
+       } else if (((is_func && type != F_FILT) && !func->res.type) || 
                   (!is_func && func->res.type)) {
                if (list_func)
                        list_destroy(list_func);
diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c
--- a/sql/storage/bat/bat_storage.c
+++ b/sql/storage/bat/bat_storage.c
@@ -342,8 +342,7 @@ append_col(sql_trans *tr, sql_column *c,
 {
        sql_delta *bat = c->data;
 
-       /* appends only write (isn't save!, ie also set read times) */
-       c->base.rtime = c->t->base.rtime = c->t->s->base.rtime = tr->rtime = 
tr->stime;
+       /* appends only write */
        c->base.wtime = c->t->base.wtime = c->t->s->base.wtime = tr->wtime = 
tr->wstime;
        if (tpe == TYPE_bat)
                delta_append_bat(bat, i);
@@ -356,8 +355,7 @@ append_idx(sql_trans *tr, sql_idx * i, v
 {
        sql_delta *bat = i->data;
 
-       /* appends only write (isn't save!, ie also set read times) */
-       i->base.rtime = i->t->base.rtime = i->t->s->base.rtime = tr->rtime = 
tr->stime;
+       /* appends only write */
        i->base.wtime = i->t->base.wtime = i->t->s->base.wtime = tr->wtime = 
tr->wstime;
        if (tpe == TYPE_bat)
                delta_append_bat(bat, ib);
@@ -517,6 +515,7 @@ load_delta(sql_delta *bat, int bid, int 
        bat->bid = temp_create(b);
        bat->ibase = BATcount(b);
        bat->cnt = bat->ibase; 
+       bat->ucnt = 0; 
        bat->ubid = e_ubat(type);
        bat->ibid = e_bat(type);
        return LOG_OK;
@@ -676,7 +675,7 @@ create_col(sql_trans *tr, sql_column *c)
        } else if (bat && bat->ibid && !isTempTable(c->t)) {
                return new_persistent_bat(tr, c->data, c->t->sz);
        } else if (!bat->ibid) {
-               sql_column *fc;
+               sql_column *fc = NULL;
                size_t cnt = 0;
 
                /* alter ? */
@@ -1489,6 +1488,7 @@ tr_update_delta( sql_trans *tr, sql_delt
                                /* should be insert_inserted */
                                BATins(cu, ups, TRUE);
                                BATreplace(cu, ups, TRUE);
+                               obat->ucnt = BATcount(cu);
                                BATcleanProps(cu);
                                bat_destroy(cu);
                        }
@@ -1499,6 +1499,8 @@ tr_update_delta( sql_trans *tr, sql_delt
                                obat->ubid = e_ubat(cur->ttype);
                                temp_destroy(cbat->ubid);
                                cbat->ubid = e_ubat(cur->ttype);
+                               cbat->ucnt = 0;
+                               obat->ucnt = 0;
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to