Changeset: 5f28f26b9f74 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5f28f26b9f74
Added Files:
        
sql/test/BugTracker-2017/Tests/crash_after_oidx_on_sys_statistics.Bug-6251.sql
        
sql/test/BugTracker-2017/Tests/crash_after_oidx_on_sys_statistics.Bug-6251.stable.err
        
sql/test/BugTracker-2017/Tests/crash_after_oidx_on_sys_statistics.Bug-6251.stable.out
        sql/test/orderidx/Tests/oidx_all_types.sql
        sql/test/orderidx/Tests/oidx_all_types.stable.err
        sql/test/orderidx/Tests/oidx_all_types.stable.out
        sql/test/orderidx/Tests/oidx_hge_type.sql
        sql/test/orderidx/Tests/oidx_hge_type.stable.err
        sql/test/orderidx/Tests/oidx_hge_type.stable.out.int128
Modified Files:
        gdk/gdk_calc.c
        geom/monetdb5/geom_upgrade.c
        monetdb5/extras/rapi/converters.c.h
        monetdb5/extras/rapi/rapi.c
        monetdb5/mal/mal_authorize.c
        monetdb5/modules/atoms/mtime.c
        monetdb5/modules/kernel/bat5.c
        monetdb5/modules/kernel/batstr.c
        monetdb5/modules/kernel/status.c
        monetdb5/modules/mal/batExtensions.c
        monetdb5/modules/mal/bbp.c
        monetdb5/modules/mal/clients.c
        monetdb5/modules/mal/inspect.c
        monetdb5/modules/mal/mal_mapi.c
        monetdb5/modules/mal/mat.c
        monetdb5/modules/mal/mdb.c
        monetdb5/modules/mal/oltp.c
        monetdb5/modules/mal/pcre.c
        monetdb5/modules/mal/querylog.c
        monetdb5/modules/mal/remote.c
        monetdb5/modules/mal/sysmon.c
        monetdb5/modules/mal/tablet.c
        monetdb5/modules/mal/tokenizer.c
        monetdb5/modules/mal/txtsim.c
        monetdb5/optimizer/opt_mitosis.c
        monetdb5/optimizer/opt_pipes.c
        monetdb5/optimizer/opt_wrapper.c
        sql/backends/monet5/LSST/lsst.c
        sql/backends/monet5/UDF/cudf/udf.c
        sql/backends/monet5/UDF/pyapi/conversion.c
        sql/backends/monet5/UDF/pyapi/convert_loops.h
        sql/backends/monet5/UDF/pyapi/emit.c
        sql/backends/monet5/rel_bin.c
        sql/backends/monet5/sql_cat.c
        sql/backends/monet5/sql_gencode.c
        sql/backends/monet5/sql_scenario.c
        sql/benchmarks/tpch/load.sh
        sql/server/rel_rel.c
        sql/server/rel_rel.h
        sql/server/rel_select.c
        sql/server/rel_select.h
        sql/server/rel_updates.c
        sql/storage/bat/bat_storage.c
        sql/storage/store.c
        
sql/test/BugTracker-2010/Tests/ORDER_BY_over_UNION_EXCEPT_INTERSECT.Bug-2606.stable.out
        
sql/test/BugTracker-2012/Tests/rewrite_like_into_likesubselect.Bug-3179.stable.out
        sql/test/BugTracker-2017/Tests/All
        sql/test/BugTracker-2017/Tests/one-plus-nil.Bug-6243.stable.out
        sql/test/orderidx/Tests/All
Branch: protocol
Log Message:

Merge with default.


diffs (truncated from 6401 to 300 lines):

