Changeset: cdbe567135f4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/cdbe567135f4
Modified Files:
        clients/Tests/exports.stable.out
        clients/mapiclient/dump.c
        sql/backends/monet5/rel_bin.c
        sql/rel.txt
        sql/server/rel_select.c
        sql/server/rel_unnest.c
        sql/server/sql_parser.y
Branch: nested
Log Message:

Merge with default branch.


diffs (truncated from 825 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
@@ -361,8 +361,8 @@ var_t HEAP_malloc(BAT *b, size_t nbytes)
 void HEAPdecref(Heap *h, bool remove);
 gdk_return HEAPextend(Heap *h, size_t size, bool mayshare) 
__attribute__((__warn_unused_result__));
 void HEAPincref(Heap *h);
-size_t HEAPmemsize(Heap *h);
-size_t HEAPvmsize(Heap *h);
+size_t HEAPmemsize(const Heap *h) __attribute__((__pure__));
+size_t HEAPvmsize(const Heap *h) __attribute__((__pure__));
 gdk_return MT_alloc_tls(MT_TLS_t *newkey);
 int MT_check_nr_cores(void);
 void MT_cond_broadcast(MT_Cond *cond);
diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c
--- a/clients/mapiclient/dump.c
+++ b/clients/mapiclient/dump.c
@@ -1208,7 +1208,7 @@ dump_column_definition(Mapi mid, stream 
                                mnstr_printf(sqlf, " (");
                                cnt = 1;
                        }
-               } else
+               } else if (strcmp(k_type, "4") != 0)
                        mnstr_printf(sqlf, ", ");
                if (cnt)
                        dquoted_print(sqlf, c_column, NULL);
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -433,19 +433,19 @@ typedef struct BAT {
 
 /* some access functions for the bitmask type */
 static inline void
-mskSet(BAT *b, BUN p)
+mskSet(const BAT *b, BUN p)
 {
        ((uint32_t *) b->theap->base)[p / 32] |= 1U << (p % 32);
 }
 
 static inline void
-mskClr(BAT *b, BUN p)
+mskClr(const BAT *b, BUN p)
 {
        ((uint32_t *) b->theap->base)[p / 32] &= ~(1U << (p % 32));
 }
 
 static inline void
-mskSetVal(BAT *b, BUN p, msk v)
+mskSetVal(const BAT *b, BUN p, msk v)
 {
        if (v)
                mskSet(b, p);
@@ -453,16 +453,19 @@ mskSetVal(BAT *b, BUN p, msk v)
                mskClr(b, p);
 }
 
+__attribute__((__pure__))
 static inline msk
-mskGetVal(BAT *b, BUN p)
+mskGetVal(const BAT *b, BUN p)
 {
        return ((uint32_t *) b->theap->base)[p / 32] & (1U << (p % 32));
 }
 
 gdk_export gdk_return HEAPextend(Heap *h, size_t size, bool mayshare)
        __attribute__((__warn_unused_result__));
-gdk_export size_t HEAPvmsize(Heap *h);
-gdk_export size_t HEAPmemsize(Heap *h);
+gdk_export size_t HEAPvmsize(const Heap *h)
+       __attribute__((__pure__));
+gdk_export size_t HEAPmemsize(const Heap *h)
+       __attribute__((__pure__));
 gdk_export void HEAPdecref(Heap *h, bool remove);
 gdk_export void HEAPincref(Heap *h);
 
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -2874,6 +2874,8 @@ BATsort(BAT **sorted, BAT **order, BAT *
                        }
                        goto error;
                }
+               if (reverse)
+                       bn->tseqbase = oid_nil;
                bn->tsorted = !reverse && !nilslast;
                bn->trevsorted = reverse && nilslast;
                if (m != NULL) {
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -2423,7 +2423,7 @@ BBPdump(void)
                        MT_rwlock_rdunlock(&b->thashlock);
                }
                printf(" role: %s\n",
-                      b->batRole == PERSISTENT ? "persistent" : "transient");
+                      b->batRole == PERSISTENT ? "persistent" : b->batRole == 
SYSTRANS ? "systrans" : "transient");
        }
        printf("# %d bats: mem=%zu, vm=%zu\n", n, mem, vm);
        fflush(stdout);
