Changeset: 876b180dc580 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=876b180dc580
Added Files:
sql/test/BugTracker-2020/Tests/ilike-matches.Bug-6864.sql
sql/test/BugTracker-2020/Tests/ilike-matches.Bug-6864.stable.err
sql/test/BugTracker-2020/Tests/ilike-matches.Bug-6864.stable.out
Modified Files:
buildtools/conf/Maddlog
configure.ag
gdk/gdk_batop.c
monetdb5/modules/mal/pcre.c
sql/server/rel_optimizer.c
sql/server/rel_unnest.c
sql/test/BugTracker-2016/Tests/memory-consumption-query-PLAN-25joins.Bug-3972.stable.out
sql/test/BugTracker-2020/Tests/All
Branch: default
Log Message:
Merged with Jun2020
diffs (truncated from 523 to 300 lines):
diff --git a/buildtools/conf/Maddlog b/buildtools/conf/Maddlog
--- a/buildtools/conf/Maddlog
+++ b/buildtools/conf/Maddlog
@@ -123,7 +123,7 @@ fi
case "$CL" in
'')
d=.
- while [ ! -f $d/vertoo.data -a ! -f $d/ChangeLog -a ! -f $d/ChangeLog.$tag
]; do
+ while [ ! -f $d/.bumpversion.cfg -a ! -f $d/ChangeLog -a ! -f
$d/ChangeLog.$tag ]; do
if [ $d -ef / ]; then
echo "$0: cannot find top directory of package" >&2
exit 1
diff --git a/configure.ag b/configure.ag
--- a/configure.ag
+++ b/configure.ag
@@ -131,7 +131,7 @@ AS_CASE([$CC],
# __GNUC_MINOR__, and __GNUC_PATCHLEVEL__ macros.
CC="$CC -no-gcc"])
-AS_IF([test -f "$srcdir"/vertoo.data],
+AS_IF([test -f "$srcdir"/.bumpversion.cfg],
[
# Developers compiling from Mercurial:
# default is --enable-strict --enable-assert --enable-debug
--disable-optimize --enable-developer --enable-profiler=auto
@@ -1989,15 +1989,15 @@ AM_CONDITIONAL([HAVE_LIDAR], [test "x$ha
dnl check for profiler library
AS_CASE([$enable_profiler],
- [no], [have_profiler=no],
+ [no], [],
[
PKG_CHECK_MODULES([PROFILER], [libprofiler],
- [have_profiler=yes],
- [have_profiler=no; why_not_profiler="(profiler library
not found)"])
- AS_VAR_IF([have_profiler], [yes], [
+ [enable_profiler=yes],
+ [enable_profiler=no; why_not_profiler="(profiler
library not found)"])
+ AS_VAR_IF([enable_profiler], [yes], [
AC_DEFINE([HAVE_LIBPROFILER], 1, [Define if you have
the profiler library])
AC_SUBST([PKG_PROFILER], [libprofiler])])])
-AM_CONDITIONAL([HAVE_LIBPROFILER], [test x$have_profiler != xno])
+AM_CONDITIONAL([HAVE_LIBPROFILER], [test enable_profiler != xno])
# checks for header files
@@ -2605,6 +2605,7 @@ for comp in \
'optimize ' \
'developer ' \
'sanitizer ' \
+ 'profiler ' \
; do
AS_VAR_COPY([dft], [dft_$comp])
AS_VAR_COPY([enable], [enable_$comp])
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -865,6 +865,15 @@ BATreplace(BAT *b, BAT *p, BAT *n, bool
return GDK_FAIL;
}
+ BATiter bi = bat_iterator(b);
+ BATiter ni = bat_iterator(n);
+ if (BATcount(b) == 0 ||
+ (b->tsorted && b->trevsorted &&
+ n->tsorted && n->trevsorted &&
+ ATOMcmp(b->ttype, BUNtail(bi, 0), BUNtail(ni, 0)) == 0)) {
+ return GDK_SUCCEED;
+ }
+
HASHdestroy(b);
OIDXdestroy(b);
IMPSdestroy(b);
@@ -881,8 +890,6 @@ BATreplace(BAT *b, BAT *p, BAT *n, bool
int (*atomcmp)(const void *, const void *) = ATOMcompare(b->ttype);
const void *nil = ATOMnilptr(b->ttype);
oid hseqend = b->hseqbase + BATcount(b);
- BATiter bi = bat_iterator(b);
- BATiter ni = bat_iterator(n);
bool anynil = false;
b->theap.dirty = true;
@@ -2127,8 +2134,29 @@ BATconstant(oid hseq, int tailtype, cons
((hge *) p)[i] = *(hge *) v;
break;
#endif
+ case TYPE_str:
+ /* insert the first value, then just copy the
+ * offset lots of times */
+ if (tfastins_nocheck(bn, 0, v, Tsize(bn)) !=
GDK_SUCCEED) {
+ BBPreclaim(bn);
+ return NULL;
+ }
+ char val[sizeof(var_t)];
+ memcpy(val, bn->theap.base, bn->twidth);
+ if (bn->twidth == 1 && n > 1) {
+ /* single byte value: we have a
+ * function for that */
+ memset(bn->theap.base + 1, val[0], n - 1);
+ } else {
+ char *p = bn->theap.base;
+ for (i = 1; i < n; i++) {
+ p += bn->twidth;
+ memcpy(p, val, bn->twidth);
+ }
+ }
+ break;
default:
- for (i = 0, n += i; i < n; i++)
+ for (i = 0; i < n; i++)
if (tfastins_nocheck(bn, i, v, Tsize(bn)) !=
GDK_SUCCEED) {
BBPreclaim(bn);
return NULL;
diff --git a/monetdb5/modules/mal/pcre.c b/monetdb5/modules/mal/pcre.c
--- a/monetdb5/modules/mal/pcre.c
+++ b/monetdb5/modules/mal/pcre.c
@@ -477,7 +477,7 @@ re_create(const char *pat, bool caseigno
} else if (*wp == esc) {
escaped = true;
} else if (*wp == '%') {
- n->len = (size_t) (wq - r->w);
+ n->len = (size_t) (wq - n->w);
while (wp[1] == '%')
wp++;
if (wp[1]) {
@@ -507,7 +507,7 @@ re_create(const char *pat, bool caseigno
} else if ((unsigned char) *p == esc) {
escaped = true;
} else if (*p == '%') {
- n->len = (size_t) (q - r->k);
+ n->len = (size_t) (q - n->k);
while (p[1] == '%')
p++;
if (p[1]) {
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
@@ -1265,10 +1265,7 @@ exp_rename(mvc *sql, sql_exp *e, sql_rel
sql->errstr[0] = 0;
if (!e && exp_is_atom(ne))
return ne;
- ne = exp_ref(sql, e);
- if (is_outerjoin(t->op)) /* TODO if e is found on the left
side of the left join or the right of the right join the has_no_nil flag can be
kept */
- set_has_nil(ne);
- return ne;
+ return exp_ref(sql ,e);
case e_cmp:
if (e->flag == cmp_or || e->flag == cmp_filter) {
list *l = exps_rename(sql, e->l, f, t);
@@ -2440,21 +2437,58 @@ rel_distinct_project2groupby(mvc *sql, s
(l->op == op_select || l->op == op_semi) && exps_unique(sql, rel,
rel->exps))
set_nodistinct(rel);
- /* rewrite distinct project ( join(p,f) [ p.pk = f.fk] ) [ p.pk ] ->
- * project(p)[p.pk]
- */
+ /* rewrite distinct project ( join(p,f) [ p.pk = f.fk ] ) [ p.pk ]
+ * into project( (semi)join(p,f) [ p.pk = f.fk ] ) [ p.pk ] */
if (rel->op == op_project && rel->l && !rel->r /* no order by */ &&
need_distinct(rel) &&
- l && l->op == op_join && rel_is_join_on_pkey(l) /* [ pk == fk ] */)
{
- sql_rel *j = l;
- sql_rel *p = j->l;
- sql_exp *je = l->exps->h->data, *le = je->l;
-
- if (exps_find_exp(rel->exps, le)) { /* rel must have the same
primary key on the projection list */
- int pside = (rel_find_exp(p, le) != NULL)?1:0;
-
- p = (pside)?j->l:j->r;
- rel->l = rel_dup(p);
- rel_destroy(j);
+ l && (is_select(l->op) || l->op == op_join) &&
rel_is_join_on_pkey(l) /* [ pk == fk ] */) {
+ sql_exp *found = NULL, *pk = NULL;
+ bool all_exps_atoms = true;
+
+ for (node *m = l->exps->h ; m ; m = m->next) { /* find a
primary key join */
+ sql_exp *je = (sql_exp *) m->data;
+ sql_exp *le = je->l, *re = je->r;
+
+ if (find_prop(le->p, PROP_HASHCOL)) { /* le is the
primary key */
+ all_exps_atoms = true;
+
+ for (node *n = rel->exps->h; n &&
all_exps_atoms; n = n->next) {
+ sql_exp *e = (sql_exp *) n->data;
+
+ if (exp_match(e, le) || exp_refers(e,
le))
+ found = e;
+ else if (e->card > CARD_ATOM)
+ all_exps_atoms = false;
+ }
+ pk = le;
+ }
+ if (!found && find_prop(re->p, PROP_HASHCOL)) { /* re
is the primary key */
+ all_exps_atoms = true;
+
+ for (node *n = rel->exps->h; n &&
all_exps_atoms; n = n->next) {
+ sql_exp *e = (sql_exp *) n->data;
+
+ if (exp_match(e, re) || exp_refers(e,
re))
+ found = e;
+ else if (e->card > CARD_ATOM)
+ all_exps_atoms = false;
+ }
+ pk = re;
+ }
+ }
+
+ if (all_exps_atoms && found) { /* rel must have the same
primary key on the projection list */
+ /* if the join has no multiple references it can be
re-written into a semijoin */
+ if (l->op == op_join && !(rel_is_ref(l)) &&
list_length(rel->exps) == 1) { /* other expressions may come from the other
side */
+ if (rel_find_exp(l->r, pk)) {
+ sql_rel *temp = l->l;
+ l->l = l->r;
+ l->r = temp;
+
+ l->op = op_semi;
+ } else if (rel_find_exp(l->l, pk)) {
+ l->op = op_semi;
+ }
+ }
*changes = 1;
set_nodistinct(rel);
return rel;
@@ -3988,28 +4022,73 @@ rel_merge_rse(mvc *sql, sql_rel *rel, in
return rel;
}
-/* find in the list of expression an expression which uses e */
+static sql_exp *list_exps_uses_exp(list *exps, const char *rname, const char
*name);
+
+static sql_exp*
+exp_uses_exp(sql_exp *e, const char *rname, const char *name)
+{
+ sql_exp *res = NULL;
+
+ switch (e->type) {
+ case e_psm:
+ case e_atom:
+ break;
+ case e_convert:
+ return exp_uses_exp(e->l, rname, name);
+ case e_column: {
+ if (e->l && rname && strcmp(e->l, rname) == 0 &&
+ e->r && name && strcmp(e->r, name) == 0)
+ return e;
+ if (!e->l && !rname &&
+ e->r && name && strcmp(e->r, name) == 0)
+ return e;
+ } break;
+ case e_func:
+ case e_aggr: {
+ if (e->l)
+ return list_exps_uses_exp(e->l, rname, name);
+ } break;
+ case e_cmp: {
+ if (e->flag == cmp_in || e->flag == cmp_notin) {
+ if ((res = exp_uses_exp(e->l, rname, name)))
+ return res;
+ return list_exps_uses_exp(e->r, rname, name);
+ } else if (e->flag == cmp_or || e->flag == cmp_filter) {
+ if ((res = list_exps_uses_exp(e->l, rname,
name)))
+ return res;
+ return list_exps_uses_exp(e->r, rname, name);
+ } else {
+ if ((res = exp_uses_exp(e->l, rname, name)))
+ return res;
+ if ((res = exp_uses_exp(e->r, rname, name)))
+ return res;
+ if (e->f)
+ return exp_uses_exp(e->f, rname, name);
+ }
+ } break;
+ }
+ return NULL;
+}
+
static sql_exp *
-exps_uses_exp( list *exps, sql_exp *e)
-{
- node *n;
- const char *rname = exp_relname(e);
- const char *name = exp_name(e);
+list_exps_uses_exp(list *exps, const char *rname, const char *name)
+{
+ sql_exp *res = NULL;
if (!exps)
return NULL;
-
- for ( n = exps->h; n; n = n->next) {
- sql_exp *u = n->data;
-
- if (u->l && rname && strcmp(u->l, rname) == 0 &&
- u->r && name && strcmp(u->r, name) == 0)
- return u;
- if (!u->l && !rname &&
- u->r && name && strcmp(u->r, name) == 0)
- return u;
- }
- return NULL;
+ for (node *n = exps->h; n && !res; n = n->next) {
+ sql_exp *e = n->data;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list