Changeset: 27c026ea256c for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/27c026ea256c Modified Files: gdk/gdk.h gdk/gdk_bbp.c sql/server/rel_optimize_proj.c sql/server/rel_rewriter.c sql/test/SQLancer/Tests/sqlancer23.test sql/test/miscellaneous/Tests/simple_plans.test Branch: properties Log Message:
Merged with default diffs (truncated from 330 to 300 lines): diff --git a/documentation/source/manual_pages/mserver5.rst.in b/documentation/source/manual_pages/mserver5.rst.in --- a/documentation/source/manual_pages/mserver5.rst.in +++ b/documentation/source/manual_pages/mserver5.rst.in @@ -99,7 +99,7 @@ MSERVER5 OPTIONS **-d**\ [*value*] Set debug level. This is mostly for debugging purposes. The *value* together with the **=** sign is optional. If not specified, it - defaults to **1**. In the short form **-d**, the value, if present, + defaults to **2**. In the short form **-d**, the value, if present, must immediately (i.e. without space) follow the option. The values of multiple instances of this flag are OR-ed together. The value is an integer, which can be (a bit-wise OR of): @@ -108,11 +108,7 @@ MSERVER5 OPTIONS (THRDMASK) thread-specific debug output **2** - (CHECKMASK) property enforcing on new BATs - - **8** - (PROPMASK) property checking on all values: tells about wrongly - set properties + (CHECKMASK) property checking on new BATs **16** (IOMASK) major IO activity @@ -195,7 +191,7 @@ MSERVER5 OPTIONS Equivalent to **--debug=**\ *(DEADBEEFMASK)*. **--properties** - Equivalent to **--debug=**\ *(CHECKMASK \| PROPMASK \| BATMASK)*. + Equivalent to **--debug=**\ *(CHECKMASK)*. **--threads** Equivalent to **--debug=**\ *(THRDMASK \| PARMASK)*. diff --git a/gdk/gdk.h b/gdk/gdk.h --- a/gdk/gdk.h +++ b/gdk/gdk.h @@ -378,8 +378,8 @@ gdk_export _Noreturn void GDKfatal(_In_z #define THRDMASK (1) #define CHECKMASK (1<<1) #define CHECKDEBUG if (GDKdebug & CHECKMASK) -#define PROPMASK (1<<3) -#define PROPDEBUG if (GDKdebug & PROPMASK) +#define PROPMASK (1<<3) /* unused */ +#define PROPDEBUG if (GDKdebug & PROPMASK) /* unused */ #define IOMASK (1<<4) #define BATMASK (1<<5) #define PARMASK (1<<7) diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c --- a/gdk/gdk_bat.c +++ b/gdk/gdk_bat.c @@ -2457,7 +2457,7 @@ BATmode(BAT *b, bool transient) #ifdef NDEBUG /* assertions are disabled, turn failing tests into a message */ #undef assert -#define assert(test) ((void) ((test) || (TRC_CRITICAL_ENDIF(BAT_, "Assertion `%s' failed\n", #test), 0))) +#define assert(test) ((void) ((test) || (TRC_CRITICAL_ENDIF(CHECK, "Assertion `%s' failed\n", #test), 0))) #endif /* Assert that properties are set correctly. @@ -2706,9 +2706,8 @@ BATassertProps(BAT *b) return; } - /* only do a scan if property checking is requested and the bat - * is not a view */ - if (!isview1 && !isview2 && GDKdebug & PROPMASK) { + /* only do a scan if the bat is not a view */ + if (!isview1 && !isview2) { const void *maxval = NULL; const void *minval = NULL; bool seenmax = false, seenmin = false; diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c --- a/gdk/gdk_bbp.c +++ b/gdk/gdk_bbp.c @@ -3062,7 +3062,7 @@ BBPkeepref(BAT *b) BATsettrivprop(b); MT_lock_unset(&b->theaplock); } - if (GDKdebug & (CHECKMASK | PROPMASK)) + if (GDKdebug & CHECKMASK) BATassertProps(b); if (BATsetaccess(b, BAT_READ) == NULL) return; /* already decreffed */ diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c --- a/gdk/gdk_logger.c +++ b/gdk/gdk_logger.c @@ -1116,7 +1116,7 @@ logger_read_transaction(logger *lg) int dbg = GDKdebug; if (!lg->flushing) - GDKdebug &= ~(CHECKMASK|PROPMASK); + GDKdebug &= ~CHECKMASK; while (err == LOG_OK && (ok=log_read_format(lg, &l))) { if (l.flag == 0 && l.id == 0) { @@ -2001,7 +2001,7 @@ logger_load(int debug, const char *fn, c needcommit = true; } dbg = GDKdebug; - GDKdebug &= ~(CHECKMASK|PROPMASK); + GDKdebug &= ~CHECKMASK; if (needcommit && bm_commit(lg) != GDK_SUCCEED) { GDKerror("Logger_new: commit failed"); goto error; @@ -2026,7 +2026,7 @@ logger_load(int debug, const char *fn, c } } dbg = GDKdebug; - GDKdebug &= ~(CHECKMASK|PROPMASK); + GDKdebug &= ~CHECKMASK; if (logger_commit(lg) != GDK_SUCCEED) { goto error; } diff --git a/gdk/gdk_logger_old.c b/gdk/gdk_logger_old.c --- a/gdk/gdk_logger_old.c +++ b/gdk/gdk_logger_old.c @@ -1016,7 +1016,7 @@ logger_readlog(old_logger *lg, char *fil int dbg = GDKdebug; int fd; - GDKdebug &= ~(CHECKMASK|PROPMASK); + GDKdebug &= ~CHECKMASK; if (lg->lg->debug & 1) { fprintf(stderr, "#logger_readlog opening %s\n", filename); diff --git a/monetdb5/mal/mal.h b/monetdb5/mal/mal.h --- a/monetdb5/mal/mal.h +++ b/monetdb5/mal/mal.h @@ -57,7 +57,7 @@ mal_export stream *maleventstream; */ #define GRPthreads (THRDMASK | PARMASK) #define GRPmemory (ALLOCMASK ) -#define GRPproperties (CHECKMASK | PROPMASK | BATMASK ) +#define GRPproperties (CHECKMASK ) #define GRPio (IOMASK | PERFMASK ) #define GRPheaps (HEAPMASK) #define GRPtransactions (TMMASK | DELTAMASK | TEMMASK) diff --git a/monetdb5/mal/mal_interpreter.c b/monetdb5/mal/mal_interpreter.c --- a/monetdb5/mal/mal_interpreter.c +++ b/monetdb5/mal/mal_interpreter.c @@ -855,7 +855,7 @@ str runMALsequence(Client cntxt, MalBlkP lhs->val.pval != stk->stk[getArg(pci, i)].val.pval) GDKfree(lhs->val.pval); } - if (GDKdebug & (CHECKMASK|PROPMASK) && exceptionVar < 0) { + if (GDKdebug & CHECKMASK && exceptionVar < 0) { BAT *b; for (i = 0; i < pci->retc; i++) { diff --git a/sql/ChangeLog b/sql/ChangeLog --- a/sql/ChangeLog +++ b/sql/ChangeLog @@ -1,6 +1,9 @@ # ChangeLog file for sql # This file is updated with Maddlog +* do apr 21 2022 Nuno Faria <nunofpfa...@gmail.com> +- Added the UNLOGGED TABLE feature. + * Fri Feb 4 2022 Sjoerd Mullender <sjo...@acm.org> - Removed functions sys.index and sys.strings. 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 @@ -1444,7 +1444,27 @@ rel_simplify_sum(visitor *v, sql_rel *re if ((!e1ok && e2ok) || (e1ok && !e2ok)) { sql_exp *ocol = e1ok ? e2 : e1, *constant = e1ok ? e1 : e2, *mul, *colref, *naggr, *newop, *col = ocol, *match; - bool add_col = true; + bool add_col = true, prepend = false; + + /* if 'col' is a projection from the under relation, then use it */ + while (is_numeric_upcast(col)) + col = col->l; + if (col->type == e_column) { + sql_exp *colf = exps_find_exp(l->exps, col); + + /* col is already found in the inner relation. Also look for a new reference for col, eg sql_add(col, 1), 1 as col */ + if (colf && list_position(l->exps, colf) < list_position(l->exps, oexp)) { + add_col = false; + } else if (!colf && is_simple_project(l->op) && list_empty(l->r) && !rel_is_ref(l) && !need_distinct(l)) { + prepend = true; + add_col = false; + } else if (!colf && (is_simple_project(l->op) || is_groupby(l->op))) { + /* on these scenarios the new column expression will be ordered/(grouped for distinct) or create potential ambiguity (multiple ref), so skip */ + continue; + } + } else if ((is_simple_project(l->op) && (!list_empty(l->r) || rel_is_ref(l) || need_distinct(l))) || is_groupby(l->op)) { + continue; + } /* add count star */ count_star_exp = rel_groupby_add_count_star(v->sql, groupby, count_star_exp, &count_added); @@ -1457,20 +1477,6 @@ rel_simplify_sum(visitor *v, sql_rel *re if (!has_label(mul)) exp_label(v->sql->sa, mul, ++v->sql->label); - /* if 'col' is a projection from the under relation, then use it */ - while (is_numeric_upcast(col)) - col = col->l; - if (col->type == e_column) { - sql_exp *colf = exps_find_exp(l->exps, col); - - /* col is already found in the inner relation. Also look for a new reference for col, eg sql_add(col, 1), 1 as col */ - if (colf && list_position(l->exps, colf) < list_position(l->exps, oexp)) { - add_col = false; - } else if (!colf && is_simple_project(l->op) && list_empty(l->r) && !rel_is_ref(l) && !need_distinct(l)) { - list_prepend(l->exps, exp_ref(v->sql, col)); - add_col = false; - } - } colref = exp_ref(v->sql, ocol); if (add_col) /* if 'col' will be added, then make sure it has an unique label */ exp_label(v->sql->sa, colref, ++v->sql->label); @@ -1505,6 +1511,10 @@ rel_simplify_sum(visitor *v, sql_rel *re continue; } + /* a column reference can be prepended to the inner relation, add it after all the check type calls succeed */ + if (prepend) + list_prepend(l->exps, exp_ref(v->sql, col)); + /* the new generate function calls are valid, update relations */ /* we need a new relation for the multiplication and addition/subtraction */ if (!upper) { @@ -1654,6 +1664,9 @@ rel_simplify_groupby_columns(visitor *v, sql_exp *ne = exp_ref(v->sql, col); list_prepend(l->exps, ne); n->data = exp_ref(v->sql, ne); + } else if (!colf && (is_simple_project(l->op) || is_groupby(l->op))) { + /* on these scenarios the new column expression will be ordered/(grouped for distinct) or create potential ambiguity (multiple ref), so skip */ + continue; } else { sql_exp *ne = exp_ref(v->sql, col); @@ -1713,7 +1726,7 @@ rel_groupby_cse(visitor *v, sql_rel *rel if (!needed) return rel; - if (!is_simple_project(l->op) || !list_empty(l->r) || rel_is_ref(l) || need_distinct(l) || is_single(l)) + if (!is_simple_project(l->op) || !list_empty(l->r) || rel_is_ref(l) || need_distinct(l)) rel->l = l = rel_project(v->sql->sa, l, rel_projections(v->sql, l, NULL, 1, 1)); for (node *n=((list*)rel->r)->h; n ; ) { diff --git a/sql/server/rel_rewriter.c b/sql/server/rel_rewriter.c --- a/sql/server/rel_rewriter.c +++ b/sql/server/rel_rewriter.c @@ -221,6 +221,8 @@ rewrite_simplify(visitor *v, uint8_t cyc rel->r = NULL; rel->op = op_select; } + /* make sure the single expression is false, so the generate NULL values won't match */ + rel->exps->h->data = exp_atom_bool(v->sql->sa, 0); rel->l = rel_project(v->sql->sa, NULL, nexps); rel->card = CARD_ATOM; v->changes++; diff --git a/sql/test/SQLancer/Tests/sqlancer23.test b/sql/test/SQLancer/Tests/sqlancer23.test --- a/sql/test/SQLancer/Tests/sqlancer23.test +++ b/sql/test/SQLancer/Tests/sqlancer23.test @@ -163,6 +163,10 @@ SELECT 1 FROM t0, (SELECT 1 FROM (SELECT WHERE CASE WHEN TRUE THEN 2 = ANY(VALUES (vx.vx)) WHEN FALSE THEN t0.c0 = t0.c0 END ---- +query I nosort +SELECT 1 FROM t0 GROUP BY t0.c0 HAVING max(FALSE) IS NULL +---- + # Postgres doesn't give an error here, but we are confident it must statement error GDK reported error: mergejoin: more than one match SELECT 1 FROM t0 CROSS JOIN LATERAL (SELECT (VALUES (y.y), (y.y)) FROM (SELECT 1) y(y) WHERE t0.c0 = 2) x(x) diff --git a/sql/test/miscellaneous/Tests/simple_plans.test b/sql/test/miscellaneous/Tests/simple_plans.test --- a/sql/test/miscellaneous/Tests/simple_plans.test +++ b/sql/test/miscellaneous/Tests/simple_plans.test @@ -701,3 +701,8 @@ SELECT sum(CASE x.x WHEN 1 THEN 1 END + ---- 3 3 + +query I nosort +SELECT sum(y.y) FROM (SELECT DISTINCT x + 1 FROM (SELECT 1) x(x)) y(y) +---- +2 diff --git a/tools/mserver/mserver5.1.in b/tools/mserver/mserver5.1.in --- a/tools/mserver/mserver5.1.in +++ b/tools/mserver/mserver5.1.in @@ -136,7 +136,7 @@ The together with the .B = sign is optional. If not specified, it defaults to -.BR 1 . +.BR 2 . In the short form \fB\-d\fP, the value, if present, must immediately (i.e. without space) follow the option. The values of multiple instances of this flag are OR-ed together. @@ -147,11 +147,7 @@ The value is an integer, which can be (a (THRDMASK) thread-specific debug output .TP .B 2 _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org