Changeset: 019c9ae2e4a3 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/019c9ae2e4a3
Branch: default
Log Message:
merge
diffs (truncated from 2540 to 300 lines):
diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -754,3 +754,4 @@ 97e76b882f9fb28327393d21708fb22f2f6c22f1
f458e1c71c73d6bd9636369c1406eadb74f016bf Jan2022_9
f458e1c71c73d6bd9636369c1406eadb74f016bf Jan2022_SP1_release
00463fdd0d51d7ce058549a82bc74efaea6035a2 Jul2021_15
+00463fdd0d51d7ce058549a82bc74efaea6035a2 Jul2021_SP3_release
diff --git a/common/utils/msabaoth.c b/common/utils/msabaoth.c
--- a/common/utils/msabaoth.c
+++ b/common/utils/msabaoth.c
@@ -612,14 +612,26 @@ msab_pickSecret(char **generated_secret)
}
}
#else
- (void)bin_secret;
- if (generated_secret)
- // do not return an error, just continue without a secret
- *generated_secret = NULL;
- free(secret);
- return NULL;
+ int rfd = open("/dev/urandom", O_RDONLY);
+ if (rfd >= 0) {
+ ssize_t nr;
+ for (size_t n = 0; n < sizeof(bin_secret); n += nr) {
+ nr = read(rfd, bin_secret + n, sizeof(bin_secret) - n);
+ if (nr < 0) {
+ free(secret);
+ return strdup("reading /dev/urandom failed");
+ }
+ }
+ close(rfd);
+ } else {
+ (void)bin_secret;
+ if (generated_secret)
+ // do not return an error, just continue without a
secret
+ *generated_secret = NULL;
+ free(secret);
+ return NULL;
+ }
#endif
-#if defined(HAVE_GETENTROPY) || defined(HAVE_RAND_S)
int fd;
FILE *f;
for (size_t i = 0; i < sizeof(bin_secret); i++) {
@@ -659,7 +671,6 @@ msab_pickSecret(char **generated_secret)
else
free(secret);
return NULL;
-#endif
}
/**
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -775,6 +775,8 @@ typedef struct BAT {
batTransient:1; /* should the BAT persist on disk? */
uint8_t /* adjacent bit fields are packed together (if they fit) */
batRestricted:2; /* access privileges */
+ uint16_t /* adjacent bit fields are packed together (if they fit) */
+ selcnt:10; /* how often used in equi select without hash */
role_t batRole; /* role of the bat */
uint16_t unused; /* value=0 for now (sneakily used by mat.c) */
int batSharecnt; /* incoming view count */
diff --git a/gdk/gdk_calc_convert.c b/gdk/gdk_calc_convert.c
--- a/gdk/gdk_calc_convert.c
+++ b/gdk/gdk_calc_convert.c
@@ -443,7 +443,7 @@ convert_##TYPE1##_##TYPE2(const TYPE1 *s
dst[i] = TYPE2##_nil; \
nils++; \
} else { \
- long double m = (long double) v * mul; \
+ ldouble m = (ldouble) v * mul; \
dst[i] = (TYPE2) rounddbl(m); \
if ((is_##TYPE2##_nil(dst[i]) || \
(precision && \
@@ -467,7 +467,7 @@ convert_##TYPE1##_##TYPE2(const TYPE1 *s
dst[i] = TYPE2##_nil; \
nils++; \
} else { \
- long double m = (long double) v * mul; \
+ ldouble m = (ldouble) v * mul; \
dst[i] = (TYPE2) rounddbl(m); \
if ((is_##TYPE2##_nil(dst[i]) || \
(precision && \
diff --git a/gdk/gdk_calc_muldiv.c b/gdk/gdk_calc_muldiv.c
--- a/gdk/gdk_calc_muldiv.c
+++ b/gdk/gdk_calc_muldiv.c
@@ -360,7 +360,7 @@ mul_##TYPE1##_##TYPE2##_##TYPE3(
\
dst[k] = TYPE3##_nil; \
nils++; \
} else { \
- long double m = lft[i] * (long double) rgt[j]; \
+ ldouble m = lft[i] * (ldouble) rgt[j]; \
dst[k] = (TYPE3) rounddbl(m); \
} \
} \
@@ -382,7 +382,7 @@ mul_##TYPE1##_##TYPE2##_##TYPE3(
\
dst[k] = TYPE3##_nil; \
nils++; \
} else { \
- long double m = lft[i] * (long double) rgt[j]; \
+ ldouble m = lft[i] * (ldouble) rgt[j]; \
dst[k] = (TYPE3) rounddbl(m); \
} \
} \
@@ -2674,7 +2674,7 @@ div_##TYPE1##_##TYPE2##_##TYPE3(
\
dst[k] = TYPE3##_nil; \
nils++; \
} else { \
- dst[k] = (TYPE3) rounddbl(lft[i] /
(long double) rgt[j]); \
+ dst[k] = (TYPE3) rounddbl(lft[i] /
(ldouble) rgt[j]); \
} \
} \
} \
@@ -2704,7 +2704,7 @@ div_##TYPE1##_##TYPE2##_##TYPE3(
\
dst[k] = TYPE3##_nil; \
nils++; \
} else { \
- dst[k] = (TYPE3) rounddbl(lft[i] /
(long double) rgt[j]); \
+ dst[k] = (TYPE3) rounddbl(lft[i] /
(ldouble) rgt[j]); \
} \
} \
} \
diff --git a/gdk/gdk_calc_private.h b/gdk/gdk_calc_private.h
--- a/gdk/gdk_calc_private.h
+++ b/gdk/gdk_calc_private.h
@@ -651,8 +651,28 @@ BUN dofsum(const void *restrict values,
} \
} while (0)
+#if defined(_MSC_VER) && defined(__INTEL_COMPILER)
+/* with Intel compiler on Windows, avoid using roundl and llroundl: they
+ * cause a mysterious crash; long double is the same size as double
+ * anyway */
+typedef double ldouble;
#ifdef TRUNCATE_NUMBERS
#define rounddbl(x) (x)
#else
+#define rounddbl(x) round(x)
+#endif
+#else
+typedef long double ldouble;
+#ifdef TRUNCATE_NUMBERS
+#define rounddbl(x) (x)
+#else
+#ifdef HAVE_HGE
+/* can't round to hge via lng since we might loose significant bits, so
+ * just keep it long double */
#define rounddbl(x) roundl(x)
+#else
+/* round long double to long long int in one go */
+#define rounddbl(x) llroundl(x)
#endif
+#endif
+#endif
diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c
--- a/gdk/gdk_select.c
+++ b/gdk/gdk_select.c
@@ -1603,6 +1603,14 @@ BATselect(BAT *b, BAT *s, const void *tl
(!b->batTransient &&
ATOMsize(b->ttype) >= sizeof(BUN) / 4 &&
BATcount(b) * (ATOMsize(b->ttype) + 2 * sizeof(BUN)) <
GDK_mem_maxsize / 2);
+ if (!wanthash) {
+ MT_lock_set(&b->theaplock);
+ if (++b->selcnt > 1000) {
+ wanthash = true;
+ b->selcnt = 1000; /* limit value */
+ }
+ MT_lock_unset(&b->theaplock);
+ }
if (wanthash && !havehash) {
MT_lock_set(&b->theaplock);
if (b->tunique_est != 0 &&
@@ -1624,7 +1632,7 @@ BATselect(BAT *b, BAT *s, const void *tl
* to do a binary search on the candidate list (or 1
* if no need for search)) */
tmp = BBP_cache(parent);
- if (tmp && BATcheckhash(tmp)) {
+ if (BATcheckhash(tmp)) {
MT_rwlock_rdlock(&tmp->thashlock);
phash = tmp->thash != NULL &&
(BATcount(tmp) == BATcount(b) ||
@@ -1637,8 +1645,17 @@ BATselect(BAT *b, BAT *s, const void *tl
}
/* create a hash on the parent bat (and use it) if it is
* the same size as the view and it is persistent */
+ bool wantphash = false;
+ if (!phash) {
+ MT_lock_set(&tmp->theaplock);
+ if (++tmp->selcnt > 1000) {
+ wantphash = true;
+ tmp->selcnt = 1000;
+ }
+ MT_lock_unset(&tmp->theaplock);
+ }
if (!phash &&
- !tmp->batTransient &&
+ (!tmp->batTransient || wantphash) &&
BATcount(tmp) == BATcount(b) &&
BAThash(tmp) == GDK_SUCCEED) {
MT_rwlock_rdlock(&tmp->thashlock);
@@ -1885,7 +1902,17 @@ BATselect(BAT *b, BAT *s, const void *tl
assert(oidxh == NULL);
/* upper limit for result size */
maximum = ci.ncand;
- if (b->tkey) {
+ if (equi && havehash) {
+ /* we can look in the hash struct to see whether all
+ * values are distinct and set estimate accordingly */
+ if (phash) {
+ BAT *tmp = BBP_cache(parent);
+ if (tmp->thash->nunique == tmp->batCount)
+ estimate = 1;
+ } else if (b->thash->nunique == b->batCount)
+ estimate = 1;
+ }
+ if (estimate == BUN_NONE && (b->tkey || (parent != 0 &&
BBP_cache(parent)->tkey))) {
/* exact result size in special cases */
if (equi) {
estimate = 1;
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
@@ -1149,9 +1149,8 @@ exp_bin(backend *be, sql_exp *e, stmt *l
list_append(l, const_column(be,
(stmt*)n->data));
r = stmt_list(be, l);
} else if (r->type == st_table && e->card ==
CARD_ATOM) { /* fetch value */
- sql_rel *ll = (sql_rel*) l->l;
r = lst->op4.lval->h->data;
- if (!r->aggr && lastexp(ll)->card >
CARD_ATOM) /* if the cardinality is atom, no fetch call needed */
+ if (!r->aggr) /* if the cardinality is
atom, no fetch call needed */
r = stmt_fetch(be, r);
}
if (r->type == st_list)
@@ -1204,6 +1203,8 @@ exp_bin(backend *be, sql_exp *e, stmt *l
stmt *cond = exp_bin(be, e->l, left, right, grp, ext,
cnt, sel, 0, 0, push);
if (!cond)
return NULL;
+ if (cond->nrcols)
+ cond = stmt_fetch(be, cond);
return stmt_exception(be, cond, (const char *) e->r, 0);
}
break;
@@ -2175,7 +2176,6 @@ rel2bin_table(backend *be, sql_rel *rel,
} else if (rel->l) { /* handle sub query via function */
int i;
char name[16], *nme;
- sql_rel *fr;
nme = number2name(name, sizeof(name), ++be->remote);
@@ -2185,7 +2185,7 @@ rel2bin_table(backend *be, sql_rel *rel,
sub = stmt_list(be, l);
if (!(sub = stmt_func(be, sub, sa_strdup(sql->sa, nme), rel->l,
0)))
return NULL;
- fr = rel->l = sub->op4.rel; /* rel->l may get rewritten */
+ rel->l = sub->op4.rel; /* rel->l may get rewritten */
l = sa_list(sql->sa);
for(i = 0, n = rel->exps->h; n; n = n->next, i++ ) {
sql_exp *c = n->data;
@@ -2194,8 +2194,6 @@ rel2bin_table(backend *be, sql_rel *rel,
const char *rnme = exp_relname(c);
s = stmt_alias(be, s, rnme, nme);
- if (fr->card <= CARD_ATOM) /* single value, get result
from bat */
- s = stmt_fetch(be, s);
list_append(l, s);
}
sub = stmt_list(be, l);
diff --git a/sql/backends/monet5/sql_cast.c b/sql/backends/monet5/sql_cast.c
--- a/sql/backends/monet5/sql_cast.c
+++ b/sql/backends/monet5/sql_cast.c
@@ -384,6 +384,23 @@ bailout:
#define lng_is_numeric 1
#define hge_is_numeric 1
+/* stringify token */
+#define _STRNG_(s) #s
+#define STRNG(t) _STRNG_(t)
+
+/* concatenate two, three or four tokens */
+#define CONCAT_2(a,b) a##b
+#define CONCAT_3(a,b,c) a##b##c
+#define CONCAT_4(a,b,c,d) a##b##c##d
+
+#define NIL(t) CONCAT_2(t,_nil)
+#define ISNIL(t) CONCAT_3(is_,t,_nil)
+#define TPE(t) CONCAT_2(TYPE_,t)
+#define GDKmin(t) CONCAT_3(GDK_,t,_min)
+#define GDKmax(t) CONCAT_3(GDK_,t,_max)
+#define FUN(a,b,c,d) CONCAT_4(a,b,c,d)
+#define IS_NUMERIC(t) CONCAT_2(t,_is_numeric)
+
/* up casting */
#define TP1 bte
@@ -480,8 +497,6 @@ bailout:
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]