diff --git a/gdk/gdk_heap.c b/gdk/gdk_heap.c
--- a/gdk/gdk_heap.c
+++ b/gdk/gdk_heap.c
@@ -900,7 +900,7 @@ HEAPsave(Heap *h, const char *nme, const
 
 /* Return the (virtual) size of the heap. */
 size_t
-HEAPvmsize(Heap *h)
+HEAPvmsize(const Heap *h)
 {
        if (h && h->base && h->free)
                return h->size;
@@ -910,7 +910,7 @@ HEAPvmsize(Heap *h)
 /* Return the allocated size of the heap, i.e. if the heap is memory
  * mapped and not copy-on-write (privately mapped), return 0. */
 size_t
-HEAPmemsize(Heap *h)
+HEAPmemsize(const Heap *h)
 {
        if (h && h->base && h->free && h->storage != STORE_MMAP)
                return h->size;
diff --git a/monetdb5/extras/rapi/Tests/All b/monetdb5/extras/rapi/Tests/All
--- a/monetdb5/extras/rapi/Tests/All
+++ b/monetdb5/extras/rapi/Tests/All
@@ -1,9 +1,9 @@
-HAVE_LIBR&NOT_WIN32?rapi00
-HAVE_LIBR&NOT_WIN32?rapi01
-HAVE_LIBR&HAVE_HGE&NOT_WIN32?rapi02
-HAVE_LIBR&NOT_WIN32?rapi03
-HAVE_LIBR&NOT_WIN32?rapi04
-HAVE_LIBR&NOT_WIN32?rapi05
-HAVE_LIBR&NOT_WIN32?rapi07
-HAVE_LIBR&NOT_WIN32?rapi08
-HAVE_LIBR&NOT_WIN32?rapi10
+HAVE_LIBR?rapi00
+HAVE_LIBR?rapi01
+HAVE_LIBR&HAVE_HGE?rapi02
+HAVE_LIBR?rapi03
+HAVE_LIBR?rapi04
+HAVE_LIBR?rapi05
+HAVE_LIBR?rapi07
+HAVE_LIBR?rapi08
+HAVE_LIBR?rapi10
diff --git a/sql/backends/monet5/Tests/All b/sql/backends/monet5/Tests/All
--- a/sql/backends/monet5/Tests/All
+++ b/sql/backends/monet5/Tests/All
@@ -1,25 +1,24 @@
 optimizers
 
-HAVE_LIBR&NOT_WIN32?rapi00
-HAVE_LIBR&NOT_WIN32?rapi01
-HAVE_LIBR&NOT_WIN32?rapi02
-HAVE_LIBR&NOT_WIN32?rapi03
-HAVE_LIBR&NOT_WIN32?rapi05
-HAVE_LIBR&NOT_WIN32?rapi06
-HAVE_LIBR&NOT_WIN32?rapi07
-#HAVE_LIBR&NOT_WIN32?rapi08
-HAVE_LIBR&NOT_WIN32?rapi09
-HAVE_LIBR&NOT_WIN32&!R_VERSION>=4.2.0?rapi09a
-HAVE_LIBR&NOT_WIN32?rapi10
-HAVE_LIBR&NOT_WIN32?rapi12
-HAVE_LIBR&NOT_WIN32?rapi13
-HAVE_LIBR&NOT_WIN32?rapi14
-HAVE_LIBR&NOT_WIN32?rapi15
-HAVE_LIBR&NOT_WIN32?rapi16
-HAVE_LIBR&NOT_WIN32?rapi17
-HAVE_LIBR&NOT_WIN32?rapi18
-HAVE_LIBR&NOT_WIN32?rapi19
-HAVE_LIBR&NOT_WIN32?rapi20
+HAVE_LIBR?rapi00
+HAVE_LIBR?rapi01
+HAVE_LIBR?rapi02
+HAVE_LIBR?rapi03
+HAVE_LIBR?rapi05
+HAVE_LIBR?rapi06
+HAVE_LIBR?rapi07
+HAVE_LIBR?rapi09
+HAVE_LIBR&!R_VERSION>=4.2.0?rapi09a
+HAVE_LIBR?rapi10
+HAVE_LIBR?rapi12
+HAVE_LIBR?rapi13
+HAVE_LIBR?rapi14
+HAVE_LIBR?rapi15
+HAVE_LIBR?rapi16
+HAVE_LIBR?rapi17
+HAVE_LIBR?rapi18
+HAVE_LIBR?rapi19
+HAVE_LIBR?rapi20
 
 
 # should this work?
diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c
--- a/sql/backends/monet5/rel_bin.c
+++ b/sql/backends/monet5/rel_bin.c
@@ -1209,9 +1209,10 @@ exp2bin_named_placeholders(backend *be, 
 
        if (list_empty(args))
                return NULL;
-       for (node *n = args->h; n; n = n->next, argc++) {
+       for (node *n = args->h, *m = be->mvc->params->h; n && m; n = n->next, m 
= m->next, argc++) {
                sql_exp *a = n->data;
-               sql_subtype *t = exp_subtype(a);
+               sql_arg *p = m->data;
+               sql_subtype *t = &p->type;
                stmt *s = exp_bin(be, a, NULL, NULL, NULL, NULL, NULL, NULL, 1, 
0, 1);
                InstrPtr q = newAssignment(be->mb);
 
diff --git a/sql/rel.txt b/sql/rel.txt
--- a/sql/rel.txt
+++ b/sql/rel.txt
@@ -139,7 +139,7 @@ e_cmp
 
                        cmp_filter = 6,         filters                 ->l/r 
are both lists
 
-                       cmp_in = 8,                     in list handling        
->r is a list of values
+                       cmp_in = 8,             in list handling        ->r is 
a list of values
                        cmp_notin = 9,          not in list handling    ->r is 
a list of values
 
                        cmp_conjunctive = 10,                   and handling    
        -> l is a list
diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c
--- a/sql/server/rel_select.c
+++ b/sql/server/rel_select.c
@@ -4477,9 +4477,10 @@ rel_cast(sql_query *query, sql_rel **rel
        if (tpe->type->eclass == EC_DEC) {
                sql_subtype *et = exp_subtype(e);
                if (e->type == e_atom && !tpe->digits) {
-                       if (et->type->eclass == EC_NUM || et->type->eclass == 
EC_DEC) {
-                               tpe->digits = atom_num_digits(e->l);
-                               tpe = sql_bind_subtype(sql->sa, "decimal", 
tpe->digits, et->scale);
+                       if (e->l && (et->type->eclass == EC_NUM || 
et->type->eclass == EC_DEC)) {
+                               tpe->digits = atom_num_digits(e->l) + 1;
+                               tpe->scale = 1;
+                               tpe = sql_bind_subtype(sql->sa, "decimal", 
tpe->digits, tpe->scale);
                        } else if (EC_VARCHAR(et->type->eclass)) {
                                char *s = E_ATOM_STRING(e);
                                unsigned int min_precision = 0, min_scale = 0;
@@ -4523,8 +4524,10 @@ rel_next_value_for( mvc *sql, symbol *se
        sql_subtype t;
        sql_subfunc *f;
 
-       if (!sname)
-               sname = "sys";
+       if (!sname) {
+               sql_schema *s = cur_schema(sql);
+               sname = s->base.name;
+       }
        if (!stack_find_rel_view(sql, seqname)) {
                if (!(seq = find_sequence_on_scope(sql, sname, seqname, "NEXT 
VALUE FOR")))
                        return NULL;
@@ -4942,7 +4945,8 @@ rel_order_by(sql_query *query, sql_rel *
                        assert(is_project(rel->op));
                        for(node *n = rel->exps->h; n; n = n->next) {
                                sql_exp *e = n->data;
-                               append(exps, exp_ref(sql, e));
+                               append(exps, e=exp_ref(sql, e));
+                               set_ascending(e);
                        }
                        return exps;
                }
@@ -6292,9 +6296,12 @@ rel_select_exp(sql_query *query, sql_rel
                 */
                pexps = list_merge(pexps, exps_copy(sql, te), (fdup)NULL);
        }
+       int card = inner->card;
        if (rel && is_groupby(rel->op) && rel->flag) {
                list *gbe = rel->r;
                if (!list_empty(gbe)) {
+                       inner->card = CARD_AGGR;
+                       card = CARD_MULTI;
                        for (node *n=gbe->h; n; n = n->next) {
                                sql_exp *e = n->data;
                                if (rel->flag == 1 && is_atom(e->type) && 
a_no_name(&e->alias)) {
@@ -6319,6 +6326,7 @@ rel_select_exp(sql_query *query, sql_rel
                set_processed(rel);
        }
        rel = rel_project(sql->sa, rel, pexps);
+       rel->card = card;
 
        rel = rel_having_limits_nodes(query, rel, sn, ek, group_totals);
        return rel;
diff --git a/sql/server/rel_unnest.c b/sql/server/rel_unnest.c
--- a/sql/server/rel_unnest.c
+++ b/sql/server/rel_unnest.c
@@ -2390,6 +2390,32 @@ rewrite_empty_project(visitor *v, sql_re
 #define is_division(sf) (strcmp(sf->func->base.name, "sql_div") == 0)
 #define is_multiplication(sf) (strcmp(sf->func->base.name, "sql_mul") == 0)
 
+static sql_exp *
+exp_atom_set_type_null(visitor *v, sql_exp *el, sql_subtype *t)
+{
+       if (el->type == e_atom && !el->f && !el->r) {
+               sql_subtype *f = exp_subtype(el);
+               if ((!f || f->type->eclass == EC_ANY) && !el->l) { /* 
parameter, set type, or return ERR?? */
+                       sql_arg *a = sql_bind_paramnr(v->sql, el->flag);
+                       if (!a->type.type || a->type.type->eclass == EC_ANY) {
+                               a->type = *t;
+                               el->tpe = a->type;
+                               v->changes++;
+                               return el;
+                       }
+               } else if ((!f || f->type->eclass == EC_ANY) && el->l) { /* 
NULL? */
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to