Changeset: f5d14a56cd88 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f5d14a56cd88
Added Files:
        sql/backends/monet5/sql_cast_impl_down_from_flt.h
        sql/backends/monet5/sql_cast_impl_down_from_int.h
        sql/backends/monet5/sql_cast_impl_up_to_flt.h
        sql/backends/monet5/sql_cast_impl_up_to_int.h
        sql/backends/monet5/sql_decimal.mal.sh
Removed Files:
        sql/backends/monet5/sql_cast.sh
        sql/backends/monet5/sql_decimal.sh
Modified Files:
        configure.ag
        gdk/gdk.h
        monetdb5/modules/kernel/bat5.c
        monetdb5/modules/mal/tablet.c
        sql/backends/monet5/Makefile.ag
        sql/backends/monet5/sql.c
        sql/backends/monet5/sql_cast.c
        sql/backends/monet5/sql_cast.h
        sql/backends/monet5/sql_decimal.mal
        sql/include/sql_relation.h
        sql/server/rel_schema.c
        sql/storage/bat/bat_storage.c
        sql/storage/store.c
Branch: default
Log Message:

Merge with Jan2014 branch.


diffs (truncated from 13399 to 300 lines):

diff --git a/configure.ag b/configure.ag
--- a/configure.ag
+++ b/configure.ag
@@ -1703,7 +1703,7 @@ AM_CONDITIONAL(HAVE_JAVAMEROCONTROL,test
 if test x$have_java_jdbc = xno -a x$have_java_control = xno; then
        # no point doing anything with Java if all Java packages are disabled
        have_java=no
-       if test x$why_have_java = x ; then
+       if test "x$why_have_java" = x ; then
                why_have_java="(have_java_jdbc = no && have_java_control = no)"
        fi
 fi
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -1928,13 +1928,16 @@ gdk_export BBPrec *BBP[N_BBPINIT];
 #define BBPcurstamp()  BBP_curstamp
 #define BBPrefs(i)     (BBPcheck((i),"BBPrefs")?BBP_refs(i):-1)
 #define BBPcache(i)    (BBPcheck((i),"BBPcache")?BBP_cache(i):(BAT*) NULL)
+/* we use ABS(i) instead of -(i) here because of a bug in gcc 4.8.2
+ * (at least) with optimization enabled; it incorrectly complains
+ * about an array bound error in monetdb5/modules/kernel/status.c */
 #define BBPname(i)                                                     \
        (BBPcheck((i), "BBPname") ?                                     \
         ((i) > 0 ?                                                     \
          BBP[(i) >> BBPINITLOG][(i) & (BBPINIT - 1)].logical[0] :      \
-         (BBP[-(i) >> BBPINITLOG][-(i) & (BBPINIT - 1)].logical[1] ?   \
-          BBP[-(i) >> BBPINITLOG][-(i) & (BBPINIT - 1)].logical[1] :   \
-          BBP[-(i) >> BBPINITLOG][-(i) & (BBPINIT - 1)].logical[0])) : \
+         (BBP[ABS(i) >> BBPINITLOG][ABS(i) & (BBPINIT - 1)].logical[1] ? \
+          BBP[ABS(i) >> BBPINITLOG][ABS(i) & (BBPINIT - 1)].logical[1] : \
+          BBP[ABS(i) >> BBPINITLOG][ABS(i) & (BBPINIT - 1)].logical[0])) : \
         "")
 #define BBPvalid(i)    (BBP_logical(i) != NULL && *BBP_logical(i) != '.')
 #define BATgetId(b)    BBPname((b)->batCacheid)
