Changeset: 3fbb9d9ac622 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/3fbb9d9ac622
Modified Files:
        sql/server/rel_statistics.c
Branch: persistent_sketches
Log Message:

merged with default


diffs (truncated from 854 to 300 lines):

diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -356,8 +356,10 @@ This package contains the files needed t
 Summary: MonetDB ODBC driver
 Group: Applications/Databases
 Requires: %{name}-client-lib%{?_isa} = %{version}-%{release}
+%if (0%{?fedora} < 45)
 Requires(post): %{_bindir}/odbcinst
 Requires(postun): %{_bindir}/odbcinst
+%endif
 
 %description client-odbc
 MonetDB is a database management system that is developed from a
@@ -367,6 +369,7 @@ accelerators.  It also has an SQL front 
 
 This package contains the MonetDB ODBC driver.
 
+%if (0%{?fedora} < 45)
 %post client-odbc
 # install driver if first install of package or if driver not installed yet
 if [ "$1" -eq 1 ] || ! odbcinst -d -q -n MonetDB >& /dev/null; then
@@ -384,13 +387,22 @@ fi
 if [ "$1" -eq 0 ]; then
     odbcinst -u -d -n MonetDB
 fi
+%endif
 
 %files client-odbc
 %license LICENSE
 %defattr(-,root,root)
+%if (0%{?fedora} >= 45)
+%dir %{_prefix}/lib/odbc
+%dir %{_prefix}/lib/odbc/odbcinst.d
+%{_prefix}/lib/odbc/odbcinst.d/30-monetdb.ini
+%{_libdir}/odbc/libMonetODBC.so
+%{_libdir}/odbc/libMonetODBCs.so
+%else
 %{_libdir}/libMonetODBC.so
 %{_libdir}/libMonetODBCs.so
 %endif
+%endif
 
 %if %{without compat}
 %package client-tests
@@ -1020,6 +1032,18 @@ rm "${RPM_BUILD_ROOT}"%{_sysconfdir}/log
 rm "${RPM_BUILD_ROOT}"%{_sysusersdir}/monetdb.conf
 rm "${RPM_BUILD_ROOT}"%{_tmpfilesdir}/monetdbd.conf
 rm "${RPM_BUILD_ROOT}"%{_unitdir}/monetdbd.service
+%else
+%if (0%{?fedora} >= 45)
+mkdir -p "${RPM_BUILD_ROOT}"%{_prefix}/lib/odbc/odbcinst.d
+mkdir -p "${RPM_BUILD_ROOT}"%{_libdir}/odbc
+cat > "${RPM_BUILD_ROOT}"%{_prefix}/lib/odbc/odbcinst.d/30-monetdb.ini <<\EOF
+[MonetDB]
+Description = ODBC for MonetDB
+Driver = libMonetODBC.so
+Setup = libMonetODBCs.so
+EOF
+mv "${RPM_BUILD_ROOT}"%{_libdir}/libMonetODBC*.so 
"${RPM_BUILD_ROOT}"%{_libdir}/odbc
+%endif
 %endif
 
 %changelog
