Changeset: c8afbe243112 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c8afbe243112 Modified Files: NT/monetdb_config.h.in configure.ag gdk/gdk_batop.c gdk/gdk_posix.c monetdb5/extras/rapi/rapi.c sql/backends/monet5/sql_rank.c sql/include/sql_catalog.h sql/include/sql_relation.h sql/server/rel_dump.c sql/server/rel_exp.c sql/server/rel_optimizer.c sql/server/rel_rel.c sql/server/rel_select.c sql/server/rel_unnest.c sql/server/sql_semantic.c sql/storage/bat/bat_logger.c sql/test/BugTracker-2016/Tests/memory-consumption-query-PLAN-25joins.Bug-3972.stable.out sql/test/BugTracker-2018/Tests/count_from_commented_function_signatures.Bug-6542.stable.out sql/test/analytics/Tests/analytics01.stable.out sql/test/mergetables/Tests/sqlsmith-exists.sql sql/test/mergetables/Tests/sqlsmith-exists.stable.out sql/test/subquery/Tests/subquery3.sql sql/test/subquery/Tests/subquery3.stable.err Branch: gdk_tracer Log Message:
Merge with default diffs (truncated from 1312 to 300 lines): diff --git a/NT/monetdb_config.h.in b/NT/monetdb_config.h.in --- a/NT/monetdb_config.h.in +++ b/NT/monetdb_config.h.in @@ -394,9 +394,6 @@ /* Define if semtimedop exists */ /* #undef HAVE_SEMTIMEDOP */ -/* Define to 1 if you have the `setenv' function. */ -/* #undef HAVE_SETENV */ - /* Define to 1 if you have the `setsid' function. */ /* #undef HAVE_SETSID */ diff --git a/configure.ag b/configure.ag --- a/configure.ag +++ b/configure.ag @@ -2427,7 +2427,6 @@ AC_CHECK_FUNCS([\ posix_fallocate \ posix_madvise \ putenv \ - setenv \ setsid \ shutdown \ sigaction \ diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c --- a/gdk/gdk_batop.c +++ b/gdk/gdk_batop.c @@ -840,6 +840,10 @@ BATdel(BAT *b, BAT *d) gdk_return BATreplace(BAT *b, BAT *p, BAT *n, bool force) { + lng t0 = 0; + + ALGODEBUG t0 = GDKusec(); + if (b == NULL || b->ttype == TYPE_void || p == NULL || n == NULL) { return GDK_SUCCEED; } @@ -988,6 +992,87 @@ BATreplace(BAT *b, BAT *p, BAT *n, bool #endif } } + } else if (BATtdense(p)) { + oid updid = BUNtoid(p, 0); + + if (updid < b->hseqbase || updid + BATcount(p) > hseqend) { + GDKerror("BATreplace: id out of range\n"); + return GDK_FAIL; + } + updid -= b->hseqbase; + if (!force && updid < b->batInserted) { + GDKerror("BATreplace: updating committed value\n"); + return GDK_FAIL; + } + + /* we copy all of n, so if there are nils in n we get + * nils in b (and else we don't know) */ + b->tnil = n->tnil; + /* we may not copy over all of b, so we only know that + * there are no nils in b afterward if there weren't + * any in either b or n to begin with */ + b->tnonil &= n->tnonil; + if (n->ttype == TYPE_void) { + assert(b->ttype == TYPE_oid); + oid *o = Tloc(b, updid); + if (is_oid_nil(n->tseqbase)) { + /* we may or may not overwrite the old + * min/max values */ + BATrmprop(b, GDK_MAX_VALUE); + BATrmprop(b, GDK_MIN_VALUE); + for (BUN i = 0, j = BATcount(p); i < j; i++) + o[i] = oid_nil; + b->tnil = true; + } else { + oid v = n->tseqbase; + /* we know min/max of n, so we know + * the new min/max of b if those of n + * are smaller/larger than the old */ + if (minprop && v <= minprop->v.val.oval) + BATsetprop(b, GDK_MIN_VALUE, TYPE_oid, &v); + else + BATrmprop(b, GDK_MIN_VALUE); + for (BUN i = 0, j = BATcount(p); i < j; i++) + o[i] = v++; + if (maxprop && --v >= maxprop->v.val.oval) + BATsetprop(b, GDK_MAX_VALUE, TYPE_oid, &v); + else + BATrmprop(b, GDK_MAX_VALUE); + } + } else { + /* if the extremes of n are at least as + * extreme as those of b, we can replace b's + * min/max, else we don't know what b's new + * min/max are*/ + PROPrec *prop; + if (maxprop != NULL && + (prop = BATgetprop(n, GDK_MAX_VALUE)) != NULL && + atomcmp(VALptr(&maxprop->v), VALptr(&prop->v)) <= 0) + BATsetprop(b, GDK_MAX_VALUE, b->ttype, VALptr(&prop->v)); + else + BATrmprop(b, GDK_MAX_VALUE); + if (minprop != NULL && + (prop = BATgetprop(n, GDK_MIN_VALUE)) != NULL && + atomcmp(VALptr(&minprop->v), VALptr(&prop->v)) >= 0) + BATsetprop(b, GDK_MIN_VALUE, b->ttype, VALptr(&prop->v)); + else + BATrmprop(b, GDK_MIN_VALUE); + memcpy(Tloc(b, updid), Tloc(n, 0), + BATcount(p) * b->twidth); + } + if (BATcount(p) == BATcount(b)) { + /* if we replaced all values of b by values + * from n, we can also copy the min/max + * properties */ + if ((minprop = BATgetprop(n, GDK_MIN_VALUE)) != NULL) + BATsetprop(b, GDK_MIN_VALUE, b->ttype, VALptr(&minprop->v)); + if ((maxprop = BATgetprop(n, GDK_MAX_VALUE)) != NULL) + BATsetprop(b, GDK_MAX_VALUE, b->ttype, VALptr(&maxprop->v)); + if (BATtdense(n)) { + /* replaced all of b with a dense sequence */ + BATtseqbase(b, n->tseqbase); + } + } } else { for (BUN i = 0, j = BATcount(p); i < j; i++) { oid updid = BUNtoid(p, i); @@ -1078,6 +1163,11 @@ BATreplace(BAT *b, BAT *p, BAT *n, bool } } } + ALGODEBUG fprintf(stderr, + "#%s: BATreplace(" ALGOBATFMT "," ALGOBATFMT "," ALGOBATFMT ") " LLFMT " usec\n", + MT_thread_getname(), + ALGOBATPAR(b), ALGOBATPAR(p), ALGOBATPAR(n), + GDKusec() - t0); return GDK_SUCCEED; bunins_failed: diff --git a/gdk/gdk_posix.c b/gdk/gdk_posix.c --- a/gdk/gdk_posix.c +++ b/gdk/gdk_posix.c @@ -41,12 +41,6 @@ # include <sys/user.h> #endif -#ifdef NDEBUG -#ifndef NVALGRIND -#define NVALGRIND NDEBUG -#endif -#endif - #if defined(__GNUC__) && defined(HAVE_VALGRIND) #include <valgrind.h> #else @@ -69,30 +63,6 @@ #define O_CLOEXEC 0 #endif -/* DDALERT: AIX4.X 64bits needs HAVE_SETENV==0 due to a AIX bug, but - * it probably isn't detected so by configure */ - -#ifndef HAVE_SETENV -int -setenv(const char *name, const char *value, int overwrite) -{ - int ret = 0; - - if (overwrite || getenv(name) == NULL) { - char *p = GDKmalloc(2 + strlen(name) + strlen(value)); - - if (p == NULL) - return -1; - strcpy(p, name); - strcat(p, "="); - strcat(p, value); - ret = putenv(p); - /* GDKfree(p); LEAK INSERTED DUE TO SOME WEIRD CRASHES */ - } - return ret; -} -#endif - /* Crude VM buffer management that keep a list of all memory mapped * regions. * diff --git a/monetdb5/extras/rapi/rapi.c b/monetdb5/extras/rapi/rapi.c --- a/monetdb5/extras/rapi/rapi.c +++ b/monetdb5/extras/rapi/rapi.c @@ -105,7 +105,7 @@ static char *RAPIinitialize(void) { char *e; // set R_HOME for packages etc. We know this from our configure script - setenv("R_HOME", RHOME, TRUE); + putenv("R_HOME=" RHOME); // set some command line arguments { diff --git a/sql/backends/monet5/sql_rank.c b/sql/backends/monet5/sql_rank.c --- a/sql/backends/monet5/sql_rank.c +++ b/sql/backends/monet5/sql_rank.c @@ -558,57 +558,90 @@ SQLcume_dist(Client cntxt, MalBlkPtr mb, (void)cntxt; if (isaBatType(getArgType(mb, pci, 1))) { bat *res = getArgReference_bat(stk, pci, 0); - BAT *b = BATdescriptor(*getArgReference_bat(stk, pci, 1)), *p, *r; - BUN cnt; - int j; - dbl *rb, *rp, *end, cnt_cast; - bit *np; + BAT *b = BATdescriptor(*getArgReference_bat(stk, pci, 1)), *p, *o, *r; + BUN ncnt, j = 0; + bit *np, *no, *bo1, *bo2, *end; + dbl *rb, *rp, cnt_cast, nres; if (!b) throw(SQL, "sql.cume_dist", SQLSTATE(HY005) "Cannot access column descriptor"); - cnt = BATcount(b); - cnt_cast = (dbl) cnt; - voidresultBAT(r, TYPE_dbl, cnt, b, "sql.cume_dist"); + voidresultBAT(r, TYPE_dbl, BATcount(b), b, "sql.cume_dist"); rb = rp = (dbl*)Tloc(r, 0); - end = rp + cnt; if (isaBatType(getArgType(mb, pci, 2))) { if (isaBatType(getArgType(mb, pci, 3))) { p = BATdescriptor(*getArgReference_bat(stk, pci, 2)); - if (!p) { + o = BATdescriptor(*getArgReference_bat(stk, pci, 3)); + if (!p || !o) { BBPunfix(b->batCacheid); + if (p) BBPunfix(p->batCacheid); + if (o) BBPunfix(o->batCacheid); throw(SQL, "sql.cume_dist", SQLSTATE(HY005) "Cannot access column descriptor"); } np = (bit*)Tloc(p, 0); - for(j=0; rp<end; j++, np++, rp++) { + end = np + BATcount(p); + bo1 = bo2 = no = (bit*)Tloc(o, 0); + + for (; np<end; np++, no++) { if (*np) { - for(; rb<rp; rb++) - *rb = j / cnt_cast; + ncnt = no - bo2; + cnt_cast = (dbl) ncnt; + for (; bo2<no; bo2++) { + if (*bo2) { + j += (bo2 - bo1); + nres = j / cnt_cast; + for (; bo1 < bo2; bo1++, rb++) + *rb = nres; + } + } + for (; bo1 < bo2; bo1++, rb++) + *rb = 1; } } - for(; rb<rp; rb++) + ncnt = no - bo2; + cnt_cast = (dbl) ncnt; + for (; bo2<no; bo2++) { + if (*bo2) { + j += (bo2 - bo1); + nres = j / cnt_cast; + for (; bo1 < bo2; bo1++, rb++) + *rb = nres; + } + } + for (; bo1 < bo2; bo1++, rb++) *rb = 1; } else { /* single value, ie no ordering */ - p = BATdescriptor(*getArgReference_bat(stk, pci, 2)); - if (!p) { + rp = rb + BATcount(b); + for (; rb<rp; rb++) + *rb = 1; + } + } else { /* single value, ie no partitions */ + if (isaBatType(getArgType(mb, pci, 3))) { + o = BATdescriptor(*getArgReference_bat(stk, pci, 3)); + if (!o) { BBPunfix(b->batCacheid); throw(SQL, "sql.cume_dist", SQLSTATE(HY005) "Cannot access column descriptor"); } - np = (bit*)Tloc(p, 0); - for(j=0; rp<end; j++, np++, rp++) { - if (*np) { - for(; rb<rp; rb++) - *rb = j / cnt_cast; + bo1 = bo2 = (bit*)Tloc(o, 0); + no = bo1 + BATcount(b); + cnt_cast = (dbl) BATcount(b); + for (; bo2<no; bo2++) { + if (*bo2) { + j += (bo2 - bo1); + nres = j / cnt_cast; + for (; bo1 < bo2; bo1++, rb++) + *rb = nres; } } - for(; rb<rp; rb++) _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list