diff --git a/monetdb5/modules/kernel/bat5.c b/monetdb5/modules/kernel/bat5.c
--- a/monetdb5/modules/kernel/bat5.c
+++ b/monetdb5/modules/kernel/bat5.c
@@ -1892,7 +1892,7 @@ BKCheat(int *res, str *input)
        int bid = BBPindex(*input);
 
        if (bid) {
-               *res = BBP_lastused(bid) & 0x7fffffff;
+               *res = BBPLASTUSED(BBP_lastused(bid));
        }
        throw(MAL, "bat", PROGRAM_NYI);
 }
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
@@ -258,24 +258,19 @@ TABLETcollect_parts(Tablet *as, BUN offs
                BAT *bv = NULL;
 
                BATsetaccess(b, BAT_READ);
-               bv = BATslice(b, offset, BATcount(b));
+               bv = BATslice(b, (offset>0)?offset-1:0, BATcount(b));
                bats[i] = bv;
                BATderiveProps(bv, 1);
 
-               b->hkey &= bv->hkey;
-               b->tkey &= bv->tkey;
-               b->H->nonil &= bv->H->nonil;
+               b->tkey = (offset>0)?FALSE:bv->tkey; 
                b->T->nonil &= bv->T->nonil;
-               b->hdense &= bv->hdense;
                b->tdense &= bv->tdense;
-               if (b->hsorted != bv->hsorted)
-                       b->hsorted = 0;
-               if (b->hrevsorted != bv->hrevsorted)
-                       b->hrevsorted = 0;
                if (b->tsorted != bv->tsorted)
                        b->tsorted = 0;
                if (b->trevsorted != bv->trevsorted)
                        b->trevsorted = 0;
+               if (b->tdense)
+                       b->tkey = TRUE;
                b->batDirty = TRUE;
 
                if (cnt != BATcount(b)) {
diff --git a/sql/backends/monet5/Makefile.ag b/sql/backends/monet5/Makefile.ag
--- a/sql/backends/monet5/Makefile.ag
+++ b/sql/backends/monet5/Makefile.ag
@@ -48,6 +48,10 @@ lib__sql = {
                sql_result.c sql_result.h \
                sql_readline.c sql_readline.h \
                sql_cast.c sql_cast.h \
+               sql_cast_impl_down_from_flt.h \
+               sql_cast_impl_down_from_int.h \
+               sql_cast_impl_up_to_flt.h \
+               sql_cast_impl_up_to_int.h \
                sql_round.c sql_bat2time.c sql_fround.c sql_rdf.c
        LIBS = ../../server/libsqlserver \
                   ../../storage/libstore \
diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -502,7 +502,7 @@ alter_table(mvc *sql, char *sname, sql_t
                if (nt->pkey) {
                        for (n = t->idxs.nelm; n; n = n->next) {
                                sql_idx *i = n->data;
-                               if (i->key->type == pkey)
+                               if (i->key && i->key->type == pkey)
                                        return sql_message("40000!CONSTRAINT 
PRIMARY KEY: a table can have only one PRIMARY KEY\n");
                        }
                }
@@ -695,46 +695,6 @@ drop_key(mvc *sql, char *sname, char *kn
 }
 
 static str
-create_index(mvc *sql, char *iname, int itype, char *sname, char *tname, 
MalStkPtr stk, InstrPtr pci)
-{
-       sql_schema *s = NULL;
-       sql_table *t = NULL;
-       sql_idx *i = NULL;
-
-       if (!(s = mvc_bind_schema(sql, sname)))
-               return sql_message("3F000!CREATE INDEX: no such schema '%s'", 
sname);
-
-       i = mvc_bind_idx(sql, s, iname);
-       t = mvc_bind_table(sql, s, tname);
-       if (i) {
-               return sql_message("42S11!CREATE INDEX: name '%s' already in 
use", iname);
-       } else if (!t) {
-               return sql_message("42S02!CREATE INDEX: no such table '%s'", 
tname);
-       } else if (isView(t)) {
-               return sql_message("42S02!CREATE INDEX: cannot create index on 
view '%s'", tname);
-       } else {
-               int n;
-               sql_idx *i = mvc_create_idx(sql, t, iname, (idx_type) itype);
-
-               if (!i)
-                       return sql_message("40000!CREATE INDEX: failed to 
create index '%s'", iname);
-
-               for (n = 6; n < pci->argc; n++) {
-                       char *cname = *(str *) getArgReference(stk, pci, n);
-                       sql_column *c = mvc_bind_column(sql, t, cname);
-
-                       if (!c) {
-                               return sql_message("42S22!CREATE INDEX: no such 
column '%s'", cname);
-                       } else {
-                               mvc_create_ic(sql, i, c);
-                               mvc_create_dependency(sql, c->base.id, 
i->base.id, INDEX_DEPENDENCY);
-                       }
-               }
-       }
-       return NULL;
-}
-
-static str
 drop_index(mvc *sql, char *sname, char *iname)
 {
        sql_schema *s = NULL;
@@ -1177,13 +1137,6 @@ SQLcatalog(Client cntxt, MalBlkPtr mb, M
                msg = sql_drop_role(sql, role);
                break;
        }
-       case DDL_CREATE_INDEX:{
-               int itype = *(int *) getArgReference(stk, pci, 3);
-               char *ssname = *(str *) getArgReference(stk, pci, 4);
-               char *tname = *(str *) getArgReference(stk, pci, 5);
-               msg = create_index(sql, sname, itype, ssname, tname, stk, pci);
-               break;
-       }
        case DDL_DROP_INDEX:{
                char *iname = *(str *) getArgReference(stk, pci, 3);
                msg = drop_index(sql, sname, iname);
diff --git a/sql/backends/monet5/sql_cast.c b/sql/backends/monet5/sql_cast.c
--- a/sql/backends/monet5/sql_cast.c
+++ b/sql/backends/monet5/sql_cast.c
@@ -543,11042 +543,281 @@ SQLbatstr_cast(Client cntxt, MalBlkPtr m
        return msg;
 }
 
-str
-bte_2_bte(bte *res, bte *v)
-{
-       /* shortcut nil */
-       if (*v == bte_nil) {
-               *res = bte_nil;
-               return (MAL_SUCCEED);
-       }
+/* sql_cast_impl_up_to_int */
 
-       /* since the bte type is bigger than or equal to the bte type, it will
-          always fit */
-       *res = (bte) *v;
-       return (MAL_SUCCEED);
-}
+#define TP1 bte
+#define TP2 bte
+#include "sql_cast_impl_up_to_int.h"
+#undef TP2
+#undef TP1
 
-str
-batbte_2_bte(int *res, int *bid)
-{
-       BAT *b, *bn;
-       bte *p, *q;
-       bte *o;
+#define TP1 bte
+#define TP2 sht
+#include "sql_cast_impl_up_to_int.h"
+#undef TP2
+#undef TP1
 
-       if ((b = BATdescriptor(*bid)) == NULL) {
-               throw(SQL, "batcalc.bte_2_bte", "Cannot access descriptor");
-       }
-       bn = BATnew(TYPE_void, TYPE_bte, BATcount(b));
-       if (bn == NULL) {
-               BBPreleaseref(b->batCacheid);
-               throw(SQL, "sql.bte_2_bte", MAL_MALLOC_FAIL);
-       }
-       bn->hsorted = b->hsorted;
-       bn->hrevsorted = b->hrevsorted;
-       BATseqbase(bn, b->hseqbase);
-       o = (bte *) Tloc(bn, BUNfirst(bn));
-       p = (bte *) Tloc(b, BUNfirst(b));
-       q = (bte *) Tloc(b, BUNlast(b));
-       bn->T->nonil = 1;
-       if (b->T->nonil) {
-               for (; p < q; p++, o++)
-                       *o = (bte) *p;
-       } else {
-               for (; p < q; p++, o++)
-                       if (*p == bte_nil) {
-                               *o = bte_nil;
-                               bn->T->nonil = FALSE;
-                       } else
-                               *o = (bte) *p;
-       }
-       BATsetcount(bn, BATcount(b));
-       bn->hrevsorted = bn->batCount <= 1;
-       bn->tsorted = 0;
-       bn->trevsorted = 0;
-       BATkey(BATmirror(bn), FALSE);
+#define TP1 sht
+#define TP2 sht
+#include "sql_cast_impl_up_to_int.h"
+#undef TP2
+#undef TP1
 
-       if (!(bn->batDirty & 2))
-               bn = BATsetaccess(bn, BAT_READ);
+#define TP1 bte
+#define TP2 int
+#include "sql_cast_impl_up_to_int.h"
+#undef TP2
+#undef TP1
 
-       if (b->htype != bn->htype) {
-               BAT *r = VIEWcreate(b, bn);
+#define TP1 sht
+#define TP2 int
+#include "sql_cast_impl_up_to_int.h"
+#undef TP2
+#undef TP1
 
-               BBPkeepref(*res = r->batCacheid);
-               BBPreleaseref(bn->batCacheid);
-               BBPreleaseref(b->batCacheid);
-               return MAL_SUCCEED;
-       }
-       BBPkeepref(*res = bn->batCacheid);
-       BBPreleaseref(b->batCacheid);
-       return MAL_SUCCEED;
-}
+#define TP1 int
+#define TP2 int
+#include "sql_cast_impl_up_to_int.h"
+#undef TP2
+#undef TP1
 
-str
-bte_dec2_bte(bte *res, int *s1, bte *v)
-{
-       int scale = *s1;
-       bte r, h = (*v < 0) ? -5 : 5;
+#define TP1 bte
+#define TP2 wrd
+#include "sql_cast_impl_up_to_int.h"
+#undef TP2
+#undef TP1
 
-       /* shortcut nil */
-       if (*v == bte_nil) {
-               *res = bte_nil;
-               return (MAL_SUCCEED);
-       }
+#define TP1 sht
+#define TP2 wrd
+#include "sql_cast_impl_up_to_int.h"
+#undef TP2
+#undef TP1
 
-       /* since the bte type is bigger than or equal to the bte type, it will
-          always fit */
-       r = (bte) *v;
-       if (scale)
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to