Changeset: 7172916901d9 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7172916901d9 Added Files: sql/test/BugTracker-2018/Tests/procedure-create-table.Bug-6604.sql sql/test/BugTracker-2018/Tests/sqlitelogictest-cast-null-not-in.Bug-6605.sql Modified Files: gdk/gdk_select.c sql/ChangeLog.Mar2018 sql/backends/monet5/rel_bin.c sql/backends/monet5/sql_upgrades.c sql/scripts/21_dependency_views.sql sql/server/rel_optimizer.c sql/server/rel_psm.c sql/server/rel_schema.c sql/server/rel_select.c sql/server/sql_parser.h sql/server/sql_parser.y sql/test/BugTracker-2014/Tests/temporary.Bug-3430.stable.err sql/test/BugTracker-2018/Tests/All sql/test/BugTracker-2018/Tests/sqlitelogictest-complex-case-not-in.Bug-6594.sql sql/test/BugTracker-2018/Tests/sqlitelogictest-complex-case-not-in.Bug-6594.stable.out sql/test/Dependencies/Tests/Dependencies.stable.out sql/test/Dependencies/Tests/Dependencies.stable.out.int128 sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128 sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.32bit sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128 sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.powerpc64.int128 sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128 sql/test/emptydb-upgrade/Tests/upgrade.stable.out sql/test/emptydb-upgrade/Tests/upgrade.stable.out.32bit sql/test/emptydb-upgrade/Tests/upgrade.stable.out.int128 sql/test/emptydb/Tests/check.stable.out sql/test/emptydb/Tests/check.stable.out.32bit sql/test/emptydb/Tests/check.stable.out.int128 sql/test/testdb-upgrade-chain-hge/Tests/upgrade.stable.out.int128 sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.32bit sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128 sql/test/testdb-upgrade-hge/Tests/upgrade.stable.out.int128 sql/test/testdb-upgrade/Tests/upgrade.stable.out sql/test/testdb-upgrade/Tests/upgrade.stable.out.32bit sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128 Branch: default Log Message:
Merge with Mar2018 branch. diffs (truncated from 1685 to 300 lines): diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c --- a/gdk/gdk_select.c +++ b/gdk/gdk_select.c @@ -439,8 +439,8 @@ BAT_hashselect(BAT *b, BAT *s, BAT *bn, /* argument list for type-specific core scan select function call */ #define scanargs \ - b, s, bn, tl, th, li, hi, equi, anti, lval, hval, p, q, cnt, off, \ - dst, candlist, maximum, use_imprints + b, s, bn, tl, th, li, hi, equi, anti, lval, hval, lnil, p, q, \ + cnt, off, dst, candlist, maximum, use_imprints #define PREVVALUEbte(x) ((x) - 1) #define PREVVALUEsht(x) ((x) - 1) @@ -499,8 +499,8 @@ BAT_hashselect(BAT *b, BAT *s, BAT *bn, #define scanfunc(NAME, TYPE, CAND, END) \ static BUN \ NAME##_##TYPE(BAT *b, BAT *s, BAT *bn, const TYPE *tl, const TYPE *th, \ - bool li, bool hi, bool equi, bool anti, bool lval, bool hval, \ - BUN r, BUN q, BUN cnt, lng off, oid *restrict dst, \ + bool li, bool hi, bool equi, bool anti, bool lval, bool hval, \ + bool lnil, BUN r, BUN q, BUN cnt, lng off, oid *restrict dst, \ const oid *candlist, BUN maximum, bool use_imprints) \ { \ TYPE vl = *tl; \ @@ -540,12 +540,15 @@ NAME##_##TYPE(BAT *b, BAT *s, BAT *bn, c END; \ if (equi) { \ assert(!use_imprints); \ - scanloop(NAME, CAND, v == vl); \ + if (lnil) \ + scanloop(NAME, CAND, is_##TYPE##_nil(v)); \ + else \ + scanloop(NAME, CAND, v == vl); \ } else if (anti) { \ if (b->tnonil) { \ choose(NAME, CAND, (v <= vl || v >= vh), TYPE); \ } else { \ - choose(NAME, CAND, (v <= vl || v >= vh) && v != nil, TYPE); \ + choose(NAME, CAND, !is_##TYPE##_nil(v) && (v <= vl || v >= vh), TYPE); \ } \ } else if (b->tnonil && vl == minval) { \ choose(NAME, CAND, v <= vh, TYPE); \ @@ -560,7 +563,7 @@ NAME##_##TYPE(BAT *b, BAT *s, BAT *bn, c static BUN candscan_any (BAT *b, BAT *s, BAT *bn, const void *tl, const void *th, bool li, bool hi, bool equi, bool anti, bool lval, bool hval, - BUN r, BUN q, BUN cnt, lng off, oid *restrict dst, + bool lnil, BUN r, BUN q, BUN cnt, lng off, oid *restrict dst, const oid *candlist, BUN maximum, bool use_imprints) { const void *v; @@ -573,6 +576,7 @@ candscan_any (BAT *b, BAT *s, BAT *bn, c (void) maximum; (void) use_imprints; + (void) lnil; if (equi) { ALGODEBUG fprintf(stderr, @@ -647,7 +651,7 @@ candscan_any (BAT *b, BAT *s, BAT *bn, c static BUN fullscan_any(BAT *b, BAT *s, BAT *bn, const void *tl, const void *th, bool li, bool hi, bool equi, bool anti, bool lval, bool hval, - BUN r, BUN q, BUN cnt, lng off, oid *restrict dst, + bool lnil, BUN r, BUN q, BUN cnt, lng off, oid *restrict dst, const oid *candlist, BUN maximum, bool use_imprints) { const void *v; @@ -661,6 +665,7 @@ fullscan_any(BAT *b, BAT *s, BAT *bn, co (void) candlist; (void) maximum; (void) use_imprints; + (void) lnil; if (equi) { ALGODEBUG fprintf(stderr, @@ -735,7 +740,7 @@ fullscan_any(BAT *b, BAT *s, BAT *bn, co static BUN fullscan_str(BAT *b, BAT *s, BAT *bn, const void *tl, const void *th, bool li, bool hi, bool equi, bool anti, bool lval, bool hval, - BUN r, BUN q, BUN cnt, lng off, oid *restrict dst, + bool lnil, BUN r, BUN q, BUN cnt, lng off, oid *restrict dst, const oid *candlist, BUN maximum, bool use_imprints) { var_t pos; @@ -744,7 +749,7 @@ fullscan_str(BAT *b, BAT *s, BAT *bn, co if (!equi || !GDK_ELIMDOUBLES(b->tvheap)) return fullscan_any(b, s, bn, tl, th, li, hi, equi, anti, - lval, hval, r, q, cnt, off, dst, + lval, hval, lnil, r, q, cnt, off, dst, candlist, maximum, use_imprints); ALGODEBUG fprintf(stderr, "#BATselect(b=%s#"BUNFMT",s=%s%s,anti=%d): " @@ -849,7 +854,7 @@ scan_sel(fullscan, o = (oid) (p+off), w static BAT * BAT_scanselect(BAT *b, BAT *s, BAT *bn, const void *tl, const void *th, bool li, bool hi, bool equi, bool anti, bool lval, bool hval, - BUN maximum, bool use_imprints) + bool lnil, BUN maximum, bool use_imprints) { #ifndef NDEBUG int (*cmp)(const void *, const void *); @@ -1812,7 +1817,7 @@ BATselect(BAT *b, BAT *s, const void *tl use_imprints = true; } bn = BAT_scanselect(b, s, bn, tl, th, li, hi, equi, anti, - lval, hval, maximum, use_imprints); + lval, hval, lnil, maximum, use_imprints); } return virtualize(bn); @@ -2233,6 +2238,7 @@ rangejoin(BAT *r1, BAT *r2, BAT *l, BAT ncnt = candscan_bte(l, sl, r1, &vl, &vh, true, true, false, false, true, true, + false, lstart, lend, cnt, off, dst1, lcand, cnt + maximum, @@ -2241,6 +2247,7 @@ rangejoin(BAT *r1, BAT *r2, BAT *l, BAT ncnt = fullscan_bte(l, sl, r1, &vl, &vh, true, true, false, false, true, true, + false, lstart, lend, cnt, off, dst1, NULL, cnt + maximum, @@ -2269,6 +2276,7 @@ rangejoin(BAT *r1, BAT *r2, BAT *l, BAT ncnt = candscan_sht(l, sl, r1, &vl, &vh, true, true, false, false, true, true, + false, lstart, lend, cnt, off, dst1, lcand, cnt + maximum, @@ -2277,6 +2285,7 @@ rangejoin(BAT *r1, BAT *r2, BAT *l, BAT ncnt = fullscan_sht(l, sl, r1, &vl, &vh, true, true, false, false, true, true, + false, lstart, lend, cnt, off, dst1, NULL, cnt + maximum, @@ -2318,6 +2327,7 @@ rangejoin(BAT *r1, BAT *r2, BAT *l, BAT ncnt = candscan_int(l, sl, r1, &vl, &vh, true, true, false, false, true, true, + false, lstart, lend, cnt, off, dst1, lcand, cnt + maximum, @@ -2326,6 +2336,7 @@ rangejoin(BAT *r1, BAT *r2, BAT *l, BAT ncnt = fullscan_int(l, sl, r1, &vl, &vh, true, true, false, false, true, true, + false, lstart, lend, cnt, off, dst1, NULL, cnt + maximum, @@ -2367,6 +2378,7 @@ rangejoin(BAT *r1, BAT *r2, BAT *l, BAT ncnt = candscan_lng(l, sl, r1, &vl, &vh, true, true, false, false, true, true, + false, lstart, lend, cnt, off, dst1, lcand, cnt + maximum, @@ -2375,6 +2387,7 @@ rangejoin(BAT *r1, BAT *r2, BAT *l, BAT ncnt = fullscan_lng(l, sl, r1, &vl, &vh, true, true, false, false, true, true, + false, lstart, lend, cnt, off, dst1, NULL, cnt + maximum, @@ -2404,6 +2417,7 @@ rangejoin(BAT *r1, BAT *r2, BAT *l, BAT ncnt = candscan_hge(l, sl, r1, &vl, &vh, true, true, false, false, true, true, + false, lstart, lend, cnt, off, dst1, lcand, cnt + maximum, @@ -2412,6 +2426,7 @@ rangejoin(BAT *r1, BAT *r2, BAT *l, BAT ncnt = fullscan_hge(l, sl, r1, &vl, &vh, true, true, false, false, true, true, + false, lstart, lend, cnt, off, dst1, NULL, cnt + maximum, @@ -2443,6 +2458,7 @@ rangejoin(BAT *r1, BAT *r2, BAT *l, BAT ncnt = candscan_flt(l, sl, r1, &vl, &vh, true, true, false, false, true, true, + false, lstart, lend, cnt, off, dst1, lcand, cnt + maximum, @@ -2451,6 +2467,7 @@ rangejoin(BAT *r1, BAT *r2, BAT *l, BAT ncnt = fullscan_flt(l, sl, r1, &vl, &vh, true, true, false, false, true, true, + false, lstart, lend, cnt, off, dst1, NULL, cnt + maximum, @@ -2481,6 +2498,7 @@ rangejoin(BAT *r1, BAT *r2, BAT *l, BAT ncnt = candscan_dbl(l, sl, r1, &vl, &vh, true, true, false, false, true, true, + false, lstart, lend, cnt, off, dst1, lcand, cnt + maximum, @@ -2489,6 +2507,7 @@ rangejoin(BAT *r1, BAT *r2, BAT *l, BAT ncnt = fullscan_dbl(l, sl, r1, &vl, &vh, true, true, false, false, true, true, + false, lstart, lend, cnt, off, dst1, NULL, cnt + maximum, diff --git a/sql/ChangeLog.Mar2018 b/sql/ChangeLog.Mar2018 --- a/sql/ChangeLog.Mar2018 +++ b/sql/ChangeLog.Mar2018 @@ -1,3 +1,6 @@ # ChangeLog file for sql # This file is updated with Maddlog +* Thu May 17 2018 Martin van Dinther <martin.van.dint...@monetdbsolutions.com> +- Corrected the definition of view: sys.ids. + 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 @@ -28,6 +28,15 @@ static stmt * subrel_bin(backend *be, sq static stmt *check_types(backend *be, sql_subtype *ct, stmt *s, check_type tpe); static stmt * +stmt_selectnil( backend *be, stmt *col) +{ + sql_subtype *t = tail_type(col); + stmt *n = stmt_atom(be, atom_general(be->mvc->sa, t, NULL)); + stmt *nn = stmt_uselect2(be, col, n, n, 3, NULL, 0); + return nn; +} + +static stmt * sql_unop_(backend *be, sql_schema *s, const char *fname, stmt *rs) { mvc *sql = be->mvc; @@ -1975,6 +1984,59 @@ rel2bin_semijoin(backend *be, sql_rel *r * first cheap join(s) (equality or idx) * second selects/filters */ + if (rel->exps && rel->op == op_anti && need_no_nil(rel)) { + sql_subtype *lng = sql_bind_localtype("lng"); + stmt *nilcnt = NULL; + + for( en = rel->exps->h; en; en = en->next ) { + sql_exp *e = en->data, *r, *l; + stmt *s; + + if (e->type != e_cmp || e->flag != cmp_equal) + break; + l = e->l; + r = e->r; + + /* for each equality join add a rel_select(r is NULL) */ + s = exp_bin(be, r, right, NULL, NULL, NULL, NULL, NULL); + if (!s) + s = exp_bin(be, l, right, NULL, NULL, NULL, NULL, NULL); + if (s && !exp_is_atom(r)) { + sql_subaggr *cnt = sql_bind_aggr(sql->sa, sql->session->schema, "count", NULL); + sql_subfunc *add = sql_bind_func_result(sql->sa, sql->session->schema, "sql_add", lng, lng, lng); + + s = stmt_selectnil(be, s); + s = stmt_aggr(be, s, NULL, NULL, cnt, 1, 0, 1); + if (nilcnt) { + nilcnt = stmt_binop(be, nilcnt, s, add); + } else { + nilcnt = s; + } + } + } + if (nilcnt) { + sql_subtype *bt = sql_bind_localtype("bit"); + sql_subfunc *ne = sql_bind_func_result(sql->sa, sql->session->schema, "<>", lng, lng, bt); + stmt *ls = bin_first_column(be, left), *s, *sel; + list *l; + + s = stmt_binop(be, nilcnt, stmt_atom_lng(be, 0), ne); + /* keep if no nulls are in the right side */ + ls = stmt_const(be, ls, stmt_bool(be,0)); + sel = stmt_uselect(be, ls, s, cmp_equal, NULL, 0); + l = sa_list(sql->sa); + for( n = left->op4.lval->h; n; n = n->next ) { _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list