diff --git a/gdk/gdk_calc.c b/gdk/gdk_calc.c
--- a/gdk/gdk_calc.c
+++ b/gdk/gdk_calc.c
@@ -13253,7 +13253,7 @@ BATcalcifthenelsecst(BAT *b, BAT *b1, co
 
        if (checkbats(b, b1, "BATcalcifthenelse") != GDK_SUCCEED)
                return NULL;
-       if (b->ttype != TYPE_bit || b1->ttype != c2->vtype) {
+       if (b->ttype != TYPE_bit || ATOMtype(b1->ttype) != ATOMtype(c2->vtype)) 
{
                GDKerror("BATcalcifthenelsecst: \"then\" and \"else\" BATs have 
different types.\n");
                return NULL;
        }
@@ -13272,7 +13272,7 @@ BATcalcifthencstelse(BAT *b, const ValRe
 
        if (checkbats(b, b2, "BATcalcifthenelse") != GDK_SUCCEED)
                return NULL;
-       if (b->ttype != TYPE_bit || b2->ttype != c1->vtype) {
+       if (b->ttype != TYPE_bit || ATOMtype(b2->ttype) != ATOMtype(c1->vtype)) 
{
                GDKerror("BATcalcifthencstelse: \"then\" and \"else\" BATs have 
different types.\n");
                return NULL;
        }
@@ -13289,7 +13289,7 @@ BATcalcifthencstelsecst(BAT *b, const Va
        BATcheck(c1, "BATcalcifthenelsecst", NULL);
        BATcheck(c2, "BATcalcifthenelsecst", NULL);
 
-       if (b->ttype != TYPE_bit || c1->vtype != c2->vtype) {
+       if (b->ttype != TYPE_bit || ATOMtype(c1->vtype) != ATOMtype(c2->vtype)) 
{
                GDKerror("BATcalcifthencstelsecst: \"then\" and \"else\" BATs 
have different types.\n");
                return NULL;
        }
diff --git a/geom/monetdb5/geom_upgrade.c b/geom/monetdb5/geom_upgrade.c
--- a/geom/monetdb5/geom_upgrade.c
+++ b/geom/monetdb5/geom_upgrade.c
@@ -13,83 +13,8 @@
 
 #include <geom.h>
 
-typedef struct list_element {
-       BAT *ob;
-       BAT *nb;
-       char *n;
-} list_element;
-
-typedef struct ulist {
-       size_t capacity;
-       size_t count;
-       list_element *elements;
-} ulist;
-
-static ulist*
-list_init(size_t capacity)
-{
-       ulist *l;
-       if ((l = GDKmalloc(sizeof(ulist))) == NULL)
-               return NULL;
-       l->capacity = capacity;
-       l->count = 0;
-       if ((l->elements = GDKzalloc(capacity*sizeof(list_element))) == NULL) {
-               GDKfree(l);
-               return NULL;
-       }
-       return l;
-}
-
-static int
-list_delete(ulist* ul)
-{
-       size_t i;
-       for (i = 0; i < ul->count; i++) {
-               GDKfree(ul->elements[i].n);
-               if (ul->elements[i].ob)
-                       BBPunfix(ul->elements[i].ob->batCacheid);
-               if (ul->elements[i].nb)
-                       BBPunfix(ul->elements[i].nb->batCacheid);
-       }
-       GDKfree(ul->elements);
-       GDKfree(ul);
-       return 1;
-}
-
-static int
-list_extend(ulist **ul)
-{
-       ulist* nl;
-       if ((nl = list_init((*ul)->capacity*2)) == NULL )
-               return 0;
-       memcpy(nl->elements, (*ul)->elements, 
sizeof(list_element)*(*ul)->count);
-       nl->count = (*ul)->count;
-       GDKfree((*ul)->elements);
-       GDKfree(*ul);
-       *ul = nl;
-       return 1;
-}
-
-static int
-list_add(ulist **ul, BAT *ob, BAT *nb, const char *n)
-{
-       char *nn;
-       if ((nn =  GDKstrdup(n)) == NULL)
-               return 0;
-       if ((*ul)->count == (*ul)->capacity)
-               if (!list_extend(ul)) {
-                       GDKfree(nn);
-                       return 0;
-               }
-       (*ul)->elements[(*ul)->count].ob = ob;
-       (*ul)->elements[(*ul)->count].nb = nb;
-       (*ul)->elements[(*ul)->count].n = nn;
-       (*ul)->count++;
-       return 1;
-}
-
 static char *
-N( char *buf, const char *pre, const char *schema, const char *post)
+N(char *buf, const char *pre, const char *schema, const char *post)
 {
        if (pre)
                snprintf(buf, 64, "%s_%s_%s", pre, schema, post);
@@ -107,38 +32,107 @@ geom_catalog_upgrade(void *lg, int olddb
        const char *s = "sys";
        char n[64];
        BUN p,q;
-       size_t ii;
-       ulist *ul;
 
-       if (olddb) {
-               /* Update the catalog to use the new geometry types */
-               if ((ul = list_init(32)) == NULL)
-                       return 0;
+       if (!olddb)
+               return 1;
 
-               ct = BATdescriptor((bat) logger_find_bat(lg, N(n, NULL, s, 
"_columns_type")));
-               cti = bat_iterator(ct);
-               cd = BATdescriptor((bat) logger_find_bat(lg, N(n, NULL, s, 
"_columns_type_digits")));
-               cdi = bat_iterator(cd);
-               cs = BATdescriptor((bat) logger_find_bat(lg, N(n, NULL, s, 
"_columns_type_scale")));
-               csi = bat_iterator(cs);
+       ct = BATdescriptor((bat) logger_find_bat(lg, N(n, NULL, s, 
"_columns_type")));
+       cti = bat_iterator(ct);
+       cd = BATdescriptor((bat) logger_find_bat(lg, N(n, NULL, s, 
"_columns_type_digits")));
+       cdi = bat_iterator(cd);
+       cs = BATdescriptor((bat) logger_find_bat(lg, N(n, NULL, s, 
"_columns_type_scale")));
+       csi = bat_iterator(cs);
 
-               if (!ct || !cd || !cs) {
-                       list_delete(ul);
-                       if (ct)
-                               BBPunfix(ct->batCacheid);
-                       if (cd)
-                               BBPunfix(cd->batCacheid);
-                       if (cs)
-                               BBPunfix(cs->batCacheid);
-                       return 0;
+       if (!ct || !cd || !cs) {
+               if (ct)
+                       BBPunfix(ct->batCacheid);
+               if (cd)
+                       BBPunfix(cd->batCacheid);
+               if (cs)
+                       BBPunfix(cs->batCacheid);
+               return 0;
+       }
+
+       cnt = COLnew(ct->hseqbase, TYPE_str, BATcount(ct), PERSISTENT);
+       cnd = COLnew(cd->hseqbase, TYPE_int, BATcount(cd), PERSISTENT);
+       cns = COLnew(cs->hseqbase, TYPE_int, BATcount(cs), PERSISTENT);
+
+       if (!cnt || !cnd || !cns) {
+               BBPreclaim(cnt);
+               BBPreclaim(cnd);
+               BBPreclaim(cns);
+               BBPunfix(ct->batCacheid);
+               BBPunfix(cd->batCacheid);
+               BBPunfix(cs->batCacheid);
+               return 0;
+       }
+
+       for(p=0, q=BUNlast(ct); p<q; p++) {
+               const char *type = BUNtail(cti, p);
+               int digits = *(int*)BUNtail(cdi, p);
+               int scale = *(int*)BUNtail(csi, p);
+
+               if (strcasecmp(type, "point") == 0) {
+                       type = "geometry";
+                       digits = wkbPoint_mdb << 2;
+                       scale = 0; // in the past we did not save the srid
+               } else if (strcasecmp(type, "linestring") == 0) {
+                       type = "geometry";
+                       digits = wkbLineString_mdb << 2;
+                       scale = 0;
+               } else if (strcasecmp(type, "curve") == 0) {
+                       type = "geometry";
+                       digits = wkbLineString_mdb << 2;
+                       scale = 0;
+               } else if (strcasecmp(type, "linearring") == 0) {
+                       type = "geometry";
+                       digits = wkbLinearRing_mdb << 2;
+                       scale = 0;
+               } else if (strcasecmp(type, "polygon") == 0) {
+                       type = "geometry";
+                       digits = wkbPolygon_mdb << 2;
+                       scale = 0;
+               } else if (strcasecmp(type, "surface") == 0) {
+                       type = "geometry";
+                       digits = wkbPolygon_mdb << 2;
+                       scale = 0;
+               } else if (strcasecmp(type, "multipoint") == 0) {
+                       type = "geometry";
+                       digits = wkbMultiPoint_mdb << 2;
+                       scale = 0;
+               } else if (strcasecmp(type, "multilinestring") == 0) {
+                       type = "geometry";
+                       digits = wkbMultiLineString_mdb << 2;
+                       scale = 0;
+               } else if (strcasecmp(type, "multicurve") == 0) {
+                       type = "geometry";
+                       digits = wkbMultiLineString_mdb << 2;
+                       scale = 0;
+               } else if (strcasecmp(type, "multipolygon") == 0) {
+                       type = "geometry";
+                       digits = wkbMultiPolygon_mdb << 2;
+                       scale = 0;
+               } else if (strcasecmp(type, "multisurface") == 0) {
+                       type = "geometry";
+                       digits = wkbMultiPolygon_mdb << 2;
+                       scale = 0;
+               } else if (strcasecmp(type, "geomcollection") == 0) {
+                       type = "geometry";
+                       digits = wkbGeometryCollection_mdb << 2;
+                       scale = 0;
+               } else if (strcasecmp(type, "geometrycollection") == 0) {
+                       type = "geometry";
+                       digits = wkbGeometryCollection_mdb << 2;
+                       scale = 0;
+               }  else if (strcasecmp(type, "geometry") == 0) {
+                       type = "geometry";
+                       digits = 0;
+                       scale = 0;
                }
 
-               cnt = COLnew(ct->hseqbase, TYPE_str, BATcount(ct), PERSISTENT);
-               cnd = COLnew(cd->hseqbase, TYPE_int, BATcount(cd), PERSISTENT);
-               cns = COLnew(cs->hseqbase, TYPE_int, BATcount(cs), PERSISTENT);
-
-               if (!cnt || !cnd || !cns) {
-                       list_delete(ul);
+               if (BUNappend(cnt, type, TRUE) != GDK_SUCCEED ||
+                   BUNappend(cnd, &digits, TRUE) != GDK_SUCCEED ||
+                   BUNappend(cns, &scale, TRUE) != GDK_SUCCEED) {
                        BBPreclaim(cnt);
                        BBPreclaim(cnd);
                        BBPreclaim(cns);
@@ -147,89 +141,28 @@ geom_catalog_upgrade(void *lg, int olddb
                        BBPunfix(cs->batCacheid);
                        return 0;
                }
+       }
 
-               for(p=0, q=BUNlast(ct); p<q; p++) {
-                       const char *type = BUNtail(cti, p);
-                       int digits = *(int*)BUNtail(cdi, p);
-                       int scale = *(int*)BUNtail(csi, p);
-
-                       if (strcasecmp(type, "point") == 0) {
-                               type = "geometry";
-                               digits = wkbPoint_mdb << 2;
-                               scale = 0; // in the past we did not save the 
srid
-                       } else if (strcasecmp(type, "linestring") == 0) {
-                               type = "geometry";
-                               digits = wkbLineString_mdb << 2;
-                               scale = 0;
-                       } else if (strcasecmp(type, "curve") == 0) {
-                               type = "geometry";
-                               digits = wkbLineString_mdb << 2;
-                               scale = 0;
-                       } else if (strcasecmp(type, "linearring") == 0) {
-                               type = "geometry";
-                               digits = wkbLinearRing_mdb << 2;
-                               scale = 0;
-                       } else if (strcasecmp(type, "polygon") == 0) {
-                               type = "geometry";
-                               digits = wkbPolygon_mdb << 2;
-                               scale = 0;
-                       } else if (strcasecmp(type, "surface") == 0) {
-                               type = "geometry";
-                               digits = wkbPolygon_mdb << 2;
-                               scale = 0;
-                       } else if (strcasecmp(type, "multipoint") == 0) {
-                               type = "geometry";
-                               digits = wkbMultiPoint_mdb << 2;
-                               scale = 0;
-                       } else if (strcasecmp(type, "multilinestring") == 0) {
-                               type = "geometry";
-                               digits = wkbMultiLineString_mdb << 2;
-                               scale = 0;
-                       } else if (strcasecmp(type, "multicurve") == 0) {
-                               type = "geometry";
-                               digits = wkbMultiLineString_mdb << 2;
-                               scale = 0;
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to