MonetDB: cmp-or-patterns - Close branch cmp-or-patterns
Changeset: 159b1058c739 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/159b1058c739 Branch: cmp-or-patterns Log Message: Close branch cmp-or-patterns ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - Merges cmp-or-patterns branch
Changeset: 5dd880ae4f97 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/5dd880ae4f97 Branch: default Log Message: Merges cmp-or-patterns branch diffs (truncated from 796 to 300 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 @@ -520,7 +520,7 @@ handle_in_tuple_exps(backend *be, sql_ex else s = cursel; } - if (sel && !(depth || !reduce)) + if (!depth && reduce) s = stmt_uselect(be, s->nrcols == 0?stmt_const(be, bin_find_smallest_column(be, left), s): s, stmt_bool(be, 1), cmp_equal, sel, 0, 0); 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 @@ -423,91 +423,366 @@ exps_cse( mvc *sql, list *oexps, list *l return res; } -static int -are_equality_exps( list *exps, sql_exp **L) +static inline int +exp_col_key(sql_exp *e) +{ + return e->nid ? e->nid : e->alias.label; +} + +static inline int +exp_cmp_eq_unique_id(sql_exp *e) +{ + return exp_col_key(e->l); +} + +static inline int +exp_multi_col_key(list *l) +{ + int k = exp_col_key(l->h->data); + for (node *n = l->h->next; n; n = n->next) { + k <<= 4; + k ^= exp_col_key(n->data); + } + return k; +} + +typedef struct exp_eq_col_values { + /* we need ->first in order to remove it from the list of cmp_eq exps +* in case that we find another occurrence (with a different value) +*/ + sql_exp* first; + sql_exp* col; /* column */ + list *vs; /* list of values */ +} eq_cv; + +typedef struct exp_eq_multi_col_values { + /* we need ->first in order to remove it from the list of multi col +* cmp_eq exps in case that we find another occurrence (with different values) +*/ + list *first; + list *cols; /* list of col exps */ + list *lvs; /* list of lists of values */ +} eq_mcv; + +static bool +detect_col_cmp_eqs(mvc *sql, list *eqs, sql_hash *eqh) { - sql_exp *l = *L; - - if (list_length(exps) == 1) { - sql_exp *e = exps->h->data, *le = e->l, *re = e->r; - - if (e->type == e_cmp && e->flag == cmp_equal && le->card != CARD_ATOM && re->card == CARD_ATOM && !is_semantics(e)) { - if (!l) { - *L = l = le; - if (!is_column(le->type)) - return 0; + bool col_multivalue_cmp_eq = false; + for (node *n = eqs->h; n; n = n->next ) { + sql_exp *e = n->data; + sql_exp *le = e->l, *re = e->r; + + /* find the le in the hash and append the re in the hash value (ea->list) */ + bool found = false; + + int key = eqh->key(le); + sql_hash_e *he = eqh->buckets[key&(eqh->size-1)]; + + for (;he && !found; he = he->chain) { + eq_cv *cv = he->value; + if (!exp_equal(le, cv->col)) { + cv->vs = append(cv->vs, re); + found = col_multivalue_cmp_eq = true; + /* remove this and the previous (->first) occurrence (if exists) from eqs */ + if (cv->first) { + list_remove_data(eqs, NULL, cv->first); + cv->first = NULL; + } + list_remove_node(eqs, NULL, n); } - return (exp_match(l, le)); + } + + if (!found) { + eq_cv *cv = SA_NEW(sql->sa, eq_cv); + cv->first = e; + cv->vs = sa_list(sql->sa); + cv->vs = append(cv->vs, re); + cv->col = le; + + hash_add(eqh, key, cv); } - if (e->type == e_cmp && e->flag == cmp_or && !is_anti(e) && !is_semantics(e)) - return (are_equality_exps(e->l, L) && are_equality_exps(e->r, L)); } - return 0; + return col_multivalue_cmp_eq; +} + +static bool +detect_multicol_cmp_eqs(mvc *sql, list *mce_ands, sql_hash *meqh) +{ + /* we get as input a list of AND associated expressions (hence the entries are lists themselves) +* we need to detect cmp_eq-only AND-associated expressions with the same columns so we can +* group together their values +* e.g. [[n = 1, m = 10], [m = 20, k = 100, l = 3000], [m = 20, n = 2]] has +* - (m,k,l) group with a single value (20, 100, 3000) +* - (n,k) group with two values (1,
MonetDB: cmp-or-patterns - Merges default
Changeset: 23f2d630885b for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/23f2d630885b Branch: cmp-or-patterns Log Message: Merges default diffs (truncated from 932 to 300 lines): diff --git a/clients/odbc/winsetup/CMakeLists.txt b/clients/odbc/winsetup/CMakeLists.txt --- a/clients/odbc/winsetup/CMakeLists.txt +++ b/clients/odbc/winsetup/CMakeLists.txt @@ -21,8 +21,6 @@ target_sources(MonetODBCs resource.h) target_include_directories(MonetODBCs -# PRIVATE -# $<$:${HAVE_AFXRES_H}> PUBLIC $ $) diff --git a/clients/odbc/winsetup/setup.rc b/clients/odbc/winsetup/setup.rc --- a/clients/odbc/winsetup/setup.rc +++ b/clients/odbc/winsetup/setup.rc @@ -10,7 +10,8 @@ // // Generated from the TEXTINCLUDE 2 resource. // -#include "afxres.h" +#include "WinResrc.h" +#define IDC_STATIC (-1) / #undef APSTUDIO_READONLY_SYMBOLS @@ -37,22 +38,7 @@ END 2 TEXTINCLUDE BEGIN -"#include ""afxres.h""\r\n" -"\0" -END - -3 TEXTINCLUDE -BEGIN -"#define _AFX_NO_SPLITTER_RESOURCES\r\n" -"#define _AFX_NO_OLE_RESOURCES\r\n" -"#define _AFX_NO_TRACKER_RESOURCES\r\n" -"#define _AFX_NO_PROPERTY_RESOURCES\r\n" -"\r\n" -"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" -"LANGUAGE 9, 1\r\n" -"#pragma code_page(1252)\r\n" -"#include ""afxres.rc"" // Standard components\r\n" -"#endif\r\n" +"#include ""WinResrc.h""\r\n" "\0" END @@ -187,25 +173,3 @@ END IDB_BANNER BITMAP "banner.bmp" #endif// English (U.S.) resources / - - - -#ifndef APSTUDIO_INVOKED -/ -// -// Generated from the TEXTINCLUDE 3 resource. -// -#define _AFX_NO_SPLITTER_RESOURCES -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE 9, 1 -#pragma code_page(1252) -#include "afxres.rc" // Standard components -#endif - -/ -#endif// not APSTUDIO_INVOKED - diff --git a/cmake/monetdb-defines.cmake b/cmake/monetdb-defines.cmake --- a/cmake/monetdb-defines.cmake +++ b/cmake/monetdb-defines.cmake @@ -20,14 +20,10 @@ function(monetdb_configure_defines) check_include_file("fcntl.h" HAVE_FCNTL_H) # use find_path for getopt.h since we need the path on Windows find_path(HAVE_GETOPT_H "getopt.h") - check_include_file("io.h" HAVE_IO_H) check_include_file("kvm.h" HAVE_KVM_H) - check_include_file("libgen.h" HAVE_LIBGEN_H) - check_include_file("libintl.h" HAVE_LIBINTL_H) check_include_file("mach/mach_init.h" HAVE_MACH_MACH_INIT_H) check_include_file("mach/task.h" HAVE_MACH_TASK_H) check_include_file("mach-o/dyld.h" HAVE_MACH_O_DYLD_H) - check_include_file("netinet/in.h" HAVE_NETINET_IN_H) check_include_file("poll.h" HAVE_POLL_H) check_include_file("procfs.h" HAVE_PROCFS_H) check_include_file("pwd.h" HAVE_PWD_H) @@ -42,13 +38,11 @@ function(monetdb_configure_defines) check_include_files("stdlib.h;sys/random.h" HAVE_SYS_RANDOM_H) check_include_file("sys/resource.h" HAVE_SYS_RESOURCE_H) check_include_file("sys/stat.h" HAVE_SYS_STAT_H) - check_include_file("sys/sysctl.h" HAVE_SYS_SYSCTL_H) check_include_file("sys/termios.h" HAVE_TERMIOS_H) check_include_file("sys/times.h" HAVE_SYS_TIMES_H) check_include_file("sys/types.h" HAVE_SYS_TYPES_H) check_include_file("sys/uio.h" HAVE_SYS_UIO_H) check_include_file("sys/un.h" HAVE_SYS_UN_H) - check_include_file("sys/wait.h" HAVE_SYS_WAIT_H) check_include_file("unistd.h" HAVE_UNISTD_H) check_include_file("winsock2.h" HAVE_WINSOCK_H) @@ -105,23 +99,15 @@ function(monetdb_configure_defines) # Some POSIX systems don't have it (e.g. Macos) check_symbol_exists("posix_fallocate" "fcntl.h" HAVE_POSIX_FALLOCATE) check_symbol_exists("posix_madvise" "sys/mman.h" HAVE_POSIX_MADVISE) - check_function_exists("putenv" HAVE_PUTENV) check_function_exists("setsid" HAVE_SETSID) check_function_exists("shutdown" HAVE_SHUTDOWN) check_function_exists("sigaction" HAVE_SIGACTION) check_function_exists("siglongjmp" HAVE_SIGLONGJMP) - check_symbol_exists("stpcpy" "string.h" HAVE_STPCPY) - check_function_exists("strcasestr" HAVE_STRCASESTR) - check_symbol_exists("strncasecmp" "strings.h" HAVE_STRNCASECMP) check_function_exists("strptime" HAVE_STRPTIME) - check_function_exists("strsignal" HAVE_STRSIGNAL) check_symbol_exists("sysconf" "unistd.h" HAVE_SYSCONF) check_function_exists("task_info" HAVE_TASK_INFO) check_function_exists("times" HAVE_TIMES) check_function_exists("uname" HAVE_UNAME) - check_symbol_exists("wcwidth" "wchar.h" HAVE_WCWIDTH) - # Some libc versions on Linux distributions don't have it -
MonetDB: cmp-or-patterns - Renames merge_ors_NEW to merge_ors
Changeset: ffaaa61f4863 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/ffaaa61f4863 Modified Files: sql/server/rel_optimize_sel.c Branch: cmp-or-patterns Log Message: Renames merge_ors_NEW to merge_ors diffs (21 lines): 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 @@ -669,7 +669,7 @@ generate_multi_col_cmp_in(mvc *sql, sql_ } static list * -merge_ors_NEW(mvc *sql, list *exps, int *changes) +merge_ors(mvc *sql, list *exps, int *changes) { sql_hash *eqh = NULL, *meqh = NULL; list *eqs = NULL, *neq = NULL, *gen_ands = NULL, *mce_ands = NULL, *ins = NULL, *mins = NULL; @@ -1020,7 +1020,7 @@ rel_select_cse(visitor *v, sql_rel *rel) rel->exps = cleanup_equal_exps(v->sql, rel, rel->exps, >changes); /* (a = b) and (a += b) */ if (is_select(rel->op) && rel->exps) - rel->exps = merge_ors_NEW(v->sql, rel->exps, >changes); + rel->exps = merge_ors(v->sql, rel->exps, >changes); if (is_select(rel->op) && rel->exps) rel->exps = merge_notequal(v->sql, rel->exps, >changes); /* x <> 1 and x <> 2 => x not in (1, 2)*/ ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: cmp-or-patterns - Removes old merge_ors impl
Changeset: 8eae9e2d5a6b for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/8eae9e2d5a6b Modified Files: sql/server/rel_optimize_sel.c Branch: cmp-or-patterns Log Message: Removes old merge_ors impl diffs (109 lines): 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 @@ -423,95 +423,6 @@ exps_cse( mvc *sql, list *oexps, list *l return res; } -static int -are_equality_exps( list *exps, sql_exp **L) -{ - sql_exp *l = *L; - - if (list_length(exps) == 1) { - sql_exp *e = exps->h->data, *le = e->l, *re = e->r; - - if (e->type == e_cmp && e->flag == cmp_equal && le->card != CARD_ATOM && re->card == CARD_ATOM && !is_semantics(e)) { - if (!l) { - *L = l = le; - if (!is_column(le->type)) - return 0; - } - return (exp_match(l, le)); - } - if (e->type == e_cmp && e->flag == cmp_or && !is_anti(e) && !is_semantics(e)) - return (are_equality_exps(e->l, L) && are_equality_exps(e->r, L)); - } - return 0; -} - -static void -get_exps( list *n, list *l ) -{ - sql_exp *e = l->h->data, *re = e->r; - - if (e->type == e_cmp && e->flag == cmp_equal && re->card == CARD_ATOM) - list_append(n, re); - if (e->type == e_cmp && e->flag == cmp_or) { - get_exps(n, e->l); - get_exps(n, e->r); - } -} - -static sql_exp * -equality_exps_2_in( mvc *sql, sql_exp *ce, list *l, list *r) -{ - list *nl = new_exp_list(sql->sa); - - get_exps(nl, l); - get_exps(nl, r); - - return exp_in( sql->sa, ce, nl, cmp_in); -} - -static list * -merge_ors(mvc *sql, list *exps, int *changes) -{ - /* n = 1 OR n = 2 ==> n in (1, 2) */ - list *nexps = NULL; - int needed = 0; - - // blindly looks for any cmp_or in the top list - for (node *n = exps->h; n && !needed; n = n->next) { - sql_exp *e = n->data; - - if (e->type == e_cmp && e->flag == cmp_or && !is_anti(e)) - needed = 1; - } - - if (needed) { - nexps = new_exp_list(sql->sa); - for (node *n = exps->h; n; n = n->next) { - sql_exp *e = n->data, *l = NULL; - - if (e->type == e_cmp && e->flag == cmp_or && !is_anti(e) && are_equality_exps(e->l, ) && are_equality_exps(e->r, ) && l) { - (*changes)++; - append(nexps, equality_exps_2_in(sql, l, e->l, e->r)); - } else { - append(nexps, e); - } - } - } else { - nexps = exps; - } - - for (node *n = nexps->h; n ; n = n->next) { - sql_exp *e = n->data; - - if (e->type == e_cmp && e->flag == cmp_or) { - e->l = merge_ors(sql, e->l, changes); - e->r = merge_ors(sql, e->r, changes); - } - } - - return nexps; -} - static inline int exp_col_key(sql_exp *e) { @@ -1108,9 +1019,6 @@ rel_select_cse(visitor *v, sql_rel *rel) if ((is_select(rel->op) || is_join(rel->op) || is_semi(rel->op)) && rel->exps) /* cleanup equal expressions */ rel->exps = cleanup_equal_exps(v->sql, rel, rel->exps, >changes); /* (a = b) and (a += b) */ - if (NULL && is_select(rel->op) && rel->exps) - rel->exps = merge_ors(v->sql, rel->exps, >changes); /* x = 1 or x = 2 => x in (1, 2)*/ - if (is_select(rel->op) && rel->exps) rel->exps = merge_ors_NEW(v->sql, rel->exps, >changes); ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: cmp-or-patterns - Properly increment v->changes
Changeset: 4b95eb0e96b6 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/4b95eb0e96b6 Modified Files: sql/server/rel_optimize_sel.c Branch: cmp-or-patterns Log Message: Properly increment v->changes diffs (31 lines): 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 @@ -818,6 +818,8 @@ merge_ors_NEW(mvc *sql, list *exps, int l = append(l, new); r = append(r, (sql_exp*)i->data); new = exp_or(sql->sa, l, r, 0); + + (*changes)++; } } @@ -838,6 +840,8 @@ merge_ors_NEW(mvc *sql, list *exps, int l = append(l, new); r = append(r, (sql_exp*)i->data); new = exp_or(sql->sa, l, r, 0); + + (*changes)++; } } @@ -865,9 +869,6 @@ merge_ors_NEW(mvc *sql, list *exps, int list_remove_node(exps, NULL, n); exps = append(exps, new); - - // TODO: should that be per col/multicol group? - (*changes)++; } } return exps; ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: cmp-or-patterns - Sets the number of buckets for merge-...
Changeset: b329b7f298ca for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/b329b7f298ca Modified Files: sql/server/rel_optimize_sel.c Branch: cmp-or-patterns Log Message: Sets the number of buckets for merge-ors opt diffs (20 lines): 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 @@ -788,14 +788,14 @@ merge_ors_NEW(mvc *sql, list *exps, int /* detect col cmp_eq exps with multiple values */ bool col_multival = false; if (list_length(eqs) > 1) { - eqh = hash_new(sql->sa, 4 /* TODO: HOW MUCH? prob. 64*/, (fkeyvalue)_col_key); + eqh = hash_new(sql->sa, 32, (fkeyvalue)_col_key); col_multival = detect_col_cmp_eqs(sql, eqs, eqh); } /* detect mutli-col cmp_eq exps with multiple (lists of) values */ bool multicol_multival = false; if (list_length(mce_ands) > 1) { - meqh = hash_new(sql->sa, 4 /* TODO: HOW MUCH? prob. 16*/, (fkeyvalue)_multi_col_key); + meqh = hash_new(sql->sa, 32, (fkeyvalue)_multi_col_key); multicol_multival = detect_multicol_cmp_eqs(sql, mce_ands, meqh); } ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: cmp-or-patterns - Renames functions for e_col hash key
Changeset: 86624d0efc0c for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/86624d0efc0c Modified Files: sql/server/rel_optimize_sel.c Branch: cmp-or-patterns Log Message: Renames functions for e_col hash key diffs (41 lines): 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 @@ -513,7 +513,7 @@ merge_ors(mvc *sql, list *exps, int *cha } static inline int -exp_unique_id(sql_exp *e) +exp_col_key(sql_exp *e) { return e->nid ? e->nid : e->alias.label; } @@ -521,16 +521,16 @@ exp_unique_id(sql_exp *e) static inline int exp_cmp_eq_unique_id(sql_exp *e) { - return exp_unique_id(e->l); + return exp_col_key(e->l); } static inline int exp_multi_col_key(list *l) { - int k = exp_unique_id(l->h->data); + int k = exp_col_key(l->h->data); for (node *n = l->h->next; n; n = n->next) { k <<= 4; - k ^= exp_unique_id(n->data); + k ^= exp_col_key(n->data); } return k; } @@ -788,7 +788,7 @@ merge_ors_NEW(mvc *sql, list *exps, int /* detect col cmp_eq exps with multiple values */ bool col_multival = false; if (list_length(eqs) > 1) { - eqh = hash_new(sql->sa, 4 /* TODO: HOW MUCH? prob. 64*/, (fkeyvalue)_unique_id); + eqh = hash_new(sql->sa, 4 /* TODO: HOW MUCH? prob. 64*/, (fkeyvalue)_col_key); col_multival = detect_col_cmp_eqs(sql, eqs, eqh); } ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: cmp-or-patterns - Replaces multi col hash key with simp...
Changeset: 5ee42fc29614 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/5ee42fc29614 Modified Files: sql/server/rel_optimize_sel.c Branch: cmp-or-patterns Log Message: Replaces multi col hash key with simpler function diffs (52 lines): 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 @@ -524,6 +524,17 @@ exp_cmp_eq_unique_id(sql_exp *e) return exp_unique_id(e->l); } +static inline int +exp_multi_col_key(list *l) +{ + int k = exp_unique_id(l->h->data); + for (node *n = l->h->next; n; n = n->next) { + k <<= 4; + k ^= exp_unique_id(n->data); + } + return k; +} + typedef struct exp_eq_col_values { /* we need ->first in order to remove it from the list of cmp_eq exps * in case that we find another occurrence (with a different value) @@ -605,20 +616,10 @@ detect_multicol_cmp_eqs(mvc *sql, list * list_append_before(mce_ands, n, sl); list_remove_node(mce_ands, NULL, n); - /* make a hash key out of the concat str of (rname1, name1, rname2, name2..) */ - char *cs = ""; - for (node *m = sl->h; m; m = m->next) { - sql_exp *col_exp = ((sql_exp*)m->data)->l; - if (col_exp->alias.rname) - cs = strconcat(cs, strconcat(col_exp->alias.rname, col_exp->alias.name)); - else - cs = strconcat(cs, col_exp->alias.name); - } - /* find the eq exp in the hash and append the values */ bool found = false; - int key = meqh->key(cs); + int key = meqh->key(sl); sql_hash_e *he = meqh->buckets[key&(meqh->size-1)]; for (;he && !found; he = he->chain) { @@ -794,7 +795,7 @@ merge_ors_NEW(mvc *sql, list *exps, int /* detect mutli-col cmp_eq exps with multiple (lists of) values */ bool multicol_multival = false; if (list_length(mce_ands) > 1) { - meqh = hash_new(sql->sa, 4 /* TODO: HOW MUCH? prob. 16*/, (fkeyvalue)_key); + meqh = hash_new(sql->sa, 4 /* TODO: HOW MUCH? prob. 16*/, (fkeyvalue)_multi_col_key); multicol_multival = detect_multicol_cmp_eqs(sql, mce_ands, meqh); } ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: cmp-or-patterns - Uselect might be needed even when we ...
Changeset: 3cc9257301c7 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/3cc9257301c7 Modified Files: sql/backends/monet5/rel_bin.c Branch: cmp-or-patterns Log Message: Uselect might be needed even when we don't have a cand list diffs (12 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 @@ -520,7 +520,7 @@ handle_in_tuple_exps(backend *be, sql_ex else s = cursel; } - if (sel && !(depth || !reduce)) + if (!depth && reduce) s = stmt_uselect(be, s->nrcols == 0?stmt_const(be, bin_find_smallest_column(be, left), s): s, stmt_bool(be, 1), cmp_equal, sel, 0, 0); ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: cmp-or-patterns - Merges default
Changeset: e04dfb7d47b5 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/e04dfb7d47b5 Branch: cmp-or-patterns Log Message: Merges default diffs (truncated from 3547 to 300 lines): diff --git a/.hgtags b/.hgtags --- a/.hgtags +++ b/.hgtags @@ -829,3 +829,4 @@ 9a694c41042503a22d6c92aeab5bc4ca1912b62e 9a694c41042503a22d6c92aeab5bc4ca1912b62e Dec2023_SP3_release e1e9e22bf3d734dc50b56151c657a57c18f56561 Aug2024_root cde7d8f7c99540a8c95856df052a9f123b0c1643 Dec2023_11 +cde7d8f7c99540a8c95856df052a9f123b0c1643 Dec2023_SP4_release diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -182,6 +182,11 @@ install(FILES DESTINATION ${EXPORT_TARGET_PATH} COMPONENT monetdbdev) +install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/MonetDBConfigVersion.cmake + DESTINATION ${EXPORT_TARGET_PATH} + COMPONENT monetdbdev) + include(monetdb-packages) include(CTest) diff --git a/clients/Tests/All b/clients/Tests/All --- a/clients/Tests/All +++ b/clients/Tests/All @@ -1,6 +1,6 @@ exports -HAVE_HGE_FITS_GEOM_LIBR_LIBPY3_NETCDF_SHP_WIN32?MAL-signatures-hge -!HAVE_HGE_FITS_GEOM_LIBR_LIBPY3_NETCDF_SHP_WIN32?MAL-signatures +HAVE_HGE_FITS_GEOM_LIBR_LIBPY3_NETCDF_SHP_CUDF?MAL-signatures-hge +!HAVE_HGE_FITS_GEOM_LIBR_LIBPY3_NETCDF_SHP_CUDF?MAL-signatures NOT_WIN32?melcheck mclient-uri testcondvar diff --git a/clients/Tests/MAL-signatures-hge.test b/clients/Tests/MAL-signatures-hge.test --- a/clients/Tests/MAL-signatures-hge.test +++ b/clients/Tests/MAL-signatures-hge.test @@ -47519,6 +47519,16 @@ command mmath.log2arg(X_0:flt, X_1:flt): MATHbinary_LOGflt; The log(x) function returns the logarithm of x in the given base. mmath +nextafter +command mmath.nextafter(X_0:dbl, X_1:dbl):dbl +MATHbinary_NEXTAFTERdbl; +The returns the next representable floating-point value of x in the direction of y. +mmath +nextafter +command mmath.nextafter(X_0:flt, X_1:flt):flt +MATHbinary_NEXTAFTERflt; +The returns the next representable floating-point value of x in the direction of y. +mmath pi command mmath.pi():dbl MATHpi; diff --git a/clients/Tests/MAL-signatures.test b/clients/Tests/MAL-signatures.test --- a/clients/Tests/MAL-signatures.test +++ b/clients/Tests/MAL-signatures.test @@ -35989,6 +35989,16 @@ command mmath.log2arg(X_0:flt, X_1:flt): MATHbinary_LOGflt; The log(x) function returns the logarithm of x in the given base. mmath +nextafter +command mmath.nextafter(X_0:dbl, X_1:dbl):dbl +MATHbinary_NEXTAFTERdbl; +The returns the next representable floating-point value of x in the direction of y. +mmath +nextafter +command mmath.nextafter(X_0:flt, X_1:flt):flt +MATHbinary_NEXTAFTERflt; +The returns the next representable floating-point value of x in the direction of y. +mmath pi command mmath.pi():dbl MATHpi; diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out --- a/clients/Tests/exports.stable.out +++ b/clients/Tests/exports.stable.out @@ -790,7 +790,6 @@ str AUTHunlockVault(const char *password str AUTHverifyPassword(const char *passwd); str BKCmirror(bat *ret, const bat *bid); str BKCnewBAT(bat *res, const int *tt, const BUN *cap, role_t role); -str CLTsessions(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); str CLTshutdown(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); str COPYrejects(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); str COPYrejects_clear(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); @@ -1022,6 +1021,7 @@ int getOidConstant(MalBlkPtr mb, oid val int getPC(MalBlkPtr mb, InstrPtr p); str getPipeCatalog(bat *nme, bat *def, bat *stat); const char *getRef; +str getScenarioLanguage(Client c); int getShtConstant(MalBlkPtr mb, sht val); int getStrConstant(MalBlkPtr mb, str val); const char *getTraceRef; @@ -1065,6 +1065,7 @@ const char *likeRef; const char *likejoinRef; const char *likeselectRef; const char *likeuselectRef; +const char *lngRef; str loadLibrary(const char *modulename, int flag); char *locate_file(const char *basename, const char *ext, bit recurse); const char *lockRef; diff --git a/common/utils/msabaoth.c b/common/utils/msabaoth.c --- a/common/utils/msabaoth.c +++ b/common/utils/msabaoth.c @@ -721,9 +721,15 @@ msab_getSingleStatus(const char *pathbuf }; /* store the database name */ - snprintf(buf, sizeof(buf), "%s/%s", pathbuf, dbname); + int dbnamestart; +#ifdef _MSC_VER + dbnamestart = snprintf(buf, sizeof(buf), "%s/", pathbuf); + snprintf(buf + dbnamestart, sizeof(buf) - dbnamestart, "%s", dbname); +#else + snprintf(buf, sizeof(buf), "%s/%n%s", pathbuf, , dbname); +#endif sdb->path = strdup(buf); - sdb->dbname = sdb->path + strlen(sdb->path) - strlen(dbname); + sdb->dbname = sdb->path + dbnamestart; /* check the state of the server by looking at its gdk lock: diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c --- a/gdk/gdk_bbp.c +++ b/gdk/gdk_bbp.c @@ -4912,6 +4912,7 @@
MonetDB: cmp-or-patterns - Merges default
Changeset: 65314a3e0074 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/65314a3e0074 Branch: cmp-or-patterns Log Message: Merges default diffs (truncated from 9025 to 300 lines): diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,34 +0,0 @@ -name: Bug report -about: Create a report to help us improve the sytem -title: '' -labels: '' -assignees: '' - - -**Describe the bug** -A clear and concise description of what the bug is. - -**To Reproduce** -Create a setting with minimal input for an external user to demonstrate the buggy behavior. -This includes the relevant part of the database schema description. -Performance trace of the rogue query (using the TRACE command) - -**Expected behavior** -A clear and concise description of what you expected to happen. - -**Screenshots** -If applicable, add screenshots to help explain your problem. - -**Software versions** - - MonetDB version number [a milestone label] - - OS and version: [e.g. Ubuntu 18.04] - - Installed from release package or self-installed and compiled - - -**Issue labeling ** -Make liberal use of the labels to characterise the issue topics. e.g. identify severity, version, etc.. - -**Additional context** -Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,61 @@ +name: Bug report +description: Use this template to report bugs in MonetDB +labels: ["needs triage"] +body: + - type: textarea +id: summary +attributes: + label: Describe the bug + description: | +Clear and concise description of what the bug is. +validations: + required: true + - type: textarea +id: reproduction +attributes: + label: Reproduction steps + description: | +Create a setting with minimal input for an external user to demonstrate the buggy behavior. +This includes the relevant part of the database schema description. +Performance trace of the rogue query (using the TRACE command). +validations: + required: false + - type: textarea +id: expected +attributes: + label: Expected behavior + description: | +Clear and concise description of what you expected to happen. +validations: + required: false + - type: input +id: mdbversion +attributes: + label: MonetDB release + placeholder: e.g., Dec2023_SP1, 11.49.1 +validations: + required: true + - type: dropdown +id: binsource +attributes: + label: Executables source + options: +- "Release packages" +- "Self compiled and installed" +validations: + required: true + - type: input +id: osversion +attributes: + label: Operating System + placeholder: e.g., Fedora Linux 39 (Workstation Edition) +validations: + required: true + - type: textarea +id: additional +attributes: + label: Additional context + description: | +Add any other context or screenshots about the problem here. +validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,20 +0,0 @@ -name: Feature request -about: Suggest an idea for this project -title: '' -labels: '' -assignees: '' - - -**Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] - -**Describe the solution you'd like** -A clear and concise description of what you want to happen. - -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. - -**Additional context** -Add any other context or screenshots about the feature request here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,36 @@ +name: Feature request +description: Use this template for feature requests +labels: ["needs triage"] +body: + - type: textarea +id: problem +attributes: + label: Is your feature request related to a problem? Describe it + description: | +A clear and concise description of what the problem is. +validations: + required: true + - type: textarea +id: solution +attributes: + label: Describe the solution you'd like to see implemented + description: | +A clear and concise description of what you want to happen. +validations: + required: true + - type: textarea +id: alternatives +
MonetDB: cmp-or-patterns - Adapts Mtests expected plan
Changeset: 8c6d50059bfb for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/8c6d50059bfb Modified Files: sql/test/miscellaneous/Tests/simple_plans.test Branch: cmp-or-patterns Log Message: Adapts Mtests expected plan diffs (12 lines): 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 @@ -132,7 +132,7 @@ plan select 1 from tab0 where ((col1 = 1 project ( | select ( | | table("sys"."tab0") [ "tab0"."col1", "tab0"."col2" ] -| ) [ (("tab0"."col2") = (int(7) "100")) or (("tab0"."col1") in (int(7) "1", int(7) "81", int(7) "100")) ] +| ) [ (("tab0"."col1") in (int(7) "1", int(7) "81", int(7) "100")) or (("tab0"."col2") = (int(7) "100")) ] ) [ tinyint(1) "1" ] query T nosort ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: cmp-or-patterns - Merges default
Changeset: df3da4e56ac4 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/df3da4e56ac4 Branch: cmp-or-patterns Log Message: Merges default diffs (truncated from 385 to 300 lines): diff --git a/clients/mapilib/ChangeLog.Aug2024 b/clients/mapilib/ChangeLog.Aug2024 --- a/clients/mapilib/ChangeLog.Aug2024 +++ b/clients/mapilib/ChangeLog.Aug2024 @@ -1,3 +1,10 @@ # ChangeLog file for mapilib # This file is updated with Maddlog +* Wed Jun 19 2024 Joeri van Ruth +- Add new columns to sys.sessions. Column 'language' is usually 'sql'. + Column 'peer' is the network address of the client (something like + '[::1]:46558' or ''). Columns 'hostname', 'application', + 'client', 'clientpid' and 'remark' can be set by the client. + Libmapi/mclient, pymonetdb and monetdb-java have been modified to fill + in sensible default values. diff --git a/gdk/gdk.h b/gdk/gdk.h --- a/gdk/gdk.h +++ b/gdk/gdk.h @@ -753,7 +753,7 @@ typedef struct { #define GDKLIBRARY_HSIZE 061045U /* first in Jan2022: heap "size" values */ #define GDKLIBRARY_JSON061046U /* first in Sep2022: json storage changes*/ #define GDKLIBRARY_STATUS 061047U /* first in Dec2023: no status/filename columns */ -#define GDKLIBRARY 061050U /* first after Dec2023 */ +#define GDKLIBRARY 061050U /* first in Aug2024 */ /* The batRestricted field indicates whether a BAT is readonly. * we have modes: BAT_WRITE = all permitted diff --git a/monetdb5/modules/mal/txtsim.c b/monetdb5/modules/mal/txtsim.c --- a/monetdb5/modules/mal/txtsim.c +++ b/monetdb5/modules/mal/txtsim.c @@ -203,8 +203,10 @@ levenshtein(int *res, const char *x, con xlen = UTF8_strlen(x); ylen = UTF8_strlen(y); - if (xlen == ylen && (strcmp(x, y) == 0)) + if (xlen == ylen && (strcmp(x, y) == 0)) { + *res = 0; return MAL_SUCCEED; + } column = GDKmalloc((xlen + 1) * sizeof(unsigned int)); if (column == NULL) diff --git a/sql/backends/monet5/generator/generator.c b/sql/backends/monet5/generator/generator.c --- a/sql/backends/monet5/generator/generator.c +++ b/sql/backends/monet5/generator/generator.c @@ -831,6 +831,7 @@ VLTgenerator_subselect(Client cntxt, Mal do { \ TPE f,l,s, low, hgh; \ BUN j; oid *v; \ + bool nil_matches = false; \ f = *getArgReference_##TPE(stk,p, 1); \ l = *getArgReference_##TPE(stk,p, 2); \ if ( p->argc == 3) \ @@ -858,18 +859,26 @@ VLTgenerator_subselect(Client cntxt, Mal low = NEXTVALUE##TPE(low); \ } else if ( strcmp(oper,">=") == 0){ \ low= *getArgReference_##TPE(stk,pci,3); \ - } else if ( strcmp(oper,"!=") == 0 || strcmp(oper, "<>") == 0){ \ + } else if (strcmp(oper, "!=") == 0 || strcmp(oper, "<>") == 0) { \ + hgh= low= *getArgReference_##TPE(stk,pci,3); \ + anti = true; \ + } else if (strcmp(oper, "==") == 0 || strcmp(oper, "=") == 0) { \ hgh= low= *getArgReference_##TPE(stk,pci,3); \ - anti = 1; \ - } else if ( strcmp(oper,"==") == 0 || strcmp(oper, "=") == 0){ \ + } else if (strcmp(oper, "ne") == 0) { \ hgh= low= *getArgReference_##TPE(stk,pci,3); \ + anti = true; \ + nil_matches = true; \ + } else if (strcmp(oper, "eq") == 0) { \ + hgh= low= *getArgReference_##TPE(stk,pci,3); \ +
MonetDB: cmp-or-patterns - Adds test for multi-col cmp_eq to cmp...
Changeset: d4c04f17a9d6 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/d4c04f17a9d6 Added Files: sql/test/rel-optimizers/Tests/merge-ors-multi-col-eq-to-cmp_in.reqtests sql/test/rel-optimizers/Tests/merge-ors-multi-col-eq-to-cmp_in.test Modified Files: sql/test/rel-optimizers/Tests/All sql/test/rel-optimizers/Tests/merge-ors-base.test Branch: cmp-or-patterns Log Message: Adds test for multi-col cmp_eq to cmp_in case by merge_ors opt diffs (175 lines): diff --git a/sql/test/rel-optimizers/Tests/All b/sql/test/rel-optimizers/Tests/All --- a/sql/test/rel-optimizers/Tests/All +++ b/sql/test/rel-optimizers/Tests/All @@ -14,3 +14,4 @@ merge-unions-base merge-unions merge-ors-base merge-ors-single-col-eq-to-cmp_in +merge-ors-multi-col-eq-to-cmp_in diff --git a/sql/test/rel-optimizers/Tests/merge-ors-base.test b/sql/test/rel-optimizers/Tests/merge-ors-base.test --- a/sql/test/rel-optimizers/Tests/merge-ors-base.test +++ b/sql/test/rel-optimizers/Tests/merge-ors-base.test @@ -2,5 +2,19 @@ statement ok create table f (n int, m int) statement ok -insert into f values (1, 20), (2, 40), (2, 0), (3, 60), (9, 180) +insert into f values (1, 20), + (2, 40), +(2, 0 ), +(3, 60), +(9, 180) +statement ok +create table b (n int, m int, k int) + +statement ok +insert into b values (1, 20, 200), + (2, 40, 400), +(2, 0, 0), +(3, 60, 600), +(9, 180, 1800) + diff --git a/sql/test/rel-optimizers/Tests/merge-ors-multi-col-eq-to-cmp_in.reqtests b/sql/test/rel-optimizers/Tests/merge-ors-multi-col-eq-to-cmp_in.reqtests new file mode 100644 --- /dev/null +++ b/sql/test/rel-optimizers/Tests/merge-ors-multi-col-eq-to-cmp_in.reqtests @@ -0,0 +1,1 @@ +merge-ors-base diff --git a/sql/test/rel-optimizers/Tests/merge-ors-multi-col-eq-to-cmp_in.test b/sql/test/rel-optimizers/Tests/merge-ors-multi-col-eq-to-cmp_in.test new file mode 100644 --- /dev/null +++ b/sql/test/rel-optimizers/Tests/merge-ors-multi-col-eq-to-cmp_in.test @@ -0,0 +1,132 @@ +query III rowsort +select * from b where n > 3 or (m = 20 and k = 200) or (m = 60 and k = 600) + +1 +20 +200 +3 +60 +600 +9 +180 +1800 + +query T nosort non-eq-two-col-2-value +plan select * from b where n > 3 or (m = 20 and k = 200) or (m = 60 and k = 600) + +project ( +| select ( +| | table("sys"."b") [ "b"."n", "b"."m", "b"."k" ] +| ) [ (( [ "b"."m", "b"."k" ]) in ( [ int(8) "20", int(11) "200" ], [ int(8) "60", int(11) "600" ])) or (("b"."n") > (int(4) "3")) ] +) [ "b"."n", "b"."m", "b"."k" ] + +query T nosort non-eq-two-col-2-value +plan select * from b where (m = 20 and k = 200) or n > 3 or (m = 60 and k = 600) + +project ( +| select ( +| | table("sys"."b") [ "b"."n", "b"."m", "b"."k" ] +| ) [ (( [ "b"."m", "b"."k" ]) in ( [ int(8) "20", int(11) "200" ], [ int(8) "60", int(11) "600" ])) or (("b"."n") > (int(4) "3")) ] +) [ "b"."n", "b"."m", "b"."k" ] + +# order of m,k equality statements are swapped in the last AND expression +query T nosort non-eq-two-col-2-value +plan select * from b where (m = 20 and k = 200) or n > 3 or (k = 600 and m = 60) + +project ( +| select ( +| | table("sys"."b") [ "b"."n", "b"."m", "b"."k" ] +| ) [ (( [ "b"."m", "b"."k" ]) in ( [ int(8) "20", int(11) "200" ], [ int(8) "60", int(11) "600" ])) or (("b"."n") > (int(4) "3")) ] +) [ "b"."n", "b"."m", "b"."k" ] + +query T nosort non-eq-two-col-2-value +plan select * from b where (m = 20 and k = 200) or (m = 60 and k = 600) or n > 3 + +project ( +| select ( +| | table("sys"."b") [ "b"."n", "b"."m", "b"."k" ] +| ) [ (( [ "b"."m", "b"."k" ]) in ( [ int(8) "20", int(11) "200" ], [ int(8) "60", int(11) "600" ])) or (("b"."n") > (int(4) "3")) ] +) [ "b"."n", "b"."m", "b"."k" ] + +query III rowsort +select * from b where (n = 1 and m = 20) or (m = 20 and k = 200) or (m = 60 and k = 600) + +1 +20 +200 +3 +60 +600 + +query T nosort two-col-1-value-two-col-2-value +plan select * from b where (n = 1 and m = 20) or (m = 20 and k = 200) or (m = 60 and k = 600) + +project ( +| select ( +| | table("sys"."b") [ "b"."n", "b"."m", "b"."k" ] +| ) [ (( [ "b"."m", "b"."k" ]) in ( [ int(8) "20", int(11) "200" ], [ int(8) "60", int(11) "600" ])) or (("b"."n") = (int(4) "1"), ("b"."m") = (int(8) "20")) ] +) [ "b"."n", "b"."m", "b"."k" ] + +query T nosort two-col-1-value-two-col-2-value +plan select * from b where (m = 20 and k = 200) or (n = 1 and m = 20) or (m = 60 and k = 600) + +project ( +| select ( +| | table("sys"."b") [ "b"."n", "b"."m", "b"."k" ] +| ) [ (( [ "b"."m", "b"."k" ]) in ( [ int(8) "20", int(11) "200" ], [ int(8) "60", int(11) "600" ])) or (("b"."n") = (int(4) "1"), ("b"."m") = (int(8) "20")) ] +) [ "b"."n", "b"."m", "b"."k" ] + +query
MonetDB: cmp-or-patterns - Renames Mtests for merge-ors optimizer
Changeset: 018ab410397e for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/018ab410397e Added Files: sql/test/rel-optimizers/Tests/merge-ors-base.test sql/test/rel-optimizers/Tests/merge-ors-single-col-eq-to-cmp_in.reqtests sql/test/rel-optimizers/Tests/merge-ors-single-col-eq-to-cmp_in.test Removed Files: sql/test/rel-optimizers/Tests/select-cse-merge-ors-base.test sql/test/rel-optimizers/Tests/select-cse-merge-ors.reqtests sql/test/rel-optimizers/Tests/select-cse-merge-ors.test Modified Files: sql/test/rel-optimizers/Tests/All Branch: cmp-or-patterns Log Message: Renames Mtests for merge-ors optimizer diffs (25 lines): diff --git a/sql/test/rel-optimizers/Tests/All b/sql/test/rel-optimizers/Tests/All --- a/sql/test/rel-optimizers/Tests/All +++ b/sql/test/rel-optimizers/Tests/All @@ -12,5 +12,5 @@ remote-replica-plan remote-replica merge-unions-base merge-unions -select-cse-merge-ors-base -select-cse-merge-ors +merge-ors-base +merge-ors-single-col-eq-to-cmp_in diff --git a/sql/test/rel-optimizers/Tests/select-cse-merge-ors-base.test b/sql/test/rel-optimizers/Tests/merge-ors-base.test rename from sql/test/rel-optimizers/Tests/select-cse-merge-ors-base.test rename to sql/test/rel-optimizers/Tests/merge-ors-base.test diff --git a/sql/test/rel-optimizers/Tests/select-cse-merge-ors.reqtests b/sql/test/rel-optimizers/Tests/merge-ors-single-col-eq-to-cmp_in.reqtests rename from sql/test/rel-optimizers/Tests/select-cse-merge-ors.reqtests rename to sql/test/rel-optimizers/Tests/merge-ors-single-col-eq-to-cmp_in.reqtests --- a/sql/test/rel-optimizers/Tests/select-cse-merge-ors.reqtests +++ b/sql/test/rel-optimizers/Tests/merge-ors-single-col-eq-to-cmp_in.reqtests @@ -1,1 +1,1 @@ -select-cse-merge-ors-base +merge-ors-base diff --git a/sql/test/rel-optimizers/Tests/select-cse-merge-ors.test b/sql/test/rel-optimizers/Tests/merge-ors-single-col-eq-to-cmp_in.test rename from sql/test/rel-optimizers/Tests/select-cse-merge-ors.test rename to sql/test/rel-optimizers/Tests/merge-ors-single-col-eq-to-cmp_in.test ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: cmp-or-patterns - Removes tests for the merge-select-rs...
Changeset: 66621f0a0b80 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/66621f0a0b80 Modified Files: sql/test/rel-optimizers/Tests/select-cse-merge-ors.test Branch: cmp-or-patterns Log Message: Removes tests for the merge-select-rse opt diffs (33 lines): diff --git a/sql/test/rel-optimizers/Tests/select-cse-merge-ors.test b/sql/test/rel-optimizers/Tests/select-cse-merge-ors.test --- a/sql/test/rel-optimizers/Tests/select-cse-merge-ors.test +++ b/sql/test/rel-optimizers/Tests/select-cse-merge-ors.test @@ -62,29 +62,6 @@ project ( | ) [ ("f"."n") in (int(4) "3", int(4) "1", int(4) "2") ] ) [ "f"."n", "f"."m" ] -query T nosort -plan select * from f -where m = 60 - or n in (1, 2) - or n in (3) - -KNOWN - -query T nosort -plan select * from f -where n in (1, 2) - or m = 60 - or n in (3) - -KNOWN - -query T nosort -plan select * from f -where n in (1, 2) - or n in (3) - or m = 60 - -KNOWN ## chained cmp_equal-atom ors with lhs in [n, m] ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: cmp-or-patterns - Adaps mtest plans to new merge_or opt
Changeset: fe71035febf9 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/fe71035febf9 Modified Files: sql/test/rel-optimizers/Tests/select-cse-merge-ors.test Branch: cmp-or-patterns Log Message: Adaps mtest plans to new merge_or opt diffs (30 lines): diff --git a/sql/test/rel-optimizers/Tests/select-cse-merge-ors.test b/sql/test/rel-optimizers/Tests/select-cse-merge-ors.test --- a/sql/test/rel-optimizers/Tests/select-cse-merge-ors.test +++ b/sql/test/rel-optimizers/Tests/select-cse-merge-ors.test @@ -97,7 +97,7 @@ where n = 1 project ( | select ( | | table("sys"."f") [ "f"."n", "f"."m" ] -| ) [ (("f"."m") = (int(8) "60")) or (("f"."n") in (int(4) "1", int(4) "2")) ] +| ) [ (("f"."n") in (int(4) "1", int(4) "2")) or (("f"."m") = (int(8) "60")) ] ) [ "f"."n", "f"."m" ] query T nosort @@ -109,7 +109,7 @@ where n = 1 project ( | select ( | | table("sys"."f") [ "f"."n", "f"."m" ] -| ) [ (("f"."m") = (int(8) "60")) or (("f"."n") in (int(4) "1", int(4) "2")) ] +| ) [ (("f"."n") in (int(4) "1", int(4) "2")) or (("f"."m") = (int(8) "60")) ] ) [ "f"."n", "f"."m" ] query T nosort @@ -121,7 +121,7 @@ where m = 60 project ( | select ( | | table("sys"."f") [ "f"."n", "f"."m" ] -| ) [ (("f"."m") = (int(8) "60")) or (("f"."n") in (int(4) "1", int(4) "2")) ] +| ) [ (("f"."n") in (int(4) "1", int(4) "2")) or (("f"."m") = (int(8) "60")) ] ) [ "f"."n", "f"."m" ] ## chained ors with lhs in [n, (n && m)] ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: cmp-or-patterns - Improves bits and comments
Changeset: 9581b643aecf for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/9581b643aecf Modified Files: sql/server/rel_optimize_sel.c Branch: cmp-or-patterns Log Message: Improves bits and comments diffs (76 lines): 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 @@ -647,12 +647,11 @@ detect_multicol_cmp_eqs(mvc *sql, list * if (!found) { eq_mcv *mcv = SA_NEW(sql->sa, eq_mcv); - // TODO: explain!! mcv->first = sl; mcv->cols = sa_list(sql->sa); for (node *m = sl->h; m; m = m->next) mcv->cols = append(mcv->cols, ((sql_exp*)m->data)->l); - /* for (group values) gv create a list and append it to the lvs list */ + /* for the list of values (atoms) create a list and append it to the lvs list */ list *atms = sa_list(sql->sa); for (node *m = sl->h; m; m = m->next) atms = append(atms, ((sql_exp*)m->data)->r); @@ -676,15 +675,16 @@ exp_or_chain_groups(mvc *sql, list *exps * * return true if there is an exp with more than one cmp_eq */ +bool eq_only = true; +for (node *n = exps->h; n && eq_only; n = n->next) { +sql_exp *e = n->data; +sql_exp *le = e->l, *re = e->r; +eq_only &= (e->type == e_cmp && e->flag == cmp_equal && +le->card != CARD_ATOM && is_column(le->type) && +re->card == CARD_ATOM && !is_semantics(e)); +} + if (list_length(exps) > 1) { - bool eq_only = true; - for (node *n = exps->h; n && eq_only; n = n->next) { - sql_exp *e = n->data; - sql_exp *le = e->l, *re = e->r; - eq_only &= (e->type == e_cmp && e->flag == cmp_equal && - le->card != CARD_ATOM && is_column(le->type) && - re->card == CARD_ATOM && !is_semantics(e)); - } if (eq_only) *mce_ands = append(*mce_ands, exps); else @@ -698,9 +698,7 @@ exp_or_chain_groups(mvc *sql, list *exps exp_or_chain_groups(sql, (list*)le, gen_ands, mce_ands, eqs, noneq); exp_or_chain_groups(sql, (list*)re, gen_ands, mce_ands, eqs, noneq); - } else if (se->type == e_cmp && se->flag == cmp_equal && - le->card != CARD_ATOM && is_column(le->type) && - re->card == CARD_ATOM && !is_semantics(se)) { + } else if (eq_only) { *eqs = append(*eqs, se); } else { *noneq = append(*noneq, se); @@ -712,7 +710,7 @@ static list * generate_single_col_cmp_in(mvc *sql, sql_hash *eqh) { /* from single col cmp_eq with multiple atoms in the hash generate -* "e_col in (val0, val1, ...)" (see exp_or_chain_groups()) +* "e_col in (val0, val1, ...)" (see detect_col_cmp_eqs()) */ list *ins = new_exp_list(sql->sa); for (int i = 0; i < eqh->size; i++) { @@ -768,10 +766,10 @@ merge_ors_NEW(mvc *sql, list *exps, int * e.g. [[e1, e2], [e3, e4, e5]] semantically translates * to [(e1 AND e2), (e3 AND e4 AND e5)] * those (internal) AND list can be then used to -* reconstructed an OR tree -* [[e1, e2], [e3, e4, e5]] => +* reconstructed an OR tree [[e1, e2], [e3, e4, e5]] => * (([e1, e2] OR [e3, e4, e5]) OR ) -* TODO: Explain why we need gen_ands and mce_ands +* gen_ands includes general expressions associated with AND +* mce_ands includes only cmp_eq expressions associated with AND */ gen_ands = new_exp_list(sql->sa); mce_ands = new_exp_list(sql->sa); ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: cmp-or-patterns - generate_single_col_cmp_in() do not h...
Changeset: 0ee68130068f for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/0ee68130068f Modified Files: sql/server/rel_optimize_sel.c Branch: cmp-or-patterns Log Message: generate_single_col_cmp_in() do not have to generate exps for unique cmp_eqs diffs (16 lines): 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 @@ -720,11 +720,9 @@ generate_single_col_cmp_in(mvc *sql, sql while (he) { eq_cv *cv = he->value; - /* only if there are multiple cmp_eq atoms for this col turn them into a cmp_in */ + /* NOTE: cmp_eq expressions with a single entry are still in eqs */ if (list_length(cv->vs) > 1) ins = append(ins, exp_in(sql->sa, cv->col, cv->vs, cmp_in)); - else - ins = append(ins, exp_compare(sql->sa, cv->col, cv->vs->h->data, cmp_equal)); he = he->chain; } } ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: cmp-or-patterns - Renames structs and struct members
Changeset: 1b28cea3141d for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/1b28cea3141d Modified Files: sql/server/rel_optimize_sel.c Branch: cmp-or-patterns Log Message: Renames structs and struct members diffs (170 lines): 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 @@ -524,17 +524,23 @@ exp_cmp_eq_unique_id(sql_exp *e) return exp_unique_id(e->l); } -typedef struct exp_eq_atoms { +typedef struct exp_eq_col_values { + /* we need ->first in order to remove it from the list of cmp_eq exps +* in case that we find another occurrence (with a different value) +*/ sql_exp* first; - sql_exp* e; - list *l; -} ea; - -typedef struct exp_eq_multi_cols_atoms { + sql_exp* col; /* column */ + list *vs; /* list of values */ +} eq_cv; + +typedef struct exp_eq_multi_col_values { + /* we need ->first in order to remove it from the list of multi col +* cmp_eq exps in case that we find another occurrence (with different values) +*/ list *first; - list *ces; /* list of col exps */ - list *gvs; /* list of lists of atoms */ -} mca; + list *cols; /* list of col exps */ + list *lvs; /* list of lists of values */ +} eq_mcv; static bool detect_col_cmp_eqs(mvc *sql, list *eqs, sql_hash *eqh) @@ -551,26 +557,26 @@ detect_col_cmp_eqs(mvc *sql, list *eqs, sql_hash_e *he = eqh->buckets[key&(eqh->size-1)]; for (;he && !found; he = he->chain) { - ea *eas = he->value; - if(!exp_equal(le, eas->e)){ - eas->l = append(eas->l, re); + eq_cv *cv = he->value; + if(!exp_equal(le, cv->col)){ + cv->vs = append(cv->vs, re); found = col_multivalue_cmp_eq = true; } - if (eas->first) { - list_remove_data(eqs, NULL, eas->first); - eas->first = NULL; + if (cv->first) { + list_remove_data(eqs, NULL, cv->first); + cv->first = NULL; } list_remove_node(eqs, NULL, n); } if (!found) { - ea *eas = SA_NEW(sql->sa, ea); - eas->first = e; - eas->l = sa_list(sql->sa); - eas->l = append(eas->l, re); - eas->e = le; - - hash_add(eqh, key, eas); + eq_cv *cv = SA_NEW(sql->sa, eq_cv); + cv->first = e; + cv->vs = sa_list(sql->sa); + cv->vs = append(cv->vs, re); + cv->col = le; + + hash_add(eqh, key, cv); } } return col_multivalue_cmp_eq; @@ -614,8 +620,8 @@ detect_multicol_cmp_eqs(mvc *sql, list * for (;he && !found; he = he->chain) { /* compare the values of the hash_entry with the cols under cmp_eq from the list */ bool same_cols = true; - mca *mcas = he->value; - for (node *m = sl->h, *k = mcas->ces->h; m && k && same_cols; m = m->next, k = k->next) { + eq_mcv *mcv = he->value; + for (node *m = sl->h, *k = mcv->cols->h; m && k && same_cols; m = m->next, k = k->next) { sql_exp *col_exp = ((sql_exp*)m->data)->l; if (exp_equal(col_exp, k->data)) same_cols = false; @@ -627,33 +633,33 @@ detect_multicol_cmp_eqs(mvc *sql, list * list *atms = sa_list(sql->sa); for (node *m = sl->h; m; m = m->next) atms = append(atms, ((sql_exp*)m->data)->r); - mcas->gvs = append(mcas->gvs, atms); + mcv->lvs = append(mcv->lvs, atms); /* remove this and the previous occurrence (which means that's the first time * that we found the *same* multi cmp_eq exp) */ - if (mcas->first) { - list_remove_data(mce_ands, NULL, mcas->first); - mcas->first = NULL; + if (mcv->first) { + list_remove_data(mce_ands, NULL, mcv->first); + mcv->first = NULL;
MonetDB: cmp-or-patterns - Removes unneeded variable from ht entry
Changeset: 2fae9d4adb56 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/2fae9d4adb56 Modified Files: sql/server/rel_optimize_sel.c Branch: cmp-or-patterns Log Message: Removes unneeded variable from ht entry diffs (19 lines): 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 @@ -531,7 +531,6 @@ typedef struct exp_eq_atoms { } ea; typedef struct exp_eq_multi_cols_atoms { - char *cs; /* col(rname, name) concat str */ list *first; list *ces; /* list of col exps */ list *gvs; /* list of lists of atoms */ @@ -642,7 +641,6 @@ detect_multicol_cmp_eqs(mvc *sql, list * if (!found) { mca *mcas = SA_NEW(sql->sa, mca); - mcas->cs = cs; // TODO: explain!! mcas->first = sl; mcas->ces = sa_list(sql->sa); ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: cmp-or-patterns - Do not re-remove the first occurrence...
Changeset: f6aee12fe3e4 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/f6aee12fe3e4 Modified Files: sql/server/rel_optimize_sel.c Branch: cmp-or-patterns Log Message: Do not re-remove the first occurrence of a multi cmp_eq (both for single and multi col exps) diffs (27 lines): 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 @@ -557,8 +557,10 @@ detect_col_cmp_eqs(mvc *sql, list *eqs, eas->l = append(eas->l, re); found = col_multivalue_cmp_eq = true; } - if (eas->first) + if (eas->first) { list_remove_data(eqs, NULL, eas->first); + eas->first = NULL; + } list_remove_node(eqs, NULL, n); } @@ -630,8 +632,10 @@ detect_multicol_cmp_eqs(mvc *sql, list * /* remove this and the previous occurrence (which means that's the first time * that we found the *same* multi cmp_eq exp) */ - if (mcas->first) + if (mcas->first) { list_remove_data(mce_ands, NULL, mcas->first); + mcas->first = NULL; + } list_remove_data(mce_ands, NULL, sl); } } ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: cmp-or-patterns - Re-introduce single col cmp_eq exps i...
Changeset: c406f25500ee for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/c406f25500ee Modified Files: sql/server/rel_optimize_sel.c Branch: cmp-or-patterns Log Message: Re-introduce single col cmp_eq exps in the OR tree diffs (43 lines): 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 @@ -525,6 +525,7 @@ exp_cmp_eq_unique_id(sql_exp *e) } typedef struct exp_eq_atoms { + sql_exp* first; sql_exp* e; list *l; } ea; @@ -556,10 +557,14 @@ detect_col_cmp_eqs(mvc *sql, list *eqs, eas->l = append(eas->l, re); found = col_multivalue_cmp_eq = true; } + if (eas->first) + list_remove_data(eqs, NULL, eas->first); + list_remove_node(eqs, NULL, n); } if (!found) { ea *eas = SA_NEW(sql->sa, ea); + eas->first = e; eas->l = sa_list(sql->sa); eas->l = append(eas->l, re); eas->e = le; @@ -807,6 +812,16 @@ merge_ors_NEW(mvc *sql, list *exps, int } } + if (list_length(eqs)) { + for (node *i = eqs->h; i; i = i->next) { + list *l = new_exp_list(sql->sa); + list *r = new_exp_list(sql->sa); + l = append(l, new); + r = append(r, (sql_exp*)i->data); + new = exp_or(sql->sa, l, r, 0); + } + } + if (mins) { for (node *i = ((ins) ? mins->h : mins->h->next); i; i = i->next) { list *l = new_exp_list(sql->sa); ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: cmp-or-patterns - Renames bool variable
Changeset: 129de5c394f8 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/129de5c394f8 Modified Files: sql/server/rel_optimize_sel.c Branch: cmp-or-patterns Log Message: Renames bool variable diffs (152 lines): 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 @@ -571,7 +571,7 @@ detect_col_cmp_eqs(mvc *sql, list *eqs, } static bool -detect_multicol_cmp_eqs(mvc *sql, list *ceq_ands, sql_hash *meqh) +detect_multicol_cmp_eqs(mvc *sql, list *mce_ands, sql_hash *meqh) { /* we get as input a list of AND associated expressions (hence the entries are lists themselves) * we need to detect cmp_eq-only AND-associated expressions with the same columns so we can @@ -583,14 +583,14 @@ detect_multicol_cmp_eqs(mvc *sql, list * * e.g. in this example (n,k) */ bool multi_multivalue_cmp_eq = false; - for (node *n = ceq_ands->h; n; n = n->next) { + for (node *n = mce_ands->h; n; n = n->next) { list *l = n->data; /* sort the list of the cmp_eq expressions based on the col exp * NOTE: from now on we only work with the sorted list, sl */ list *sl = list_sort(l, (fkeyvalue)_cmp_eq_unique_id, NULL); - list_append_before(ceq_ands, n, sl); - list_remove_node(ceq_ands, NULL, n); + list_append_before(mce_ands, n, sl); + list_remove_node(mce_ands, NULL, n); /* make a hash key out of the concat str of (rname1, name1, rname2, name2..) */ char *cs = ""; @@ -615,7 +615,7 @@ detect_multicol_cmp_eqs(mvc *sql, list * same_cols = false; } if (same_cols) { - /* we found the same multi cmp_eq exp in ceq_ands list multiple times! */ + /* we found the same multi cmp_eq exp in mce_ands list multiple times! */ found = multi_multivalue_cmp_eq = true; /* gather all the values of the list and add them to the hash entry */ list *atms = sa_list(sql->sa); @@ -626,8 +626,8 @@ detect_multicol_cmp_eqs(mvc *sql, list * * that we found the *same* multi cmp_eq exp) */ if (mcas->first) - list_remove_data(ceq_ands, NULL, mcas->first); - list_remove_data(ceq_ands, NULL, sl); + list_remove_data(mce_ands, NULL, mcas->first); + list_remove_data(mce_ands, NULL, sl); } } @@ -653,11 +653,11 @@ detect_multicol_cmp_eqs(mvc *sql, list * } static void -exp_or_chain_groups(mvc *sql, list *exps, list **gen_ands, list **ceq_ands, list **eqs, list **noneq) +exp_or_chain_groups(mvc *sql, list *exps, list **gen_ands, list **mce_ands, list **eqs, list **noneq) { /* identify three different groups * 1. gen_ands: lists of generic expressions (their inner association is AND) -* 2. ceq_ands: lists of multi_colum cmp_eq ONLY expressions (same^^^) +* 2. mce_ands: lists of multi_colum cmp_eq ONLY expressions (same^^^) * 3. eqs: equality expressions * 4. neq: non equality col expressions * @@ -673,7 +673,7 @@ exp_or_chain_groups(mvc *sql, list *exps re->card == CARD_ATOM && !is_semantics(e)); } if (eq_only) - *ceq_ands = append(*ceq_ands, exps); + *mce_ands = append(*mce_ands, exps); else *gen_ands = append(*gen_ands, exps); } else if (list_length(exps) == 1) { @@ -682,8 +682,8 @@ exp_or_chain_groups(mvc *sql, list *exps if (se->type == e_cmp && se->flag == cmp_or && !is_anti(se)) { /* for a cmp_or expression go down the tree */ - exp_or_chain_groups(sql, (list*)le, gen_ands, ceq_ands, eqs, noneq); - exp_or_chain_groups(sql, (list*)re, gen_ands, ceq_ands, eqs, noneq); + exp_or_chain_groups(sql, (list*)le, gen_ands, mce_ands, eqs, noneq); + exp_or_chain_groups(sql, (list*)re, gen_ands, mce_ands, eqs, noneq); } else if (se->type == e_cmp && se->flag == cmp_equal && le->card != CARD_ATOM && is_column(le->type) && @@ -730,7 +730,7 @@ generate_multi_col_cmp_in(mvc *sql, sql_ sql_hash_e *he = meqh->buckets[i]; while (he) { mca *mcas = he->value; - /*
MonetDB: cmp-or-patterns - Moves the logic of col multi-value cm...
Changeset: 7a6cc6512fd8 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/7a6cc6512fd8 Modified Files: sql/server/rel_optimize_sel.c Branch: cmp-or-patterns Log Message: Moves the logic of col multi-value cmp_eq exps detection to a function diffs (162 lines): 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 @@ -537,6 +537,40 @@ typedef struct exp_eq_multi_cols_atoms { } mca; static bool +detect_col_cmp_eqs(mvc *sql, list *eqs, sql_hash *eqh) +{ + bool col_multivalue_cmp_eq = false; + for (node *n = eqs->h; n; n = n->next ) { + sql_exp *e = n->data; + sql_exp *le = e->l, *re = e->r; + + /* find the le in the hash and append the re in the hash value (ea->list) */ + bool found = false; + + int key = eqh->key(le); + sql_hash_e *he = eqh->buckets[key&(eqh->size-1)]; + + for (;he && !found; he = he->chain) { + ea *eas = he->value; + if(!exp_equal(le, eas->e)){ + eas->l = append(eas->l, re); + found = col_multivalue_cmp_eq = true; + } + } + + if (!found) { + ea *eas = SA_NEW(sql->sa, ea); + eas->l = sa_list(sql->sa); + eas->l = append(eas->l, re); + eas->e = le; + + hash_add(eqh, key, eas); + } + } + return col_multivalue_cmp_eq; +} + +static bool detect_multicol_cmp_eqs(mvc *sql, list *ceq_ands, sql_hash *meqh) { /* we get as input a list of AND associated expressions (hence the entries are lists themselves) @@ -618,25 +652,25 @@ detect_multicol_cmp_eqs(mvc *sql, list * return multi_multivalue_cmp_eq; } -static bool -exp_or_chain_groups(mvc *sql, list *exps, list **gen_ands, list **ceq_ands, list **noneq, sql_hash *eqh) +static void +exp_or_chain_groups(mvc *sql, list *exps, list **gen_ands, list **ceq_ands, list **eqs, list **noneq) { /* identify three different groups * 1. gen_ands: lists of generic expressions (their inner association is AND) * 2. ceq_ands: lists of multi_colum cmp_eq ONLY expressions (same^^^) -* 3. neq: non equality col expressions -* 4. eqh: col = X (we store the different X values) +* 3. eqs: equality expressions +* 4. neq: non equality col expressions * * return true if there is an exp with more than one cmp_eq */ - bool multi_atom_cmp_eq = false; - if (list_length(exps) > 1) { bool eq_only = true; for (node *n = exps->h; n && eq_only; n = n->next) { sql_exp *e = n->data; sql_exp *le = e->l, *re = e->r; - eq_only &= (e->type == e_cmp && e->flag == cmp_equal && le->card != CARD_ATOM && is_column(le->type) && re->card == CARD_ATOM && !is_semantics(e)); + eq_only &= (e->type == e_cmp && e->flag == cmp_equal && + le->card != CARD_ATOM && is_column(le->type) && + re->card == CARD_ATOM && !is_semantics(e)); } if (eq_only) *ceq_ands = append(*ceq_ands, exps); @@ -648,39 +682,17 @@ exp_or_chain_groups(mvc *sql, list *exps if (se->type == e_cmp && se->flag == cmp_or && !is_anti(se)) { /* for a cmp_or expression go down the tree */ - multi_atom_cmp_eq |= exp_or_chain_groups(sql, (list*)le, gen_ands, ceq_ands, noneq, eqh); - multi_atom_cmp_eq |= exp_or_chain_groups(sql, (list*)re, gen_ands, ceq_ands, noneq, eqh); + exp_or_chain_groups(sql, (list*)le, gen_ands, ceq_ands, eqs, noneq); + exp_or_chain_groups(sql, (list*)re, gen_ands, ceq_ands, eqs, noneq); } else if (se->type == e_cmp && se->flag == cmp_equal && le->card != CARD_ATOM && is_column(le->type) && re->card == CARD_ATOM && !is_semantics(se)) { - /* find the le in the hash and append the re in the hash value (ea->list) */ - bool found = false; - - int key = eqh->key(le); - sql_hash_e *he = eqh->buckets[key&(eqh->size-1)]; - - for (;he && !found; he = he->chain) { - ea *eas = he->value; - if(!exp_equal(le, eas->e)){ - eas->l = append(eas->l, re); - found = multi_atom_cmp_eq = true; -
MonetDB: cmp-or-patterns - Fixes generate_multi_col_cmp_in()
Changeset: 79c4900a1553 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/79c4900a1553 Modified Files: sql/server/rel_optimize_sel.c Branch: cmp-or-patterns Log Message: Fixes generate_multi_col_cmp_in() diffs (28 lines): 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 @@ -623,7 +623,7 @@ exp_or_chain_groups(mvc *sql, list *exps { /* identify three different groups * 1. gen_ands: lists of generic expressions (their inner association is AND) -* 2. ceq_ands: lists of cmp_eq ONLY expressions (same^^^) +* 2. ceq_ands: lists of multi_colum cmp_eq ONLY expressions (same^^^) * 3. neq: non equality col expressions * 4. eqh: col = X (we store the different X values) * @@ -707,13 +707,13 @@ generate_single_col_cmp_in(mvc *sql, sql } static list * -generate_multi_col_cmp_in(mvc *sql, sql_hash *eqh) +generate_multi_col_cmp_in(mvc *sql, sql_hash *meqh) { /* from multivalue cmp_eq with multiple lists of atoms in the hash generate * "(col1, col2, ...) in [(val10, val20, ...), (val11, val21, ...), ... ]" * (see detect_multicol_cmp_eqs()) */ - ins = new_exp_list(sql->sa); + list *ins = new_exp_list(sql->sa); for (int i = 0; i < meqh->size; i++) { sql_hash_e *he = meqh->buckets[i]; while (he) { ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: cmp-or-patterns - Renames bool variables
Changeset: cbe9101b7ad4 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/cbe9101b7ad4 Modified Files: sql/server/rel_optimize_sel.c Branch: cmp-or-patterns Log Message: Renames bool variables diffs (41 lines): 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 @@ -707,21 +707,21 @@ merge_ors_NEW(mvc *sql, list *exps, int neq = new_exp_list(sql->sa); eqh = hash_new(sql->sa, 4 /* TODO: HOW MUCH? prob. 64*/, (fkeyvalue)_unique_id); - bool ma = false; - ma |= exp_or_chain_groups(sql, e->l, _ands, _ands, , eqh); - ma |= exp_or_chain_groups(sql, e->r, _ands, _ands, , eqh); + bool col_multival = false; + col_multival |= exp_or_chain_groups(sql, e->l, _ands, _ands, , eqh); + col_multival |= exp_or_chain_groups(sql, e->r, _ands, _ands, , eqh); /* detect AND-chained cmp_eq-only exps with multiple values */ - bool mas = false; + bool multicol_multival = false; if (list_length(ceq_ands) > 1) { meqh = hash_new(sql->sa, 4 /* TODO: HOW MUCH? prob. 16*/, (fkeyvalue)_key); - mas |= detect_multicol_cmp_eqs(sql, ceq_ands, meqh); + multicol_multival |= detect_multicol_cmp_eqs(sql, ceq_ands, meqh); } - if (!ma && !mas) + if (!col_multival && !multicol_multival) continue; - if (ma) { + if (col_multival) { /* from equality atoms in the hash generate "e_col in (...)" for * entries with multiple atoms (see exp_or_chain_groups()) * */ @@ -741,7 +741,7 @@ merge_ors_NEW(mvc *sql, list *exps, int } } - if (mas) { + if (multicol_multival) { /* from multivalue cmp_eq atoms in the hash generate * "(col1, col2, ...) in [(val10, val20, ...), (val11, val21, ...), ... ]" * see detect_multicol_cmp_eqs() ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: cmp-or-patterns - Renames function
Changeset: 59ade49569c9 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/59ade49569c9 Modified Files: sql/server/rel_optimize_sel.c Branch: cmp-or-patterns Log Message: Renames function diffs (30 lines): 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 @@ -537,7 +537,7 @@ typedef struct exp_eq_multi_cols_atoms { } mca; static bool -detect_multivalue_cmp_eqs(mvc *sql, list *ceq_ands, sql_hash *meqh) +detect_multicol_cmp_eqs(mvc *sql, list *ceq_ands, sql_hash *meqh) { /* we get as input a list of AND associated expressions (hence the entries are lists themselves) * we need to detect cmp_eq-only AND-associated expressions with the same columns so we can @@ -715,7 +715,7 @@ merge_ors_NEW(mvc *sql, list *exps, int bool mas = false; if (list_length(ceq_ands) > 1) { meqh = hash_new(sql->sa, 4 /* TODO: HOW MUCH? prob. 16*/, (fkeyvalue)_key); - mas |= detect_multivalue_cmp_eqs(sql, ceq_ands, meqh); + mas |= detect_multicol_cmp_eqs(sql, ceq_ands, meqh); } if (!ma && !mas) @@ -744,7 +744,7 @@ merge_ors_NEW(mvc *sql, list *exps, int if (mas) { /* from multivalue cmp_eq atoms in the hash generate * "(col1, col2, ...) in [(val10, val20, ...), (val11, val21, ...), ... ]" -* see detect_multivalue_cmp_eqs() +* see detect_multicol_cmp_eqs() */ mins = new_exp_list(sql->sa); for (int i = 0; i < meqh->size; i++) { ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: cmp-or-patterns - Reverts change pushed in rel_dump
Changeset: eaffc38437ed for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/eaffc38437ed Modified Files: sql/server/rel_dump.c Branch: cmp-or-patterns Log Message: Reverts change pushed in rel_dump diffs (12 lines): diff --git a/sql/server/rel_dump.c b/sql/server/rel_dump.c --- a/sql/server/rel_dump.c +++ b/sql/server/rel_dump.c @@ -638,7 +638,7 @@ rel_print_rel(mvc *sql, stream *fout, s } if (rel->op == op_groupby) /* group by columns */ exps_print(sql, fout, rel->r, depth, refs, 1, 0, decorate, 0); - exps_print(sql, fout, rel->exps, depth, refs, 1, 0, decorate, (mvc_debug_on(sql, 32768) && rel->op == op_select)?1:0); + exps_print(sql, fout, rel->exps, depth, refs, 1, 0, decorate, 0); if (rel->r && rel->op == op_project) /* order by columns */ exps_print(sql, fout, rel->r, depth, refs, 1, 0, decorate, 0); break; ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: cmp-or-patterns - Removes unnecessary code from multiva...
Changeset: 711d2d8dc649 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/711d2d8dc649 Modified Files: sql/server/rel_optimize_sel.c Branch: cmp-or-patterns Log Message: Removes unnecessary code from multivalue handling WIP diffs (139 lines): 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 @@ -550,83 +550,70 @@ detect_multivalue_cmp_eqs(mvc *sql, list */ bool multi_multivalue_cmp_eq = false; for (node *n = ceq_ands->h; n; n = n->next) { - bool eq_only = true; list *l = n->data; - // TODO: remove this we already have what we want in cmp_eq - /* check if this list has only cmp_eq with a column lhs and an atom rhs */ - for (node *m = l->h; m && eq_only; m = m->next) { - sql_exp *se = m->data; - sql_exp *le = se->l, *re = se->r; - eq_only &= (se->type == e_cmp && se->flag == cmp_equal && le->card != CARD_ATOM && is_column(le->type) && re->card == CARD_ATOM && !is_semantics(se)); + /* sort the list of the cmp_eq expressions based on the col exp +* NOTE: from now on we only work with the sorted list, sl */ + list *sl = list_sort(l, (fkeyvalue)_cmp_eq_unique_id, NULL); + list_append_before(ceq_ands, n, sl); + list_remove_node(ceq_ands, NULL, n); + + /* make a hash key out of the concat str of (rname1, name1, rname2, name2..) */ + char *cs = ""; + for (node *m = sl->h; m; m = m->next) { + sql_exp *col_exp = ((sql_exp*)m->data)->l; + cs = strconcat(cs, strconcat(col_exp->alias.rname, col_exp->alias.name)); } - if (!eq_only) - continue; - else { - /* sort the list of the cmp_eq expressions based on the col exp -* NOTE: from now on we only work with the sorted list, sl */ - list *sl = list_sort(l, (fkeyvalue)_cmp_eq_unique_id, NULL); - list_append_before(ceq_ands, n, sl); - list_remove_node(ceq_ands, NULL, n); - - /* make a hash key out of the concat str of (rname1, name1, rname2, name2..) */ - char *cs = ""; - for (node *m = sl->h; m; m = m->next) { + /* find the eq exp in the hash and append the values */ + bool found = false; + + int key = meqh->key(cs); + sql_hash_e *he = meqh->buckets[key&(meqh->size-1)]; + + for (;he && !found; he = he->chain) { + /* compare the values of the hash_entry with the cols under cmp_eq from the list */ + bool same_cols = true; + mca *mcas = he->value; + for (node *m = sl->h, *k = mcas->ces->h; m && k && same_cols; m = m->next, k = k->next) { sql_exp *col_exp = ((sql_exp*)m->data)->l; - cs = strconcat(cs, strconcat(col_exp->alias.rname, col_exp->alias.name)); + if (exp_equal(col_exp, k->data)) + same_cols = false; } - - /* find the eq exp in the hash and append the values */ - bool found = false; - - int key = meqh->key(cs); - sql_hash_e *he = meqh->buckets[key&(meqh->size-1)]; - - for (;he && !found; he = he->chain) { - /* compare the values of the hash_entry with the cols under cmp_eq from the list */ - bool same_cols = true; - mca *mcas = he->value; - for (node *m = sl->h, *k = mcas->ces->h; m && k && same_cols; m = m->next, k = k->next) { - sql_exp *col_exp = ((sql_exp*)m->data)->l; - if (exp_equal(col_exp, k->data)) - same_cols = false; - } - if (same_cols) { - /* we found the same multi cmp_eq exp in ceq_ands list multiple times! */ - found = multi_multivalue_cmp_eq = true; - /* gather all the values of the list and add them to the hash entry */ - list *atms = sa_list(sql->sa); -for (node *m = sl->h; m; m = m->next) -atms = append(atms, ((sql_exp*)m->data)->r); -
MonetDB: cmp-or-patterns - Handling multicol single list cmp_eq ...
Changeset: 8a38f46f50f0 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/8a38f46f50f0 Modified Files: sql/server/rel_dump.c sql/server/rel_optimize_sel.c Branch: cmp-or-patterns Log Message: Handling multicol single list cmp_eq exp WIP diffs (109 lines): diff --git a/sql/server/rel_dump.c b/sql/server/rel_dump.c --- a/sql/server/rel_dump.c +++ b/sql/server/rel_dump.c @@ -638,7 +638,7 @@ rel_print_rel(mvc *sql, stream *fout, s } if (rel->op == op_groupby) /* group by columns */ exps_print(sql, fout, rel->r, depth, refs, 1, 0, decorate, 0); - exps_print(sql, fout, rel->exps, depth, refs, 1, 0, decorate, 0); + exps_print(sql, fout, rel->exps, depth, refs, 1, 0, decorate, (mvc_debug_on(sql, 32768) && rel->op == op_select)?1:0); if (rel->r && rel->op == op_project) /* order by columns */ exps_print(sql, fout, rel->r, depth, refs, 1, 0, decorate, 0); break; 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 @@ -531,6 +531,7 @@ typedef struct exp_eq_atoms { typedef struct exp_eq_multi_cols_atoms { char *cs; /* col(rname, name) concat str */ + list *first; list *ces; /* list of col exps */ list *gvs; /* list of lists of atoms */ } mca; @@ -552,6 +553,7 @@ detect_multivalue_cmp_eqs(mvc *sql, list bool eq_only = true; list *l = n->data; + // TODO: remove this we already have what we want in cmp_eq /* check if this list has only cmp_eq with a column lhs and an atom rhs */ for (node *m = l->h; m && eq_only; m = m->next) { sql_exp *se = m->data; @@ -598,12 +600,20 @@ detect_multivalue_cmp_eqs(mvc *sql, list for (node *m = sl->h; m; m = m->next) atms = append(atms, ((sql_exp*)m->data)->r); mcas->gvs = append(mcas->gvs, atms); + /* remove this and the previous occurrence (which means that's the first time +* that we found the *same* multi cmp_eq exp) +*/ + if (mcas->first) + list_remove_data(ceq_ands, NULL, mcas->first); + list_remove_data(ceq_ands, NULL, sl); } } if (!found) { mca *mcas = SA_NEW(sql->sa, mca); mcas->cs = cs; + // TODO: explain!! + mcas->first = sl; mcas->ces = sa_list(sql->sa); for (node *m = sl->h; m; m = m->next) mcas->ces = append(mcas->ces, ((sql_exp*)m->data)->l); @@ -746,7 +756,7 @@ merge_ors_NEW(mvc *sql, list *exps, int if (mas) { /* from multivalue cmp_eq atoms in the hash generate -* "(col1, col2, ...) in [(val10, val20, ...), (val11, val21, ...)]" +* "(col1, col2, ...) in [(val10, val20, ...), (val11, val21, ...), ... ]" * see detect_multivalue_cmp_eqs() */ mins = new_exp_list(sql->sa); @@ -754,13 +764,12 @@ merge_ors_NEW(mvc *sql, list *exps, int sql_hash_e *he = meqh->buckets[i]; while (he) { mca *mcas = he->value; + /* NOTE: multivalue cmp_eq expressions with a single entry are still in ceq_ands */ if (list_length(mcas->gvs) > 1) { sql_exp *mc = exp_label(sql->sa, exp_values(sql->sa, mcas->ces), ++sql->label); for (node *a = mcas->gvs->h; a; a = a->next) a->data = exp_values(sql->sa, a->data); mins = append(mins, exp_in(sql->sa, mc, mcas->gvs, cmp_in)); - } else { - /* TODO */ } he = he->chain; } @@ -781,7 +790,7 @@ merge_ors_NEW(mvc *sql, list *exps, int
MonetDB: cmp-or-patterns - Proper ordering between col-multival ...
Changeset: 435fd3f384e6 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/435fd3f384e6 Modified Files: sql/server/rel_optimize_sel.c Branch: cmp-or-patterns Log Message: Proper ordering between col-multival and multicol-multival exp WIP diffs (155 lines): 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 @@ -690,7 +690,7 @@ static list * merge_ors_NEW(mvc *sql, list *exps, int *changes) { sql_hash *eqh = NULL, *meqh = NULL; - list *neq, *gen_ands, *ceq_ands, *ins, *mins; + list *neq = NULL, *gen_ands = NULL, *ceq_ands = NULL, *ins = NULL, *mins = NULL; for (node *n = exps->h; n; n = n->next) { sql_exp *e = n->data; @@ -710,85 +710,84 @@ merge_ors_NEW(mvc *sql, list *exps, int neq = new_exp_list(sql->sa); eqh = hash_new(sql->sa, 4 /* TODO: HOW MUCH? prob. 64*/, (fkeyvalue)_unique_id); - /* if no multi-atom cmp_eq exps bailout, we don't need to gen cmp_in */ bool ma = false; ma |= exp_or_chain_groups(sql, e->l, _ands, _ands, , eqh); ma |= exp_or_chain_groups(sql, e->r, _ands, _ands, , eqh); - // TODO: this has to be combined with the detect_multivalue_cmp_eqs result - /*if (!ma)*/ - /*continue;*/ - /* detect AND-chained cmp_eq-only exps with multiple values */ bool mas = false; if (list_length(ceq_ands) > 1) { meqh = hash_new(sql->sa, 4 /* TODO: HOW MUCH? prob. 16*/, (fkeyvalue)_key); - mas = detect_multivalue_cmp_eqs(sql, ceq_ands, meqh); + mas |= detect_multivalue_cmp_eqs(sql, ceq_ands, meqh); } if (!ma && !mas) continue; - /* from equality atoms in the hash generate "e_col in (...)" for -* entries with multiple atoms (see exp_or_chain_groups()) -* */ - ins = new_exp_list(sql->sa); - for (int i = 0; i < eqh->size; i++) { - sql_hash_e *he = eqh->buckets[i]; - - while (he) { - ea *eas = he->value; - /* only if there are multiple cmp_eq atoms for this col turn them into a cmp_in */ - if (list_length(eas->l) > 1) - ins = append(ins, exp_in(sql->sa, eas->e, eas->l, cmp_in)); - else - ins = append(ins, exp_compare(sql->sa, eas->e, eas->l->h->data, cmp_equal)); - he = he->chain; + if (ma) { + /* from equality atoms in the hash generate "e_col in (...)" for +* entries with multiple atoms (see exp_or_chain_groups()) +* */ + ins = new_exp_list(sql->sa); + for (int i = 0; i < eqh->size; i++) { + sql_hash_e *he = eqh->buckets[i]; + + while (he) { + ea *eas = he->value; + /* only if there are multiple cmp_eq atoms for this col turn them into a cmp_in */ + if (list_length(eas->l) > 1) + ins = append(ins, exp_in(sql->sa, eas->e, eas->l, cmp_in)); + else + ins = append(ins, exp_compare(sql->sa, eas->e, eas->l->h->data, cmp_equal)); + he = he->chain; + } } } - /* from multivalue cmp_eq atoms in the hash generate -* "(col1, col2, ...) in [(val10, val20, ...), (val11, val21, ...)]" -* see detect_multivalue_cmp_eqs() -*/ - mins = new_exp_list(sql->sa); - for (int i = 0; i < meqh->size; i++) { - sql_hash_e *he = meqh->buckets[i]; - while (he) { -mca *mcas = he->value; -if (list_length(mcas->gvs) > 1) { -
MonetDB: cmp-or-patterns - Chains multi-col multi-value cmp_in WIP
Changeset: af94c3291ab5 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/af94c3291ab5 Modified Files: sql/server/rel_optimize_sel.c Branch: cmp-or-patterns Log Message: Chains multi-col multi-value cmp_in WIP diffs (127 lines): 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 @@ -595,10 +595,8 @@ detect_multivalue_cmp_eqs(mvc *sql, list found = multi_multivalue_cmp_eq = true; /* gather all the values of the list and add them to the hash entry */ list *atms = sa_list(sql->sa); - for (node *m = sl->h; m; m = m->next) { - sql_exp *val_exp = ((sql_exp*)m->data)->r; - atms = append(atms, (atom*)val_exp->l); - } +for (node *m = sl->h; m; m = m->next) +atms = append(atms, ((sql_exp*)m->data)->r); mcas->gvs = append(mcas->gvs, atms); } } @@ -607,16 +605,12 @@ detect_multivalue_cmp_eqs(mvc *sql, list mca *mcas = SA_NEW(sql->sa, mca); mcas->cs = cs; mcas->ces = sa_list(sql->sa); - for (node *m = sl->h; m; m = m->next) { - sql_exp *col_exp = ((sql_exp*)m->data)->l; - mcas->ces = append(mcas->ces, col_exp); - } + for (node *m = sl->h; m; m = m->next) + mcas->ces = append(mcas->ces, ((sql_exp*)m->data)->l); /* for (group values) gv create a list and append it to the gvs list */ list *atms = sa_list(sql->sa); - for (node *m = sl->h; m; m = m->next) { - sql_exp *val_exp = ((sql_exp*)m->data)->r; - atms = append(atms, (atom*)val_exp->l); - } + for (node *m = sl->h; m; m = m->next) + atms = append(atms, ((sql_exp*)m->data)->r); mcas->gvs = sa_list(sql->sa); mcas->gvs = append(mcas->gvs, atms); @@ -696,7 +690,7 @@ static list * merge_ors_NEW(mvc *sql, list *exps, int *changes) { sql_hash *eqh = NULL, *meqh = NULL; - list *neq, *gen_ands, *ceq_ands, *ins; + list *neq, *gen_ands, *ceq_ands, *ins, *mins; for (node *n = exps->h; n; n = n->next) { sql_exp *e = n->data; @@ -704,7 +698,7 @@ merge_ors_NEW(mvc *sql, list *exps, int /* NOTE: gen_ands and ceq_ands are both a list of lists since the AND association * between expressions is expressed with a list * e.g. [[e1, e2], [e3, e4, e5]] semantically translates -* to [(e1 AND e2), (e3 AND e4 AND e5)] +* to [(e1 AND e2), (e3 AND e4 AND e5)] * those (internal) AND list can be then used to * reconstructed an OR tree * [[e1, e2], [e3, e4, e5]] => @@ -720,7 +714,19 @@ merge_ors_NEW(mvc *sql, list *exps, int bool ma = false; ma |= exp_or_chain_groups(sql, e->l, _ands, _ands, , eqh); ma |= exp_or_chain_groups(sql, e->r, _ands, _ands, , eqh); - if (!ma) + + // TODO: this has to be combined with the detect_multivalue_cmp_eqs result + /*if (!ma)*/ + /*continue;*/ + + /* detect AND-chained cmp_eq-only exps with multiple values */ + bool mas = false; + if (list_length(ceq_ands) > 1) { + meqh = hash_new(sql->sa, 4 /* TODO: HOW MUCH? prob. 16*/, (fkeyvalue)_key); + mas = detect_multivalue_cmp_eqs(sql, ceq_ands, meqh); + } + + if (!ma && !mas) continue; /* from equality atoms in the hash generate "e_col in (...)" for @@ -741,12 +747,29 @@ merge_ors_NEW(mvc *sql, list *exps, int } } - /* detect AND-chained cmp_eq-only exps with multiple values */ -
MonetDB: cmp-or-patterns - merge_ors optimizer splits cmp_eq_and...
Changeset: 13b1bc8f3e3a for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/13b1bc8f3e3a Modified Files: sql/server/rel_optimize_sel.c Branch: cmp-or-patterns Log Message: merge_ors optimizer splits cmp_eq_ands and generic_ands WIP diffs (152 lines): 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 @@ -536,7 +536,7 @@ typedef struct exp_eq_multi_cols_atoms { } mca; static bool -detect_multivalue_cmp_eqs(mvc *sql, list *ands, sql_hash *meqh) +detect_multivalue_cmp_eqs(mvc *sql, list *ceq_ands, sql_hash *meqh) { /* we get as input a list of AND associated expressions (hence the entries are lists themselves) * we need to detect cmp_eq-only AND-associated expressions with the same columns so we can @@ -548,7 +548,7 @@ detect_multivalue_cmp_eqs(mvc *sql, list * e.g. in this example (n,k) */ bool multi_multivalue_cmp_eq = false; - for (node *n = ands->h; n; n = n->next) { + for (node *n = ceq_ands->h; n; n = n->next) { bool eq_only = true; list *l = n->data; @@ -565,8 +565,8 @@ detect_multivalue_cmp_eqs(mvc *sql, list /* sort the list of the cmp_eq expressions based on the col exp * NOTE: from now on we only work with the sorted list, sl */ list *sl = list_sort(l, (fkeyvalue)_cmp_eq_unique_id, NULL); - list_append_before(ands, n, sl); - list_remove_node(ands, NULL, n); + list_append_before(ceq_ands, n, sl); + list_remove_node(ceq_ands, NULL, n); /* make a hash key out of the concat str of (rname1, name1, rname2, name2..) */ char *cs = ""; @@ -591,7 +591,7 @@ detect_multivalue_cmp_eqs(mvc *sql, list same_cols = false; } if (same_cols) { - /* we found the same multi cmp_eq exp in ands list multiple times! */ + /* we found the same multi cmp_eq exp in ceq_ands list multiple times! */ found = multi_multivalue_cmp_eq = true; /* gather all the values of the list and add them to the hash entry */ list *atms = sa_list(sql->sa); @@ -622,35 +622,43 @@ detect_multivalue_cmp_eqs(mvc *sql, list hash_add(meqh, key, mcas); } - - /* TODO: manage the entries: remove the entry of the ands list as we are going to reconstruct it later */ } } return multi_multivalue_cmp_eq; } static bool -exp_or_chain_groups(mvc *sql, list *exps, list **ands, list **noneq, sql_hash *eqh) +exp_or_chain_groups(mvc *sql, list *exps, list **gen_ands, list **ceq_ands, list **noneq, sql_hash *eqh) { /* identify three different groups -* 1. ands: lists of expressions (their inner association is AND) -* 2. neq: non equality col expressions -* 3. eqh: col = X (we store the different X values) +* 1. gen_ands: lists of generic expressions (their inner association is AND) +* 2. ceq_ands: lists of cmp_eq ONLY expressions (same^^^) +* 3. neq: non equality col expressions +* 4. eqh: col = X (we store the different X values) * * return true if there is an exp with more than one cmp_eq */ bool multi_atom_cmp_eq = false; if (list_length(exps) > 1) { - *ands = append(*ands, exps); + bool eq_only = true; + for (node *n = exps->h; n && eq_only; n = n->next) { + sql_exp *e = n->data; + sql_exp *le = e->l, *re = e->r; + eq_only &= (e->type == e_cmp && e->flag == cmp_equal && le->card != CARD_ATOM && is_column(le->type) && re->card == CARD_ATOM && !is_semantics(e)); + } + if (eq_only) + *ceq_ands = append(*ceq_ands, exps); + else + *gen_ands = append(*gen_ands, exps); } else if (list_length(exps) == 1) { sql_exp *se = exps->h->data; sql_exp *le = se->l, *re = se->r; if (se->type == e_cmp && se->flag == cmp_or && !is_anti(se)) { /* for a cmp_or expression go down the tree */ - multi_atom_cmp_eq |= exp_or_chain_groups(sql, (list*)le, ands, noneq, eqh); - multi_atom_cmp_eq |= exp_or_chain_groups(sql, (list*)re, ands, noneq, eqh); + multi_atom_cmp_eq |= exp_or_chain_groups(sql, (list*)le,
MonetDB: cmp-or-patterns - Adds multi multivalue cmp_eq exp opti...
Changeset: 8d7615bb914b for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/8d7615bb914b Modified Files: sql/server/rel_optimize_sel.c Branch: cmp-or-patterns Log Message: Adds multi multivalue cmp_eq exp optimizer WIP diffs (143 lines): 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 @@ -518,11 +518,117 @@ exp_unique_id(sql_exp *e) return e->nid ? e->nid : e->alias.label; } +static inline int +exp_cmp_eq_unique_id(sql_exp *e) +{ + return exp_unique_id(e->l); +} + typedef struct exp_eq_atoms { sql_exp* e; list *l; } ea; +typedef struct exp_eq_multi_cols_atoms { + char *cs; /* col(rname, name) concat str */ + list *ces; /* list of col exps */ + list *gvs; /* list of lists of atoms */ +} mca; + +static bool +detect_multivalue_cmp_eqs(mvc *sql, list *ands, sql_hash *meqh) +{ + /* we get as input a list of AND associated expressions (hence the entries are lists themselves) +* we need to detect cmp_eq-only AND-associated expressions with the same columns so we can +* group together their values +* e.g. [[n = 1, m = 10], [m = 20, k = 100, l = 3000], [m = 20, n = 2]] has +* - (m,k,l) group with a single value (20, 100, 3000) +* - (n,k) group with two values (1, 10) and (2, 20) +* at the end we return true only if we have at least a group of columns with more than a single value +* e.g. in this example (n,k) +*/ + bool multi_multivalue_cmp_eq = false; + for (node *n = ands->h; n; n = n->next) { + bool eq_only = true; + list *l = n->data; + + /* check if this list has only cmp_eq with a column lhs and an atom rhs */ + for (node *m = l->h; m && eq_only; m = m->next) { + sql_exp *se = m->data; + sql_exp *le = se->l, *re = se->r; + eq_only &= (se->type == e_cmp && se->flag == cmp_equal && le->card != CARD_ATOM && is_column(le->type) && re->card == CARD_ATOM && !is_semantics(se)); + } + + if (!eq_only) + continue; + else { + /* sort the list of the cmp_eq expressions based on the col exp +* NOTE: from now on we only work with the sorted list, sl */ + list *sl = list_sort(l, (fkeyvalue)_cmp_eq_unique_id, NULL); + list_append_before(ands, n, sl); + list_remove_node(ands, NULL, n); + + /* make a hash key out of the concat str of (rname1, name1, rname2, name2..) */ + char *cs = ""; + for (node *m = sl->h; m; m = m->next) { + sql_exp *col_exp = ((sql_exp*)m->data)->l; + cs = strconcat(cs, strconcat(col_exp->alias.rname, col_exp->alias.name)); + } + + /* find the eq exp in the hash and append the values */ + bool found = false; + + int key = meqh->key(cs); + sql_hash_e *he = meqh->buckets[key&(meqh->size-1)]; + + for (;he && !found; he = he->chain) { + /* compare the values of the hash_entry with the cols under cmp_eq from the list */ + bool same_cols = true; + mca *mcas = he->value; + for (node *m = sl->h, *k = mcas->ces->h; m && k && same_cols; m = m->next, k = k->next) { + sql_exp *col_exp = ((sql_exp*)m->data)->l; + if (exp_equal(col_exp, k->data)) + same_cols = false; + } + if (same_cols) { + /* we found the same multi cmp_eq exp in ands list multiple times! */ + found = multi_multivalue_cmp_eq = true; + /* gather all the values of the list and add them to the hash entry */ + list *atms = sa_list(sql->sa); + for (node *m = sl->h; m; m = m->next) { + sql_exp *val_exp = ((sql_exp*)m->data)->r; + atms = append(atms, (atom*)val_exp->l); + } + mcas->gvs = append(mcas->gvs, atms); + } + } + + if (!found) { + mca *mcas = SA_NEW(sql->sa, mca); +
MonetDB: cmp-or-patterns - Merges default
Changeset: d8e385f9d392 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/d8e385f9d392 Branch: cmp-or-patterns Log Message: Merges default diffs (truncated from 2049 to 300 lines): diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out --- a/clients/Tests/exports.stable.out +++ b/clients/Tests/exports.stable.out @@ -188,7 +188,7 @@ gdk_return BATrtree(BAT *wkb, BAT *mbr); BAT *BATsample(BAT *b, BUN n); BAT *BATsample_with_seed(BAT *b, BUN n, uint64_t seed); gdk_return BATsave(BAT *b) __attribute__((__warn_unused_result__)); -BAT *BATselect(BAT *b, BAT *s, const void *tl, const void *th, bool li, bool hi, bool anti); +BAT *BATselect(BAT *b, BAT *s, const void *tl, const void *th, bool li, bool hi, bool anti, bool nil_matches); gdk_return BATsemijoin(BAT **r1p, BAT **r2p, BAT *l, BAT *r, BAT *sl, BAT *sr, bool nil_matches, bool max_one, BUN estimate) __attribute__((__warn_unused_result__)); BAT *BATsetaccess(BAT *b, restrict_t mode) __attribute__((__warn_unused_result__)); void BATsetcapacity(BAT *b, BUN cnt); diff --git a/cmake/monetdb-custom-targets.cmake b/cmake/monetdb-custom-targets.cmake --- a/cmake/monetdb-custom-targets.cmake +++ b/cmake/monetdb-custom-targets.cmake @@ -100,7 +100,7 @@ endif() if(CTAGS_PATH) add_custom_target(tags - COMMAND ${CTAGS_PATH} -R --kinds-C=+pLl --fields=+iaS --exclude=*.js + COMMAND ${CTAGS_PATH} -R --kinds-C=+pLl --fields=+iaS --exclude=*.js --exclude=build --exclude=install ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ln -sf ${CMAKE_CURRENT_BINARY_DIR}/tags ${CMAKE_CURRENT_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/gdk/gdk.h b/gdk/gdk.h --- a/gdk/gdk.h +++ b/gdk/gdk.h @@ -2265,7 +2265,7 @@ gdk_export ValPtr BATsetprop_nolock(BAT #define JOIN_BAND 3 #define JOIN_NE(-3) -gdk_export BAT *BATselect(BAT *b, BAT *s, const void *tl, const void *th, bool li, bool hi, bool anti); +gdk_export BAT *BATselect(BAT *b, BAT *s, const void *tl, const void *th, bool li, bool hi, bool anti, bool nil_matches); gdk_export BAT *BATthetaselect(BAT *b, BAT *s, const void *val, const char *op); gdk_export BAT *BATconstant(oid hseq, int tt, const void *val, BUN cnt, role_t role); diff --git a/gdk/gdk_firstn.c b/gdk/gdk_firstn.c --- a/gdk/gdk_firstn.c +++ b/gdk/gdk_firstn.c @@ -1067,7 +1067,7 @@ BATfirstn_grouped(BAT **topn, BAT **gids BAT *bn1, *bn2; bn1 = bn; - bn2 = BATselect(bi->b, s, BUNtail(*bi, last - bi->b->hseqbase), NULL, true, false, false); + bn2 = BATselect(bi->b, s, BUNtail(*bi, last - bi->b->hseqbase), NULL, true, false, false, false); if (bn2 == NULL) { BBPunfix(bn1->batCacheid); return GDK_FAIL; @@ -1193,7 +1193,7 @@ BATfirstn_grouped_with_groups(BAT **topn BAT *bn1, *bn2, *bn3, *bn4; bn1 = bn; - bn2 = BATselect(g, NULL, , NULL, true, false, false); + bn2 = BATselect(g, NULL, , NULL, true, false, false, false); if (bn2 == NULL) { BBPunfix(bn1->batCacheid); return GDK_FAIL; @@ -1204,7 +1204,7 @@ BATfirstn_grouped_with_groups(BAT **topn BBPunfix(bn1->batCacheid); return GDK_FAIL; } - bn4 = BATselect(bi->b, bn3, BUNtail(*bi, last - hseq), NULL, true, false, false); + bn4 = BATselect(bi->b, bn3, BUNtail(*bi, last - hseq), NULL, true, false, false, false); BBPunfix(bn3->batCacheid); if (bn4 == NULL) { BBPunfix(bn1->batCacheid); diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c --- a/gdk/gdk_join.c +++ b/gdk/gdk_join.c @@ -391,7 +391,7 @@ selectjoin(BAT **r1p, BAT **r2p, BAT **r return rc; } - bn = BATselect(r, rci->s, v, NULL, true, true, false); + bn = BATselect(r, rci->s, v, NULL, true, true, false, false); bat_iterator_end(); if (bn == NULL) { return GDK_FAIL; @@ -518,7 +518,7 @@ selectjoin(BAT **r1p, BAT **r2p, BAT **r mark = 0; } else { /* no match, search for NIL in r */ - BAT *n = BATselect(r, rci->s, ATOMnilptr(r->ttype), NULL, true, true, false); + BAT *n = BATselect(r, rci->s, ATOMnilptr(r->ttype), NULL, true, true, false, false); if (n == NULL) goto bailout; mark = BATcount(n) == 0 ? 0 : bit_nil; @@ -605,12 +605,12 @@ mergejoin_void(BAT **r1p, BAT **r2p, BAT /* at this point, the matchable values in r are [lo..hi) */ if (!nil_on_miss) { assert(r3p == NULL); - r1 =
MonetDB: cmp-or-patterns - Merges default
Changeset: bff9f6913ee1 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/bff9f6913ee1 Branch: cmp-or-patterns Log Message: Merges default diffs (112 lines): diff --git a/clients/Tests/MAL-signatures.test b/clients/Tests/MAL-signatures.test --- a/clients/Tests/MAL-signatures.test +++ b/clients/Tests/MAL-signatures.test @@ -38365,8 +38365,13 @@ SQLstr_auto_vacuum; auto vacuum string column with interval(sec) sql vacuum +unsafe pattern sql.vacuum(X_0:str, X_1:str):void +SQLstr_vacuum; +vacuum a string column +sql +vacuum unsafe pattern sql.vacuum(X_0:str, X_1:str, X_2:str):void -SQLstr_column_vacuum; +SQLstr_vacuum; vacuum a string column sql variance diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c --- a/gdk/gdk_bbp.c +++ b/gdk/gdk_bbp.c @@ -2176,7 +2176,7 @@ BBPinit(bool allow_hge_upgrade) } } - if (MT_create_thread(, BBPmanager, NULL, MT_THR_DETACHED, "BBPmanager") < 0) { + if (!GDKinmemory(0) && MT_create_thread(, BBPmanager, NULL, MT_THR_DETACHED, "BBPmanager") < 0) { TRC_CRITICAL(GDK, "Could not start BBPmanager thread."); return GDK_FAIL; } diff --git a/sql/storage/objectset.c b/sql/storage/objectset.c --- a/sql/storage/objectset.c +++ b/sql/storage/objectset.c @@ -643,9 +643,9 @@ tc_commit_objectversion(sql_trans *tr, s (void)oldest; if (!tr->parent) change->obj->new = 0; - ATOMIC_INC(>cat->schema_version); - } - else { + if (!ov->os->temporary) + ATOMIC_INC(>cat->schema_version); + } else { os_rollback(ov, tr->store); } diff --git a/sql/test/emptydb/Tests/check.stable.out b/sql/test/emptydb/Tests/check.stable.out --- a/sql/test/emptydb/Tests/check.stable.out +++ b/sql/test/emptydb/Tests/check.stable.out @@ -2704,6 +2704,7 @@ select 'null in fkeys.delete_action', de [ "sys.functions", "sys", "stddev_samp", "SYSTEM", "create window stddev_samp(val tinyint) returns double external name \"sql\".\"stdev\";", "sql", "MAL", "Analytic function",false, false, false, true, NULL, "result", "double", 53, 0, "out", "val", "tinyint", 7, 0, "in", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL] [ "sys.functions", "sys", "stop", "SYSTEM", "create procedure sys.stop(tag bigint) external name sysmon.stop;", "sysmon", "MAL", "Procedure",true, false, false, true, NULL, "tag", "bigint", 63, 0, "in", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL] [ "sys.functions", "sys", "stop", "SYSTEM", "create procedure sys.stop(tag bigint, username string) external name sysmon.stop;","sysmon", "MAL", "Procedure",true, false, false, true, NULL, "tag", "bigint", 63, 0, "in", "username", "varchar", 0, 0, "in", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL] +[ "sys.functions", "sys", "stop_vacuum", "SYSTEM", "create procedure sys.stop_vacuum(sname string, tname string) external name sql.stop_vacuum;", "sql", "MAL", "Procedure",true, false, false, true, NULL, "sname","varchar", 0, 0, "in", "tname","varchar", 0, 0, "in", NULL, NULL,
MonetDB: cmp-or-patterns - Properly increment changes
Changeset: 653a3c613f2f for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/653a3c613f2f Modified Files: sql/server/rel_optimize_sel.c Branch: cmp-or-patterns Log Message: Properly increment changes diffs (12 lines): 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 @@ -653,7 +653,7 @@ merge_ors_NEW(mvc *sql, list *exps, int list_remove_node(exps, NULL, n); exps = append(exps, new); - changes++; + (*changes)++; } } return exps; ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: cmp-or-patterns - Adjusts test's expected plan output
Changeset: f014ac54f79b for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/f014ac54f79b Modified Files: sql/test/miscellaneous/Tests/simple_plans.test Branch: cmp-or-patterns Log Message: Adjusts test's expected plan output diffs (12 lines): 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 @@ -132,7 +132,7 @@ plan select 1 from tab0 where ((col1 = 1 project ( | select ( | | table("sys"."tab0") [ "tab0"."col1", "tab0"."col2" ] -| ) [ ((("tab0"."col1") in (int(7) "1", int(7) "81")) or (("tab0"."col2") = (int(7) "100"))) or (("tab0"."col1") = (int(7) "100")) ] +| ) [ (("tab0"."col2") = (int(7) "100")) or (("tab0"."col1") in (int(7) "1", int(7) "81", int(7) "100")) ] ) [ tinyint(1) "1" ] query T nosort ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: cmp-or-patterns - Keeps ins list uninitialized
Changeset: 55ef94ced509 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/55ef94ced509 Modified Files: sql/server/rel_optimize_sel.c Branch: cmp-or-patterns Log Message: Keeps ins list uninitialized diffs (12 lines): 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 @@ -582,7 +582,7 @@ static list * merge_ors_NEW(mvc *sql, list *exps, int *changes) { sql_hash *eqh = NULL; - list *neq, *ands, *ins = exps; + list *neq, *ands, *ins; for (node *n = exps->h; n; n = n->next) { sql_exp *e = n->data; ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: cmp-or-patterns - Fixes the hash key function for expre...
Changeset: d051b39b212b for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/d051b39b212b Modified Files: sql/server/rel_optimize_sel.c Branch: cmp-or-patterns Log Message: Fixes the hash key function for expression diffs (13 lines): 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 @@ -515,8 +515,7 @@ merge_ors(mvc *sql, list *exps, int *cha static inline int exp_unique_id(sql_exp *e) { - assert(e->nid); - return e->nid; + return e->nid ? e->nid : e->alias.label; } typedef struct exp_eq_atoms { ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: cmp-or-patterns - Adds tests for merge_ors optimizer
Changeset: 37a2b64c0c90 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/37a2b64c0c90 Added Files: sql/test/rel-optimizers/Tests/select-cse-merge-ors-base.test sql/test/rel-optimizers/Tests/select-cse-merge-ors.reqtests sql/test/rel-optimizers/Tests/select-cse-merge-ors.test Modified Files: sql/test/rel-optimizers/Tests/All Branch: cmp-or-patterns Log Message: Adds tests for merge_ors optimizer diffs (195 lines): diff --git a/sql/test/rel-optimizers/Tests/All b/sql/test/rel-optimizers/Tests/All --- a/sql/test/rel-optimizers/Tests/All +++ b/sql/test/rel-optimizers/Tests/All @@ -12,3 +12,5 @@ remote-replica-plan remote-replica merge-unions-base merge-unions +select-cse-merge-ors-base +select-cse-merge-ors diff --git a/sql/test/rel-optimizers/Tests/select-cse-merge-ors-base.test b/sql/test/rel-optimizers/Tests/select-cse-merge-ors-base.test new file mode 100644 --- /dev/null +++ b/sql/test/rel-optimizers/Tests/select-cse-merge-ors-base.test @@ -0,0 +1,6 @@ +statement ok +create table f (n int, m int) + +statement ok +insert into f values (1, 20), (2, 40), (2, 0), (3, 60), (9, 180) + diff --git a/sql/test/rel-optimizers/Tests/select-cse-merge-ors.reqtests b/sql/test/rel-optimizers/Tests/select-cse-merge-ors.reqtests new file mode 100644 --- /dev/null +++ b/sql/test/rel-optimizers/Tests/select-cse-merge-ors.reqtests @@ -0,0 +1,1 @@ +select-cse-merge-ors-base diff --git a/sql/test/rel-optimizers/Tests/select-cse-merge-ors.test b/sql/test/rel-optimizers/Tests/select-cse-merge-ors.test new file mode 100644 --- /dev/null +++ b/sql/test/rel-optimizers/Tests/select-cse-merge-ors.test @@ -0,0 +1,164 @@ +query T nosort +plan select * from f +where n = 1 + or n = 2 + or n = 3 + +project ( +| select ( +| | table("sys"."f") [ "f"."n", "f"."m" ] +| ) [ ("f"."n") in (int(4) "1", int(4) "2", int(4) "3") ] +) [ "f"."n", "f"."m" ] + +query II rowsort +select * from f +where n = 1 + or n = 2 + or m = 40; + +1 +20 +2 +0 +2 +40 + +query II rowsort +select * from f +where n = 1 + or m = 40 + or n = 2; + +1 +20 +2 +0 +2 +40 + +query II rowsort +select * from f +where m = 40 + or n = 1 + or n = 2; + +1 +20 +2 +0 +2 +40 + +## chained where-in for n + +query T nosort +plan select * from f +where n in (1, 2) + or n in (3) + +project ( +| select ( +| | table("sys"."f") [ "f"."n", "f"."m" ] +| ) [ ("f"."n") in (int(4) "3", int(4) "1", int(4) "2") ] +) [ "f"."n", "f"."m" ] + +query T nosort +plan select * from f +where m = 60 + or n in (1, 2) + or n in (3) + +KNOWN + +query T nosort +plan select * from f +where n in (1, 2) + or m = 60 + or n in (3) + +KNOWN + +query T nosort +plan select * from f +where n in (1, 2) + or n in (3) + or m = 60 + +KNOWN + +## chained cmp_equal-atom ors with lhs in [n, m] + +query T nosort +plan select * from f +where n = 1 + or n = 2 + or m = 60; + +project ( +| select ( +| | table("sys"."f") [ "f"."n", "f"."m" ] +| ) [ (("f"."m") = (int(8) "60")) or (("f"."n") in (int(4) "1", int(4) "2")) ] +) [ "f"."n", "f"."m" ] + +query T nosort +plan select * from f +where n = 1 + or m = 60 + or n = 2; + +project ( +| select ( +| | table("sys"."f") [ "f"."n", "f"."m" ] +| ) [ (("f"."m") = (int(8) "60")) or (("f"."n") in (int(4) "1", int(4) "2")) ] +) [ "f"."n", "f"."m" ] + +query T nosort +plan select * from f +where m = 60 + or n = 1 + or n = 2; + +project ( +| select ( +| | table("sys"."f") [ "f"."n", "f"."m" ] +| ) [ (("f"."m") = (int(8) "60")) or (("f"."n") in (int(4) "1", int(4) "2")) ] +) [ "f"."n", "f"."m" ] + +## chained ors with lhs in [n, (n && m)] + +query T nosort +plan select * from f +where (n = 3 and m = 60) + or n = 1 + or n = 2; + +project ( +| select ( +| | table("sys"."f") [ "f"."n", "f"."m" ] +| ) [ (("f"."n") in (int(4) "1", int(4) "2")) or (("f"."n") = (int(4) "3"), ("f"."m") = (int(8) "60")), ("f"."n") in (int(4) "3", int(4) "1", int(4) "2") ] +) [ "f"."n", "f"."m" ] + +query T nosort +plan select * from f +where n = 1 + or (n = 3 and m = 60) + or n = 2; + +project ( +| select ( +| | table("sys"."f") [ "f"."n", "f"."m" ] +| ) [ (("f"."n") in (int(4) "1", int(4) "2")) or (("f"."n") = (int(4) "3"), ("f"."m") = (int(8) "60")), ("f"."n") in (int(4) "3", int(4) "1", int(4) "2") ] +) [ "f"."n", "f"."m" ] + +query T nosort +plan select * from f +where n = 1 + or n = 2 + or (n = 3 and m = 60) + +project ( +| select ( +| | table("sys"."f") [ "f"."n", "f"."m" ] +| ) [ (("f"."n") in (int(4) "1", int(4) "2")) or (("f"."n") = (int(4) "3"), ("f"."m") = (int(8) "60")), ("f"."n") in (int(4) "3", int(4) "1", int(4) "2") ] +) [ "f"."n", "f"."m" ] + ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: cmp-or-patterns - New implementation of merge_ors
Changeset: e0131bc1dd88 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/e0131bc1dd88 Modified Files: sql/server/rel_optimize_sel.c Branch: cmp-or-patterns Log Message: New implementation of merge_ors diffs (183 lines): 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 @@ -472,9 +472,11 @@ equality_exps_2_in( mvc *sql, sql_exp *c static list * merge_ors(mvc *sql, list *exps, int *changes) { + /* n = 1 OR n = 2 ==> n in (1, 2) */ list *nexps = NULL; int needed = 0; + // blindly looks for any cmp_or in the top list for (node *n = exps->h; n && !needed; n = n->next) { sql_exp *e = n->data; @@ -510,6 +512,154 @@ merge_ors(mvc *sql, list *exps, int *cha return nexps; } +static inline int +exp_unique_id(sql_exp *e) +{ + assert(e->nid); + return e->nid; +} + +typedef struct exp_eq_atoms { + sql_exp* e; + list *l; +} ea; + +static bool +exp_or_chain_groups(mvc *sql, list *exps, list **ands, list **noneq, sql_hash *eqh) +{ + /* identify three different groups +* 1. ands: lists of expressions (their inner association is AND) +* 2. neq: non equality col expressions +* 3. eqh: col = X (we store the different X values) +* +* return true if there is an exp with more than one cmp_eq +*/ + bool multi_atom_cmp_eq = false; + + if (list_length(exps) > 1) { + *ands = append(*ands, exps); + } else if (list_length(exps) == 1) { + sql_exp *se = exps->h->data; + sql_exp *le = se->l, *re = se->r; + + if (se->type == e_cmp && se->flag == cmp_or && !is_anti(se)) { + /* for a cmp_or expression go down the tree */ + multi_atom_cmp_eq |= exp_or_chain_groups(sql, (list*)le, ands, noneq, eqh); + multi_atom_cmp_eq |= exp_or_chain_groups(sql, (list*)re, ands, noneq, eqh); + + } else if (se->type == e_cmp && se->flag == cmp_equal && + le->card != CARD_ATOM && is_column(le->type) && + re->card == CARD_ATOM && !is_semantics(se)) { + /* find the le in the hash and append the re in the hash value (ea->list) */ + bool found = false; + + int key = eqh->key(le); + sql_hash_e *he = eqh->buckets[key&(eqh->size-1)]; + + for (;he && !found; he = he->chain) { + ea *eas = he->value; + if(!exp_equal(le, eas->e)){ + eas->l = append(eas->l, re); + found = multi_atom_cmp_eq = true; + } + } + + if (!found) { + ea *eas = SA_NEW(sql->sa, ea); + eas->l = sa_list(sql->sa); + eas->l = append(eas->l, re); + eas->e = le; + + hash_add(eqh, key, eas); + } + } else { + *noneq = append(*noneq, se); + } + } + return multi_atom_cmp_eq; +} + +static list * +merge_ors_NEW(mvc *sql, list *exps, int *changes) +{ + sql_hash *eqh = NULL; + list *neq, *ands, *ins = exps; + for (node *n = exps->h; n; n = n->next) { + sql_exp *e = n->data; + + if (e->type == e_cmp && e->flag == cmp_or && !is_anti(e)) { + /* NOTE: ands is a list of lists since the AND association +* between expressions is expressed with a list +* e.g. [[e1, e2], [e3, e4, e5]] semantically translates +* to [(e1 AND e2), (e3 AND e4 AND e5)] +* those (internal) AND list can be then used to +* reconstructed an OR tree +* [[e1, e2], [e3, e4, e5]] => +* (([e1, e2] OR [e3, e4, e5]) OR ) +*/ + ands = new_exp_list(sql->sa); + neq = new_exp_list(sql->sa); + eqh = hash_new(sql->sa, 4 /* TODO: HOW MUCH? prob. 64*/, (fkeyvalue)_unique_id); + + /* if no multi-atom cmp_eq exps bailout, we don't need to gen cmp_in */ + bool ma = false; + ma |= exp_or_chain_groups(sql, e->l, , , eqh); + ma |= exp_or_chain_groups(sql, e->r, , , eqh); + if (!ma) + continue; + + /* from equality
MonetDB: cmp-or-patterns - Merges default
Changeset: f1fd65631f85 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/f1fd65631f85 Branch: cmp-or-patterns Log Message: Merges default diffs (44 lines): diff --git a/sql/backends/monet5/sql_gencode.c b/sql/backends/monet5/sql_gencode.c --- a/sql/backends/monet5/sql_gencode.c +++ b/sql/backends/monet5/sql_gencode.c @@ -1691,6 +1691,13 @@ void } void +_exps_print(mvc *sql, list *l) { + if (l) + for (node *n = l->h; n; n = n->next) + _exp_print(sql, n->data); +} + +void rel_print(mvc *sql, sql_rel *rel, int depth) { list *refs = sa_list(sql->sa); diff --git a/sql/backends/monet5/sql_gencode.h b/sql/backends/monet5/sql_gencode.h --- a/sql/backends/monet5/sql_gencode.h +++ b/sql/backends/monet5/sql_gencode.h @@ -35,6 +35,7 @@ extern void rel_print(mvc *sql, sql_rel extern void _rel_print(mvc *sql, sql_rel *rel); extern void _exp_print(mvc *sql, sql_exp *e); +extern void _exps_print(mvc *sql, list *l); extern int constantAtom(backend *be, MalBlkPtr mb, atom *a); extern InstrPtr table_func_create_result(MalBlkPtr mb, InstrPtr q, sql_func *f, list *restypes); diff --git a/sql/server/rel_exp.c b/sql/server/rel_exp.c --- a/sql/server/rel_exp.c +++ b/sql/server/rel_exp.c @@ -1215,12 +1215,6 @@ exp_equal( sql_exp *e1, sql_exp *e2) if (e1->alias.label && e1->alias.label == e2->alias.label) return 0; return -1; - if (e1->alias.rname && e2->alias.rname && strcmp(e1->alias.rname, e2->alias.rname) == 0) - if (e1->alias.name && e2->alias.name && strcmp(e1->alias.name, e2->alias.name) == 0) - return 0; - if (!e1->alias.rname && !e2->alias.rname && /*has_label(e1) &&*/ e1->alias.label == e2->alias.label && e1->alias.name && e2->alias.name) - return strcmp(e1->alias.name, e2->alias.name); - return -1; } int ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - Adds _exps_print
Changeset: 46fcf4d5271a for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/46fcf4d5271a Modified Files: sql/backends/monet5/sql_gencode.c sql/backends/monet5/sql_gencode.h Branch: default Log Message: Adds _exps_print diffs (28 lines): diff --git a/sql/backends/monet5/sql_gencode.c b/sql/backends/monet5/sql_gencode.c --- a/sql/backends/monet5/sql_gencode.c +++ b/sql/backends/monet5/sql_gencode.c @@ -1691,6 +1691,13 @@ void } void +_exps_print(mvc *sql, list *l) { + if (l) + for (node *n = l->h; n; n = n->next) + _exp_print(sql, n->data); +} + +void rel_print(mvc *sql, sql_rel *rel, int depth) { list *refs = sa_list(sql->sa); diff --git a/sql/backends/monet5/sql_gencode.h b/sql/backends/monet5/sql_gencode.h --- a/sql/backends/monet5/sql_gencode.h +++ b/sql/backends/monet5/sql_gencode.h @@ -35,6 +35,7 @@ extern void rel_print(mvc *sql, sql_rel extern void _rel_print(mvc *sql, sql_rel *rel); extern void _exp_print(mvc *sql, sql_exp *e); +extern void _exps_print(mvc *sql, list *l); extern int constantAtom(backend *be, MalBlkPtr mb, atom *a); extern InstrPtr table_func_create_result(MalBlkPtr mb, InstrPtr q, sql_func *f, list *restypes); ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - Cleans up exps_equal
Changeset: 392bd5c66d4a for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/392bd5c66d4a Modified Files: sql/server/rel_exp.c Branch: default Log Message: Cleans up exps_equal diffs (16 lines): diff --git a/sql/server/rel_exp.c b/sql/server/rel_exp.c --- a/sql/server/rel_exp.c +++ b/sql/server/rel_exp.c @@ -1215,12 +1215,6 @@ exp_equal( sql_exp *e1, sql_exp *e2) if (e1->alias.label && e1->alias.label == e2->alias.label) return 0; return -1; - if (e1->alias.rname && e2->alias.rname && strcmp(e1->alias.rname, e2->alias.rname) == 0) - if (e1->alias.name && e2->alias.name && strcmp(e1->alias.name, e2->alias.name) == 0) - return 0; - if (!e1->alias.rname && !e2->alias.rname && /*has_label(e1) &&*/ e1->alias.label == e2->alias.label && e1->alias.name && e2->alias.name) - return strcmp(e1->alias.name, e2->alias.name); - return -1; } int ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: cmp-or-patterns - New branch
Changeset: 31ed0eec76ba for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/31ed0eec76ba Branch: cmp-or-patterns Log Message: New branch ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - When breaking list of exps with single entry ...
Changeset: 7bdc764bbe7c for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/7bdc764bbe7c Modified Files: sql/server/rel_dump.c Branch: default Log Message: When breaking list of exps with single entry don't ident the closing bracket diffs (19 lines): diff --git a/sql/server/rel_dump.c b/sql/server/rel_dump.c --- a/sql/server/rel_dump.c +++ b/sql/server/rel_dump.c @@ -431,12 +431,13 @@ exps_print(mvc *sql, stream *fout, list if (expbrk && en->next!=NULL) print_indent(sql, fout, depth+2, decorate); } - if (expbrk) + int multi_exps = expbrk && (list_length(exps) > 1); + if (multi_exps) print_indent(sql, fout, depth+1, decorate); if (brackets) mnstr_printf(fout, ")"); else - mnstr_printf(fout, expbrk?"]":" ]"); + mnstr_printf(fout, multi_exps?"]":" ]"); } static int ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - Implements break for expressions list (by def...
Changeset: efd0930c1c01 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/efd0930c1c01 Modified Files: sql/server/rel_dump.c Branch: default Log Message: Implements break for expressions list (by default is off) If you want to have it enabled change the expbrk arg of exps_print() in rel_print_rel() to 1 for the operator that you are interested in diffs (192 lines): diff --git a/sql/server/rel_dump.c b/sql/server/rel_dump.c --- a/sql/server/rel_dump.c +++ b/sql/server/rel_dump.c @@ -110,7 +110,7 @@ dump_sql_subtype(allocator *sa, sql_subt return sa_strdup(sa, buf); } -static void exps_print(mvc *sql, stream *fout, list *exps, int depth, list *refs, int alias, int brackets, int decorate); +static void exps_print(mvc *sql, stream *fout, list *exps, int depth, list *refs, int alias, int brackets, int decorate, int expbrk); static void rel_print_rel(mvc *sql, stream *fout, sql_rel *rel, int depth, list *refs, int decorate); @@ -153,14 +153,14 @@ exp_print(mvc *sql, stream *fout, sql_ex } else if (e->flag & PSM_WHILE) { mnstr_printf(fout, "while "); exp_print(sql, fout, e->l, depth, refs, 0, 0, decorate); - exps_print(sql, fout, e->r, depth, refs, 0, 0, decorate); + exps_print(sql, fout, e->r, depth, refs, 0, 0, decorate, 0); alias = 0; } else if (e->flag & PSM_IF) { mnstr_printf(fout, "if "); exp_print(sql, fout, e->l, depth, refs, 0, 0, decorate); - exps_print(sql, fout, e->r, depth, refs, 0, 0, decorate); + exps_print(sql, fout, e->r, depth, refs, 0, 0, decorate, 0); if (e->f) - exps_print(sql, fout, e->f, depth, refs, 0, 0, decorate); + exps_print(sql, fout, e->f, depth, refs, 0, 0, decorate, 0); alias = 0; } else if (e->flag & PSM_REL) { rel_print_rel(sql, fout, e->l, depth+10, refs, 1); @@ -209,7 +209,7 @@ exp_print(mvc *sql, stream *fout, sql_ex mnstr_printf(fout, "\"%s\"", dump_escape_ident(sql->ta, vname->name)); } else if (e->f) { /* values list */ list *l = e->f; - exps_print(sql, fout, l, depth, refs, 0, 0, decorate); + exps_print(sql, fout, l, depth, refs, 0, 0, decorate, 0); } else { /* numbered arguments */ mnstr_printf(fout, "A%u", e->flag); } @@ -220,11 +220,11 @@ exp_print(mvc *sql, stream *fout, sql_ex mnstr_printf(fout, "\"%s\".\"%s\"", f->func->s?dump_escape_ident(sql->ta, f->func->s->base.name):"sys", dump_escape_ident(sql->ta, f->func->base.name)); - exps_print(sql, fout, e->l, depth, refs, 0, 1, decorate); + exps_print(sql, fout, e->l, depth, refs, 0, 1, decorate, 0); if (e->r) { /* list of optional lists */ list *l = e->r; for(node *n = l->h; n; n = n->next) - exps_print(sql, fout, n->data, depth, refs, 0, 1, decorate); + exps_print(sql, fout, n->data, depth, refs, 0, 1, decorate, 0); } if (e->flag && is_compare_func(f)) mnstr_printf(fout, " %s", e->flag==1?"ANY":"ALL"); @@ -241,7 +241,7 @@ exp_print(mvc *sql, stream *fout, sql_ex if (zero_if_empty(e)) mnstr_printf(fout, " zero if empty "); if (e->l) - exps_print(sql, fout, e->l, depth, refs, 0, 1, decorate); + exps_print(sql, fout, e->l, depth, refs, 0, 1, decorate, 0); else mnstr_printf(fout, "()"); } break; @@ -268,23 +268,23 @@ exp_print(mvc *sql, stream *fout, sql_ex if (is_anti(e)) mnstr_printf(fout, " !"); cmp_print(sql, fout, e->flag); - exps_print(sql, fout, e->r, depth, refs, 0, 1, decorate); + exps_print(sql, fout, e->r, depth, refs, 0, 1, decorate, 0); } else if (e->flag == cmp_or) { - exps_print(sql, fout, e->l, depth, refs, 0, 1, decorate); + exps_print(sql, fout, e->l, depth, refs, 0, 1, decorate, 0); if (is_anti(e)) mnstr_printf(fout, " !"); cmp_print(sql, fout, e->flag); - exps_print(sql, fout, e->r, depth, refs, 0, 1, decorate); +
MonetDB: default - Merges Aug2024
Changeset: fd9ff8ddfe43 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/fd9ff8ddfe43 Branch: default Log Message: Merges Aug2024 diffs (23 lines): diff --git a/ctest/tools/monetdbe/Tests/example_proxy.SQL.py b/ctest/tools/monetdbe/Tests/example_proxy.SQL.py --- a/ctest/tools/monetdbe/Tests/example_proxy.SQL.py +++ b/ctest/tools/monetdbe/Tests/example_proxy.SQL.py @@ -19,6 +19,7 @@ results = subprocess.run(cmd, stdout=sub if results.stderr: print(results.stderr) +exit(1) lines = results.stdout.splitlines() diff --git a/gdk/gdk_rtree.c b/gdk/gdk_rtree.c --- a/gdk/gdk_rtree.c +++ b/gdk/gdk_rtree.c @@ -313,7 +313,7 @@ RTREEdestroy(BAT *b) } //If the rtree is not loaded (pb->trtree is null), but there is a file with the index (from previous execution), //we should remove the file - else if (RTREEexistsonfile(pb)) { + else if (pb->theap && !GDKinmemory(pb->theap->farmid) && RTREEexistsonfile(pb)) { GDKunlink(pb->theap->farmid, BATDIR, BBP_physical(b->batCacheid), ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: Aug2024 - Exit if there is an error in example_proxy test
Changeset: 4c7a3024462b for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/4c7a3024462b Modified Files: ctest/tools/monetdbe/Tests/example_proxy.SQL.py Branch: Aug2024 Log Message: Exit if there is an error in example_proxy test diffs (11 lines): diff --git a/ctest/tools/monetdbe/Tests/example_proxy.SQL.py b/ctest/tools/monetdbe/Tests/example_proxy.SQL.py --- a/ctest/tools/monetdbe/Tests/example_proxy.SQL.py +++ b/ctest/tools/monetdbe/Tests/example_proxy.SQL.py @@ -19,6 +19,7 @@ results = subprocess.run(cmd, stdout=sub if results.stderr: print(results.stderr) +exit(1) lines = results.stdout.splitlines() ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: Aug2024 - Fixes RTREEdestroy flow for monetdbe
Changeset: 5cb10400f35b for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/5cb10400f35b Modified Files: gdk/gdk_rtree.c Branch: Aug2024 Log Message: Fixes RTREEdestroy flow for monetdbe diffs (12 lines): diff --git a/gdk/gdk_rtree.c b/gdk/gdk_rtree.c --- a/gdk/gdk_rtree.c +++ b/gdk/gdk_rtree.c @@ -313,7 +313,7 @@ RTREEdestroy(BAT *b) } //If the rtree is not loaded (pb->trtree is null), but there is a file with the index (from previous execution), //we should remove the file - else if (RTREEexistsonfile(pb)) { + else if (pb->theap && !GDKinmemory(pb->theap->farmid) && RTREEexistsonfile(pb)) { GDKunlink(pb->theap->farmid, BATDIR, BBP_physical(b->batCacheid), ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: Aug2024 - Eliminates op_union creation
Changeset: 7bf2478b3374 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/7bf2478b3374 Modified Files: sql/server/rel_unnest.c Branch: Aug2024 Log Message: Eliminates op_union creation diffs (219 lines): diff --git a/sql/server/rel_unnest.c b/sql/server/rel_unnest.c --- a/sql/server/rel_unnest.c +++ b/sql/server/rel_unnest.c @@ -1497,6 +1497,7 @@ push_up_set(mvc *sql, sql_rel *rel, list /* left of rel should be a set */ if (d && is_distinct_set(sql, d, ad) && s && is_set(s->op)) { + assert(s->op != op_union); sql_rel *sl = s->l, *sr = s->r, *ns; sl = rel_project(sql->sa, rel_dup(sl), rel_projections(sql, sl, NULL, 1, 1)); @@ -1557,10 +1558,12 @@ push_up_set(mvc *sql, sql_rel *rel, list ns->r = rel_project(sql->sa, ns->r, rel_projections(sql, ns->r, NULL, 1, 1)); if (is_semi(rel->op)) /* only push left side of semi/anti join */ ns->exps = rel_projections(sql, ns->l, NULL, 1, 1); - if (rel->op == op_anti && s->op == op_union) - ns->op = op_inter; - if (rel->op == op_anti && s->op == op_inter) - ns->op = op_union; + if (rel->op == op_anti && s->op == op_inter) { + list *urs = sa_list(sql->sa); + urs = append(urs, ns->l); + urs = append(urs, ns->r); + rel_inplace_setop_n_ary(sql, ns, urs, op_munion, ns->exps); + } rel_destroy(rel); return ns; } @@ -3005,8 +3008,11 @@ rel_union_exps(mvc *sql, sql_exp **l, li if (!u) { u = sq; } else { - u = rel_setop(sql->sa, u, sq, op_union); - rel_setop_set_exps(sql, u, exps, false); + list *urs = sa_list(sql->sa); + urs = append(urs, u); + urs = append(urs, sq); + u = rel_setop_n_ary(sql->sa, urs, op_munion); + rel_setop_n_ary_set_exps(sql, u, exps, false); set_distinct(u); set_processed(u); } @@ -3688,6 +3694,7 @@ rewrite_ifthenelse(visitor *v, sql_rel * )[not(cond) or cond is null] ) [ cols ] */ sql_rel *lsq = NULL, *rsq = NULL, *usq = NULL; + list *urs = sa_list(v->sql->sa); if (exp_has_rel(then_exp)) { lsq = exp_rel_get_rel(v->sql->sa, then_exp); @@ -3720,8 +3727,10 @@ rewrite_ifthenelse(visitor *v, sql_rel * set_processed(rsq); rsq = rel_select(v->sql->sa, rsq, not_cond); set_processed(rsq); - usq = rel_setop(v->sql->sa, lsq, rsq, op_union); - rel_setop_set_exps(v->sql, usq, append(sa_list(v->sql->sa), exp_ref(v->sql, e)), false); + urs = append(urs, lsq); + urs = append(urs, rsq); + usq = rel_setop_n_ary(v->sql->sa, urs, op_munion); + rel_setop_n_ary_set_exps(v->sql, usq, append(sa_list(v->sql->sa), exp_ref(v->sql, e)), false); if (single) set_single(usq); set_processed(usq); @@ -3888,7 +3897,7 @@ rewrite_groupings(visitor *v, sql_rel *r /* ROLLUP, CUBE, GROUPING SETS cases */ if ((found = find_prop(rel->p, PROP_GROUPINGS))) { list *sets = (list*) found->value.pval; - sql_rel *unions = NULL; + list *grpr = sa_list(v->sql->sa); rel->p = prop_remove(rel->p, found); /* remove property */ for (node *n = sets->h ; n ; n = n->next) { @@ -3980,27 +3989,20 @@ rewrite_groupings(visitor *v, sql_rel *r } nrel = rel_project(v->sql->sa, nrel, pexps); set_processed(nrel); - - if (!unions) - unions = nrel; - else { - unions = rel_setop(v->sql->sa, unions, nrel, op_union); - rel_setop_set_exps(v->sql, unions, rel_projections(v->sql, rel, NULL, 1, 1), false); - set_processed(unions); - } - if (!unions) -
MonetDB: Aug2024 - Removes dead code
Changeset: 4c16486c623b for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/4c16486c623b Modified Files: sql/server/rel_optimize_proj.c Branch: Aug2024 Log Message: Removes dead code diffs (125 lines): 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 @@ -977,19 +977,6 @@ bind_project_reduce_casts(visitor *v, gl return gp->cnt[op_project] && (flag & project_reduce_casts) ? rel_project_reduce_casts : NULL; } -#if 0 -static sql_rel * -exp_skip_output_parts(sql_rel *rel) -{ - while ((is_topn(rel->op) || is_project(rel->op) || is_sample(rel->op)) && rel->l) { - if (is_union(rel->op) || is_munion(rel->op) || (is_groupby(rel->op) && list_empty(rel->r))) - return rel; /* a group-by with no columns is a plain aggregate and hence always returns one row */ - rel = rel->l; - } - return rel; -} -#endif - static sql_column * exp_find_column_( sql_rel *rel, sql_exp *exp, int pnr, sql_rel **bt ) { @@ -1086,101 +1073,6 @@ rel_is_join_on_pkey(sql_rel *rel, bool p return NULL; } -#if 0 -/* return true if the given expression is guaranteed to have no rows */ -static int -exp_is_zero_rows(visitor *v, sql_rel *rel, sql_rel *sel) -{ - if (!rel || mvc_highwater(v->sql)) - return 0; - rel = exp_skip_output_parts(rel); - if (is_select(rel->op) && rel->l) { - sel = rel; - rel = exp_skip_output_parts(rel->l); - } - - sql_table *t = is_basetable(rel->op) && rel->l ? rel->l : NULL; - bool table_readonly = t && isTable(t) && t->access == TABLE_READONLY; - - if (sel && !list_empty(sel->exps) && (v->value_based_opt || table_readonly)) { - for (node *n = sel->exps->h; n; n = n->next) { - sql_exp *e = n->data; - - /* if the expression is false, then the select is empty */ - if (v->value_based_opt && (exp_is_false(e) || exp_is_null(e))) - return 1; - if (table_readonly && e->type == e_cmp && (e->flag == cmp_equal || e->f)) { - /* half-ranges are theoretically optimizable here, but not implemented */ - sql_exp *c = e->l; - if (c->type == e_column) { - sql_exp *l = e->r; - sql_exp *h = e->f; - - atom *lval = exp_flatten(v->sql, v->value_based_opt, l); - atom *hval = h ? exp_flatten(v->sql, v->value_based_opt, h) : lval; - if (lval && hval) { - sql_rel *bt; - sql_column *col = name_find_column(sel, exp_relname(c), exp_name(c), -2, ); - void *min = NULL, *max = NULL; - atom *amin, *amax; - sql_subtype *ct = exp_subtype(c); - - if (col - && col->t == t - && sql_trans_ranges(v->sql->session->tr, col, , ) - && min && max - && (amin = atom_general_ptr(v->sql->sa, ct, min)) && (amax = atom_general_ptr(v->sql->sa, ct, max)) - && !exp_range_overlap(amin, amax, lval, hval, false, false)) { - return 1; - } - } - } - } - } - } - if ((is_innerjoin(rel->op) || is_left(rel->op) || is_right(rel->op) || is_semi(rel->op)) && !list_empty(rel->exps)) { - sql_exp *je; - - /* check non overlaping pk-fk join */ - if ((je = rel_is_join_on_pkey(rel, true))) { - int lpnr = rel_part_nr(rel->l, je); - - if (lpnr >= 0 && !rel_uses_part_nr(rel->r, je, lpnr)) - return 1; - } - return (((is_innerjoin(rel->op) || is_left(rel->op) || is_semi(rel->op)) && exp_is_zero_rows(v, rel->l, sel)) || - ((is_innerjoin(rel->op) || is_right(rel->op)) && exp_is_zero_rows(v, rel->r, sel))); - } - /* global aggregates always return 1 row */ - if (is_simple_project(rel->op) || (is_groupby(rel->op) && !list_empty(rel->r)) ||
MonetDB: Aug2024 - Partial cleanup of munion impl
Changeset: d48550dc5df9 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/d48550dc5df9 Modified Files: sql/server/rel_optimize_proj.c Branch: Aug2024 Log Message: Partial cleanup of munion impl diffs (truncated from 645 to 300 lines): 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 @@ -977,7 +977,7 @@ bind_project_reduce_casts(visitor *v, gl return gp->cnt[op_project] && (flag & project_reduce_casts) ? rel_project_reduce_casts : NULL; } - +#if 0 static sql_rel * exp_skip_output_parts(sql_rel *rel) { @@ -988,6 +988,7 @@ exp_skip_output_parts(sql_rel *rel) } return rel; } +#endif static sql_column * exp_find_column_( sql_rel *rel, sql_exp *exp, int pnr, sql_rel **bt ) @@ -1085,6 +1086,7 @@ rel_is_join_on_pkey(sql_rel *rel, bool p return NULL; } +#if 0 /* return true if the given expression is guaranteed to have no rows */ static int exp_is_zero_rows(visitor *v, sql_rel *rel, sql_rel *sel) @@ -1160,56 +1162,6 @@ exp_is_zero_rows(visitor *v, sql_rel *re return 0; } -/* discard sides of UNION or UNION ALL which cannot produce any rows, as per -statistics, similarly to the merge table optimizer, e.g. - select * from a where x between 1 and 2 union all select * from b where x between 1 and 2 --> select * from b where x between 1 and 2 [assuming a has no rows with 1<=x<=2] -*/ -static inline sql_rel * -rel_remove_union_partitions(visitor *v, sql_rel *rel) -{ - if (!is_union(rel->op) || rel_is_ref(rel)) - return rel; - int left_zero_rows = !rel_is_ref(rel->l) && exp_is_zero_rows(v, rel->l, NULL); - int right_zero_rows = !rel_is_ref(rel->r) && exp_is_zero_rows(v, rel->r, NULL); - - if (left_zero_rows && right_zero_rows) { - /* generate dummy relation */ - list *converted = sa_list(v->sql->sa); - sql_rel *nrel = rel_project_exp(v->sql, exp_atom_bool(v->sql->sa, 1)); - nrel = rel_select(v->sql->sa, nrel, exp_atom_bool(v->sql->sa, 0)); - set_processed(nrel); - - for (node *n = rel->exps->h ; n ; n = n->next) { - sql_exp *e = n->data, *a = exp_atom(v->sql->sa, atom_general(v->sql->sa, exp_subtype(e), NULL, 0)); - exp_prop_alias(v->sql->sa, a, e); - list_append(converted, a); - } - rel_destroy(rel); - v->changes++; - return rel_project(v->sql->sa, nrel, converted); - } else if (left_zero_rows) { - sql_rel *r = rel->r; - if (!is_project(r->op)) - r = rel_project(v->sql->sa, r, rel_projections(v->sql, r, NULL, 1, 1)); - rel_rename_exps(v->sql, rel->exps, r->exps); - rel->r = NULL; - rel_destroy(rel); - v->changes++; - return r; - } else if (right_zero_rows) { - sql_rel *l = rel->l; - if (!is_project(l->op)) - l = rel_project(v->sql->sa, l, rel_projections(v->sql, l, NULL, 1, 1)); - rel_rename_exps(v->sql, rel->exps, l->exps); - rel->l = NULL; - rel_destroy(rel); - v->changes++; - return l; - } - return rel; -} - static int rel_match_projections(sql_rel *l, sql_rel *r) { @@ -1227,6 +1179,7 @@ rel_match_projections(sql_rel *l, sql_re return 0; return 1; } +#endif static int exps_has_predicate( list *l ) @@ -1252,55 +1205,6 @@ rel_find_select( sql_rel *r) return NULL; } -static inline sql_rel * -rel_merge_union(visitor *v, sql_rel *rel) -{ - sql_rel *l = rel->l; - sql_rel *r = rel->r; - sql_rel *ref = NULL; - - if (is_union(rel->op) && - l && is_project(l->op) && !project_unsafe(l,0) && - r && is_project(r->op) && !project_unsafe(r,0) && - (ref = rel_find_ref(l)) != NULL && ref == rel_find_ref(r)) { - /* Find selects and try to merge */ - sql_rel *ls = rel_find_select(l); - sql_rel *rs = rel_find_select(r); - - /* can we merge ? */ - if (!ls || !rs) - return rel; - - /* merge any extra projects */ - if (l->l != ls) - rel->l = l = rel_merge_projects_(v, l); - if (r->l != rs) - rel->r = r = rel_merge_projects_(v, r); - - if (!rel_match_projections(l,r)) - return rel; - - /* for now only union(project*(select(R),project*(select(R))) */ - if (ls != l->l || rs != r->l || - ls->l != rs->l || !rel_is_ref(ls->l)) - return rel; - - if
MonetDB: Aug2024 - Adds test for recursive munions with group-by
Changeset: ba487f6886f1 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/ba487f6886f1 Modified Files: sql/test/rel-optimizers/Tests/merge-unions.test Branch: Aug2024 Log Message: Adds test for recursive munions with group-by diffs (29 lines): diff --git a/sql/test/rel-optimizers/Tests/merge-unions.test b/sql/test/rel-optimizers/Tests/merge-unions.test --- a/sql/test/rel-optimizers/Tests/merge-unions.test +++ b/sql/test/rel-optimizers/Tests/merge-unions.test @@ -257,3 +257,25 @@ 2 5 1 +query T nosort +plan select n, count(n) from f_merge_rec group by n + +project ( +| group by ( +| | munion ( +| | | group by ( +| | | | table("sys"."f1") [ "f1"."n" UNIQUE as "f_merge_rec"."n" ] +| | | ) [ "f_merge_rec"."n" UNIQUE ] [ "f_merge_rec"."n" UNIQUE, "sys"."count" no nil ("f_merge_rec"."n" UNIQUE) NOT NULL as "%1"."%1" ], +| | | group by ( +| | | | table("sys"."f2") [ "f2"."n" UNIQUE as "f_merge_rec"."n" ] +| | | ) [ "f_merge_rec"."n" UNIQUE ] [ "f_merge_rec"."n" UNIQUE, "sys"."count" no nil ("f_merge_rec"."n" UNIQUE) NOT NULL as "%1"."%1" ], +| | | group by ( +| | | | table("sys"."f3") [ "f3"."n" UNIQUE as "f_merge_rec"."n" ] +| | | ) [ "f_merge_rec"."n" UNIQUE ] [ "f_merge_rec"."n" UNIQUE, "sys"."count" no nil ("f_merge_rec"."n" UNIQUE) NOT NULL as "%1"."%1" ], +| | | group by ( +| | | | table("sys"."f4") [ "f4"."n" UNIQUE as "f_merge_rec"."n" ] +| | | ) [ "f_merge_rec"."n" UNIQUE ] [ "f_merge_rec"."n" UNIQUE, "sys"."count" no nil ("f_merge_rec"."n" UNIQUE) NOT NULL as "%1"."%1" ] +| | ) [ "f_merge_rec"."n", "%1"."%1" NOT NULL ] +| ) [ "f_merge_rec"."n" ] [ "f_merge_rec"."n", "sys"."sum" no nil ("%1"."%1" NOT NULL) NOT NULL as "%1"."%1" ] +) [ "f_merge_rec"."n" UNIQUE, "%1"."%1" NOT NULL ] + ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: Aug2024 - Fixes merge_unions tests
Changeset: d437ce53766a for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/d437ce53766a Modified Files: sql/test/rel-optimizers/Tests/merge-unions.test Branch: Aug2024 Log Message: Fixes merge_unions tests diffs (30 lines): diff --git a/sql/test/rel-optimizers/Tests/merge-unions.test b/sql/test/rel-optimizers/Tests/merge-unions.test --- a/sql/test/rel-optimizers/Tests/merge-unions.test +++ b/sql/test/rel-optimizers/Tests/merge-unions.test @@ -209,20 +209,18 @@ query I rowsort select * from f_merge_rec where n > 1 and n < 5 -1 2 2 3 3 4 4 -5 query T nosort plan select * from f_merge_rec where n > 1 and n < 5 -tmunion ( +munion ( | project ( | | select ( | | | table("sys"."f1") [ "f1"."n" UNIQUE as "f_merge_rec"."n" ] @@ -259,4 +257,3 @@ 2 5 1 - ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: Aug2024 - Grafts merge_unions opt tests from default
Changeset: 5fa7d5d1bb6b for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/5fa7d5d1bb6b Added Files: sql/test/rel-optimizers/Tests/merge-unions-base.test sql/test/rel-optimizers/Tests/merge-unions.reqtests sql/test/rel-optimizers/Tests/merge-unions.test Modified Files: sql/test/rel-optimizers/Tests/All Branch: Aug2024 Log Message: Grafts merge_unions opt tests from default diffs (truncated from 363 to 300 lines): diff --git a/sql/test/rel-optimizers/Tests/All b/sql/test/rel-optimizers/Tests/All --- a/sql/test/rel-optimizers/Tests/All +++ b/sql/test/rel-optimizers/Tests/All @@ -10,3 +10,5 @@ local-replica local-replica-with-actual-remote remote-replica-plan remote-replica +merge-unions-base +merge-unions diff --git a/sql/test/rel-optimizers/Tests/merge-unions-base.test b/sql/test/rel-optimizers/Tests/merge-unions-base.test new file mode 100644 --- /dev/null +++ b/sql/test/rel-optimizers/Tests/merge-unions-base.test @@ -0,0 +1,76 @@ +statement ok +create table f1 (n int) + +statement ok +create table f2 (n int) + +statement ok +create table f3 (n int) + +statement ok +create table f4 (n int) + +statement ok +insert into f1 values (1), (2) + +statement ok +insert into f2 values (2), (3) + +statement ok +insert into f3 values (3), (4) + +statement ok +insert into f4 values(4), (5) + +statement ok +create view f_uchain as +select * from f1 +union all +select * from f2 +union all +select * from f3 +union all +select * from f4 + +statement ok +create merge table f12 (n int) + +statement ok +alter table f12 add table f1 + +statement ok +alter table f12 add table f2 + +statement ok +create merge table f34 (n int) + +statement ok +alter table f34 add table f3 + +statement ok +alter table f34 add table f4 + +statement ok +create merge table f_merge_rec (n int) + +statement ok +alter table f_merge_rec add table f12 + +statement ok +alter table f_merge_rec add table f34 + +statement ok +create merge table f_merge (n int) + +statement ok +alter table f_merge add table f1 + +statement ok +alter table f_merge add table f2 + +statement ok +alter table f_merge add table f3 + +statement ok +alter table f_merge add table f4 + diff --git a/sql/test/rel-optimizers/Tests/merge-unions.reqtests b/sql/test/rel-optimizers/Tests/merge-unions.reqtests new file mode 100644 --- /dev/null +++ b/sql/test/rel-optimizers/Tests/merge-unions.reqtests @@ -0,0 +1,1 @@ +merge-unions-base diff --git a/sql/test/rel-optimizers/Tests/merge-unions.test b/sql/test/rel-optimizers/Tests/merge-unions.test new file mode 100644 --- /dev/null +++ b/sql/test/rel-optimizers/Tests/merge-unions.test @@ -0,0 +1,262 @@ +query I rowsort +select * from f_uchain + +1 +2 +2 +3 +3 +4 +4 +5 + +query T nosort +plan select * from f_uchain + +munion ( +| project ( +| | table("sys"."f4") [ "f4"."n" UNIQUE ] +| ) [ "f4"."n" UNIQUE as "f_uchain"."n" ], +| project ( +| | table("sys"."f3") [ "f3"."n" UNIQUE ] +| ) [ "f3"."n" UNIQUE as "f_uchain"."n" ], +| project ( +| | table("sys"."f1") [ "f1"."n" UNIQUE ] +| ) [ "f1"."n" UNIQUE as "f_uchain"."n" ], +| project ( +| | table("sys"."f2") [ "f2"."n" UNIQUE ] +| ) [ "f2"."n" UNIQUE as "f_uchain"."n" ] +) [ "f_uchain"."n" ] + +query I rowsort +select * from f_uchain +where n > 1 and n < 5 + +2 +2 +3 +3 +4 +4 + +query T nosort +plan select * from f_uchain + where n > 1 and n < 5 + +munion ( +| project ( +| | select ( +| | | table("sys"."f4") [ "f4"."n" UNIQUE ] +| | ) [ (int(2) "1") < ("f4"."n" UNIQUE) < (int(2) "5") ] +| ) [ "f4"."n" UNIQUE as "f_uchain"."n" ], +| project ( +| | select ( +| | | table("sys"."f3") [ "f3"."n" UNIQUE ] +| | ) [ (int(2) "1") < ("f3"."n" UNIQUE) < (int(2) "5") ] +| ) [ "f3"."n" UNIQUE as "f_uchain"."n" ], +| project ( +| | select ( +| | | table("sys"."f1") [ "f1"."n" UNIQUE ] +| | ) [ (int(2) "1") < ("f1"."n" UNIQUE) < (int(2) "5") ] +| ) [ "f1"."n" UNIQUE as "f_uchain"."n" ], +| project ( +| | select ( +| | | table("sys"."f2") [ "f2"."n" UNIQUE ] +| | ) [ (int(2) "1") < ("f2"."n" UNIQUE) < (int(2) "5") ] +| ) [ "f2"."n" UNIQUE as "f_uchain"."n" ] +) [ "f_uchain"."n" ] + +query II rowsort +select n, count(n) from f_uchain group by n + +1 +1 +2 +2 +3 +2 +4 +2 +5 +1 + +query T nosort +plan select * from f_uchain + where n > 1 and n < 5 + +munion ( +| project ( +| | select ( +| | | table("sys"."f4") [ "f4"."n" UNIQUE ] +| | ) [ (int(2) "1") < ("f4"."n" UNIQUE) < (int(2) "5") ] +| ) [ "f4"."n" UNIQUE as "f_uchain"."n" ], +| project ( +| | select ( +| | | table("sys"."f3") [ "f3"."n" UNIQUE ] +| | ) [ (int(2) "1") < ("f3"."n" UNIQUE) < (int(2) "5") ] +| ) [ "f3"."n" UNIQUE as "f_uchain"."n" ], +| project ( +| | select ( +| | | table("sys"."f1") [ "f1"."n" UNIQUE ] +| | ) [ (int(2) "1") < ("f1"."n" UNIQUE) < (int(2) "5") ] +| ) [ "f1"."n" UNIQUE as "f_uchain"."n" ], +| project ( +| | select ( +| | | table("sys"."f2") [ "f2"."n" UNIQUE ] +| | ) [ (int(2) "1") < ("f2"."n"
MonetDB: default - Adds tests from merge_unions opt
Changeset: faf3deaa31c4 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/faf3deaa31c4 Added Files: sql/test/rel-optimizers/Tests/merge-unions-base.test sql/test/rel-optimizers/Tests/merge-unions.reqtests sql/test/rel-optimizers/Tests/merge-unions.test Modified Files: sql/test/rel-optimizers/Tests/All Branch: default Log Message: Adds tests from merge_unions opt diffs (truncated from 363 to 300 lines): diff --git a/sql/test/rel-optimizers/Tests/All b/sql/test/rel-optimizers/Tests/All --- a/sql/test/rel-optimizers/Tests/All +++ b/sql/test/rel-optimizers/Tests/All @@ -10,3 +10,5 @@ local-replica local-replica-with-actual-remote remote-replica-plan remote-replica +merge-unions-base +merge-unions diff --git a/sql/test/rel-optimizers/Tests/merge-unions-base.test b/sql/test/rel-optimizers/Tests/merge-unions-base.test new file mode 100644 --- /dev/null +++ b/sql/test/rel-optimizers/Tests/merge-unions-base.test @@ -0,0 +1,76 @@ +statement ok +create table f1 (n int) + +statement ok +create table f2 (n int) + +statement ok +create table f3 (n int) + +statement ok +create table f4 (n int) + +statement ok +insert into f1 values (1), (2) + +statement ok +insert into f2 values (2), (3) + +statement ok +insert into f3 values (3), (4) + +statement ok +insert into f4 values(4), (5) + +statement ok +create view f_uchain as +select * from f1 +union all +select * from f2 +union all +select * from f3 +union all +select * from f4 + +statement ok +create merge table f12 (n int) + +statement ok +alter table f12 add table f1 + +statement ok +alter table f12 add table f2 + +statement ok +create merge table f34 (n int) + +statement ok +alter table f34 add table f3 + +statement ok +alter table f34 add table f4 + +statement ok +create merge table f_merge_rec (n int) + +statement ok +alter table f_merge_rec add table f12 + +statement ok +alter table f_merge_rec add table f34 + +statement ok +create merge table f_merge (n int) + +statement ok +alter table f_merge add table f1 + +statement ok +alter table f_merge add table f2 + +statement ok +alter table f_merge add table f3 + +statement ok +alter table f_merge add table f4 + diff --git a/sql/test/rel-optimizers/Tests/merge-unions.reqtests b/sql/test/rel-optimizers/Tests/merge-unions.reqtests new file mode 100644 --- /dev/null +++ b/sql/test/rel-optimizers/Tests/merge-unions.reqtests @@ -0,0 +1,1 @@ +merge-unions-base diff --git a/sql/test/rel-optimizers/Tests/merge-unions.test b/sql/test/rel-optimizers/Tests/merge-unions.test new file mode 100644 --- /dev/null +++ b/sql/test/rel-optimizers/Tests/merge-unions.test @@ -0,0 +1,262 @@ +query I rowsort +select * from f_uchain + +1 +2 +2 +3 +3 +4 +4 +5 + +query T nosort +plan select * from f_uchain + +munion ( +| project ( +| | table("sys"."f4") [ "f4"."n" UNIQUE ] +| ) [ "f4"."n" UNIQUE as "f_uchain"."n" ], +| project ( +| | table("sys"."f3") [ "f3"."n" UNIQUE ] +| ) [ "f3"."n" UNIQUE as "f_uchain"."n" ], +| project ( +| | table("sys"."f1") [ "f1"."n" UNIQUE ] +| ) [ "f1"."n" UNIQUE as "f_uchain"."n" ], +| project ( +| | table("sys"."f2") [ "f2"."n" UNIQUE ] +| ) [ "f2"."n" UNIQUE as "f_uchain"."n" ] +) [ "f_uchain"."n" ] + +query I rowsort +select * from f_uchain +where n > 1 and n < 5 + +2 +2 +3 +3 +4 +4 + +query T nosort +plan select * from f_uchain + where n > 1 and n < 5 + +munion ( +| project ( +| | select ( +| | | table("sys"."f4") [ "f4"."n" UNIQUE ] +| | ) [ (int(2) "1") < ("f4"."n" UNIQUE) < (int(2) "5") ] +| ) [ "f4"."n" UNIQUE as "f_uchain"."n" ], +| project ( +| | select ( +| | | table("sys"."f3") [ "f3"."n" UNIQUE ] +| | ) [ (int(2) "1") < ("f3"."n" UNIQUE) < (int(2) "5") ] +| ) [ "f3"."n" UNIQUE as "f_uchain"."n" ], +| project ( +| | select ( +| | | table("sys"."f1") [ "f1"."n" UNIQUE ] +| | ) [ (int(2) "1") < ("f1"."n" UNIQUE) < (int(2) "5") ] +| ) [ "f1"."n" UNIQUE as "f_uchain"."n" ], +| project ( +| | select ( +| | | table("sys"."f2") [ "f2"."n" UNIQUE ] +| | ) [ (int(2) "1") < ("f2"."n" UNIQUE) < (int(2) "5") ] +| ) [ "f2"."n" UNIQUE as "f_uchain"."n" ] +) [ "f_uchain"."n" ] + +query II rowsort +select n, count(n) from f_uchain group by n + +1 +1 +2 +2 +3 +2 +4 +2 +5 +1 + +query T nosort +plan select * from f_uchain + where n > 1 and n < 5 + +munion ( +| project ( +| | select ( +| | | table("sys"."f4") [ "f4"."n" UNIQUE ] +| | ) [ (int(2) "1") < ("f4"."n" UNIQUE) < (int(2) "5") ] +| ) [ "f4"."n" UNIQUE as "f_uchain"."n" ], +| project ( +| | select ( +| | | table("sys"."f3") [ "f3"."n" UNIQUE ] +| | ) [ (int(2) "1") < ("f3"."n" UNIQUE) < (int(2) "5") ] +| ) [ "f3"."n" UNIQUE as "f_uchain"."n" ], +| project ( +| | select ( +| | | table("sys"."f1") [ "f1"."n" UNIQUE ] +| | ) [ (int(2) "1") < ("f1"."n" UNIQUE) < (int(2) "5") ] +| ) [ "f1"."n" UNIQUE as "f_uchain"."n" ], +| project ( +| | select ( +| | | table("sys"."f2") [ "f2"."n" UNIQUE ] +| | ) [ (int(2) "1") < ("f2"."n" UNIQUE) <
MonetDB: label - Track v->changes in merge_unions opt
Changeset: 73b32db83cbd for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/73b32db83cbd Modified Files: sql/server/rel_optimize_proj.c Branch: label Log Message: Track v->changes in merge_unions opt diffs (11 lines): 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 @@ -3480,6 +3480,7 @@ rel_merge_unions(visitor *v, sql_rel *re rel_destroy(i); if (!next) next = l->h; + v->changes++; } n = next; } ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: balanced_union - Merges default
Changeset: 56bc5532d998 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/56bc5532d998 Modified Files: clients/NT/mclient.bat.in clients/NT/msqldump.bat.in debian/libmonetdb28.install monetdb5/NT/M5server.bat.in sql/ChangeLog.Dec2023 sql/backends/monet5/rel_bin.c sql/include/sql_relation.h sql/rel.txt sql/server/rel_exp.c sql/server/rel_optimize_others.c sql/server/rel_optimize_proj.c sql/server/rel_optimizer.c sql/server/rel_rel.c sql/server/rel_rel.h sql/server/rel_select.c sql/server/rel_unnest.c sql/test/emptydb/Tests/check.stable.out.int128 sql/test/strings/Tests/asciify.test sql/test/strings/Tests/batstr_asciify.test sql/test/strings/Tests/endswith.test Branch: balanced_union Log Message: Merges default diffs (truncated from 31141 to 300 lines): diff --git a/.hgtags b/.hgtags --- a/.hgtags +++ b/.hgtags @@ -826,3 +826,4 @@ dcc8c702e685a4faf21ccf663028d1bc3d1165d1 d656785f49ee62c19705722aa6b7c171904c64d5 Dec2023_7 d656785f49ee62c19705722aa6b7c171904c64d5 Dec2023_SP2_release 9a694c41042503a22d6c92aeab5bc4ca1912b62e Dec2023_9 +9a694c41042503a22d6c92aeab5bc4ca1912b62e Dec2023_SP3_release diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ # ChangeLog file for devel # This file is updated with Maddlog +* Wed May 8 2024 Sjoerd Mullender +- The shared library (.dll aka .so files) now have the version number + as part of the name. This should allow the building of compatibility + versions that can be installed in parallel to the latest version. +- Some of the Debian/Ubuntu packages have been renamed. The old monetdb5 + names have been changed to plain monetdb, and libmonetdb5-server-* + packages have been renamed monetdb-*. +- The names of some of the provided RPM files have been changed. + References to the old MonetDB5 name have been removed. All packages + are now just MonetDB. + +* Wed May 8 2024 Niels Nes +- Add support for select exp, count(*) group by 1 order by 1; ie. using + numeric references Added support for group by all and order by all. The + later is ordering on all columns of the selection. The group by all + finds all expressions from the selections which aren't aggregations + and groups on those. All can also be replaced by '*'. + diff --git a/MonetDB.spec b/MonetDB.spec --- a/MonetDB.spec +++ b/MonetDB.spec @@ -8,8 +8,12 @@ # Copyright August 2008 - 2023 MonetDB B.V.; # Copyright 1997 - July 2008 CWI. -%global name MonetDB %global version 11.50.0 + +%bcond_with compat + +%global name MonetDB%{?with_compat:%version} + %{!?buildno: %global buildno %(date +%Y%m%d)} # Use bcond_with to add a --with option; i.e., "without" is default. @@ -57,7 +61,7 @@ # available. However, the geos library is available in the Extra # Packages for Enterprise Linux (EPEL). %if %{fedpkgs} && (0%{?rhel} != 7) && (0%{?rhel} != 8) -# By default create the MonetDB-geom-MonetDB5 package on Fedora and RHEL 7 +# By default create the MonetDB-geom package on Fedora and RHEL 7 %bcond_without geos %endif @@ -91,7 +95,7 @@ Group: Applications/Databases License: MPL-2.0 URL: https://www.monetdb.org/ BugURL: https://github.com/MonetDB/MonetDB/issues -Source: https://www.monetdb.org/downloads/sources/Dec2023-SP3/%{name}-%{version}.tar.bz2 +Source: https://www.monetdb.org/downloads/sources/Dec2023-SP3/MonetDB-%{version}.tar.bz2 # The Fedora packaging document says we need systemd-rpm-macros for # the _unitdir and _tmpfilesdir macros to exist; however on RHEL 7 @@ -117,7 +121,9 @@ BuildRequires: unixODBC-devel BuildRequires: readline-devel %else BuildRequires: pkgconfig(bzip2) +%if %{without compat} BuildRequires: pkgconfig(odbc) +%endif BuildRequires: pkgconfig(readline) %endif %if %{with fits} @@ -154,8 +160,8 @@ BuildRequires: pkgconfig(libR) # BuildRequires: pkgconfig(valgrind)# -DWITH_VALGRIND=ON %if (0%{?fedora} >= 22) -Recommends: %{name}-SQL-server5%{?_isa} = %{version}-%{release} -Recommends: MonetDB5-server%{?_isa} = %{version}-%{release} +Recommends: %{name}-SQL%{?_isa} = %{version}-%{release} +Recommends: %{name}-server%{?_isa} = %{version}-%{release} Suggests: %{name}-client%{?_isa} = %{version}-%{release} %endif @@ -167,8 +173,8 @@ accelerators. It also has an SQL front This package contains the core components of MonetDB in the form of a single shared library. If you want to use MonetDB, you will certainly -need this package, but you will also need at least the MonetDB5-server -package, and most likely also %{name}-SQL-server5, as well as one or +need this package, but you will also need at least the %{name}-server +package, and most likely also %{name}-SQL, as well as one or more client packages. %ldconfig_scriptlets @@ -176,8 +182,9 @@ more client packages. %files %license COPYING %defattr(-,root,root) -%{_libdir}/libbat.so.*
MonetDB: balanced_union - Fixes munion stats for case of subrel ...
Changeset: b9858dd60394 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/b9858dd60394 Modified Files: sql/server/rel_statistics.c Branch: balanced_union Log Message: Fixes munion stats for case of subrel without PROP_COUNT diffs (20 lines): 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 @@ -882,9 +882,15 @@ rel_get_statistics_(visitor *v, sql_rel /* we need new munion statistics */ /* propagate row count */ BUN rv = need_distinct(rel) ? rel_calc_nuniques(v->sql, r, r->exps) : get_rel_count(r); + /* if PROP_COUNT does not exist we assume at least a row (see get_rel_count def) */ + if (rv == BUN_NONE) { + cnt++; + continue; + } if (!rv && can_be_pruned) needs_pruning = true; - if (rv > (BUN_MAX - cnt)) /* overflow check */ + /* overflow check */ + if (rv > (BUN_MAX - cnt)) rv = BUN_MAX; else cnt += rv; ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: balanced_union - Adjusts emptydb check output (labels c...
Changeset: ccc9fc310534 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/ccc9fc310534 Modified Files: sql/test/emptydb/Tests/check.stable.out.int128 Branch: balanced_union Log Message: Adjusts emptydb check output (labels changes and alias propagation) diffs (truncated from 639 to 300 lines): diff --git a/sql/test/emptydb/Tests/check.stable.out.int128 b/sql/test/emptydb/Tests/check.stable.out.int128 --- a/sql/test/emptydb/Tests/check.stable.out.int128 +++ b/sql/test/emptydb/Tests/check.stable.out.int128 @@ -5195,8 +5195,8 @@ select 'null in fkeys.delete_action', de % %1, name, name, start, minvalue, maxvalue, increment, cacheinc, cycle, comment # name % varchar, varchar,varchar,bigint, bigint, bigint, bigint, bigint, boolean,varchar # type % 0, 0, 0, 1, 1, 1, 1, 1, 5, 0 # length -% .%17 # table_name -% %17 # name +% .%16 # table_name +% %16 # name % bigint # type % 1 # length [ 0] @@ -5676,16 +5676,16 @@ select 'null in fkeys.delete_action', de % %2, %1, id # name % varchar, bigint, int # type % 0, 1, 1 # length -% .%11,sys.%7, sys.tables # table_name -% %11, %7, id # name +% .%7, sys.%6, sys.tables # table_name +% %7, %6, id # name % varchar, bigint, int # type % 0, 1, 1 # length % .%2, sys.%1, sys._columns # table_name % %2, %1, id # name % varchar, bigint, int # type % 0, 1, 1 # length -% .%10,sys.%6, sys.columns # table_name -% %10, %6, id # name +% .%6, sys.%5, sys.columns # table_name +% %6, %5, id # name % varchar, bigint, int # type % 0, 1, 1 # length % .%2, sys.%1, sys.functions # table_name @@ -5768,8 +5768,8 @@ select 'null in fkeys.delete_action', de % %2, %1, name # name % varchar, bigint, varchar # type % 0, 1, 0 # length -% .%23,.%17, .statistics # table_name -% %23, %17,column_id # name +% .%22,.%16, .statistics # table_name +% %22, %16,column_id # name % varchar, bigint, int # type % 0, 1, 1 # length % .%3, .%2,.%1,.%1,.%1 # table_name @@ -5816,12 +5816,12 @@ select 'null in fkeys.delete_action', de % %2, %1, id # name % varchar, bigint, int # type % 0, 1, 1 # length -% .%175, .%167, .ids # table_name -% %175,%167, id # name +% .%150, .%147, .ids # table_name +% %150,%147, id # name % varchar, bigint, int # type % 0, 1, 1 # length -% .%105, .%104, .var_values # table_name -% %105,%104, var_name # name +% .%75,.%74, .var_values # table_name +% %75, %74,var_name # name % varchar, bigint, varchar # type % 0, 1, 0 # length % .%2, sys.%1, sys.table_partitions # table_name @@ -5848,8 +5848,8 @@ select 'null in fkeys.delete_action', de % %2, %1, action_id # name % varchar, bigint, smallint # type % 0, 1, 1 # length -% .%13,.%12, .fkeys # table_name -% %13, %12,id # name +% .%12,.%11, .fkeys # table_name +% %12, %11,id # name % varchar, bigint, int # type % 0, 1, 1 # length % .%2, sys.%1, sys.schemas # table_name @@ -5860,32 +5860,32 @@ select 'null in fkeys.delete_action', de % %2, %1, schema_id, name # name % varchar, bigint, int,varchar # type % 0, 1, 1, 0 # length -% .%11,sys.%7, sys.tables, sys.tables # table_name -% %11, %7, schema_id, name # name +% .%7, sys.%6, sys.tables, sys.tables # table_name +% %7, %6, schema_id, name # name % varchar, bigint, int,varchar # type % 0, 1, 1, 0 # length % .%2, sys.%1, sys._columns, sys._columns # table_name % %2, %1, table_id, name # name % varchar, bigint, int,varchar # type % 0, 1, 1, 0 # length -% .%10,sys.%6, sys.columns,sys.columns # table_name -% %10, %6, table_id, name # name +% .%6, sys.%5, sys.columns,sys.columns # table_name +% %6, %5, table_id, name # name % varchar, bigint, int,varchar # type % 0, 1, 1, 0 # length % .%2, sys.%1, sys._columns, sys._columns # table_name % %2, %1, table_id, number # name % varchar, bigint, int,int # type % 0, 1, 1, 1 # length -% .%10,sys.%6, sys.columns,sys.columns # table_name -% %10, %6, table_id, number # name +% .%6, sys.%5, sys.columns,sys.columns # table_name +% %6, %5, table_id, number # name % varchar, bigint, int,int # type % 0, 1, 1, 1 # length -% .%21,.%20, .t # table_name -% %21, %20,id # name +% .%16,.%15, .t # table_name +% %16, %15,id # name % varchar, bigint, int # type % 0, 1, 1 # length -% .%36,.%33, .t # table_name -% %36, %33,id # name +% .%27,.%26, .t # table_name +% %27, %26,
MonetDB: balanced_union - Adjusts prepare-complex expected output
Changeset: 4c56469adc77 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/4c56469adc77 Modified Files: sql/test/prepare/Tests/prepare-complex.stable.out Branch: balanced_union Log Message: Adjusts prepare-complex expected output diffs (19 lines): diff --git a/sql/test/prepare/Tests/prepare-complex.stable.out b/sql/test/prepare/Tests/prepare-complex.stable.out --- a/sql/test/prepare/Tests/prepare-complex.stable.out +++ b/sql/test/prepare/Tests/prepare-complex.stable.out @@ -17,11 +17,11 @@ stdout of test 'prepare-complex` in dire % type,digits, scale, schema, table, column # name % varchar, int,int,varchar,varchar,varchar # type % 7, 2, 1, 0, 3, 3 # length -[ "decimal", 2, 1, "", "%22", "%13" ] -[ "int", 32, 0, "", "%22", "c2"] +[ "decimal", 2, 1, "", "%20", "%12" ] +[ "int", 32, 0, "", "%20", "c2"] [ "decimal", 2, 1, NULL, NULL, NULL] -[ "int", 32, 0, NULL, NULL, NULL] -[ "int", 32, 0, NULL, NULL, NULL] +[ "int", 31, 0, NULL, NULL, NULL] +[ "int", 31, 0, NULL, NULL, NULL] [ "boolean", 1, 0, NULL, NULL, NULL] #ROLLBACK; ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: balanced_union - Makes sure that inplace set op has ->r...
Changeset: 68caecf084a4 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/68caecf084a4 Modified Files: sql/server/rel_rel.c Branch: balanced_union Log Message: Makes sure that inplace set op has ->r NULL diffs (11 lines): diff --git a/sql/server/rel_rel.c b/sql/server/rel_rel.c --- a/sql/server/rel_rel.c +++ b/sql/server/rel_rel.c @@ -557,6 +557,7 @@ rel_inplace_setop_n_ary(mvc *sql, sql_re rel_inplace_reset_props(rel); /* rl should be a list of relations */ rel->l = rl; + rel->r = NULL; rel->op = setop; rel->card = CARD_MULTI; rel_setop_n_ary_set_exps(sql, rel, exps, false); ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: balanced_union - Make sure that op_project doesn't have...
Changeset: 777ea4d09189 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/777ea4d09189 Modified Files: sql/server/rel_statistics.c Branch: balanced_union Log Message: Make sure that op_project doesn't have anything at ->r diffs (11 lines): 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 @@ -933,6 +933,7 @@ rel_get_statistics_(visitor *v, sql_rel l = rel_select(v->sql->sa, l, exp_atom_bool(v->sql->sa, 0)); set_count_prop(v->sql->sa, l, 0); rel->op = op_project; + rel->r = NULL; rel->l = l; rel->exps = rel_projections(v->sql, l, NULL, 1, 1); set_count_prop(v->sql->sa, rel, 0); ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: balanced_union - Rewrites mtest query to be readable
Changeset: 3d776f91ae10 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/3d776f91ae10 Modified Files: sql/test/BugDay_2005-10-06_2.9.3/Tests/simple_union.SF-1005596.test Branch: balanced_union Log Message: Rewrites mtest query to be readable diffs (212 lines): diff --git a/sql/test/BugDay_2005-10-06_2.9.3/Tests/simple_union.SF-1005596.test b/sql/test/BugDay_2005-10-06_2.9.3/Tests/simple_union.SF-1005596.test --- a/sql/test/BugDay_2005-10-06_2.9.3/Tests/simple_union.SF-1005596.test +++ b/sql/test/BugDay_2005-10-06_2.9.3/Tests/simple_union.SF-1005596.test @@ -6,79 +6,135 @@ create table test ( ) query TIIITT rowsort -SELECT * FROM ( SELECT 'demo' AS "TABLE_CAT", -"schemas"."name" AS "TABLE_SCHEM", "tables"."name" AS -"TABLE_NAME", 'SYSTEM TABLE' AS "TABLE_TYPE", '' AS -"REMARKS", null AS "TYPE_CAT", null AS "TYPE_SCHEM", -null AS "TYPE_NAME", 'rowid' AS -"SELF_REFERENCING_COL_NAME", 'SYSTEM' AS -"REF_GENERATION" FROM "tables", "schemas" WHERE -"tables"."schema_id" = "schemas"."id" AND -"tables"."system" = true AND "tables"."type" = 0 -UNION ALL SELECT 'demo' AS "TABLE_CAT", -"schemas"."name" AS "TABLE_SCHEM", "tables"."name" AS -"TABLE_NAME", 'TABLE' AS "TABLE_TYPE", '' AS "REMARKS", -null AS "TYPE_CAT", null AS "TYPE_SCHEM", null AS -"TYPE_NAME", 'rowid' AS "SELF_REFERENCING_COL_NAME", -'SYSTEM' AS "REF_GENERATION" FROM "tables", "schemas" -WHERE "tables"."schema_id" = "schemas"."id" AND -"tables"."system" = false AND "tables".name = 'test' -AND "tables"."type" = 0 UNION ALL SELECT 'demo' AS "TABLE_CAT", -"schemas"."name" AS "TABLE_SCHEM", "tables"."name" AS -"TABLE_NAME", 'SYSTEM VIEW' AS "TABLE_TYPE", '' AS -"REMARKS", null AS "TYPE_CAT", null AS "TYPE_SCHEM", -null AS "TYPE_NAME", 'rowid' AS -"SELF_REFERENCING_COL_NAME", 'SYSTEM' AS -"REF_GENERATION" FROM "tables", "schemas" WHERE -"tables"."schema_id" = "schemas"."id" AND -"tables"."system" = true AND "tables"."type" = 1 -UNION ALL SELECT 'demo' AS "TABLE_CAT", -"schemas"."name" AS "TABLE_SCHEM", "tables"."name" AS -"TABLE_NAME", 'VIEW' AS "TABLE_TYPE", '' AS "REMARKS", -null AS "TYPE_CAT", null AS "TYPE_SCHEM", null AS -"TYPE_NAME", 'rowid' AS "SELF_REFERENCING_COL_NAME", -'SYSTEM' AS "REF_GENERATION" FROM "tables", "schemas" -WHERE "tables"."schema_id" = "schemas"."id" AND -"tables"."system" = false AND "tables".name = 'test' -AND "tables"."type" = 1 UNION ALL SELECT 'demo' AS "TABLE_CAT", -"schemas"."name" AS "TABLE_SCHEM", "tables"."name" AS -"TABLE_NAME", 'SYSTEM SESSION TABLE' AS "TABLE_TYPE", -'' AS "REMARKS", null AS "TYPE_CAT", null AS -"TYPE_SCHEM", null AS "TYPE_NAME", 'rowid' AS -"SELF_REFERENCING_COL_NAME", 'SYSTEM' AS -"REF_GENERATION" FROM tmp."_tables" AS "tables", -"schemas" WHERE "tables"."schema_id" = "schemas"."id" -AND "tables"."system" = true AND "tables"."type" = -0 UNION ALL SELECT 'demo' AS "TABLE_CAT", -"schemas"."name" AS "TABLE_SCHEM", "tables"."name" AS -"TABLE_NAME", 'SESSION TABLE' AS "TABLE_TYPE", '' AS -"REMARKS", null AS "TYPE_CAT", null AS "TYPE_SCHEM", -null AS "TYPE_NAME", 'rowid' AS -"SELF_REFERENCING_COL_NAME", 'SYSTEM' AS -"REF_GENERATION" FROM tmp."_tables" AS "tables", -"schemas" WHERE "tables"."schema_id" = "schemas"."id" -AND "tables"."system" = false AND "tables".name = 'test' -AND "tables"."type" = 0 UNION ALL SELECT 'demo' AS "TABLE_CAT", -"schemas"."name" AS "TABLE_SCHEM", "tables"."name" AS -"TABLE_NAME", 'SYSTEM SESSION VIEW' AS "TABLE_TYPE", '' -AS "REMARKS", null AS "TYPE_CAT", null AS "TYPE_SCHEM", -null AS "TYPE_NAME", 'rowid' AS -"SELF_REFERENCING_COL_NAME", 'SYSTEM' AS -"REF_GENERATION" FROM tmp."_tables" AS "tables", -"schemas" WHERE "tables"."schema_id" = "schemas"."id" -AND "tables"."system" = true AND "tables"."type" = -1 UNION ALL SELECT 'demo' AS "TABLE_CAT", -"schemas"."name" AS "TABLE_SCHEM", "tables"."name" AS -"TABLE_NAME", 'SESSION VIEW' AS "TABLE_TYPE", '' AS -"REMARKS", null AS "TYPE_CAT", null AS "TYPE_SCHEM", -null AS "TYPE_NAME", 'rowid' AS -"SELF_REFERENCING_COL_NAME", 'SYSTEM' AS -"REF_GENERATION" FROM tmp."_tables" AS "tables", -"schemas" WHERE "tables"."schema_id" = "schemas"."id" -AND "tables"."system" = false AND "tables".name = 'test' -AND "tables"."type" = 1 ) AS "tables" WHERE 1 = 1 AND ("TABLE_TYPE" LIKE -'TABLE' OR "TABLE_TYPE" LIKE 'VIEW') ORDER BY -"TABLE_TYPE", "TABLE_SCHEM", "TABLE_NAME" +SELECT * FROM ( +SELECT 'demo' AS "TABLE_CAT", +"schemas"."name" AS "TABLE_SCHEM", + "tables"."name" AS "TABLE_NAME", + 'SYSTEM TABLE' AS "TABLE_TYPE", + '' AS "REMARKS", + null AS "TYPE_CAT", + null AS "TYPE_SCHEM", +null AS "TYPE_NAME", + 'rowid' AS "SELF_REFERENCING_COL_NAME", + 'SYSTEM' AS "REF_GENERATION" + FROM "tables", "schemas" + WHERE "tables"."schema_id" = "schemas"."id" AND + "tables"."system" = true AND + "tables"."type" = 0 +UNION ALL +SELECT 'demo' AS "TABLE_CAT", +
MonetDB: default - Merges other head
Changeset: acb560eab26d for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/acb560eab26d Branch: default Log Message: Merges other head diffs (12 lines): diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c --- a/sql/server/rel_select.c +++ b/sql/server/rel_select.c @@ -1303,7 +1303,7 @@ bool group_by_pk_project_uk_cond(mvc* sq continue; } } - if (pki && pki->columns->cnt == 1 && ((list*) inner->r)->cnt == 1) { + if (pki && pki->columns->cnt == 1 && inner->r && ((list*) inner->r)->cnt == 1) { /* for now only check simple case where primary key and group by expression is a single column*/ sql_exp* gbe = ((list*) inner->r)->h->data; assert(gbe->type == e_column); ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - Adds some reader empathy in mtest
Changeset: 7c21b8cfa4f6 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/7c21b8cfa4f6 Modified Files: sql/test/BugDay_2005-10-06_2.9.3/Tests/simple_union.SF-1005596.test Branch: default Log Message: Adds some reader empathy in mtest diffs (212 lines): diff --git a/sql/test/BugDay_2005-10-06_2.9.3/Tests/simple_union.SF-1005596.test b/sql/test/BugDay_2005-10-06_2.9.3/Tests/simple_union.SF-1005596.test --- a/sql/test/BugDay_2005-10-06_2.9.3/Tests/simple_union.SF-1005596.test +++ b/sql/test/BugDay_2005-10-06_2.9.3/Tests/simple_union.SF-1005596.test @@ -6,79 +6,135 @@ create table test ( ) query TIIITT rowsort -SELECT * FROM ( SELECT 'demo' AS "TABLE_CAT", -"schemas"."name" AS "TABLE_SCHEM", "tables"."name" AS -"TABLE_NAME", 'SYSTEM TABLE' AS "TABLE_TYPE", '' AS -"REMARKS", null AS "TYPE_CAT", null AS "TYPE_SCHEM", -null AS "TYPE_NAME", 'rowid' AS -"SELF_REFERENCING_COL_NAME", 'SYSTEM' AS -"REF_GENERATION" FROM "tables", "schemas" WHERE -"tables"."schema_id" = "schemas"."id" AND -"tables"."system" = true AND "tables"."type" = 0 -UNION ALL SELECT 'demo' AS "TABLE_CAT", -"schemas"."name" AS "TABLE_SCHEM", "tables"."name" AS -"TABLE_NAME", 'TABLE' AS "TABLE_TYPE", '' AS "REMARKS", -null AS "TYPE_CAT", null AS "TYPE_SCHEM", null AS -"TYPE_NAME", 'rowid' AS "SELF_REFERENCING_COL_NAME", -'SYSTEM' AS "REF_GENERATION" FROM "tables", "schemas" -WHERE "tables"."schema_id" = "schemas"."id" AND -"tables"."system" = false AND "tables".name = 'test' -AND "tables"."type" = 0 UNION ALL SELECT 'demo' AS "TABLE_CAT", -"schemas"."name" AS "TABLE_SCHEM", "tables"."name" AS -"TABLE_NAME", 'SYSTEM VIEW' AS "TABLE_TYPE", '' AS -"REMARKS", null AS "TYPE_CAT", null AS "TYPE_SCHEM", -null AS "TYPE_NAME", 'rowid' AS -"SELF_REFERENCING_COL_NAME", 'SYSTEM' AS -"REF_GENERATION" FROM "tables", "schemas" WHERE -"tables"."schema_id" = "schemas"."id" AND -"tables"."system" = true AND "tables"."type" = 1 -UNION ALL SELECT 'demo' AS "TABLE_CAT", -"schemas"."name" AS "TABLE_SCHEM", "tables"."name" AS -"TABLE_NAME", 'VIEW' AS "TABLE_TYPE", '' AS "REMARKS", -null AS "TYPE_CAT", null AS "TYPE_SCHEM", null AS -"TYPE_NAME", 'rowid' AS "SELF_REFERENCING_COL_NAME", -'SYSTEM' AS "REF_GENERATION" FROM "tables", "schemas" -WHERE "tables"."schema_id" = "schemas"."id" AND -"tables"."system" = false AND "tables".name = 'test' -AND "tables"."type" = 1 UNION ALL SELECT 'demo' AS "TABLE_CAT", -"schemas"."name" AS "TABLE_SCHEM", "tables"."name" AS -"TABLE_NAME", 'SYSTEM SESSION TABLE' AS "TABLE_TYPE", -'' AS "REMARKS", null AS "TYPE_CAT", null AS -"TYPE_SCHEM", null AS "TYPE_NAME", 'rowid' AS -"SELF_REFERENCING_COL_NAME", 'SYSTEM' AS -"REF_GENERATION" FROM tmp."_tables" AS "tables", -"schemas" WHERE "tables"."schema_id" = "schemas"."id" -AND "tables"."system" = true AND "tables"."type" = -0 UNION ALL SELECT 'demo' AS "TABLE_CAT", -"schemas"."name" AS "TABLE_SCHEM", "tables"."name" AS -"TABLE_NAME", 'SESSION TABLE' AS "TABLE_TYPE", '' AS -"REMARKS", null AS "TYPE_CAT", null AS "TYPE_SCHEM", -null AS "TYPE_NAME", 'rowid' AS -"SELF_REFERENCING_COL_NAME", 'SYSTEM' AS -"REF_GENERATION" FROM tmp."_tables" AS "tables", -"schemas" WHERE "tables"."schema_id" = "schemas"."id" -AND "tables"."system" = false AND "tables".name = 'test' -AND "tables"."type" = 0 UNION ALL SELECT 'demo' AS "TABLE_CAT", -"schemas"."name" AS "TABLE_SCHEM", "tables"."name" AS -"TABLE_NAME", 'SYSTEM SESSION VIEW' AS "TABLE_TYPE", '' -AS "REMARKS", null AS "TYPE_CAT", null AS "TYPE_SCHEM", -null AS "TYPE_NAME", 'rowid' AS -"SELF_REFERENCING_COL_NAME", 'SYSTEM' AS -"REF_GENERATION" FROM tmp."_tables" AS "tables", -"schemas" WHERE "tables"."schema_id" = "schemas"."id" -AND "tables"."system" = true AND "tables"."type" = -1 UNION ALL SELECT 'demo' AS "TABLE_CAT", -"schemas"."name" AS "TABLE_SCHEM", "tables"."name" AS -"TABLE_NAME", 'SESSION VIEW' AS "TABLE_TYPE", '' AS -"REMARKS", null AS "TYPE_CAT", null AS "TYPE_SCHEM", -null AS "TYPE_NAME", 'rowid' AS -"SELF_REFERENCING_COL_NAME", 'SYSTEM' AS -"REF_GENERATION" FROM tmp."_tables" AS "tables", -"schemas" WHERE "tables"."schema_id" = "schemas"."id" -AND "tables"."system" = false AND "tables".name = 'test' -AND "tables"."type" = 1 ) AS "tables" WHERE 1 = 1 AND ("TABLE_TYPE" LIKE -'TABLE' OR "TABLE_TYPE" LIKE 'VIEW') ORDER BY -"TABLE_TYPE", "TABLE_SCHEM", "TABLE_NAME" +SELECT * FROM ( +SELECT 'demo' AS "TABLE_CAT", +"schemas"."name" AS "TABLE_SCHEM", + "tables"."name" AS "TABLE_NAME", + 'SYSTEM TABLE' AS "TABLE_TYPE", + '' AS "REMARKS", + null AS "TYPE_CAT", + null AS "TYPE_SCHEM", +null AS "TYPE_NAME", + 'rowid' AS "SELF_REFERENCING_COL_NAME", + 'SYSTEM' AS "REF_GENERATION" + FROM "tables", "schemas" + WHERE "tables"."schema_id" = "schemas"."id" AND + "tables"."system" = true AND + "tables"."type" = 0 +UNION ALL +SELECT 'demo' AS "TABLE_CAT", +"schemas"."name"
MonetDB: balanced_union - Fixes crash: ->r needs to be NULL from...
Changeset: 6d7de45082d0 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/6d7de45082d0 Modified Files: sql/server/rel_statistics.c Branch: balanced_union Log Message: Fixes crash: ->r needs to be NULL from munion to project op conversion diffs (11 lines): 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 @@ -910,6 +910,7 @@ rel_get_statistics_(visitor *v, sql_rel rel->l = nl; if (list_length(nl) == 1) { sql_rel *l = rel->l = nl->h->data; /* ugh */ + rel->r = NULL; rel->op = op_project; for (node *n = rel->exps->h, *m = l->exps->h ; n && m ; n = n->next, m = m->next) { ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: balanced_union - Prune munion members only if it's not ref
Changeset: 9fe2224d5195 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/9fe2224d5195 Modified Files: sql/server/rel_statistics.c Branch: balanced_union Log Message: Prune munion members only if it's not ref diffs (12 lines): 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 @@ -893,7 +893,7 @@ rel_get_statistics_(visitor *v, sql_rel for (node *n = rel->exps->h ; n ; n = n->next, i++) rel_munion_get_statistics(v->sql, rel, nrels, n->data, i); - if (needs_pruning) { + if (needs_pruning && !rel_is_ref(rel)) { v->changes++; list *nl = sa_list(l->sa); ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: balanced_union - Fixes errors in join_push_down_munion ...
Changeset: f9b374a7c095 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/f9b374a7c095 Modified Files: sql/server/rel_optimize_proj.c Branch: balanced_union Log Message: Fixes errors in join_push_down_munion implementation diffs (35 lines): 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 @@ -3779,10 +3779,10 @@ rel_push_join_down_munion(visitor *v, sq sql_rel *rp = rel_dup(m->data); if (!is_project(rp->op)) rp = rel_project(v->sql->sa, rp, rel_projections(v->sql, rp, NULL, 1, 1)); - rel_rename_exps(v->sql, l->exps, rp->exps); - if (l != ol) { + rel_rename_exps(v->sql, r->exps, rp->exps); + if (r != or) { rp = rel_project(v->sql->sa, rp, NULL); - rp->exps = exps_copy(v->sql, ol->exps); + rp->exps = exps_copy(v->sql, or->exps); set_processed(rp); } /* combine them */ @@ -3805,13 +3805,13 @@ rel_push_join_down_munion(visitor *v, sq sql_rel *pc = rel_dup(n->data); if (!is_project(pc->op)) pc = rel_project(v->sql->sa, pc, rel_projections(v->sql, pc, NULL, 1, 1)); - rel_rename_exps(v->sql, l->exps, pc->exps); - if (l != ol) { + rel_rename_exps(v->sql, r->exps, pc->exps); + if (r != or) { pc = rel_project(v->sql->sa, pc, NULL); - pc->exps = exps_copy(v->sql, ol->exps); + pc->exps = exps_copy(v->sql, or->exps); set_processed(pc); } - pc = rel_crossproduct(v->sql->sa, pc, rel_dup(ol), rel->op); + pc = rel_crossproduct(v->sql->sa, rel_dup(ol), pc, rel->op); pc->exps = exps_copy(v->sql, exps); pc->attr = exps_copy(v->sql, attr); set_processed(pc); ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: balanced_union - Adapts expected relational plan
Changeset: 1d8cb62ff615 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/1d8cb62ff615 Modified Files: sql/test/rel-optimizers/Tests/join-merge-remote-replica-plan.test Branch: balanced_union Log Message: Adapts expected relational plan diffs (37 lines): diff --git a/sql/test/rel-optimizers/Tests/join-merge-remote-replica-plan.test b/sql/test/rel-optimizers/Tests/join-merge-remote-replica-plan.test --- a/sql/test/rel-optimizers/Tests/join-merge-remote-replica-plan.test +++ b/sql/test/rel-optimizers/Tests/join-merge-remote-replica-plan.test @@ -63,22 +63,20 @@ select * from foo_p1 query T nosort plan select * from foo_merge, members_rpl -union ( -| union ( +munion ( +| project ( +| | crossproduct ( +| | | table("sys"."foo_p1") [ "foo_p1"."n" UNIQUE as "foo_merge"."n", "foo_p1"."m" as "foo_merge"."m" ], +| | | table("sys"."members_n1") [ "members_n1"."n" UNIQUE as "members_rpl"."n", "members_n1"."m" UNIQUE as "members_rpl"."m", "members_n1"."%TID%" NOT NULL UNIQUE as "members_rpl"."%TID%" ] +| | ) [ ] +| ) [ "foo_merge"."n", "foo_merge"."m", "members_rpl"."n", "members_rpl"."m" ], +| table ( | | project ( | | | crossproduct ( -| | | | table("sys"."foo_p1") [ "foo_p1"."n" UNIQUE as "foo_merge"."n", "foo_p1"."m" as "foo_merge"."m" ], -| | | | table("sys"."members_n1") [ "members_n1"."n" UNIQUE as "members_rpl"."n", "members_n1"."m" UNIQUE as "members_rpl"."m", "members_n1"."%TID%" NOT NULL UNIQUE as "members_rpl"."%TID%" ] +| | | | REMOTE("sys"."foo_p2") [ "foo_p2"."n" as "foo_merge"."n", "foo_p2"."m" as "foo_merge"."m" ], +| | | | REMOTE("sys"."members_n2") [ "members_n2"."n" as "members_rpl"."n", "members_n2"."m" as "members_rpl"."m", "members_n2"."%TID%" NOT NULL UNIQUE as "members_rpl"."%TID%" ] | | | ) [ ] -| | ) [ "foo_merge"."n", "foo_merge"."m", "members_rpl"."n", "members_rpl"."m" ], -| | table ( -| | | project ( -| | | | crossproduct ( -| | | | | REMOTE("sys"."foo_p2") [ "foo_p2"."n" as "foo_merge"."n", "foo_p2"."m" as "foo_merge"."m" ], -| | | | | REMOTE("sys"."members_n2") [ "members_n2"."n" as "members_rpl"."n", "members_n2"."m" as "members_rpl"."m", "members_n2"."%TID%" NOT NULL UNIQUE as "members_rpl"."%TID%" ] -| | | | ) [ ] -| | | ) [ "foo_merge"."n", "foo_merge"."m", "members_rpl"."n", "members_rpl"."m" ] REMOTE mapi:monetdb://localhost:50002/node2 -| | ) [ "foo_merge"."n", "foo_merge"."m", "members_rpl"."n", "members_rpl"."m" ] +| | ) [ "foo_merge"."n", "foo_merge"."m", "members_rpl"."n", "members_rpl"."m" ] REMOTE mapi:monetdb://localhost:50002/node2 | ) [ "foo_merge"."n", "foo_merge"."m", "members_rpl"."n", "members_rpl"."m" ], | table ( | | project ( ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: balanced_union - Dup the proper (left in this case) pro...
Changeset: cd94173fdc28 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/cd94173fdc28 Modified Files: sql/server/rel_optimize_proj.c Branch: balanced_union Log Message: Dup the proper (left in this case) projections diffs (12 lines): 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 @@ -3811,7 +3811,7 @@ rel_push_join_down_munion(visitor *v, sq pc->exps = exps_copy(v->sql, ol->exps); set_processed(pc); } - pc = rel_crossproduct(v->sql->sa, pc, rel_dup(or), rel->op); + pc = rel_crossproduct(v->sql->sa, pc, rel_dup(ol), rel->op); pc->exps = exps_copy(v->sql, exps); pc->attr = exps_copy(v->sql, attr); set_processed(pc); ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: balanced_union - Fixes memory management bugs
Changeset: 19377b09172f for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/19377b09172f Modified Files: sql/server/rel_optimize_proj.c Branch: balanced_union Log Message: Fixes memory management bugs diffs (45 lines): 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 @@ -3737,6 +3737,7 @@ rel_push_join_down_munion(visitor *v, sq if (is_munion(l->op) && !need_distinct(l) && !is_single(l) && !is_munion(r->op)){ /* join(munion(a,b,c), d) -> munion(join(a,d), join(b,d), join(c,d)) */ + list *js = sa_list(v->sql->sa); for (node *n = ((list*)l->l)->h; n; n = n->next) { sql_rel *pc = rel_dup(n->data); if (!is_project(pc->op)) @@ -3752,10 +3753,10 @@ rel_push_join_down_munion(visitor *v, sq pc->attr = exps_copy(v->sql, attr); set_processed(pc); pc = rel_project(v->sql->sa, pc, rel_projections(v->sql, pc, NULL, 1, 1)); - n->data = pc; + js = append(js, pc); } v->changes++; - return rel_inplace_setop_n_ary(v->sql, rel, l->l, op_munion, + return rel_inplace_setop_n_ary(v->sql, rel, js, op_munion, rel_projections(v->sql, rel, NULL, 1, 1)); } else if (is_munion(l->op) && !need_distinct(l) && !is_single(l) && is_munion(r->op) && !need_distinct(r) && !is_single(r) && @@ -3799,6 +3800,7 @@ rel_push_join_down_munion(visitor *v, sq is_munion(r->op) && !need_distinct(r) && !is_single(r) && !is_semi(rel->op)) { /* join(a, munion(b,c,d)) -> munion(join(a,b), join(a,c), join(a,d)) */ + list *js = sa_list(v->sql->sa); for (node *n = ((list*)r->l)->h; n; n = n->next) { sql_rel *pc = rel_dup(n->data); if (!is_project(pc->op)) @@ -3814,10 +3816,10 @@ rel_push_join_down_munion(visitor *v, sq pc->attr = exps_copy(v->sql, attr); set_processed(pc); pc = rel_project(v->sql->sa, pc, rel_projections(v->sql, pc, NULL, 1, 1)); - n->data = pc; + js = append(js, pc); } v->changes++; - return rel_inplace_setop_n_ary(v->sql, rel, r->l, op_munion, + return rel_inplace_setop_n_ary(v->sql, rel, js, op_munion, rel_projections(v->sql, rel, NULL, 1, 1)); } else if (!is_munion(l->op) && is_munion(r->op) && !need_distinct(r) && !is_single(r) && ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: balanced_union - Implements push_join_down_munion optim...
Changeset: 043afd5efe04 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/043afd5efe04 Modified Files: sql/server/rel_optimize_proj.c Branch: balanced_union Log Message: Implements push_join_down_munion optimizer WIP 4 diffs (59 lines): 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 @@ -3822,16 +3822,42 @@ rel_push_join_down_munion(visitor *v, sq } else if (!is_munion(l->op) && is_munion(r->op) && !need_distinct(r) && !is_single(r) && is_semi(rel->op) && je) { - /* {semi}join ( A1, munion (B, A2, C)) [A1.partkey = A2.partkey] -> -* {semi}join ( A1, A2 ) -* (ie a single part on n-th munion operand) + /* {semi}join ( A1, munion (B, A2a, C, A2b)) [A1.partkey = A2.partkey] -> +* {semi}join ( A1, munion (A2a, A2b)) +* (ie some parts of an n-th munion operand) * * How to detect that a relation isn't matching? * partitioning is currently done only on pkey/fkey's * ie only matching per part if join is on pkey/fkey (parts) * and part numbers should match. * */ - // TODO + int lpnr = rel_part_nr(l, je); + if (lpnr < 0) + return rel; + + list *ups = sa_list(v->sql->sa); + for (node *n = ((list*)r->l)->h; n; n = n->next) { + if (rel_uses_part_nr(n->data, je, lpnr)) { + sql_rel *pc = rel_dup(n->data); + /*if (!is_project(pc->op))*/ + /*pc = rel_project(v->sql->sa, pc,*/ + /*rel_projections(v->sql, pc, NULL, 1, 1));*/ + /*rel_rename_exps(v->sql, r->exps, pc->exps);*/ + /*if (r != or) {*/ + /*pc = rel_project(v->sql->sa, pc, NULL);*/ + /*pc->exps = exps_copy(v->sql, or->exps);*/ + /*set_processed(pc);*/ + /*}*/ + /*pc = rel_crossproduct(v->sql->sa, rel_dup(ol), pc, rel->op);*/ + /*pc->exps = exps_copy(v->sql, exps);*/ + /*pc->attr = exps_copy(v->sql, attr);*/ + /*set_processed(pc);*/ + ups = append(ups, pc); + } + } + v->changes++; + return rel_inplace_setop_n_ary(v->sql, r, ups, op_munion, + rel_projections(v->sql, rel, NULL, 1, 1)); } } return rel; @@ -3842,7 +3868,7 @@ rel_optimize_unions_topdown_(visitor *v, { rel = rel_push_project_down_union(v, rel); // TODO: implement rel_push_join_down_munion - rel = rel_push_join_down_union(v, rel); + rel = rel_push_join_down_munion(v, rel); return rel; } ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: balanced_union - Implements push_join_down_munion optim...
Changeset: 7f4298bc94c6 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/7f4298bc94c6 Modified Files: sql/server/rel_optimize_proj.c Branch: balanced_union Log Message: Implements push_join_down_munion optimizer WIP 3 diffs (31 lines): 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 @@ -3799,7 +3799,26 @@ rel_push_join_down_munion(visitor *v, sq is_munion(r->op) && !need_distinct(r) && !is_single(r) && !is_semi(rel->op)) { /* join(a, munion(b,c,d)) -> munion(join(a,b), join(a,c), join(a,d)) */ - // TODO + for (node *n = ((list*)r->l)->h; n; n = n->next) { + sql_rel *pc = rel_dup(n->data); + if (!is_project(pc->op)) + pc = rel_project(v->sql->sa, pc, rel_projections(v->sql, pc, NULL, 1, 1)); + rel_rename_exps(v->sql, l->exps, pc->exps); + if (l != ol) { + pc = rel_project(v->sql->sa, pc, NULL); + pc->exps = exps_copy(v->sql, ol->exps); + set_processed(pc); + } + pc = rel_crossproduct(v->sql->sa, pc, rel_dup(or), rel->op); + pc->exps = exps_copy(v->sql, exps); + pc->attr = exps_copy(v->sql, attr); + set_processed(pc); + pc = rel_project(v->sql->sa, pc, rel_projections(v->sql, pc, NULL, 1, 1)); + n->data = pc; + } + v->changes++; + return rel_inplace_setop_n_ary(v->sql, rel, r->l, op_munion, + rel_projections(v->sql, rel, NULL, 1, 1)); } else if (!is_munion(l->op) && is_munion(r->op) && !need_distinct(r) && !is_single(r) && is_semi(rel->op) && je) { ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: balanced_union - Implements push_join_down_munion optim...
Changeset: 3391fa2b099f for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/3391fa2b099f Modified Files: sql/server/rel_optimize_proj.c Branch: balanced_union Log Message: Implements push_join_down_munion optimizer WIP 2 diffs (63 lines): 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 @@ -3726,10 +3726,14 @@ rel_push_join_down_munion(visitor *v, sq !(je = rel_is_join_on_pkey(rel, aligned_pk_fk return rel; - // TODO: why? bailout for no semijoin without pkey joins + // TODO: why? bailout for union semijoin without pkey joins expressions if (is_semi(rel->op) && is_munion(l->op) && !je) return rel; + /* if both sides are munions we assume that they will have the same number of children */ + if (is_munion(l->op) && is_munion(r->op) && list_length(l->l) != list_length(r->l)) + return rel; + if (is_munion(l->op) && !need_distinct(l) && !is_single(l) && !is_munion(r->op)){ /* join(munion(a,b,c), d) -> munion(join(a,d), join(b,d), join(c,d)) */ @@ -3756,8 +3760,41 @@ rel_push_join_down_munion(visitor *v, sq } else if (is_munion(l->op) && !need_distinct(l) && !is_single(l) && is_munion(r->op) && !need_distinct(r) && !is_single(r) && je) { - /* join(munion(a,b,c), union(d,e,f)) -> munion(join(a,d), join(b,e), join(c,f)) */ - // TODO + /* join(munion(a,b,c), munion(d,e,f)) -> munion(join(a,d), join(b,e), join(c,f)) */ + list *cps = sa_list(v->sql->sa); + /* create pairwise joins between left and right parts. assume eq num of parts (see earlier bailout) */ + for (node *n = ((list*)l->l)->h, *m=((list*)r->l)->h; n && m; n = n->next, m = m->next) { + /* left part */ + sql_rel *lp = rel_dup(n->data); + if (!is_project(lp->op)) + lp = rel_project(v->sql->sa, lp, rel_projections(v->sql, lp, NULL, 1, 1)); + rel_rename_exps(v->sql, l->exps, lp->exps); + if (l != ol) { + lp = rel_project(v->sql->sa, lp, NULL); + lp->exps = exps_copy(v->sql, ol->exps); + set_processed(lp); + } + /* right part */ + sql_rel *rp = rel_dup(m->data); + if (!is_project(rp->op)) + rp = rel_project(v->sql->sa, rp, rel_projections(v->sql, rp, NULL, 1, 1)); + rel_rename_exps(v->sql, l->exps, rp->exps); + if (l != ol) { + rp = rel_project(v->sql->sa, rp, NULL); + rp->exps = exps_copy(v->sql, ol->exps); + set_processed(rp); + } + /* combine them */ + sql_rel *cp = rel_crossproduct(v->sql->sa, lp, rp, rel->op); + cp->exps = exps_copy(v->sql, exps); + cp->attr = exps_copy(v->sql, attr); + set_processed(cp); + cp = rel_project(v->sql->sa, cp, rel_projections(v->sql, cp, NULL, 1, 1)); + cps = append(cps, cp); + } + v->changes++; + return rel_inplace_setop_n_ary(v->sql, rel, cps, op_munion, + rel_projections(v->sql, rel, NULL, 1, 1)); } else if (!is_munion(l->op) && is_munion(r->op) && !need_distinct(r) && !is_single(r) && !is_semi(rel->op)) { ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: balanced_union - Implements push_join_down_munion optim...
Changeset: 1407c0aa2015 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/1407c0aa2015 Modified Files: sql/server/rel_optimize_proj.c Branch: balanced_union Log Message: Implements push_join_down_munion optimizer WIP diffs (116 lines): 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 @@ -3524,7 +3524,8 @@ rel_push_join_down_union(visitor *v, sql nl = rel_project(v->sql->sa, nl, rel_projections(v->sql, nl, NULL, 1, 1)); nr = rel_project(v->sql->sa, nr, rel_projections(v->sql, nr, NULL, 1, 1)); v->changes++; - return rel_inplace_setop(v->sql, rel, nl, nr, op_union, rel_projections(v->sql, rel, NULL, 1, 1)); + return rel_inplace_setop(v->sql, rel, nl, nr, op_union, + rel_projections(v->sql, rel, NULL, 1, 1)); } else if (is_union(l->op) && !need_distinct(l) && !is_single(l) && is_union(r->op) && !need_distinct(r) && !is_single(r) && je) { sql_rel *nl, *nr; @@ -3684,6 +3685,102 @@ rel_push_join_down_union(visitor *v, sql return rel; } +/* + * Push (semi)joins down unions, this is basically for merge tables, where + * we know that the fk-indices are split over two clustered merge tables. + */ +static inline sql_rel * +rel_push_join_down_munion(visitor *v, sql_rel *rel) +{ + if ((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; + sql_exp *je = NULL; + + /* we would like to optimize in place reference rels which point +* to replica tables and let the replica optimizer handle those +* later. otherwise we miss the push join down optimization due +* to the rel_is_ref bailout +*/ + if (rel_is_ref(l) && is_basetable(l->op) && l->l && isReplicaTable((sql_table*)l->l)) { + rel->l = rel_copy(v->sql, l, true); + rel_destroy(l); + } + if (rel_is_ref(r) && is_basetable(r->op) && r->l && isReplicaTable((sql_table*)r->l)) { + rel->r = rel_copy(v->sql, r, true); + rel_destroy(r); + } + + // TODO: do we need to check if it's l/r are refs? + if (!l || !r || need_distinct(l) || need_distinct(r) || rel_is_ref(l) || rel_is_ref(r)) + return rel; + if (l->op == op_project) + l = l->l; + if (r->op == op_project) + r = r->l; + + /* both sides only if we have a join index ASSUMING pkey-fkey are aligned */ + // TODO: we could also check if the join cols are (not) unique + bool aligned_pk_fk = true; + if (!l || !r || (is_munion(l->op) && is_munion(r->op) && + !(je = rel_is_join_on_pkey(rel, aligned_pk_fk + return rel; + + // TODO: why? bailout for no semijoin without pkey joins + if (is_semi(rel->op) && is_munion(l->op) && !je) + return rel; + + if (is_munion(l->op) && !need_distinct(l) && !is_single(l) && + !is_munion(r->op)){ + /* join(munion(a,b,c), d) -> munion(join(a,d), join(b,d), join(c,d)) */ + for (node *n = ((list*)l->l)->h; n; n = n->next) { + sql_rel *pc = rel_dup(n->data); + if (!is_project(pc->op)) + pc = rel_project(v->sql->sa, pc, rel_projections(v->sql, pc, NULL, 1, 1)); + rel_rename_exps(v->sql, l->exps, pc->exps); + if (l != ol) { + pc = rel_project(v->sql->sa, pc, NULL); + pc->exps = exps_copy(v->sql, ol->exps); + set_processed(pc); + } + pc = rel_crossproduct(v->sql->sa, pc, rel_dup(or), rel->op); + pc->exps = exps_copy(v->sql, exps); + pc->attr = exps_copy(v->sql, attr); + set_processed(pc); + pc = rel_project(v->sql->sa, pc, rel_projections(v->sql, pc, NULL, 1, 1)); + n->data = pc; + } + v->changes++; + return rel_inplace_setop_n_ary(v->sql, rel, l->l, op_munion, +
MonetDB: balanced_union - Expects munion instead of union operator
Changeset: bb72c109e7bd for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/bb72c109e7bd Modified Files: sql/test/BugTracker-2017/Tests/caching_stats_bug.6374.test Branch: balanced_union Log Message: Expects munion instead of union operator diffs (12 lines): diff --git a/sql/test/BugTracker-2017/Tests/caching_stats_bug.6374.test b/sql/test/BugTracker-2017/Tests/caching_stats_bug.6374.test --- a/sql/test/BugTracker-2017/Tests/caching_stats_bug.6374.test +++ b/sql/test/BugTracker-2017/Tests/caching_stats_bug.6374.test @@ -69,7 +69,7 @@ PLAN select count(*) from mt where i >= project ( | group by ( -| | union ( +| | munion ( | | | group by ( | | | | select ( | | | | | table("sys"."sub1") [ "sub1"."i" NOT NULL UNIQUE as "mt"."i" ] ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: balanced_union - Fixes sqlancer_prepare expected automa...
Changeset: fe0b28876ef9 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/fe0b28876ef9 Modified Files: sql/test/prepare/Tests/sqlancer_prepare.stable.out.int128 Branch: balanced_union Log Message: Fixes sqlancer_prepare expected automatic col naming diffs (63 lines): diff --git a/sql/test/prepare/Tests/sqlancer_prepare.stable.out.int128 b/sql/test/prepare/Tests/sqlancer_prepare.stable.out.int128 --- a/sql/test/prepare/Tests/sqlancer_prepare.stable.out.int128 +++ b/sql/test/prepare/Tests/sqlancer_prepare.stable.out.int128 @@ -11,8 +11,8 @@ % type,digits, scale, schema, table, column # name % varchar, int,int,varchar,varchar,varchar # type % 12, 2, 1, 0, 3, 2 # length -[ "boolean", 1, 0, "", "%10", "c0"] -[ "sec_interval", 13, 0, "", "%10", "%1"] +[ "boolean", 1, 0, "", "%7", "c0"] +[ "sec_interval", 13, 0, "", "%7", "%1"] [ "boolean", 1, 0, NULL, NULL, NULL] [ "sec_interval", 13, 0, NULL, NULL, NULL] #ROLLBACK; @@ -28,8 +28,8 @@ % type,digits, scale, schema, table, column # name % varchar, int,int,varchar,varchar,varchar # type % 7, 2, 1, 0, 3, 3 # length -[ "decimal", 2, 1, "", "%22", "%13" ] -[ "int", 31, 0, "", "%22", "c2"] +[ "decimal", 2, 1, "", "%20", "%12" ] +[ "int", 31, 0, "", "%20", "c2"] [ "decimal", 2, 1, NULL, NULL, NULL] [ "int", 31, 0, NULL, NULL, NULL] [ "int", 31, 0, NULL, NULL, NULL] @@ -75,7 +75,7 @@ % type,digits, scale, schema, table, column # name % varchar, int,int,varchar,varchar,varchar # type % 7, 2, 1, 0, 3, 2 # length -[ "bigint",63, 0, "", "%12", "%4"] +[ "bigint",63, 0, "", "%11", "%4"] [ "varchar", 0, 0, NULL, NULL, NULL] [ "bigint",63, 0, NULL, NULL, NULL] #PREPARE VALUES (CASE WHEN true THEN 5 BETWEEN 4 AND 2 END); @@ -153,23 +153,23 @@ % type,digits, scale, schema, table, column # name % varchar, int,int,varchar,varchar,varchar # type % 7, 3, 1, 0, 3, 3 # length -[ "json", 0, 0, "", "%15", "%15" ] +[ "json", 0, 0, "", "%14", "%14" ] [ "hugeint", 127,0, NULL, NULL, NULL] % .prepare,.prepare, .prepare, .prepare, .prepare, .prepare # table_name % type,digits, scale, schema, table, column # name % varchar, int,int,varchar,varchar,varchar # type % 7, 3, 1, 0, 3, 3 # length -[ "json", 0, 0, "", "%15", "%15" ] +[ "json", 0, 0, "", "%14", "%14" ] [ "hugeint", 127,0, NULL, NULL, NULL] % .prepare,.prepare, .prepare, .prepare, .prepare, .prepare # table_name % type,digits, scale, schema, table, column # name % varchar, int,int,varchar,varchar,varchar # type % 7, 1, 1, 0, 3, 3 # length -[ "varchar", 1, 0, "", "%22", "%14" ] +[ "varchar", 1, 0, "", "%20", "%13" ] [ "varchar", 1, 0, NULL, NULL, NULL] [ "boolean", 1, 0, NULL, NULL, NULL] -% .%22 # table_name -% %14 # name +% .%20 # table_name +% %13 # name % varchar # type % 1 # length [ "b" ] ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: balanced_union - Handle recursive merge tables
Changeset: f671a61deda1 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/f671a61deda1 Modified Files: sql/server/rel_optimizer.c Branch: balanced_union Log Message: Handle recursive merge tables diffs (23 lines): 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 @@ -55,6 +55,8 @@ typedef struct { sql_rel *sel; } merge_table_prune_info; +static sql_rel *merge_table_prune_and_unionize(visitor *v, sql_rel *mt_rel, merge_table_prune_info *info); + static sql_rel * rel_wrap_select_around_mt_child(visitor *v, sql_rel *t, merge_table_prune_info *info) { @@ -62,8 +64,8 @@ rel_wrap_select_around_mt_child(visitor sql_table *subt = (sql_table *)t->l; if (isMergeTable(subt)) { - // TODO: handle it - return NULL; + if ((t = merge_table_prune_and_unionize(v, t, info)) == NULL) + return NULL; } if (info) { ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: balanced_union - Fix plans of merge table tests
Changeset: fdcfc9ab7e9e for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/fdcfc9ab7e9e Modified Files: sql/test/merge-partitions/Tests/mergepart31.test Branch: balanced_union Log Message: Fix plans of merge table tests diffs (292 lines): diff --git a/sql/test/merge-partitions/Tests/mergepart31.test b/sql/test/merge-partitions/Tests/mergepart31.test --- a/sql/test/merge-partitions/Tests/mergepart31.test +++ b/sql/test/merge-partitions/Tests/mergepart31.test @@ -49,7 +49,7 @@ project ( query T nosort plan select 1 from splitted where stamp IN (TIMESTAMP '2000-01-01 00:00:00', TIMESTAMP '2010-01-01 00:00:00') -union ( +munion ( | project ( | | select ( | | | table("sys"."first_decade") [ "first_decade"."stamp" UNIQUE as "splitted"."stamp" ] @@ -65,25 +65,23 @@ union ( query T nosort plan select 1 from splitted where stamp IN (TIMESTAMP '2000-02-01 00:00:00', TIMESTAMP '2010-02-01 00:00:00', TIMESTAMP '2020-02-01 00:00:00') -union ( -| union ( -| | project ( -| | | select ( -| | | | table("sys"."first_decade") [ "first_decade"."stamp" UNIQUE as "splitted"."stamp" ] -| | | ) [ ("splitted"."stamp" UNIQUE) in (timestamp(7) "2000-02-01 00:00:00.00", timestamp(7) "2010-02-01 00:00:00.00", timestamp(7) "2020-02-01 00:00:00.00") ] -| | ) [ tinyint(1) "1" ], -| | project ( -| | | select ( -| | | | table("sys"."second_decade") [ "second_decade"."stamp" UNIQUE as "splitted"."stamp" ] -| | | ) [ ("splitted"."stamp" UNIQUE) in (timestamp(7) "2000-02-01 00:00:00.00", timestamp(7) "2010-02-01 00:00:00.00", timestamp(7) "2020-02-01 00:00:00.00") ] -| | ) [ tinyint(1) "1" ] -| ) [ "%7"."%7" NOT NULL ], +munion ( +| project ( +| | select ( +| | | table("sys"."first_decade") [ "first_decade"."stamp" UNIQUE as "splitted"."stamp" ] +| | ) [ ("splitted"."stamp" UNIQUE) in (timestamp(7) "2000-02-01 00:00:00.00", timestamp(7) "2010-02-01 00:00:00.00", timestamp(7) "2020-02-01 00:00:00.00") ] +| ) [ tinyint(1) "1" ], +| project ( +| | select ( +| | | table("sys"."second_decade") [ "second_decade"."stamp" UNIQUE as "splitted"."stamp" ] +| | ) [ ("splitted"."stamp" UNIQUE) in (timestamp(7) "2000-02-01 00:00:00.00", timestamp(7) "2010-02-01 00:00:00.00", timestamp(7) "2020-02-01 00:00:00.00") ] +| ) [ tinyint(1) "1" ], | project ( | | select ( | | | table("sys"."third_decade") [ "third_decade"."stamp" UNIQUE as "splitted"."stamp" ] | | ) [ ("splitted"."stamp" UNIQUE) in (timestamp(7) "2000-02-01 00:00:00.00", timestamp(7) "2010-02-01 00:00:00.00", timestamp(7) "2020-02-01 00:00:00.00") ] | ) [ tinyint(1) "1" ] -) [ "%6"."%6" NOT NULL ] +) [ "%10"."%10" NOT NULL ] query T nosort plan select 1 from splitted where stamp BETWEEN TIMESTAMP '2020-01-01 00:00:00' AND TIMESTAMP '2020-10-01 00:00:00' @@ -97,7 +95,7 @@ project ( query T nosort plan select 1 from splitted where stamp NOT BETWEEN TIMESTAMP '2020-01-01 00:00:00' AND TIMESTAMP '2020-10-01 00:00:00' -union ( +munion ( | project ( | | select ( | | | table("sys"."first_decade") [ "first_decade"."stamp" UNIQUE as "splitted"."stamp" ] @@ -113,7 +111,7 @@ union ( query T nosort plan select 1 from splitted where stamp BETWEEN TIMESTAMP '2010-01-01 00:00:00' AND TIMESTAMP '2020-03-01 00:00:00' -union ( +munion ( | project ( | | select ( | | | table("sys"."second_decade") [ "second_decade"."stamp" UNIQUE as "splitted"."stamp" ] @@ -129,25 +127,23 @@ union ( query T nosort plan select 1 from splitted where stamp BETWEEN TIMESTAMP '2000-02-01 00:00:00' AND TIMESTAMP '2020-03-01 00:00:00' -union ( -| union ( -| | project ( -| | | select ( -| | | | table("sys"."first_decade") [ "first_decade"."stamp" UNIQUE as "splitted"."stamp" ] -| | | ) [ (timestamp(7) "2000-02-01 00:00:00.00") <= ("splitted"."stamp" UNIQUE) <= (timestamp(7) "2020-03-01 00:00:00.00") ] -| | ) [ tinyint(1) "1" ], -| | project ( -| | | select ( -| | | | table("sys"."second_decade") [ "second_decade"."stamp" UNIQUE as "splitted"."stamp" ] -| | | ) [ (timestamp(7) "2000-02-01 00:00:00.00") <= ("splitted"."stamp" UNIQUE) <= (timestamp(7) "2020-03-01 00:00:00.00") ] -| | ) [ tinyint(1) "1" ] -| ) [ "%6"."%6" NOT NULL ], +munion ( +| project ( +| | select ( +| | | table("sys"."first_decade") [ "first_decade"."stamp" UNIQUE as "splitted"."stamp" ] +| | ) [ (timestamp(7) "2000-02-01 00:00:00.00") <= ("splitted"."stamp" UNIQUE) <= (timestamp(7) "2020-03-01 00:00:00.00") ] +| ) [ tinyint(1) "1" ], +| project ( +| | select ( +| | | table("sys"."second_decade") [ "second_decade"."stamp" UNIQUE as "splitted"."stamp" ] +| | ) [ (timestamp(7) "2000-02-01 00:00:00.00") <= ("splitted"."stamp" UNIQUE) <= (timestamp(7) "2020-03-01 00:00:00.00") ] +| ) [ tinyint(1) "1" ], | project ( | | select ( | | | table("sys"."third_decade") [ "third_decade"."stamp" UNIQUE as "splitted"."stamp" ] | | ) [ (timestamp(7) "2000-02-01 00:00:00.00") <=
MonetDB: balanced_union - Fixes expected plan with munion instea...
Changeset: 6600ed068099 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/6600ed068099 Modified Files: sql/test/mergetables/Tests/part-elim.test Branch: balanced_union Log Message: Fixes expected plan with munion instead of union diffs (48 lines): diff --git a/sql/test/mergetables/Tests/part-elim.test b/sql/test/mergetables/Tests/part-elim.test --- a/sql/test/mergetables/Tests/part-elim.test +++ b/sql/test/mergetables/Tests/part-elim.test @@ -52,7 +52,7 @@ analyze sys.mt2 (id,posX) query T nosort plan select * from test where id between 1 and 1 -union ( +munion ( | project ( | | table("sys"."mt1") [ "mt1"."id" NOT NULL UNIQUE as "test"."id", "mt1"."posx" NOT NULL UNIQUE as "test"."posx" ] | ) [ "test"."id" NOT NULL UNIQUE, "test"."posx" NOT NULL UNIQUE ], @@ -71,7 +71,7 @@ project ( query T nosort plan select * from test where id between 1 and 1 -union ( +munion ( | project ( | | table("sys"."mt1") [ "mt1"."id" NOT NULL UNIQUE as "test"."id", "mt1"."posx" NOT NULL UNIQUE as "test"."posx" ] | ) [ "test"."id" NOT NULL UNIQUE, "test"."posx" NOT NULL UNIQUE ], @@ -90,7 +90,7 @@ project ( query T nosort plan select * from test where id between 1 and 1000*10 -union ( +munion ( | project ( | | table("sys"."mt1") [ "mt1"."id" NOT NULL UNIQUE as "test"."id", "mt1"."posx" NOT NULL UNIQUE as "test"."posx" ] | ) [ "test"."id" NOT NULL UNIQUE, "test"."posx" NOT NULL UNIQUE ], @@ -102,7 +102,7 @@ union ( query T nosort plan select * from test where id between 1 and 100*10 -union ( +munion ( | project ( | | select ( | | | table("sys"."mt1") [ "mt1"."id" NOT NULL UNIQUE as "test"."id", "mt1"."posx" NOT NULL UNIQUE as "test"."posx" ] @@ -118,7 +118,7 @@ union ( query T nosort plan select * from test where id in (1, 1022) -union ( +munion ( | project ( | | select ( | | | table("sys"."mt1") [ "mt1"."id" NOT NULL UNIQUE as "test"."id", "mt1"."posx" NOT NULL UNIQUE as "test"."posx" ] ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: balanced_union - Fixes expected plan with munion instea...
Changeset: e566e8978d5c for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/e566e8978d5c Modified Files: sql/test/mergetables/Tests/mergequery.test Branch: balanced_union Log Message: Fixes expected plan with munion instead of union diffs (21 lines): diff --git a/sql/test/mergetables/Tests/mergequery.test b/sql/test/mergetables/Tests/mergequery.test --- a/sql/test/mergetables/Tests/mergequery.test +++ b/sql/test/mergetables/Tests/mergequery.test @@ -196,7 +196,7 @@ SELECT * FROM complete where x > 1.0 AND query T nosort PLAN SELECT * FROM complete where x >= 1.0 AND x <= 2.0 -union ( +munion ( | project ( | | select ( | | | table("sys"."part1") [ "part1"."x" NOT NULL as "complete"."x", "part1"."y" NOT NULL as "complete"."y", "part1"."z" NOT NULL as "complete"."z" ] @@ -228,7 +228,7 @@ 0.000 query T nosort PLAN SELECT * FROM complete WHERE x BETWEEN 0 AND 2 AND Y BETWEEN 0 AND 2 -union ( +munion ( | project ( | | table("sys"."part1") [ "part1"."x" NOT NULL as "complete"."x", "part1"."y" NOT NULL as "complete"."y", "part1"."z" NOT NULL as "complete"."z" ] | ) [ "complete"."x" NOT NULL, "complete"."y" NOT NULL, "complete"."z" NOT NULL ], ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: balanced_union - Renames function for mt unionization
Changeset: 0121faa509fb for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/0121faa509fb Modified Files: sql/server/rel_optimizer.c Branch: balanced_union Log Message: Renames function for mt unionization diffs (51 lines): 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 @@ -56,7 +56,7 @@ typedef struct { } merge_table_prune_info; static sql_rel * -rel_wrap_select_around_table(visitor *v, sql_rel *t, merge_table_prune_info *info) +rel_wrap_select_around_mt_child(visitor *v, sql_rel *t, merge_table_prune_info *info) { // TODO: it has to be a table (merge table component) add checks sql_table *subt = (sql_table *)t->l; @@ -89,9 +89,9 @@ rel_unionize_mt_tables_balanced(visitor /* merge (via union) every *two* consequtive nodes of the list */ for (node *n = tables->h; n && n->next; n = n->next->next) { /* first (left) node */ - sql_rel *tl = rel_wrap_select_around_table(v, n->data, info); + sql_rel *tl = rel_wrap_select_around_mt_child(v, n->data, info); /* second (right) node */ - sql_rel *tr = rel_wrap_select_around_table(v, n->next->data, info); + sql_rel *tr = rel_wrap_select_around_mt_child(v, n->next->data, info); /* create the union */ sql_rel *tu = rel_setop(v->sql->sa, tl, tr, op_union); rel_setop_set_exps(v->sql, tu, rel_projections(v->sql, mt, NULL, 1, 1), true); @@ -112,7 +112,7 @@ rel_unionize_mt_tables_munion(visitor *v /* create the list of all the operand rels */ list *rels = sa_list(v->sql->sa); for (node *n = tables->h; n; n = n->next) { - sql_rel *r = rel_wrap_select_around_table(v, n->data, info); + sql_rel *r = rel_wrap_select_around_mt_child(v, n->data, info); append(rels, r); } @@ -422,7 +422,7 @@ merge_table_prune_and_unionize(visitor * if (mvc_debug_on(v->sql, 16)) { /* In case of a single table there in nothing to unionize */ if (tables->cnt == 1) { - nrel = rel_wrap_select_around_table(v, tables->h->data, info); + nrel = rel_wrap_select_around_mt_child(v, tables->h->data, info); } else { //nrel = rel_unionize_mt_tables_balanced(v, mt_rel, tables, info); nrel = rel_setop_n_ary(v->sql->sa, tables, op_munion); @@ -451,7 +451,7 @@ merge_table_prune_and_unionize(visitor * } } else { if (tables->cnt == 1) { - nrel = rel_wrap_select_around_table(v, tables->h->data, info); + nrel = rel_wrap_select_around_mt_child(v, tables->h->data, info); } else { nrel = rel_unionize_mt_tables_munion(v, mt_rel, tables, info); } ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: balanced_union - Mergetables unionized with munion by d...
Changeset: 2afc5cbdfcc1 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/2afc5cbdfcc1 Modified Files: sql/server/rel_optimizer.c Branch: balanced_union Log Message: Mergetables unionized with munion by default diffs (29 lines): 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 @@ -428,12 +428,6 @@ merge_table_prune_and_unionize(visitor * nrel = rel_setop_n_ary(v->sql->sa, tables, op_munion); } } else if (mvc_debug_on(v->sql, 32)) { - if (tables->cnt == 1) { - nrel = rel_wrap_select_around_table(v, tables->h->data, info); - } else { - nrel = rel_unionize_mt_tables_munion(v, mt_rel, tables, info); - } - } else { for (node *n = tables->h; n ; n = n->next) { sql_rel *next = n->data; sql_table *subt = (sql_table *) next->l; @@ -455,6 +449,12 @@ merge_table_prune_and_unionize(visitor * nrel = next; } } + } else { + if (tables->cnt == 1) { + nrel = rel_wrap_select_around_table(v, tables->h->data, info); + } else { + nrel = rel_unionize_mt_tables_munion(v, mt_rel, tables, info); + } } } return nrel; ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: balanced_union - Merges default
Changeset: e7f9880d0b63 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/e7f9880d0b63 Branch: balanced_union Log Message: Merges default diffs (truncated from 8650 to 300 lines): diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out --- a/clients/Tests/exports.stable.out +++ b/clients/Tests/exports.stable.out @@ -800,9 +800,9 @@ str QLOGcatalog(BAT **r); str QLOGdisable(void *ret); str QLOGempty(void *ret); str QLOGenable(void *ret); -str QLOGenableThreshold(void *ret, int *threshold); +str QLOGenableThreshold(void *ret, const int *threshold); int QLOGisset(void); -str RMTdisconnect(void *ret, str *conn); +str RMTdisconnect(void *ret, const char *const *conn); BUN SQLload_file(Client cntxt, Tablet *as, bstream *b, stream *out, const char *csep, const char *rsep, char quote, lng skip, lng maxrow, int best, bool from_stdin, const char *tabnam, bool escape); str TABLETcollect(BAT **bats, Tablet *as); str TABLETcreate_bats(Tablet *as, BUN est); diff --git a/monetdb5/modules/atoms/batxml.c b/monetdb5/modules/atoms/batxml.c --- a/monetdb5/modules/atoms/batxml.c +++ b/monetdb5/modules/atoms/batxml.c @@ -760,7 +760,7 @@ BATXMLroot(bat *ret, const bat *bid, con *standalone); snprintf(buf + i, len - i, "?>%s", t + 1); buf++; - XMLisdocument(, );/* check well-formedness */ + XMLisdocument(, &(const char *){buf});/* check well-formedness */ buf--; if (!isdoc) { err = XML_NOT_WELL_FORMED; diff --git a/monetdb5/modules/atoms/blob.c b/monetdb5/modules/atoms/blob.c --- a/monetdb5/modules/atoms/blob.c +++ b/monetdb5/modules/atoms/blob.c @@ -130,7 +130,7 @@ BLOBnitems_bulk(Client cntxt, MalBlkPtr } static str -BLOBtoblob(blob **retval, str *s) +BLOBtoblob(blob **retval, const char *const *s) { size_t len = strLen(*s); blob *b = (blob *) GDKmalloc(blobsize(len)); @@ -144,7 +144,7 @@ BLOBtoblob(blob **retval, str *s) } static str -BLOBblob_blob(blob **d, blob **s) +BLOBblob_blob(blob **d, const blob *const*s) { size_t len = blobsize((*s)->nitems); blob *b; @@ -238,7 +238,7 @@ BLOBblob_blob_bulk(bat *res, const bat * } static str -BLOBblob_fromstr(blob **b, const char **s) +BLOBblob_fromstr(blob **b, const char *const*s) { size_t len = 0; diff --git a/monetdb5/modules/atoms/identifier.c b/monetdb5/modules/atoms/identifier.c --- a/monetdb5/modules/atoms/identifier.c +++ b/monetdb5/modules/atoms/identifier.c @@ -93,7 +93,7 @@ IDtoString(char **retval, size_t *len, c * to parse the string. */ static str -IDentifier(identifier *retval, str *in) +IDentifier(identifier *retval, const char *const *in) { size_t len = 0; diff --git a/monetdb5/modules/atoms/inet.c b/monetdb5/modules/atoms/inet.c --- a/monetdb5/modules/atoms/inet.c +++ b/monetdb5/modules/atoms/inet.c @@ -229,7 +229,7 @@ INETtoString(str *retval, size_t *len, c * to parse the string. */ static str -INETnew(inet *retval, str *in) +INETnew(inet *retval, const char *const *in) { ssize_t pos; size_t len = sizeof(inet); @@ -787,7 +787,7 @@ INET_inet(inet *d, const inet *s) } static str -INET_fromstr(inet *ret, str *s) +INET_fromstr(inet *ret, const char *const *s) { size_t len = sizeof(inet); if (INETfromString(*s, , (void **) , false) < 0) diff --git a/monetdb5/modules/atoms/json.c b/monetdb5/modules/atoms/json.c --- a/monetdb5/modules/atoms/json.c +++ b/monetdb5/modules/atoms/json.c @@ -233,7 +233,7 @@ JSONtoStorageString(JSON *jt, int idx, j return msg; } -static str JSONstr2json(json *ret, const char **j); +static str JSONstr2json(json *ret, const char *const*j); static ssize_t JSONfromString(const char *src, size_t *len, void **J, bool external) @@ -338,7 +338,7 @@ JSONtoString(str *s, size_t *len, const } static BAT * -JSONdumpInternal(JSON *jt, int depth) +JSONdumpInternal(const JSON *jt, int depth) { int i, idx; JSONterm *je; @@ -464,7 +464,7 @@ JSONdump(Client cntxt, MalBlkPtr mb, Mal (void) cntxt; bat *ret = getArgReference_bat(stk, pci, 0); - json *val = (json *) getArgReference(stk, pci, 1); + const json *val = (json *) getArgReference(stk, pci, 1); JSON *jt = JSONparse(*val); CHECK_JSON(jt); @@ -503,7 +503,7 @@ JSON2json(json *ret, const json *j) } static str -JSONstr2json(json *ret, const char **j) +JSONstr2json(json *ret, const char *const*j) { str msg = MAL_SUCCEED; json buf = NULL; @@ -541,7 +541,7 @@ JSONstr2json(json *ret, const char **j) } static str -JSONisvalid(bit *ret, str *j) +JSONisvalid(bit *ret, const char *const *j) { if (strNil(*j)) { *ret = bit_nil; @@ -556,12 +556,12 @@ JSONisvalid(bit *ret, str *j) } static
MonetDB: balanced_union - Fixes expected plan in test Bug-7140
Changeset: 547c5e34780d for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/547c5e34780d Modified Files: sql/test/BugTracker-2021/Tests/plan-not-optimal-view.Bug-7140.test Branch: balanced_union Log Message: Fixes expected plan in test Bug-7140 diffs (33 lines): diff --git a/sql/test/BugTracker-2021/Tests/plan-not-optimal-view.Bug-7140.test b/sql/test/BugTracker-2021/Tests/plan-not-optimal-view.Bug-7140.test --- a/sql/test/BugTracker-2021/Tests/plan-not-optimal-view.Bug-7140.test +++ b/sql/test/BugTracker-2021/Tests/plan-not-optimal-view.Bug-7140.test @@ -121,17 +121,21 @@ project ( | | | munion ( | | | | group by ( | | | | | project ( -| | | | | | select ( -| | | | | | | table("sys"."plantest0") [ "plantest0"."id" ] -| | | | | | ) [ ("plantest0"."id") >= (bigint(28) "15000") ] -| | | | | ) [ "sys"."sql_div"("plantest0"."id" NOT NULL, int(24) "1000") NOT NULL as "t"."id_r" ] +| | | | | | project ( +| | | | | | | select ( +| | | | | | | | table("sys"."plantest0") [ "plantest0"."id" ] +| | | | | | | ) [ ("plantest0"."id") >= (bigint(28) "15000") ] +| | | | | | ) [ "sys"."sql_div"("plantest0"."id" NOT NULL, int(24) "1000") NOT NULL as "id_div" ] +| | | | | ) [ "id_div" NOT NULL as "t"."id_r" ] | | | | ) [ "t"."id_r" NOT NULL ] [ "t"."id_r" NOT NULL, "sys"."count" no nil ("t"."id_r" NOT NULL) NOT NULL as "%5"."%5" ], | | | | group by ( | | | | | project ( -| | | | | | select ( -| | | | | | | table("sys"."plantest1") [ "plantest1"."id" ] -| | | | | | ) [ ("plantest1"."id") >= (bigint(28) "15000") ] -| | | | | ) [ "sys"."sql_div"("plantest1"."id" NOT NULL, int(24) "1000") NOT NULL as "t"."id_r" ] +| | | | | | project ( +| | | | | | | select ( +| | | | | | | | table("sys"."plantest1") [ "plantest1"."id" ] +| | | | | | | ) [ ("plantest1"."id") >= (bigint(28) "15000") ] +| | | | | | ) [ "sys"."sql_div"("plantest1"."id" NOT NULL, int(24) "1000") NOT NULL as "id_div" ] +| | | | | ) [ "id_div" NOT NULL as "t"."id_r" ] | | | | ) [ "t"."id_r" NOT NULL ] [ "t"."id_r" NOT NULL, "sys"."count" no nil ("t"."id_r" NOT NULL) NOT NULL as "%5"."%5" ] | | | ) [ "t"."id_r" NOT NULL, "%5"."%5" NOT NULL ] | | ) [ "t"."id_r" NOT NULL ] [ "t"."id_r" NOT NULL, "sys"."sum" no nil ("%5"."%5" NOT NULL) NOT NULL as "%5"."%5" ] ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: balanced_union - Fixes plan in test Bug-3955
Changeset: 276cd2e84b60 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/276cd2e84b60 Modified Files: sql/test/BugTracker-2016/Tests/merge_project.Bug-3955.test Branch: balanced_union Log Message: Fixes plan in test Bug-3955 diffs (57 lines): diff --git a/sql/test/BugTracker-2016/Tests/merge_project.Bug-3955.test b/sql/test/BugTracker-2016/Tests/merge_project.Bug-3955.test --- a/sql/test/BugTracker-2016/Tests/merge_project.Bug-3955.test +++ b/sql/test/BugTracker-2016/Tests/merge_project.Bug-3955.test @@ -41,8 +41,8 @@ FROM ( ) AS tmp query IR rowsort -select * from r - +select * from r + 0 2.283 1 @@ -55,23 +55,25 @@ PLAN select * from r project ( | project ( -| | crossproduct ( -| | | table("sys"."v") [ "v"."a1" UNIQUE, "v"."a2" ], -| | | project ( -| | | | crossproduct ( -| | | | | project ( -| | | | | | select ( -| | | | | | | table("sys"."input_double") [ "input_double"."a1" UNIQUE, "input_double"."a2" UNIQUE ] -| | | | | | ) [ ("input_double"."a1" UNIQUE) = (varchar "latitude") ] -| | | | | ) [ "input_double"."a2" UNIQUE as "tmp_2"."a2" ], -| | | | | project ( -| | | | | | select ( -| | | | | | | table("sys"."input_double") [ "input_double"."a1" UNIQUE, "input_double"."a2" UNIQUE ] -| | | | | | ) [ ("input_double"."a1" UNIQUE) = (varchar "longitude") ] -| | | | | ) [ "input_double"."a2" UNIQUE as "tmp_3"."a2" ] -| | | | ) [ ] -| | | ) [ "sys"."st_point"("tmp_2"."a2", "tmp_3"."a2") as "p"."a1" ] -| | ) [ ] +| | project ( +| | | crossproduct ( +| | | | table("sys"."v") [ "v"."a1" UNIQUE, "v"."a2" ], +| | | | project ( +| | | | | crossproduct ( +| | | | | | project ( +| | | | | | | select ( +| | | | | | | | table("sys"."input_double") [ "input_double"."a1" UNIQUE, "input_double"."a2" UNIQUE ] +| | | | | | | ) [ ("input_double"."a1" UNIQUE) = (varchar "latitude") ] +| | | | | | ) [ "input_double"."a2" UNIQUE as "tmp_2"."a2" ], +| | | | | | project ( +| | | | | | | select ( +| | | | | | | | table("sys"."input_double") [ "input_double"."a1" UNIQUE, "input_double"."a2" UNIQUE ] +| | | | | | | ) [ ("input_double"."a1" UNIQUE) = (varchar "longitude") ] +| | | | | | ) [ "input_double"."a2" UNIQUE as "tmp_3"."a2" ] +| | | | | ) [ ] +| | | | ) [ "sys"."st_point"("tmp_2"."a2", "tmp_3"."a2") as "a1" ] +| | | ) [ ] +| | ) [ "v"."a1", "v"."a2", "a1" as "p"."a1" ] | ) [ "v"."a1" as "a1", "sys"."st_distance"("v"."a2", "p"."a1") as "prob" ] ) [ "a1" as "r"."a1", "prob" as "r"."prob" ] ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: balanced_union - Compile without having to comment out ...
Changeset: a8ae01bd155d for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/a8ae01bd155d Modified Files: sql/server/rel_optimize_proj.c Branch: balanced_union Log Message: Compile without having to comment out half the file diffs (12 lines): 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 @@ -1422,6 +1422,8 @@ bind_optimize_unions_bottomup(visitor *v int flag = v->sql->sql_optimizer; return gp->opt_level == 1 && gp->cnt[op_munion] && (flag & optimize_unions_bottomup) ? rel_optimize_munions_bottomup : NULL; + // TODO: remove the next return + return rel_optimize_unions_bottomup; } ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: balanced_union - Fixes plans in Bug-2606 tests
Changeset: 4126ca52dcdd for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/4126ca52dcdd Modified Files: sql/test/BugTracker-2010/Tests/ORDER_BY_over_UNION_EXCEPT_INTERSECT.Bug-2606.test Branch: balanced_union Log Message: Fixes plans in Bug-2606 tests diffs (102 lines): diff --git a/sql/test/BugTracker-2010/Tests/ORDER_BY_over_UNION_EXCEPT_INTERSECT.Bug-2606.test b/sql/test/BugTracker-2010/Tests/ORDER_BY_over_UNION_EXCEPT_INTERSECT.Bug-2606.test --- a/sql/test/BugTracker-2010/Tests/ORDER_BY_over_UNION_EXCEPT_INTERSECT.Bug-2606.test +++ b/sql/test/BugTracker-2010/Tests/ORDER_BY_over_UNION_EXCEPT_INTERSECT.Bug-2606.test @@ -77,8 +77,8 @@ project ( | | project ( | | | table("sys"."t2606b") [ "t2606b"."a" NOT NULL UNIQUE ] | | ) [ "t2606b"."a" NOT NULL UNIQUE as "%2"."a" ] -| ) [ "%1"."a" NOT NULL UNIQUE as "%5"."a" ] -) [ "%5"."a" NOT NULL UNIQUE ] [ "%5"."a" ASC NOT NULL UNIQUE ] +| ) [ "%1"."a" NOT NULL UNIQUE as "%4"."a" ] +) [ "%4"."a" NOT NULL UNIQUE ] [ "%4"."a" ASC NOT NULL UNIQUE ] query I rowsort select * from t2606a union select * from t2606b order by a @@ -104,8 +104,8 @@ project ( | | project ( | | | table("sys"."t2606b") [ "t2606b"."a" NOT NULL UNIQUE ] | | ) [ "t2606b"."a" NOT NULL UNIQUE as "%2"."a" ] -| ) [ "%1"."a" NOT NULL UNIQUE as "%5"."a" ] -) [ "%5"."a" NOT NULL UNIQUE ] [ "%5"."a" ASC NOT NULL UNIQUE ] +| ) [ "%1"."a" NOT NULL UNIQUE as "%4"."a" ] +) [ "%4"."a" NOT NULL UNIQUE ] [ "%4"."a" ASC NOT NULL UNIQUE ] query I rowsort ( select * from t2606a union select * from t2606b ) order by a @@ -131,8 +131,8 @@ project ( | | project ( | | | table("sys"."t2606b") [ "t2606b"."a" NOT NULL UNIQUE ] | | ) [ "t2606b"."a" NOT NULL UNIQUE as "%2"."a" ] -| ) [ "%1"."a" NOT NULL UNIQUE as "%5"."a" ] -) [ "%5"."a" NOT NULL UNIQUE ] [ "%5"."a" ASC NOT NULL UNIQUE ] +| ) [ "%1"."a" NOT NULL UNIQUE as "%4"."a" ] +) [ "%4"."a" NOT NULL UNIQUE ] [ "%4"."a" ASC NOT NULL UNIQUE ] query I rowsort ( select * from t2606a ) union ( select * from t2606b ) order by a @@ -158,8 +158,8 @@ project ( | | project ( | | | table("sys"."t2606b") [ "t2606b"."a" NOT NULL UNIQUE ] | | ) [ "t2606b"."a" NOT NULL UNIQUE as "%2"."a" ] -| ) [ "%1"."a" NOT NULL UNIQUE as "%5"."a" ] -) [ "%5"."a" NOT NULL UNIQUE ] [ "%5"."a" ASC NOT NULL UNIQUE ] +| ) [ "%1"."a" NOT NULL UNIQUE as "%4"."a" ] +) [ "%4"."a" NOT NULL UNIQUE ] [ "%4"."a" ASC NOT NULL UNIQUE ] query I rowsort select * from t2606a except select * from t2606b order by a @@ -179,8 +179,8 @@ project ( | | project ( | | | table("sys"."t2606b") [ "t2606b"."a" NOT NULL UNIQUE ] | | ) [ "t2606b"."a" NOT NULL UNIQUE as "%2"."a" ] -| ) [ "%1"."a" NOT NULL UNIQUE as "%5"."a" ] -) [ "%5"."a" NOT NULL UNIQUE ] [ "%5"."a" ASC NOT NULL UNIQUE ] +| ) [ "%1"."a" NOT NULL UNIQUE as "%4"."a" ] +) [ "%4"."a" NOT NULL UNIQUE ] [ "%4"."a" ASC NOT NULL UNIQUE ] query I rowsort ( select * from t2606a except select * from t2606b ) order by a @@ -200,8 +200,8 @@ project ( | | project ( | | | table("sys"."t2606b") [ "t2606b"."a" NOT NULL UNIQUE ] | | ) [ "t2606b"."a" NOT NULL UNIQUE as "%2"."a" ] -| ) [ "%1"."a" NOT NULL UNIQUE as "%5"."a" ] -) [ "%5"."a" NOT NULL UNIQUE ] [ "%5"."a" ASC NOT NULL UNIQUE ] +| ) [ "%1"."a" NOT NULL UNIQUE as "%4"."a" ] +) [ "%4"."a" NOT NULL UNIQUE ] [ "%4"."a" ASC NOT NULL UNIQUE ] query I rowsort ( select * from t2606a ) except ( select * from t2606b ) order by a @@ -221,8 +221,8 @@ project ( | | project ( | | | table("sys"."t2606b") [ "t2606b"."a" NOT NULL UNIQUE ] | | ) [ "t2606b"."a" NOT NULL UNIQUE as "%2"."a" ] -| ) [ "%1"."a" NOT NULL UNIQUE as "%5"."a" ] -) [ "%5"."a" NOT NULL UNIQUE ] [ "%5"."a" ASC NOT NULL UNIQUE ] +| ) [ "%1"."a" NOT NULL UNIQUE as "%4"."a" ] +) [ "%4"."a" NOT NULL UNIQUE ] [ "%4"."a" ASC NOT NULL UNIQUE ] query I rowsort select * from t2606a intersect select * from t2606b order by a @@ -242,8 +242,8 @@ project ( | | project ( | | | table("sys"."t2606b") [ "t2606b"."a" NOT NULL UNIQUE ] | | ) [ "t2606b"."a" NOT NULL UNIQUE as "%2"."a" ] -| ) [ "%1"."a" NOT NULL UNIQUE as "%5"."a" ] -) [ "%5"."a" NOT NULL UNIQUE ] [ "%5"."a" ASC NOT NULL UNIQUE ] +| ) [ "%1"."a" NOT NULL UNIQUE as "%4"."a" ] +) [ "%4"."a" NOT NULL UNIQUE ] [ "%4"."a" ASC NOT NULL UNIQUE ] query I rowsort ( select * from t2606a intersect select * from t2606b ) order by a @@ -263,8 +263,8 @@ project ( | | project ( | | | table("sys"."t2606b") [ "t2606b"."a" NOT NULL UNIQUE ] | | ) [ "t2606b"."a" NOT NULL UNIQUE as "%2"."a" ] -| ) [ "%1"."a" NOT NULL UNIQUE as "%5"."a" ] -) [ "%5"."a" NOT NULL UNIQUE ] [ "%5"."a" ASC NOT NULL UNIQUE ] +| ) [ "%1"."a" NOT NULL UNIQUE as "%4"."a" ] +) [ "%4"."a" NOT NULL UNIQUE ] [ "%4"."a" ASC NOT NULL UNIQUE ] query I rowsort ( select * from t2606a ) intersect ( select * from t2606b ) order by a ___ checkin-list mailing list --
MonetDB: balanced_union - Enables rel_optimize_unions_topdown by...
Changeset: 743eacfd5581 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/743eacfd5581 Modified Files: sql/server/rel_optimize_proj.c Branch: balanced_union Log Message: Enables rel_optimize_unions_topdown by default diffs (30 lines): 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 @@ -1404,6 +1404,7 @@ rel_optimize_unions_bottomup(visitor *v, static sql_rel * rel_optimize_munions_bottomup_(visitor *v, sql_rel *rel) { + // TODO: implement rel_remove_munion_partitions rel = rel_merge_munion(v, rel); return rel; } @@ -3685,6 +3686,7 @@ static sql_rel * rel_optimize_unions_topdown_(visitor *v, sql_rel *rel) { rel = rel_push_project_down_union(v, rel); + // TODO: implement rel_push_join_down_munion rel = rel_push_join_down_union(v, rel); return rel; } @@ -3700,9 +3702,7 @@ run_optimizer bind_optimize_unions_topdown(visitor *v, global_props *gp) { (void) v; - // TODO: remove this and default to munion - int op = mvc_debug_on(v->sql, 32) ? gp->cnt[op_munion] : gp->cnt[op_union]; - return gp->opt_level == 1 && op ? rel_optimize_unions_topdown : NULL; + return gp->opt_level == 1 && gp->cnt[op_munion] ? rel_optimize_unions_topdown : NULL; } ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: balanced_union - Removes leftover return
Changeset: 5238bc758fd4 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/5238bc758fd4 Modified Files: sql/server/rel_optimize_proj.c Branch: balanced_union Log Message: Removes leftover return diffs (12 lines): 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 @@ -1421,8 +1421,6 @@ bind_optimize_unions_bottomup(visitor *v int flag = v->sql->sql_optimizer; return gp->opt_level == 1 && gp->cnt[op_munion] && (flag & optimize_unions_bottomup) ? rel_optimize_munions_bottomup : NULL; - return gp->opt_level == 1 && gp->cnt[op_union] && (flag & optimize_unions_bottomup) - ? rel_optimize_unions_bottomup : NULL; } ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: balanced_union - Fixes expected plan from rtrim_bug test
Changeset: 2f7383141123 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/2f7383141123 Modified Files: sql/test/bugs/Tests/rtrim_bug.test Branch: balanced_union Log Message: Fixes expected plan from rtrim_bug test diffs (16 lines): diff --git a/sql/test/bugs/Tests/rtrim_bug.test b/sql/test/bugs/Tests/rtrim_bug.test --- a/sql/test/bugs/Tests/rtrim_bug.test +++ b/sql/test/bugs/Tests/rtrim_bug.test @@ -53,8 +53,10 @@ project ( | | | ) [ ("sys"."length"("t1"."m" NOT NULL UNIQUE) NOT NULL) > (int(31) "1") ] | | ) [ "t1"."m" NOT NULL UNIQUE, "sys"."rtrim"("t1"."m" NOT NULL UNIQUE) NOT NULL as "%5"."%5" ], | | project ( -| | | table("sys"."t1") [ "t1"."m" NOT NULL UNIQUE ] -| | ) [ "sys"."rtrim"("t1"."m" NOT NULL UNIQUE) NOT NULL as "%4"."%4" ] +| | | project ( +| | | | table("sys"."t1") [ "t1"."m" NOT NULL UNIQUE ] +| | | ) [ "sys"."rtrim"("t1"."m" NOT NULL UNIQUE) NOT NULL as "%1"."%1" ] +| | ) [ "%1"."%1" NOT NULL as "%4"."%4" ] | ) [ ("%5"."%5" NOT NULL) = ("%4"."%4" NOT NULL) ] ) [ "sys"."length"("t1"."m" NOT NULL UNIQUE) NOT NULL as "data_length", "t1"."m" NOT NULL UNIQUE as "data_value" ] ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: balanced_union - Fixes plan of sqlancer test
Changeset: 683a8b9d086f for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/683a8b9d086f Modified Files: sql/test/SQLancer/Tests/sqlancer17.test Branch: balanced_union Log Message: Fixes plan of sqlancer test diffs (12 lines): diff --git a/sql/test/SQLancer/Tests/sqlancer17.test b/sql/test/SQLancer/Tests/sqlancer17.test --- a/sql/test/SQLancer/Tests/sqlancer17.test +++ b/sql/test/SQLancer/Tests/sqlancer17.test @@ -80,7 +80,7 @@ project ( | | | | ) [ ("%6"."%6" NOT NULL) ! <= (tinyint(3) "1") ! <= ("%6"."%6" NOT NULL), (tinyint(3) "3") <= ("%6"."%6" NOT NULL) <= (tinyint(3) "5") ] | | | ) [ "%6"."%6" NOT NULL as "v0"."vc0" ] | | ) [ "v0"."vc0" NOT NULL ] -| ) [ "sys"."sql_max"(tinyint(1) "1", tinyint(1) "1") NOT NULL as "v20"."vc0" ] +| ) [ "sys"."sql_max"(tinyint(1) "1", tinyint(1) "1") NOT NULL as "%17"."%17" ] ) [ tinyint(1) "1" ] statement ok ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: balanced_union - Merges default
Changeset: fe0346d0a13f for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/fe0346d0a13f Modified Files: sql/backends/monet5/rel_bin.c sql/server/rel_exp.c sql/server/rel_optimize_proj.c sql/server/rel_select.c sql/server/rel_unnest.c sql/test/miscellaneous/Tests/simple_plans.test Branch: balanced_union Log Message: Merges default diffs (truncated from 2573 to 300 lines): diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -48,7 +48,12 @@ jobs: ref: ${{ github.ref }} - name: install pymonetdb cryptography -run: pip3 install pymonetdb cryptography +run: pip3 install --user --upgrade pymonetdb cryptography +if: runner.os != 'macOS' + + - name: install pymonetdb cryptography +run: pip3 install --user --break-system-packages --upgrade pymonetdb cryptography +if: runner.os == 'macOS' - name: make MonetDB on linux run: | @@ -83,7 +88,23 @@ jobs: -DBISON_EXECUTABLE=/usr/local/opt/bison/bin/bison \ -DCMAKE_SUMMARY=ON make install -j3 -if: runner.os == 'macOS' +if: runner.os == 'macOS' && runner.arch == 'x64' + + - name: make MonetDB on macos +run: | + mkdir build + cd build + cmake .. \ +-DCMAKE_INSTALL_PREFIX=$HOME/MDB \ +-DPY3INTEGRATION=OFF \ +-DRINTEGRATION=OFF \ +-DCMAKE_BUILD_TYPE=Release \ +-DASSERT=OFF \ +-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \ +-DBISON_EXECUTABLE=/opt/homebrew/opt/bison/bin/bison \ +-DCMAKE_SUMMARY=ON + make install -j3 +if: runner.os == 'macOS' && runner.arch == 'arm64' - name: choco packages run: | diff --git a/.hgtags b/.hgtags --- a/.hgtags +++ b/.hgtags @@ -825,3 +825,4 @@ dcc8c702e685a4faf21ccf663028d1bc3d1165d1 dcc8c702e685a4faf21ccf663028d1bc3d1165d1 Dec2023_SP1_release d656785f49ee62c19705722aa6b7c171904c64d5 Dec2023_7 d656785f49ee62c19705722aa6b7c171904c64d5 Dec2023_SP2_release +9a694c41042503a22d6c92aeab5bc4ca1912b62e Dec2023_9 diff --git a/MonetDB.spec b/MonetDB.spec --- a/MonetDB.spec +++ b/MonetDB.spec @@ -91,7 +91,7 @@ Group: Applications/Databases License: MPL-2.0 URL: https://www.monetdb.org/ BugURL: https://github.com/MonetDB/MonetDB/issues -Source: https://www.monetdb.org/downloads/sources/Dec2023-SP2/%{name}-%{version}.tar.bz2 +Source: https://www.monetdb.org/downloads/sources/Dec2023-SP3/%{name}-%{version}.tar.bz2 # The Fedora packaging document says we need systemd-rpm-macros for # the _unitdir and _tmpfilesdir macros to exist; however on RHEL 7 @@ -916,6 +916,25 @@ fi %endif %changelog +* Thu May 02 2024 Sjoerd Mullender - 11.49.9-20240502 +- Rebuilt. +- GH#7422: Aggregate functions with variadic arguments +- GH#7472: MonetDB server crashes in `tail_type` +- GH#7473: MonetDB server crashes in `SQLunionfunc` +- GH#7478: MonetDB server crashes in `exp_equal` +- GH#7496: Query on view fails to produce a resultset. Assertion triggered + in rel2bin_select. +- GH#7499: create schema + set schema inside a transaction that is rolled + back causes the connection to be aborted +- GH#7501: files remain in backup causing problems at restart +- GH#7503: MonetDB server crashes using `WHEN MATCHED THEN UPDATE` +- GH#7504: possible deadlock when a bat is made persistent when it is also + getting unloaded +- GH#7506: MonetDB Dec2023-SP2 crashes at `rel_value_exp2` +- GH#7507: BBPextend: ERROR: trying to extend BAT pool beyond the limit + (16384) +- GH#7508: MonetDB Dec2023-SP2 crashes at `exp_ref` + * Tue Apr 09 2024 Sjoerd Mullender - 11.49.7-20240409 - Rebuilt. - GH#7469: Crash when using `CONTAINS` diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c --- a/clients/mapilib/mapi.c +++ b/clients/mapilib/mapi.c @@ -1777,6 +1777,11 @@ mapi_new(msettings *settings) Mapi mid; static ATOMIC_TYPE index = ATOMIC_VAR_INIT(0); + if (!ATOMIC_TAS(_initialized)) { + if (mnstr_init() < 0) + return NULL; + } + mid = malloc(sizeof(*mid)); if (mid == NULL) return NULL; @@ -1885,11 +1890,6 @@ mapi_mapiuri(const char *url, const char { Mapi mid; - if (!ATOMIC_TAS(_initialized)) { - if (mnstr_init() < 0) - return NULL; - } - mid = mapi_new(NULL); if (mid == NULL) return NULL; @@ -1944,11 +1944,6 @@ mapi_mapi(const char *host, int port, co { Mapi mid; - if (!ATOMIC_TAS(_initialized)) { - if (mnstr_init() < 0) - return NULL; - } - mid = mapi_new(NULL); if (mid == NULL) return NULL; diff --git a/cmake/monetdb-versions.cmake
MonetDB: balanced_union - Removes leftovers after merge with def...
Changeset: a576e0c9bbf5 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/a576e0c9bbf5 Modified Files: sql/server/rel_optimize_proj.c Branch: balanced_union Log Message: Removes leftovers after merge with default diffs (65 lines): 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 @@ -53,14 +53,6 @@ rel_used_projections(mvc *sql, list *exp return nexps; } -static int -data_equal( sql_exp *e1, sql_exp *e2) -{ - if (e1 == e2) - return 0; - return -1; -} - /* move projects down with the goal op removing them completely (ie push renames/reduced lists into basetable) * for some cases we can directly remove iff renames rename into same alias * */ @@ -90,45 +82,7 @@ rel_push_project_down_(visitor *v, sql_r } else if (list_check_prop_all(rel->exps, (prop_check_func)_is_useless_rename)) { if ((is_project(l->op) && list_length(l->exps) == list_length(rel->exps)) || ((v->parent && is_project(v->parent->op)) && -(is_mset(l->op) || is_select(l->op) || is_join(l->op) || is_semi(l->op) || is_topn(l->op) || is_sample(l->op { - rel->l = NULL; - rel_destroy(rel); - v->changes++; - return l; - } - } else if (list_check_prop_all(rel->exps, (prop_check_func)_is_rename)) { - /* TODO for positional (setops), if not top relation, rename in order of the inner */ - /* check for selfrefs, ie if l has self refs we cannot reduce (or rename) the expressions */ - if (is_simple_project(l->op) && !l->r) { - list *nexps = sa_list(v->sql->sa); - - /* first find all required expressions */ - for(node *n = rel->exps->h; n; n = n->next) { - sql_exp *e = n->data, *ne = NULL; - - if (e->l) - ne = exps_bind_column2(l->exps, e->l, e->r, NULL); - if (!ne && !e->l) - ne = exps_bind_column(l->exps, e->r, NULL, NULL, 1); - if (!ne) - return rel; - if (ne && exp_has_selfref(v->sql, ne)) - return rel; - /* make sure we don't have duplicates */ - if (list_find(nexps, ne, (fcmp)_equal)) - return rel; - append(nexps, ne); - } - /* rename using outer expressions */ - for(node *n = rel->exps->h, *m = nexps->h; n && m; n = n->next, m = m->next) { - sql_exp *e = n->data, *ne = m->data; - - exp_setname(v->sql->sa, ne, exp_relname(e), exp_name(e)); - exp_propagate(v->sql->sa, ne, e); - } - /* reset hash after renaming */ - list_hash_clear(nexps); - l->exps = nexps; +(is_mset(l->op) || is_set(l->op) || is_select(l->op) || is_join(l->op) || is_semi(l->op) || is_topn(l->op) || is_sample(l->op { rel->l = NULL; rel_destroy(rel); v->changes++; ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: balanced_union - Removes wrong set_selfref() for projec...
Changeset: f8e03e321dba for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/f8e03e321dba Modified Files: sql/server/rel_optimize_proj.c Branch: balanced_union Log Message: Removes wrong set_selfref() for project exp diffs (11 lines): 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 @@ -827,7 +827,6 @@ add_exp_too_project(mvc *sql, sql_exp *e e = ne; } e = exp_ref(sql, e); - set_selfref(e); return e; } ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org