diff --git a/monetdb5/mal/mal_pipelines.c b/monetdb5/mal/mal_pipelines.c
--- a/monetdb5/mal/mal_pipelines.c
+++ b/monetdb5/mal/mal_pipelines.c
@@ -284,6 +284,11 @@ runMALpipelines(Client cntxt, MalBlkPtr 
        if (!s)
                throw(MAL, "pipelines", SQLSTATE(HY013) MAL_MALLOC_FAIL);
        MT_lock_set(&pipelineLock);
+       if (ATOMIC_GET(&exiting)) {
+               MT_lock_unset(&pipelineLock);
+               return MAL_SUCCEED;
+       }
+
        bool profiler = cntxt->sqlprofiler;
        *s = (Pipelines) {
                .mb = mb,
@@ -332,9 +337,13 @@ runMALpipelines(Client cntxt, MalBlkPtr 
                }
                if (j) {
                        /* here we should wait */
-       MT_lock_unset(&pipelineLock);
+                       MT_lock_unset(&pipelineLock);
                        MT_sleep_ms(100);
-       MT_lock_set(&pipelineLock);
+                       MT_lock_set(&pipelineLock);
+                       if (ATOMIC_GET(&exiting)) {
+                               MT_lock_unset(&pipelineLock);
+                               return MAL_SUCCEED;
+                       }
                }
        }
 
@@ -345,6 +354,10 @@ runMALpipelines(Client cntxt, MalBlkPtr 
        MT_sema_destroy(&s->s);
        MT_lock_destroy(&s->l);
        MT_lock_set(&pipelineLock);
+       if (ATOMIC_GET(&exiting)) {
+               MT_lock_unset(&pipelineLock);
+               return MAL_SUCCEED;
+       }
        bool has_sink = (s->sink != 0);
        str err = s->error;
        if (err) {
diff --git a/monetdb5/modules/mal/heapn.c b/monetdb5/modules/mal/heapn.c
--- a/monetdb5/modules/mal/heapn.c
+++ b/monetdb5/modules/mal/heapn.c
@@ -1275,6 +1275,7 @@ extern void BATswap_heaps(BAT *u, BAT *b
                                                                \
                for(; i<cnt; i++)               \
                        ri[pi[i]] = bi[si[i]];  \
+               handled = true;                 \
        }
 
 #define aproject(T,w,Toff) \
@@ -1284,6 +1285,7 @@ extern void BATswap_heaps(BAT *u, BAT *b
                                                                \
                for(; i<cnt; i++)               \
                        ri[pi[i]] = bi[si[i]];  \
+               handled = true;                 \
        }
 
 #define aproject_(T) \
@@ -1300,6 +1302,7 @@ extern void BATswap_heaps(BAT *u, BAT *b
                                        err = 1; \
                } \
                bat_iterator_end(&bi); \
+               handled = true;                 \
        }
 
 static str
@@ -1402,6 +1405,7 @@ HEAPproject(Client ctx, bat *rid, bat *p
                oid *si = Tloc(S, 0);
                size_t i = 0;
                BUN cnt = BATcount(P);
+               bool handled = false;
 
                project(bte)
                project(sht)
@@ -1415,7 +1419,7 @@ HEAPproject(Client ctx, bat *rid, bat *p
                project(flt)
                project(dbl)
                project(uuid)
-               if (local_storage) {
+               if (local_storage && !handled) {
        //              aproject_(str)
        if (ATOMstorage(tt) == TYPE_str) { \
                BATiter bi = bat_iterator(b); \
@@ -1433,13 +1437,15 @@ HEAPproject(Client ctx, bat *rid, bat *p
                                err = 1; \
                } \
                bat_iterator_end(&bi); \
+               handled = true;                 \
        }
-               } else {
+               } else if(!handled) {
                        aproject(str,1,uint8_t)
                        aproject(str,2,uint16_t)
                        aproject(str,4,uint32_t)
                        aproject(str,8,var_t)
                }
+               assert(handled);
                if (!err) {
                        if (!private)
                                pipeline_lock2(r);
diff --git a/sql/backends/monet5/rel_physical.c 
b/sql/backends/monet5/rel_physical.c
--- a/sql/backends/monet5/rel_physical.c
+++ b/sql/backends/monet5/rel_physical.c
@@ -451,6 +451,8 @@ find_payload_exps(mvc *sql, list **exps_
                else
                        exps = list_merge(list_dup(exps, NULL), p->attr, NULL);
        }
+       if (is_topn(p->op) && p->l)
+               p = p->l;
        if (is_select(p->op) || is_join(p->op))
                exps = NULL;
        if (exps_hsh) {
diff --git a/sql/backends/monet5/rel_pphash.c b/sql/backends/monet5/rel_pphash.c
--- a/sql/backends/monet5/rel_pphash.c
+++ b/sql/backends/monet5/rel_pphash.c
@@ -803,9 +803,13 @@ rel2bin_oahash_cart(backend *be, sql_rel
        assert(stmts_ht->type == st_list && stmts_prb_res->type == st_list);
 
        stmt *rowrepeat = stmts_ht->op4.lval->h->data;
-       stmt *setrepeat = stmts_prb_res->op4.lval->h->data;
-       assert(rowrepeat && setrepeat); /* must find */
+       stmt *setrepeat = 
!list_empty(stmts_prb_res->op4.lval)?stmts_prb_res->op4.lval->h->data:NULL;
+       prop *count = find_prop(rel->p, PROP_COUNT);
+       (void)count;
+       assert(rowrepeat && (setrepeat || (count && !count->value.lval))); /* 
must find */
 
+       if (!setrepeat)
+               setrepeat = stmt_bat_new(be, sql_fetch_localtype(TYPE_bte), 0);
        /* Check for single: either rel->r is single or rel->l is empty. */
        if (rel->single && list_empty(rel->exps)) {
                if (rowrepeat->nrcols > 0) {
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
@@ -838,6 +838,12 @@ setVariable(Client cntxt, MalBlkPtr mb, 
                                        throw(SQL, "sql.setVariable", 
SQLSTATE(HY013) MAL_MALLOC_FAIL);
                        } else if (!sqlvar_set_string(m->session->sa, 
find_global_var(m, s, varname), newopt))
                                throw(SQL, "sql.setVariable", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
+               } else if (strcmp(s->base.name, "sys") == 0 &&
+                                  strcmp(varname, "pipeline") == 0) {
+                       bit val = *getArgReference_bit(stk, pci, 4);
+                       if (is_bit_nil(val))
+                               throw(SQL, "sql.setVariable", SQLSTATE(42000) 
"Variable '%s.%s' cannot be NULL", sname, varname);
+                       cntxt->qryctx.pipeline_mode = (bool) val;
                } else {
                        ValPtr ptr = &stk->stk[getArg(pci, 4)];
 
diff --git a/sql/server/rel_optimize_sel.c b/sql/server/rel_optimize_sel.c
--- a/sql/server/rel_optimize_sel.c
+++ b/sql/server/rel_optimize_sel.c
@@ -1306,6 +1306,8 @@ push_up_join_exps( mvc *sql, sql_rel *re
        if (rel_is_ref(rel))
                return NULL;
 
+       if (is_single(rel))
+               return NULL;
        switch(rel->op) {
        case op_join: {
                sql_rel *rl = rel->l;
@@ -1614,6 +1616,7 @@ find_fk( mvc *sql, list *rels, list *exp
                                                i->p = NULL;
                                                je = exp_compare(sql->sa, i, t, 
cmp_equal);
                                        }
+                                       //t->p = prop_create(sql->sa, 
PROP_HASHCOL, NULL);
 
                                        /* Remove all join expressions */
                                        for (n = eje->h; n; n = n->next) {
@@ -2819,8 +2822,12 @@ exp_selectivity(visitor *v, sql_exp *e, 
                if (!is_semantics(e) || !has_nil(el) || !has_nil(er)) {
                        BUN lu = lv, ru = rv, nlv = lv, nrv = rv;
                        prop *up = NULL;
+                       if (el->type == e_column && (is_select(l->op) || 
is_basetable(l->op)))
+                               el = rel_find_exp(l, el);
                        if ((up = find_prop(el->p, PROP_NUNIQUES)))
                                lu = (BUN) up->value.dval;
+                       if (er->type == e_column && (is_select(r->op) || 
is_basetable(r->op)))
+                               er = rel_find_exp(r, er);
                        if ((up = find_prop(er->p, PROP_NUNIQUES)))
                                ru = (BUN) up->value.dval;
                        if (is_unique(el) || (is_unique(er) && runique)) {
@@ -4038,8 +4045,6 @@ rel_join_order_(visitor *v, sql_rel *rel
        }
        if (is_join(rel->op))
                rel = reorder_join(v, rel);
-       if (rel && v->opt >= 0)
-               rel->opt = v->opt;
        return rel;
 }
 
diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c
--- a/sql/server/rel_optimizer.c
+++ b/sql/server/rel_optimizer.c
@@ -108,6 +108,11 @@ rel_unionize_mt_tables_munion(visitor *v
        /* create the munion */
        sql_rel *mu = rel_setop_n_ary(v->sql->sa, rels, op_munion);
        rel_setop_n_ary_set_exps(v->sql, mu, rel_projections(v->sql, mt, NULL, 
1, 1), true);
+       for(node *n = mu->exps->h; n; n = n->next) {
+               sql_exp *e = n->data;
+               e->unique = 0;
+       }
+
        set_processed(mu);
 
        return mu;
@@ -413,8 +418,11 @@ merge_table_prune_and_unionize(visitor *
                        if (tables->cnt == 1) {
                                nrel = rel_wrap_select_around_mt_child(v, 
tables->h->data, info);
                        } else {
-                               //nrel = rel_unionize_mt_tables_balanced(v, 
mt_rel, tables, info);
                                nrel = rel_setop_n_ary(v->sql->sa, tables, 
op_munion);
+                               for(node *n = nrel->exps->h; n; n = n->next) {
+                                       sql_exp *e = n->data;
+                                       e->unique = 0;
+                               }
                        }
                } else if (mvc_debug_on(v->sql, 32)) {
                        for (node *n = tables->h; n ; n = n->next) {
@@ -433,6 +441,10 @@ merge_table_prune_and_unionize(visitor *
                                if (nrel) {
                                        nrel = rel_setop_n_ary(v->sql->sa, 
append(append(sa_list(v->sql->sa), nrel), next), op_munion);
                                        rel_setop_n_ary_set_exps(v->sql, nrel, 
rel_projections(v->sql, mt_rel, NULL, 1, 1), true);
+                                       for(node *n = nrel->exps->h; n; n = 
n->next) {
+                                               sql_exp *e = n->data;
+                                               e->unique = 0;
+                                       }
                                        set_processed(nrel);
                                } else {
                                        nrel = next;
diff --git a/sql/server/rel_statistics.c b/sql/server/rel_statistics.c
--- a/sql/server/rel_statistics.c
+++ b/sql/server/rel_statistics.c
@@ -1300,9 +1300,8 @@ rel_get_statistics(visitor *v, global_pr
 run_optimizer
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to