Changeset: b2d5e292a4b8 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/b2d5e292a4b8
Modified Files:
sql/backends/monet5/rel_bin.c
sql/backends/monet5/rel_physical.c
sql/backends/monet5/sql_optimizer.c
sql/server/rel_optimize_proj.c
sql/server/rel_optimize_sel.c
sql/server/rel_statistics.c
Branch: default
Log Message:
Use atomic variable correctly.
diffs (157 lines):
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
@@ -1802,7 +1802,7 @@ exp_bin(backend *be, sql_exp *e, stmt *l
if (strcmp(fname, "-1") == 0) /* map arguments to A0 ..
An */
return exp2bin_named_placeholders(be, e);
}
- ATOMIC_TYPE oahash_enabled = (1U<<19);
+ const ATOMIC_BASE_TYPE oahash_enabled = (1U<<19);
if (f->pipeline && f->func->mod && f->func->imp &&
strcmp(f->func->mod, "sql") == 0 && strcmp(f->func->imp, "copy_from") == 0)
return exp2bin_copyparpipe(be, e);
if (!list_empty(exps)) {
@@ -1832,7 +1832,7 @@ exp_bin(backend *be, sql_exp *e, stmt *l
list_append(l, es);
}
}
- if (SQLrunning && (GDKdebug & oahash_enabled) && f->pipeline &&
f->func->mod && f->func->imp && strcmp(f->func->mod, "generator") == 0 &&
strcmp(f->func->imp, "series") == 0)
+ if (SQLrunning && (ATOMIC_GET(&GDKdebug) & oahash_enabled) &&
f->pipeline && f->func->mod && f->func->imp && strcmp(f->func->mod,
"generator") == 0 && strcmp(f->func->imp, "series") == 0)
return exp2bin_generator(be, e, l);
if (!(s = stmt_Nop(be, stmt_list(be, l), sel, f, rows)))
return NULL;
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
@@ -426,8 +426,8 @@ rel_groupby_partition_safe(sql_rel *rel)
static int
do_oahash_join(visitor *v, sql_rel *rel, int *side)
{
- ATOMIC_TYPE oahash_enabled = (1U<<19);
- if (!(GDKdebug & oahash_enabled))
+ const ATOMIC_BASE_TYPE oahash_enabled = (1U<<19);
+ if (!(ATOMIC_GET(&GDKdebug) & oahash_enabled))
return 0;
/* fetch join */
@@ -1652,8 +1652,8 @@ rel_rewrite_physical(visitor *v, sql_rel
if (rel)
rel = rel_push_down_topn(v, rel);
if (rel) { /* split equi-join/select */
- ATOMIC_TYPE oahash_enabled = (1U<<19);
- if (SQLrunning && (GDKdebug & oahash_enabled)) {
+ const ATOMIC_BASE_TYPE oahash_enabled = (1U<<19);
+ if (SQLrunning && (ATOMIC_GET(&GDKdebug) & oahash_enabled)) {
rel = rel_count_gt_zero(v, rel);
if (rel) /* Add a projection after each join,
needed for limited number of columns in hash tables */
rel = rel_add_project(v, rel);
@@ -1681,8 +1681,8 @@ rel_physical(mvc *sql, sql_rel *rel)
v.data = NULL;
if (!sql->recursive) {
- ATOMIC_TYPE oahash_enabled = (1U<<19);
- if (!SQLrunning || !(GDKdebug & oahash_enabled) ||
gp.complex_modify || gp.cnt[op_except] || gp.cnt[op_inter]) {
+ const ATOMIC_BASE_TYPE oahash_enabled = (1U<<19);
+ if (!SQLrunning || !(ATOMIC_GET(&GDKdebug) & oahash_enabled) ||
gp.complex_modify || gp.cnt[op_except] || gp.cnt[op_inter]) {
if (v.opt >= 0)
v.opt = rel->opt+1;
(void)rel_partition(&v, sql, rel);
diff --git a/sql/backends/monet5/sql_optimizer.c
b/sql/backends/monet5/sql_optimizer.c
--- a/sql/backends/monet5/sql_optimizer.c
+++ b/sql/backends/monet5/sql_optimizer.c
@@ -136,8 +136,8 @@ addOptimizers(Client c, MalBlkPtr mb, co
be = (backend *) c->sqlcontext;
c->no_mitosis = be->no_mitosis;
- ATOMIC_TYPE oahash_enabled = (1U<<19);
- if ((GDKdebug & oahash_enabled))
+ const ATOMIC_BASE_TYPE oahash_enabled = (1U<<19);
+ if ((ATOMIC_GET(&GDKdebug) & oahash_enabled))
c->no_mitosis = 1;
assert(be && be->mvc); /* SQL clients should always have their state
set */
diff --git a/sql/server/rel_optimize_proj.c b/sql/server/rel_optimize_proj.c
--- a/sql/server/rel_optimize_proj.c
+++ b/sql/server/rel_optimize_proj.c
@@ -3339,8 +3339,8 @@ rel_project_select_exp(visitor *v, sql_r
static sql_rel *
rel_optimize_projections_(visitor *v, sql_rel *rel)
{
- ATOMIC_TYPE oahash_mask = (1U<<19);
- bool oahash_enabled = (GDKdebug & oahash_mask);
+ const ATOMIC_BASE_TYPE oahash_mask = (1U<<19);
+ bool oahash_enabled = (ATOMIC_GET(&GDKdebug) & oahash_mask);
rel = rel_project_cse(v, rel);
rel = rel_project_select_exp(v, rel);
rel = rel_use_equality_exps(v, rel);
@@ -3516,8 +3516,8 @@ rel_merge_unions(visitor *v, sql_rel *re
static inline sql_rel *
rel_push_join_down_munion(visitor *v, sql_rel *rel)
{
- ATOMIC_TYPE oahash_mask = (1U<<19);
- bool oahash_enabled = (GDKdebug & oahash_mask);
+ const ATOMIC_BASE_TYPE oahash_mask = (1U<<19);
+ bool oahash_enabled = (ATOMIC_GET(&GDKdebug) & oahash_mask);
if (!oahash_enabled && ((is_join(rel->op) && !is_outerjoin(rel->op) &&
!is_single(rel)) || is_semi(rel->op))) {
sql_rel *l = rel->l, *r = rel->r, *ol = l, *or = r;
list *exps = rel->exps, *attr = rel->attr;
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
@@ -1761,8 +1761,8 @@ rel_join_use_fk(visitor *v, sql_rel *rel
static sql_rel *
rel_optimize_joins_topdown_(visitor *v, sql_rel *rel)
{
- ATOMIC_TYPE oahash_mask = (1U<<19);
- bool oahash_enabled = (GDKdebug & oahash_mask);
+ const ATOMIC_BASE_TYPE oahash_mask = (1U<<19);
+ bool oahash_enabled = (ATOMIC_GET(&GDKdebug) & oahash_mask);
if (oahash_enabled)
rel = transitivity_rule(v, rel);
rel = rel_join_use_fk(v, rel);
@@ -3361,8 +3361,8 @@ order_joins_bushy( visitor *v, list *rel
static sql_rel *
order_joins(visitor *v, list *rels, list *exps)
{
- ATOMIC_TYPE oahash_mask = (1U<<19);
- bool oahash_enabled = (GDKdebug & oahash_mask);
+ const ATOMIC_BASE_TYPE oahash_mask = (1U<<19);
+ bool oahash_enabled = (ATOMIC_GET(&GDKdebug) & oahash_mask);
sql_rel *top = NULL, *l = NULL, *r = NULL, *f = NULL;
sql_exp *cje;
node *djn;
@@ -3730,8 +3730,8 @@ static sql_rel *rel_join_order_(visitor
sql_rel *
reorder_join(visitor *v, sql_rel *rel)
{
- ATOMIC_TYPE oahash_mask = (1U<<19);
- bool oahash_enabled = (GDKdebug & oahash_mask);
+ const ATOMIC_BASE_TYPE oahash_mask = (1U<<19);
+ bool oahash_enabled = (ATOMIC_GET(&GDKdebug) & oahash_mask);
list *exps, *rels;
allocator *ta = MT_thread_getallocator();
@@ -3868,8 +3868,8 @@ rel_join_order(visitor *v, global_props
run_optimizer
bind_join_order(visitor *v, global_props *gp)
{
- ATOMIC_TYPE oahash_mask = (1U<<19);
- bool oahash_enabled = (GDKdebug & oahash_mask);
+ const ATOMIC_BASE_TYPE oahash_mask = (1U<<19);
+ bool oahash_enabled = (ATOMIC_GET(&GDKdebug) & oahash_mask);
int flag = v->sql->sql_optimizer;
return !oahash_enabled && gp->opt_level == 1 && gp->opt_cycle < 10 &&
!gp->cnt[op_update] && (gp->cnt[op_join] || gp->cnt[op_left] ||
gp->cnt[op_right] || gp->cnt[op_full]) && (flag & join_order) ?
rel_join_order : NULL;
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
@@ -1302,8 +1302,8 @@ rel_get_statistics(visitor *v, global_pr
run_optimizer
bind_get_statistics(visitor *v, global_props *gp)
{
- ATOMIC_TYPE oahash_mask = (1U<<19);
- bool oahash_enabled = (GDKdebug & oahash_mask);
+ const ATOMIC_BASE_TYPE oahash_mask = (1U<<19);
+ bool oahash_enabled = (ATOMIC_GET(&GDKdebug) & oahash_mask);
(void) v;
return (!oahash_enabled && gp->opt_level == 1 /*&&
!gp->cnt[op_insert]*/) ? rel_get_statistics : NULL;
}
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]