MonetDB: Jun2020 - merged
Changeset: ac629c2a15e7 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ac629c2a15e7 Branch: Jun2020 Log Message: merged diffs (12 lines): diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c --- a/gdk/gdk_join.c +++ b/gdk/gdk_join.c @@ -2553,7 +2553,7 @@ hashjoin(BAT **r1p, BAT **r2p, BAT *l, B r->thash ? " ignoring existing hash" : "", swapped ? " (swapped)" : ""); if (snprintf(ext, sizeof(ext), "thshjn%x", -(unsigned) rci->s->batCacheid) >= (int) sizeof(ext)) +(unsigned) THRgettid()) >= (int) sizeof(ext)) goto bailout; if ((hsh = BAThash_impl(r, rci, ext)) == NULL) { goto bailout; ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: Jun2020 - merged
Changeset: 3165455501ef for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3165455501ef Branch: Jun2020 Log Message: merged diffs (truncated from 666 to 300 lines): diff --git a/sql/server/rel_propagate.c b/sql/server/rel_propagate.c --- a/sql/server/rel_propagate.c +++ b/sql/server/rel_propagate.c @@ -166,7 +166,7 @@ generate_partition_limits(sql_query *que } static sql_rel* -create_range_partition_anti_rel(sql_query* query, sql_table *mt, sql_table *pt, bit with_nills, sql_exp *pmin, sql_exp *pmax, bool all_ranges) +create_range_partition_anti_rel(sql_query* query, sql_table *mt, sql_table *pt, bit with_nills, sql_exp *pmin, sql_exp *pmax, bool all_ranges, bool max_equal_min) { mvc *sql = query->sql; sql_rel *anti_rel; @@ -190,14 +190,18 @@ create_range_partition_anti_rel(sql_quer if (!(e1 = exp_check_type(sql, , NULL, e1, type_equal))) return NULL; - e2 = exp_copy(sql, pmax); - if (!(e2 = exp_check_type(sql, , NULL, e2, type_equal))) - return NULL; + if (max_equal_min) { + anti_exp = exp_compare(sql->sa, exp_copy(sql, anti_le), e1, cmp_notequal); + } else { + e2 = exp_copy(sql, pmax); + if (!(e2 = exp_check_type(sql, , NULL, e2, type_equal))) + return NULL; - range1 = exp_compare(sql->sa, exp_copy(sql, anti_le), e1, 3); - range2 = exp_compare(sql->sa, exp_copy(sql, anti_le), e2, 1); - anti_exp = exp_or(sql->sa, list_append(new_exp_list(sql->sa), range1), - list_append(new_exp_list(sql->sa), range2), 0); + range1 = exp_compare(sql->sa, exp_copy(sql, anti_le), e1, cmp_lt); + range2 = exp_compare(sql->sa, exp_copy(sql, anti_le), e2, cmp_gte); + anti_exp = exp_or(sql->sa, list_append(new_exp_list(sql->sa), range1), + list_append(new_exp_list(sql->sa), range2), 0); + } } if (!with_nills) { anti_nils = exp_compare(sql->sa, anti_nils, exp_atom_bool(sql->sa, 1), cmp_equal); @@ -284,17 +288,19 @@ propagate_validation_to_upper_tables(sql int (*atomcmp)(const void *, const void *) = ATOMcompare(tpe); const void *nil = ATOMnilptr(tpe); sql_exp *e1 = NULL, *e2 = NULL; - bool found_all = false; + bool found_all = false, max_equal_min = false; if (atomcmp(spt->part.range.minvalue, nil) != 0 && atomcmp(spt->part.range.maxvalue, nil) != 0) { + max_equal_min = ATOMcmp(spt->tpe.type->localtype, spt->part.range.maxvalue, spt->part.range.minvalue) == 0; e1 = create_table_part_atom_exp(sql, spt->tpe, spt->part.range.minvalue); - e2 = create_table_part_atom_exp(sql, spt->tpe, spt->part.range.maxvalue); + if (!max_equal_min) + e2 = create_table_part_atom_exp(sql, spt->tpe, spt->part.range.maxvalue); } else { assert(spt->with_nills); found_all = is_bit_nil(spt->with_nills); } if (!found_all || !spt->with_nills) - rel = rel_list(sql->sa, rel, create_range_partition_anti_rel(query, it->t, pt, spt->with_nills, e1, e2, false)); + rel = rel_list(sql->sa, rel, create_range_partition_anti_rel(query, it->t, pt, spt->with_nills, e1, e2, false, max_equal_min)); } else if (isListPartitionTable(it->t)) { list *exps = new_exp_list(sql->sa); for (node *n = spt->part.values->h ; n ; n = n->next) { @@ -364,7 +370,12 @@ rel_alter_table_add_partition_range(sql_ rel_psm->nrcols = 0; if (!is_bit_nil(with_nills)) { - res = create_range_partition_anti_rel(query, mt, pt, with_nills, (min && max) ? pmin : NULL, (min && max) ? pmax : NULL, all_ranges); + bool min_max_equal = false; + if (pmin && pmax && pmin->type == e_atom && pmax->type == e_atom && pmin->l && pmax->l) { + atom *e1 = pmin->l, *e2 = pmax->l; +
MonetDB: Jun2020 - merged
Changeset: 4c556260b437 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4c556260b437 Branch: Jun2020 Log Message: merged diffs (19 lines): diff --git a/sql/backends/monet5/sql_scenario.c b/sql/backends/monet5/sql_scenario.c --- a/sql/backends/monet5/sql_scenario.c +++ b/sql/backends/monet5/sql_scenario.c @@ -301,6 +301,7 @@ SQLprepareClient(Client c, int login) } if (m->session->tr) reset_functions(m->session->tr); + MT_lock_unset(_contextLock); if (login) { str schema = monet5_user_set_def_schema(m, c->user); if (!schema) { @@ -311,6 +312,7 @@ SQLprepareClient(Client c, int login) } bailout: + MT_lock_set(_contextLock); /*expect SQL text first */ be->language = 'S'; /* Set state, this indicates an initialized client scenario */ ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: Jun2020 - merged
Changeset: 50365fa83f35 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=50365fa83f35 Branch: Jun2020 Log Message: merged diffs (194 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 @@ -666,13 +666,15 @@ exp_bin(backend *be, sql_exp *e, stmt *l char name[16], *nme = NULL; int nrcands = 0, push_cands = 0; - if (f->func->side_effect && left) { - if (!exps || list_empty(exps)) - append(l, - stmt_const(be, - bin_first_column(be, left), - stmt_atom_int(be, 0))); - else if (exps_card(exps) < CARD_MULTI) { + if (f->func->side_effect && left && left->nrcols > 0) { + sql_subfunc *f1 = NULL; + /* we cannot assume all SQL functions with no arguments have a correspondent with one argument, so attempt to find it. 'rand' function is the exception */ + if (list_empty(exps) && (strcmp(f->func->base.name, "rand") == 0 || (f1 = sql_find_func(sql->sa, f->func->s, f->func->base.name, 1, f->func->type, NULL { + if (f1) + f = f1; + list_append(l, stmt_const(be, bin_first_column(be, left), + stmt_atom(be, atom_general(sql->sa, f1 ? &(((sql_arg*)f1->func->ops->h->data)->type) : sql_bind_localtype("int"), NULL; + } else if (exps_card(exps) < CARD_MULTI) { rows = bin_first_column(be, left); } } @@ -791,7 +793,7 @@ exp_bin(backend *be, sql_exp *e, stmt *l if (f->func->rel) s = stmt_func(be, stmt_list(be, l), sa_strdup(sql->sa, f->func->base.name), f->func->rel, (f->func->type == F_UNION)); else - s = stmt_Nop(be, stmt_list(be, l), e->f); + s = stmt_Nop(be, stmt_list(be, l), f); if (!s) return NULL; if (s && sel && push_cands) diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c --- a/sql/backends/monet5/sql.c +++ b/sql/backends/monet5/sql.c @@ -785,14 +785,14 @@ mvc_next_value(Client cntxt, MalBlkPtr m if (!mvc_schema_privs(m, s)) throw(SQL, "sql.next_value", SQLSTATE(42000) "Access denied for %s to schema '%s'", stack_get_string(m, "current_user"), s->base.name); if (!(seq = find_sql_sequence(s, seqname))) - throw(SQL, "sql.next_value", SQLSTATE(HY050) "Failed to fetch sequence %s.%s", sname, seqname); + throw(SQL, "sql.next_value", SQLSTATE(HY050) "Cannot find the sequence %s.%s", sname, seqname); if (seq_next_value(seq, res)) { m->last_id = *res; stack_set_number(m, "last_id", m->last_id); return MAL_SUCCEED; } - throw(SQL, "sql.next_value", SQLSTATE(42000) "Error in fetching next value for sequence %s.%s", sname, seqname); + throw(SQL, "sql.next_value", SQLSTATE(HY050) "Cannot generate next sequence value %s.%s", sname, seqname); } /* str mvc_get_value(lng *res, str *sname, str *seqname); */ @@ -814,11 +814,11 @@ mvc_get_value(Client cntxt, MalBlkPtr mb if (!(s = mvc_bind_schema(m, sname))) throw(SQL, "sql.get_value", SQLSTATE(3F000) "Cannot find the schema %s", sname); if (!(seq = find_sql_sequence(s, seqname))) - throw(SQL, "sql.get_value", SQLSTATE(HY050) "Failed to fetch sequence %s.%s", sname, seqname); + throw(SQL, "sql.get_value", SQLSTATE(HY050) "Cannot find the sequence %s.%s", sname, seqname); if (seq_get_value(seq, res)) return MAL_SUCCEED; - throw(SQL, "sql.get_value", SQLSTATE(42000) "Error in fetching current value for sequence %s.%s", sname, seqname); + throw(SQL, "sql.get_value", SQLSTATE(HY050) "Cannot get sequence value %s.%s", sname, seqname); } static str diff --git a/sql/test/BugTracker-2020/Tests/All b/sql/test/BugTracker-2020/Tests/All --- a/sql/test/BugTracker-2020/Tests/All +++ b/sql/test/BugTracker-2020/Tests/All @@ -16,6 +16,7 @@ copy-decimal-with-space.Bug-6917 isauuid.Bug-6934 tpch-cube.Bug-6938 HAVE_PYMONETDB?remote-table-like.Bug-6841 +mal-multiplex.Bug-6939 KNOWNFAIL?copy-empty-blob.Bug-6948 values-like-join.Bug-6954 round.Bug-6955 diff --git a/sql/test/BugTracker-2020/Tests/mal-multiplex.Bug-6939.sql b/sql/test/BugTracker-2020/Tests/mal-multiplex.Bug-6939.sql new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2020/Tests/mal-multiplex.Bug-6939.sql
MonetDB: Jun2020 - merged
Changeset: f010115b80a1 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f010115b80a1 Branch: Jun2020 Log Message: merged diffs (36 lines): diff --git a/sql/test/SQLancer/Tests/sqlancer03.sql b/sql/test/SQLancer/Tests/sqlancer03.sql --- a/sql/test/SQLancer/Tests/sqlancer03.sql +++ b/sql/test/SQLancer/Tests/sqlancer03.sql @@ -280,6 +280,32 @@ COPY 4 RECORDS INTO "sys"."t1" FROM stdi select all sum(all cast("concat"(cast("month"(t1.c0) as string), r'1313451898') as interval month)) from t1; ROLLBACK; +START TRANSACTION; -- Unknown barrier type error +CREATE TABLE "sys"."t0" ("c0" INTEGER); +COPY 13 RECORDS INTO "sys"."t0" FROM stdin USING DELIMITERS E'\t',E'\n','"'; +-952561247 +668236378 +-2045848771 +-1790523044 +-1543588024 +-1750414901 +1790114978 +-274432932 +874627516 +-452950065 +303960197 +1 +20 + +create view v0(c0, c1, c2, c3) as ( + select distinct cast(case time '03:52:21' when time '05:04:36' then r'0.2' end as date), + coalesce (t0.c0, length(coalesce (r't%QB', replace(r' ,yO_5G刵i稶bDßᶏ''', r'0.8', r'-1e500', interval '1' month, timestamp '1970-01-16 13:47:20' from t0) with check option; +select v0.c0 from v0 join t0 on (0.3) not in +(least(cast(t0.c0 as decimal), +case least(time '19:32:57', time '16:10:04') when coalesce (time '22:25:53', time '00:14:31', time '18:12:09', time '01:59:38') +then sql_min(0.7, 0.03) else 0.3 end), coalesce (case - (t0.c0) when cast(v0.c2 as real) then abs(0.4) else 0.5 end, cast(t0.c0 as decimal))); +ROLLBACK; + START TRANSACTION; -- Bug 6924 CREATE TABLE "sys"."t0" ("a" INTEGER, "b" INTEGER NOT NULL, CONSTRAINT "t0_a_b_unique" UNIQUE ("a","b")); --This copy into must succeed ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: Jun2020 - merged
Changeset: 3cc21b190d96 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3cc21b190d96 Modified Files: gdk/gdk_join.c Branch: Jun2020 Log Message: merged diffs (86 lines): diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c --- a/gdk/gdk_join.c +++ b/gdk/gdk_join.c @@ -3363,38 +3363,52 @@ leftjoin(BAT **r1p, BAT **r2p, BAT *l, B } if (semi) r1->tkey = true; - BAT *ob; - rc = BATsort(, r2p ? : NULL, NULL, -r1, NULL, NULL, false, false, false); - BBPunfix(r1->batCacheid); - if (rc != GDK_SUCCEED) { - if (r2) + if (!VIEWtparent(r1) && + r1->ttype == TYPE_oid && + BBP_refs(r1->batCacheid) == 1 && + (r2 == NULL || +(!VIEWtparent(r2) && + BBP_refs(r2->batCacheid) == 1 && + r2->ttype == TYPE_oid))) { + /* in-place sort if we can */ + if (r2) { + GDKqsort(r1->theap.base, r2->theap.base, +NULL, r1->batCount, r1->twidth, +r2->twidth, TYPE_oid, false, +false); + r2->tsorted = false; + r2->trevsorted = false; + *r2p = r2; + } else { + GDKqsort(r1->theap.base, NULL, NULL, +r1->batCount, r1->twidth, 0, +TYPE_oid, false, false); + } + r1->tsorted = true; + r1->trevsorted = false; + *r1p = r1; + } else { + BAT *ob; + rc = BATsort(, r2p ? : NULL, NULL, +r1, NULL, NULL, false, false, false); + BBPunfix(r1->batCacheid); + if (rc != GDK_SUCCEED) { + if (r2) + BBPunfix(r2->batCacheid); + return rc; + } + *r1p = r1 = tmp; + if (r2p) { + tmp = BATproject(ob, r2); BBPunfix(r2->batCacheid); - return rc; + BBPunfix(ob->batCacheid); + if (tmp == NULL) { + BBPunfix(r1->batCacheid); + return GDK_FAIL; + } + *r2p = tmp; + } } - *r1p = r1 = tmp; - if (r2p) { - tmp = BATproject(ob, r2); - BBPunfix(r2->batCacheid); - BBPunfix(ob->batCacheid); - if (tmp == NULL) { - BBPunfix(r1->batCacheid); - return GDK_FAIL; - } - *r2p = tmp; - } -#if 0 -#ifndef NDEBUG - BAT *x1; - canditer_reset(); - canditer_reset(); - hashjoin(, NULL, l, r, , , nil_matches, false, false, false, false, false, estimate, t0, false, rhash, prhash, func); - assert(x1->batCount == r1->batCount); - for (BUN x = 0; x < x1->batCount; x++) - assert(BUNtoid(r1, x) == BUNtoid(x1, x)); - BBPunfix(x1->batCacheid); -#endif -#endif return GDK_SUCCEED; } } ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: Jun2020 - merged
Changeset: 78101bd2ed10 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=78101bd2ed10 Modified Files: sql/server/rel_optimizer.c sql/server/sql_atom.c Branch: Jun2020 Log Message: merged diffs (169 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 @@ -8705,52 +8705,38 @@ find_col_exp( list *exps, sql_exp *e) } static int -exp_range_overlap( mvc *sql, sql_exp *e, char *min, char *max, atom *emin, atom *emax) +exp_range_overlap(mvc *sql, sql_exp *e, char *min, char *max, atom *emin, atom *emax) { sql_subtype *t = exp_subtype(e); - - if (!min || !max || !emin || !emax) - return 0; - - if (strNil(min)) - return 0; - if (strNil(max)) + int localtype = t->type->localtype; + + if (!min || !max || !emin || !emax || strNil(min) || strNil(max) || emin->isnull || emax->isnull || !ATOMlinear(localtype)) return 0; - if (t->type->localtype == TYPE_dbl) { - atom *cmin = atom_general(sql->sa, t, min); - atom *cmax = atom_general(sql->sa, t, max); - - if (emax->d < cmin->data.val.dval || emin->d > cmax->data.val.dval) - return 0; - } - if (t->type->localtype == TYPE_bte) { - atom *cmin = atom_general(sql->sa, t, min); - atom *cmax = atom_general(sql->sa, t, max); - - if (emax->data.val.btval < cmin->data.val.btval || emin->data.val.btval > cmax->data.val.btval) + switch (ATOMstorage(localtype)) { + case TYPE_bte: + case TYPE_sht: + case TYPE_int: + case TYPE_lng: +#ifdef HAVE_HGE + case TYPE_hge: +#endif + case TYPE_flt: + case TYPE_dbl: + case TYPE_str: { + atom *cmin, *cmax; + +#ifdef HAVE_HGE + if (localtype == TYPE_hge && !have_hge) return 0; - } - if (t->type->localtype == TYPE_sht) { - atom *cmin = atom_general(sql->sa, t, min); - atom *cmax = atom_general(sql->sa, t, max); - - if (emax->data.val.shval < cmin->data.val.shval || emin->data.val.shval > cmax->data.val.shval) +#endif + cmin = atom_general(sql->sa, t, min); + cmax = atom_general(sql->sa, t, max); + if (VALcmp(&(emax->data), &(cmin->data)) < 0 || VALcmp(&(emin->data), &(cmax->data)) > 0) return 0; - } - if (t->type->localtype == TYPE_int || t->type->localtype == TYPE_date) { - atom *cmin = atom_general(sql->sa, t, min); - atom *cmax = atom_general(sql->sa, t, max); - - if (emax->data.val.ival < cmin->data.val.ival || emin->data.val.ival > cmax->data.val.ival) - return 0; - } - if (t->type->localtype == TYPE_lng || t->type->localtype == TYPE_timestamp) { - atom *cmin = atom_general(sql->sa, t, min); - atom *cmax = atom_general(sql->sa, t, max); - - if (emax->data.val.lval < cmin->data.val.lval || emin->data.val.lval > cmax->data.val.lval) - return 0; + } break; + default: + return 0; } return 1; } diff --git a/sql/server/sql_atom.c b/sql/server/sql_atom.c --- a/sql/server/sql_atom.c +++ b/sql/server/sql_atom.c @@ -1335,7 +1335,7 @@ atom_inc(atom *a) int atom_is_zero(atom *a) { - if (a->isnull) + if (a->isnull || !ATOMlinear(a->tpe.type->localtype)) return 0; switch (ATOMstorage(a->tpe.type->localtype)) { case TYPE_bte: @@ -1422,6 +1422,7 @@ atom_zero_value(sql_allocator *sa, sql_s { void *ret = NULL; atom *res = NULL; + int localtype = tpe->type->localtype; bte bval = 0; sht sval = 0; @@ -1433,39 +1434,41 @@ atom_zero_value(sql_allocator *sa, sql_s flt fval = 0; dbl dval = 0; - switch (ATOMstorage(tpe->type->localtype)) { - case TYPE_bte: - ret = - break; - case TYPE_sht: - ret = - break; - case TYPE_int: - ret = - break; - case TYPE_lng: - ret = - break; + if (ATOMlinear(localtype)) { + switch (ATOMstorage(localtype)) { + case TYPE_bte: + ret = + break; + case TYPE_sht: + ret = + break; + case TYPE_int: + ret = + break; + case TYPE_lng: + ret = + break; #ifdef HAVE_HGE - case TYPE_hge: - ret = - break; + case TYPE_hge: +
MonetDB: Jun2020 - merged
Changeset: f71100494412 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f71100494412 Modified Files: monetdb5/modules/kernel/algebra.c sql/backends/monet5/sql_statement.c sql/server/rel_unnest.c sql/test/mapi/Tests/utf8test.SQL.py sql/test/subquery/Tests/subquery4.sql sql/test/subquery/Tests/subquery4.stable.out sql/test/subquery/Tests/subquery6.sql sql/test/subquery/Tests/subquery6.stable.err sql/test/subquery/Tests/subquery6.stable.out testing/process.py Branch: Jun2020 Log Message: merged diffs (truncated from 382 to 300 lines): diff --git a/monetdb5/modules/kernel/algebra.c b/monetdb5/modules/kernel/algebra.c --- a/monetdb5/modules/kernel/algebra.c +++ b/monetdb5/modules/kernel/algebra.c @@ -1138,9 +1138,17 @@ ALGfetch(ptr ret, const bat *bid, const if ((b = BATdescriptor(*bid)) == NULL) { throw(MAL, "algebra.fetch", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING); } - if ((*pos < (lng) 0) || (*pos >= (lng) BUNlast(b))) { + if (*pos < (lng) 0) { + BBPunfix(b->batCacheid); + throw(MAL, "algebra.fetch", ILLEGAL_ARGUMENT ": row index to fetch must be non negative\n"); + } + if (BATcount(b) == 0) { BBPunfix(b->batCacheid); - throw(MAL, "algebra.fetch", ILLEGAL_ARGUMENT " Idx out of range\n"); + throw(MAL, "algebra.fetch", ILLEGAL_ARGUMENT ": cannot fetch a single row from an empty input\n"); + } + if (*pos >= (lng) BUNlast(b)) { + BBPunfix(b->batCacheid); + throw(MAL, "algebra.fetch", ILLEGAL_ARGUMENT ": row index to fetch is out of range\n"); } msg = doALGfetch(ret, b, (BUN) *pos); BBPunfix(b->batCacheid); diff --git a/sql/backends/monet5/sql_statement.c b/sql/backends/monet5/sql_statement.c --- a/sql/backends/monet5/sql_statement.c +++ b/sql/backends/monet5/sql_statement.c @@ -3912,13 +3912,22 @@ const_column(backend *be, stmt *val) stmt * stmt_fetch(backend *be, stmt *val) { - sql_subtype *ct = tail_type(val); + sql_subtype *ct; MalBlkPtr mb = be->mb; InstrPtr q = NULL; - int tt = ct->type->localtype; + int tt; if (val->nr < 0) return NULL; + /* pick from first column on a table case */ + if (val->type == st_table) { + if (list_length(val->op1->op4.lval) > 1) + return NULL; + val = val->op1->op4.lval->h->data; + } + ct = tail_type(val); + tt = ct->type->localtype; + q = newStmt(mb, algebraRef, fetchRef); if (q == NULL) return NULL; 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 @@ -1572,8 +1572,20 @@ static sql_exp * rewrite_exp_rel(mvc *sql, sql_rel *rel, sql_exp *e, int depth, int *changes) { (void)changes; - (void)depth; - if (exp_has_rel(e) && !is_ddl(rel->op)) { + + if (exp_is_rel(e) && is_ddl(rel->op) && rel->flag == ddl_psm) { + sql_rel *inner = exp_rel_get_rel(sql->sa, e); + if (is_single(inner)) { + /* use a dummy projection for the single join */ + sql_rel *nrel = rel_project(sql->sa, NULL, append(sa_list(sql->sa), exp_atom_bool(sql->sa, 1))); + + if (!rewrite_inner(sql, nrel, inner, depth?op_left:op_join)) + return NULL; + /* has to apply recursively */ + if (!(e->l = rel_exp_visitor_bottomup(sql, nrel, _exp_rel, changes))) + return NULL; + } + } else if (exp_has_rel(e) && !is_ddl(rel->op)) { sql_exp *ne = rewrite_inner(sql, rel, exp_rel_get_rel(sql->sa, e), depth?op_left:op_join); if (!ne) @@ -1588,10 +1600,7 @@ rewrite_exp_rel(mvc *sql, sql_rel *rel, } else { e = exp_rel_update_exp(sql, e); } - } - if (exp_is_rel(e) && is_ddl(rel->op)) - if (!(e->l = rel_exp_visitor_bottomup(sql, e->l, _exp_rel, changes))) - return NULL; + } return e; } @@ -2109,7 +2118,7 @@ static sql_exp * rewrite_anyequal(mvc *sql, sql_rel *rel, sql_exp *e, int depth) { sql_subfunc *sf; - if (e->type != e_func || is_ddl(rel->op)) + if (e->type != e_func) return e; sf = e->f; @@ -2241,6 +2250,8 @@ rewrite_anyequal(mvc *sql, sql_rel *rel, if (exp_name(e)) exp_prop_alias(sql->sa, le, e); set_processed(lsq); + if (depth == 1 && is_ddl(rel->op)) /* anyequal is at a ddl statment, it must be inside a
MonetDB: Jun2020 - Merged, sorry again
Changeset: 1e7785a30bd4 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1e7785a30bd4 Modified Files: sql/storage/bat/bat_logger.c Branch: Jun2020 Log Message: Merged, sorry again diffs (44 lines): diff --git a/sql/storage/bat/bat_logger.c b/sql/storage/bat/bat_logger.c --- a/sql/storage/bat/bat_logger.c +++ b/sql/storage/bat/bat_logger.c @@ -142,29 +142,36 @@ tabins(void *lg, bool first, int tt, con while ((cname = va_arg(va, char *)) != NULL) { cval = va_arg(va, void *); len = snprintf(lname, sizeof(lname), "%s_%s_%s", sname, tname, cname); - if (len == -1 || (size_t)len >= sizeof(lname)) + if (len == -1 || (size_t)len >= sizeof(lname) || + (b = temp_descriptor(logger_find_bat(lg, lname, 0, 0))) == NULL) { + va_end(va); return GDK_FAIL; - if ((b = temp_descriptor(logger_find_bat(lg, lname, 0, 0))) == NULL) - return GDK_FAIL; + } if (first) { BAT *bn; if ((bn = COLcopy(b, b->ttype, true, PERSISTENT)) == NULL) { BBPunfix(b->batCacheid); + va_end(va); return GDK_FAIL; } BBPunfix(b->batCacheid); if (BATsetaccess(bn, BAT_READ) != GDK_SUCCEED || logger_add_bat(lg, bn, lname, 0, 0) != GDK_SUCCEED) { BBPunfix(bn->batCacheid); + va_end(va); return GDK_FAIL; } b = bn; } rc = BUNappend(b, cval, true); BBPunfix(b->batCacheid); - if (rc != GDK_SUCCEED) + if (rc != GDK_SUCCEED) { + va_end(va); return rc; + } } + va_end(va); + if (tt >= 0) { if ((b = COLnew(0, tt, 0, PERSISTENT)) == NULL) return GDK_FAIL; ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: Jun2020 - merged
Changeset: 3f9165ba25b4 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3f9165ba25b4 Branch: Jun2020 Log Message: merged ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: Jun2020 - merged
Changeset: a9e26a5531d8 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a9e26a5531d8 Modified Files: sql/server/rel_psm.c sql/server/rel_rel.h sql/server/rel_select.c sql/test/BugTracker-2015/Tests/window_function_crash.Bug-3861.stable.err sql/test/subquery/Tests/subquery4.stable.err sql/test/subquery/Tests/subquery6.sql sql/test/subquery/Tests/subquery6.stable.err Branch: Jun2020 Log Message: merged diffs (truncated from 346 to 300 lines): diff --git a/sql/server/rel_psm.c b/sql/server/rel_psm.c --- a/sql/server/rel_psm.c +++ b/sql/server/rel_psm.c @@ -16,6 +16,15 @@ #include "rel_updates.h" #include "sql_privileges.h" +#define psm_zero_or_one(exp) \ + do { \ + if (exp && exp->card > CARD_AGGR) { \ + sql_subfunc *zero_or_one = sql_bind_func(sql->sa, sql->session->schema, "zero_or_one", exp_subtype(exp), NULL, F_AGGR); \ + assert(zero_or_one); \ + exp = exp_aggr1(sql->sa, exp, zero_or_one, 0, 0, CARD_ATOM, has_nil(exp)); \ + } \ + } while(0) + static list *sequential_block(sql_query *query, sql_subtype *restype, list *restypelist, dlist *blk, char *opt_name, int is_func); sql_rel * @@ -80,14 +89,10 @@ psm_set_exp(sql_query *query, dnode *n) tpe = stack_find_type(sql, name); } - e = rel_value_exp2(query, , val, sql_sel | sql_psm_set, ek); + e = rel_value_exp2(query, , val, sql_sel | sql_psm, ek); if (!e) return NULL; - if (e->card > CARD_AGGR) { - sql_subfunc *zero_or_one = sql_bind_func(sql->sa, sql->session->schema, "zero_or_one", exp_subtype(e), NULL, F_AGGR); - assert(zero_or_one); - e = exp_aggr1(sql->sa, e, zero_or_one, 0, 0, CARD_ATOM, has_nil(e)); - } + psm_zero_or_one(e); level = stack_find_frame(sql, name); e = rel_check_type(sql, tpe, rel, e, type_cast); @@ -238,14 +243,14 @@ rel_psm_while_do( sql_query *query, sql_ sql_rel *rel = NULL; exp_kind ek = {type_value, card_value, FALSE}; - cond = rel_logical_value_exp(query, , n->data.sym, sql_sel, ek); + cond = rel_logical_value_exp(query, , n->data.sym, sql_sel | sql_psm, ek); + psm_zero_or_one(cond); n = n->next; whilestmts = sequential_block(query, res, restypelist, n->data.lval, n->next->data.sval, is_func); if (sql->session->status || !cond || !whilestmts) return NULL; - assert(!rel); return exp_while( sql->sa, cond, whilestmts ); } return NULL; @@ -270,7 +275,8 @@ psm_if_then_else( sql_query *query, sql_ sql_rel *rel = NULL; exp_kind ek = {type_value, card_value, FALSE}; - cond = rel_logical_value_exp(query, , n->data.sym, sql_sel, ek); + cond = rel_logical_value_exp(query, , n->data.sym, sql_sel | sql_psm, ek); + psm_zero_or_one(cond); n = n->next; ifstmts = sequential_block(query, res, restypelist, n->data.lval, NULL, is_func); n = n->next; @@ -279,7 +285,6 @@ psm_if_then_else( sql_query *query, sql_ if (sql->session->status || !cond || !ifstmts) return NULL; - assert(!rel); return append(sa_list(sql->sa), exp_if( sql->sa, cond, ifstmts, elsestmts)); } else { /* else */ symbol *e = elseif->data.sym; @@ -303,7 +308,8 @@ rel_psm_if_then_else( sql_query *query, sql_rel *rel = NULL; exp_kind ek = {type_value, card_value, FALSE}; - cond = rel_logical_value_exp(query, , n->data.sym, sql_sel, ek); + cond = rel_logical_value_exp(query, , n->data.sym, sql_sel | sql_psm, ek); + psm_zero_or_one(cond); n = n->next; ifstmts = sequential_block(query, res, restypelist, n->data.lval, NULL, is_func); n = n->next; @@ -311,7 +317,6 @@ rel_psm_if_then_else( sql_query *query, if (sql->session->status || !cond || !ifstmts) return NULL; - assert(!rel); return exp_if( sql->sa, cond, ifstmts, elsestmts); } return NULL; @@ -349,30 +354,28 @@ rel_psm_case( sql_query *query, sql_subt list *else_stmt = NULL; sql_rel *rel = NULL; exp_kind ek = {type_value, card_value, FALSE}; - sql_exp *v = rel_value_exp(query, , case_value, sql_sel, ek); + sql_exp *v = rel_value_exp(query, , case_value, sql_sel | sql_psm, ek); +
MonetDB: Jun2020 - merged
Changeset: 563cf17218c4 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=563cf17218c4 Modified Files: monetdb5/optimizer/opt_postfix.c Branch: Jun2020 Log Message: merged diffs (50 lines): diff --git a/monetdb5/optimizer/opt_postfix.c b/monetdb5/optimizer/opt_postfix.c --- a/monetdb5/optimizer/opt_postfix.c +++ b/monetdb5/optimizer/opt_postfix.c @@ -32,25 +32,27 @@ OPTpostfixImplementation(Client cntxt, M for( i = 0; i< slimit; i++){ /* POSTFIX ACTION FOR THE JOIN CASE */ p= getInstrPtr(mb, i); - if ( getModuleId(p) == algebraRef && getFunctionId(p) == joinRef && getVarEolife(mb, getArg(p, p->retc -1)) == i){ - delArgument(p, p->retc -1); - typeChecker(cntxt->usermodule, mb, p, i, TRUE); - actions++; - continue; - } - if ( getModuleId(p) == algebraRef && getFunctionId(p) == leftjoinRef && getVarEolife(mb, getArg(p, p->retc -1)) == i){ - delArgument(p, p->retc -1); - typeChecker(cntxt->usermodule, mb, p, i, TRUE); - actions++; - continue; - } - if ( getModuleId(p) == algebraRef && getFunctionId(p) == semijoinRef && getVarEolife(mb, getArg(p, p->retc -1)) == i){ - delArgument(p, p->retc -1); - /* semijoin with a single output is called intersect */ - setFunctionId(p,intersectRef); - typeChecker(cntxt->usermodule, mb, p, i, TRUE); - actions++; - continue; + if ( getModuleId(p) == algebraRef) { + if ( getFunctionId(p) == joinRef || getFunctionId(p) == leftjoinRef) { + if ( getVarEolife(mb, getArg(p, p->retc -1)) == i) { + delArgument(p, p->retc -1); + typeChecker(cntxt->usermodule, mb, p, i, TRUE); + actions++; + continue; + } + } else if ( getFunctionId(p) == semijoinRef) { + int is_first_ret_not_used = getVarEolife(mb, getArg(p, p->retc -2)) == i; + int is_second_ret_not_used = getVarEolife(mb, getArg(p, p->retc -1)) == i; + assert(!is_first_ret_not_used || !is_second_ret_not_used); + if ( is_first_ret_not_used || is_second_ret_not_used) { + delArgument(p, is_second_ret_not_used ? p->retc -1 : p->retc -2); + /* semijoin with a single output is called intersect */ + setFunctionId(p,intersectRef); + typeChecker(cntxt->usermodule, mb, p, i, TRUE); + actions++; + continue; + } + } } /* POSTFIX ACTION FOR THE EXTENT CASE */ if ( getModuleId(p) == groupRef && getFunctionId(p) == groupRef && getVarEolife(mb, getArg(p, p->retc -1)) == i){ ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: Jun2020 - merged
Changeset: 25e6f0ea857a for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=25e6f0ea857a Added Files: .editorconfig Branch: Jun2020 Log Message: merged diffs (26 lines): diff --git a/.editorconfig b/.editorconfig new file mode 100644 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,21 @@ +# Unix-style newlines with a newline ending every file +[*] +end_of_line = lf +insert_final_newline = true + +[*.{c,h}] +indent_style = tab +tab_width = 4 +indent_size = tab +trim_trailing_whitespace = true +charset = utf-8 +max_line_length = 120 + +[*.py] +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true +charset = utf-8 + +[gdk/*.{c,h}] +tab_width = 8 ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: Jun2020 - merged
Changeset: 507802e1784c for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=507802e1784c Modified Files: sql/backends/monet5/rel_bin.c sql/test/SQLancer/Tests/sqlancer01.stable.out Branch: Jun2020 Log Message: merged diffs (truncated from 577 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 @@ -2172,6 +2172,89 @@ releqjoin( backend *be, list *l1, list * return res; } +static void +split_join_exps(sql_rel *rel, list *joinable, list *not_joinable) +{ + if (!list_empty(rel->exps)) { + for (node *n = rel->exps->h; n; n = n->next) { + sql_exp *e = n->data; + int left_reference = 0, right_reference = 0; + + /* we can handle thetajoins, rangejoins and filter joins (like) */ + /* ToDo how about in/notin, mark_in/notin, mark_exists/not_exists and atom expressions? */ + if (e->type == e_cmp) { + int flag = e->flag & ~CMP_BETWEEN; + /* check if its a select or join expression, ie use only expressions of one relation left and of the other right (than join) */ + if (flag < cmp_filter) { /* theta and range joins */ + /* join or select ? */ + sql_exp *l = e->l, *r = e->r, *f = e->f; + + if (l->card != CARD_ATOM) { + left_reference += rel_find_exp(rel->l, l) != NULL; + right_reference += rel_find_exp(rel->r, l) != NULL; + } + if (r->card != CARD_ATOM) { + left_reference += rel_find_exp(rel->l, r) != NULL; + right_reference += rel_find_exp(rel->r, r) != NULL; + } + if (f && f->card != CARD_ATOM) { + left_reference += rel_find_exp(rel->l, f) != NULL; + right_reference += rel_find_exp(rel->r, f) != NULL; + } + } else if (flag == cmp_filter && !e->anti) { + list *l = e->l, *r = e->r; + + for (node *n = l->h ; n ; n = n->next) { + sql_exp *ee = n->data; + + if (ee->card != CARD_ATOM) { + left_reference += rel_find_exp(rel->l, ee) != NULL; + right_reference += rel_find_exp(rel->r, ee) != NULL; + } + } + for (node *n = r->h ; n ; n = n->next) { + sql_exp *ee = n->data; + + if (ee->card != CARD_ATOM) { + left_reference += rel_find_exp(rel->l, ee) != NULL; + right_reference += rel_find_exp(rel->r, ee) != NULL; + } + } + } + } + if (left_reference && right_reference) { + append(joinable, e); + } else { + append(not_joinable, e); + } + } + } +} + +#define is_priority_exp(e) ((e)->type == e_cmp && (e)->flag == cmp_equal) + +static list * +get_equi_joins_first(mvc *sql, list *exps, int *equality_only) +{ + list *new_exps = sa_list(sql->sa); + + for( node *n = exps->h; n; n = n->next ) { + sql_exp *e = n->data; + if (is_priority_exp(e)) { + list_append(new_exps, e); + *equality_only &= (e->flag == cmp_equal); + } + } + for( node *n = exps->h; n; n = n->next ) { + sql_exp *e = n->data; + if (!is_priority_exp(e)) { + list_append(new_exps, e); + *equality_only &= (e->flag == mark_in || e->flag == mark_notin); + } + } + return new_exps; +} + static stmt * rel2bin_join(backend *be, sql_rel *rel, list *refs) { @@ -2198,129 +2281,75 @@ rel2bin_join(backend *be, sql_rel *rel,
MonetDB: Jun2020 - merged
Changeset: 8974c0702956 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8974c0702956 Modified Files: sql/test/SQLancer/Tests/sqlancer01.sql Branch: Jun2020 Log Message: merged diffs (13 lines): diff --git a/sql/test/SQLancer/Tests/sqlancer01.sql b/sql/test/SQLancer/Tests/sqlancer01.sql --- a/sql/test/SQLancer/Tests/sqlancer01.sql +++ b/sql/test/SQLancer/Tests/sqlancer01.sql @@ -92,6 +92,9 @@ union all select t0.c0 from t0 where ((sql_min("locate"(reverse('qﺛ}(C.0D?\r'), cast(t0.c1 as string), cast(-1483214882 as int)), ((cast('1186727519' as int))||(abs(785610124) not in (1.52414541E9, 0.13482326)) is null; select 1 from t0 where (3 in (1, 2)) is null; --simplified -- empty + +SELECT 1 FROM t0 WHERE t0.c0 BETWEEN SYMMETRIC (1 IN (2, 1)) AND t0.c0; + -- empty ROLLBACK; START TRANSACTION; --Bug 6897 ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: Jun2020 - merged
Changeset: d0adc5417493 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d0adc5417493 Modified Files: monetdb5/modules/atoms/mtime.c tools/merovingian/client/Tests/All Branch: Jun2020 Log Message: merged diffs (46 lines): diff --git a/monetdb5/modules/atoms/mtime.c b/monetdb5/modules/atoms/mtime.c --- a/monetdb5/modules/atoms/mtime.c +++ b/monetdb5/modules/atoms/mtime.c @@ -874,10 +874,35 @@ MTIMEstr_to_timestamp(timestamp *ret, co t = time(NULL); localtime_r(, ); tm.tm_sec = tm.tm_min = tm.tm_hour = 0; + tm.tm_isdst = -1; if (strptime(*s, *format, ) == NULL) throw(MAL, "mtime.str_to_timestamp", "format '%s', doesn't match timestamp '%s'", *format, *s); - *ret = timestamp_fromtime(mktime()); + *ret = timestamp_create(date_create(tm.tm_year + 1900, + tm.tm_mon + 1, + tm.tm_mday), + daytime_create(tm.tm_hour, + tm.tm_min, + tm.tm_sec == 60 ? 59 : tm.tm_sec, + 0)); + /* if strptime filled in DST information (tm_isdst >= 0), then the +* time is in system local time and we convert to GMT by +* subtracting the time zone offset, else we don't touch the time +* returned because it is assumed to already be in GMT */ + if (tm.tm_isdst >= 0) { + int isdst = 0; + int tz = local_timezone(); + /* if strptime's information doesn't square with our own +* information about having or not having DST, we compensate +* an hour */ + if (tm.tm_isdst > 0 && isdst == 0) { + tz += 3600; + } else if (tm.tm_isdst == 0 && isdst > 0) { + tz -= 3600; + } + + *ret = timestamp_add_usec(*ret, -tz * LL_CONSTANT(100)); + } if (is_timestamp_nil(*ret)) throw(MAL, "mtime.str_to_timestamp", "bad timestamp '%s'", *s); return MAL_SUCCEED; diff --git a/tools/merovingian/client/Tests/All b/tools/merovingian/client/Tests/All --- a/tools/merovingian/client/Tests/All +++ b/tools/merovingian/client/Tests/All @@ -1,1 +1,1 @@ -monetdb_status +NOT_WIN32?monetdb_status ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: Jun2020 - merged
Changeset: ce3dc71b7633 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ce3dc71b7633 Modified Files: sql/server/rel_exp.c sql/server/rel_exp.h sql/server/rel_optimizer.c Branch: Jun2020 Log Message: merged diffs (160 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 @@ -1525,7 +1525,7 @@ exp_is_eqjoin(sql_exp *e) } static sql_exp * -rel_find_exp_( sql_rel *rel, sql_exp *e) +rel_find_exp_and_corresponding_rel_( sql_rel *rel, sql_exp *e, sql_rel **res) { sql_exp *ne = NULL; @@ -1540,9 +1540,11 @@ rel_find_exp_( sql_rel *rel, sql_exp *e) ne = exps_bind_column(rel->exps, e->r, NULL, 1); } } + if (ne && res) + *res = rel; return ne; case e_convert: - return rel_find_exp_(rel, e->l); + return rel_find_exp_and_corresponding_rel_(rel, e->l, res); case e_aggr: case e_func: if (e->l) { @@ -1551,7 +1553,7 @@ rel_find_exp_( sql_rel *rel, sql_exp *e) ne = n->data; while (ne != NULL && n != NULL) { - ne = rel_find_exp_(rel, n->data); + ne = rel_find_exp_and_corresponding_rel_(rel, n->data, res); n = n->next; } return ne; @@ -1568,7 +1570,7 @@ rel_find_exp_( sql_rel *rel, sql_exp *e) ne = n->data; while (ne != NULL && n != NULL) { - ne = rel_find_exp_(rel, n->data); + ne = rel_find_exp_and_corresponding_rel_(rel, n->data, res); n = n->next; } return ne; @@ -1579,9 +1581,9 @@ rel_find_exp_( sql_rel *rel, sql_exp *e) } sql_exp * -rel_find_exp( sql_rel *rel, sql_exp *e) +rel_find_exp_and_corresponding_rel(sql_rel *rel, sql_exp *e, sql_rel **res) { - sql_exp *ne = rel_find_exp_(rel, e); + sql_exp *ne = rel_find_exp_and_corresponding_rel_(rel, e, res); if (rel && !ne) { switch(rel->op) { @@ -1589,38 +1591,53 @@ rel_find_exp( sql_rel *rel, sql_exp *e) case op_right: case op_full: case op_join: - ne = rel_find_exp(rel->l, e); + ne = rel_find_exp_and_corresponding_rel(rel->l, e, res); if (!ne) - ne = rel_find_exp(rel->r, e); + ne = rel_find_exp_and_corresponding_rel(rel->r, e, res); break; case op_table: if (rel->exps && e->type == e_column && e->l && exps_bind_column2(rel->exps, e->l, e->r)) ne = e; + if (ne && res) + *res = rel; break; case op_union: case op_except: case op_inter: { if (rel->l) - ne = rel_find_exp(rel->l, e); - else if (rel->exps && e->l) + ne = rel_find_exp_and_corresponding_rel(rel->l, e, res); + else if (rel->exps && e->l) { ne = exps_bind_column2(rel->exps, e->l, e->r); - else if (rel->exps) + if (ne && res) + *res = rel; + } else if (rel->exps) { ne = exps_bind_column(rel->exps, e->r, NULL, 1); + if (ne && res) + *res = rel; + } } break; case op_basetable: if (rel->exps && e->type == e_column && e->l) ne = exps_bind_column2(rel->exps, e->l, e->r); + if (ne && res) + *res = rel; break; default: if (!is_project(rel->op) && rel->l) - ne = rel_find_exp(rel->l, e); + ne = rel_find_exp_and_corresponding_rel(rel->l, e, res); } } return ne; } +sql_exp * +rel_find_exp( sql_rel *rel, sql_exp *e) +{ + return rel_find_exp_and_corresponding_rel(rel, e, NULL); +} + int exp_is_true(mvc *sql, sql_exp *e) { diff --git a/sql/server/rel_exp.h b/sql/server/rel_exp.h --- a/sql/server/rel_exp.h +++ b/sql/server/rel_exp.h @@ -123,6 +123,7 @@ extern
MonetDB: Jun2020 - merged
Changeset: f55c46023774 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f55c46023774 Modified Files: sql/backends/monet5/sql_scenario.c Branch: Jun2020 Log Message: merged diffs (11 lines): diff --git a/sql/backends/monet5/sql_scenario.c b/sql/backends/monet5/sql_scenario.c --- a/sql/backends/monet5/sql_scenario.c +++ b/sql/backends/monet5/sql_scenario.c @@ -274,6 +274,7 @@ SQLprepareClient(Client c, int login) goto bailout; } if (global_variables(m, "monetdb", "sys") < 0) { + mvc_destroy(m); msg = createException(SQL,"sql.initClient", SQLSTATE(HY013) MAL_MALLOC_FAIL); goto bailout; } ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: Jun2020 - merged
Changeset: bf10d72aa3ab for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=bf10d72aa3ab Modified Files: gdk/gdk_batop.c monetdb5/mal/mal_import.c sql/ChangeLog.Jun2020 sql/backends/monet5/sql.c sql/backends/monet5/sql_upgrades.c sql/scripts/25_debug.sql sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128 sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.powerpc64.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 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: Jun2020 Log Message: merged diffs (truncated from 1029 to 300 lines): diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c --- a/gdk/gdk_batop.c +++ b/gdk/gdk_batop.c @@ -53,7 +53,7 @@ unshare_string_heap(BAT *b) #endif static gdk_return -insert_string_bat(BAT *b, BAT *n, BAT *s, bool force) +insert_string_bat(BAT *b, BAT *n, struct canditer *ci, bool force) { BATiter ni; /* iterator */ size_t toff = ~(size_t) 0; /* tail offset */ @@ -66,20 +66,16 @@ insert_string_bat(BAT *b, BAT *n, BAT *s #endif var_t v;/* value */ size_t off; /* offset within n's string heap */ - struct canditer ci; - BUN cnt; + BUN cnt = ci->ncand; BUN oldcnt = BATcount(b); assert(b->ttype == TYPE_str); /* only transient bats can use some other bat's string heap */ assert(b->batRole == TRANSIENT || b->tvheap->parentid == b->batCacheid); - if (n->batCount == 0 || (s && s->batCount == 0)) + if (cnt == 0) return GDK_SUCCEED; ni = bat_iterator(n); tp = NULL; - cnt = canditer_init(, n, s); - if (cnt == 0) - return GDK_SUCCEED; if ((!GDK_ELIMDOUBLES(b->tvheap) || oldcnt == 0) && !GDK_ELIMDOUBLES(n->tvheap) && b->tvheap->hashash == n->tvheap->hashash) { @@ -106,7 +102,7 @@ insert_string_bat(BAT *b, BAT *n, BAT *s * heap */ if (oldcnt == 0 && b->tvheap != n->tvheap && - ci.tpe == cand_dense) { + ci->tpe == cand_dense) { if (b->tvheap->parentid != bid) { BBPunshare(b->tvheap->parentid); } else { @@ -118,7 +114,7 @@ insert_string_bat(BAT *b, BAT *n, BAT *s b->batDirtydesc = true; toff = 0; } else if (b->tvheap->parentid == n->tvheap->parentid && - ci.tpe == cand_dense) { + ci->tpe == cand_dense) { toff = 0; } else if (b->tvheap->parentid != bid && unshare_string_heap(b) != GDK_SUCCEED) { @@ -148,7 +144,7 @@ insert_string_bat(BAT *b, BAT *n, BAT *s size_t len = b->tvheap->hashash ? 1024 * EXTRALEN : 0; for (i = 0; i < 1024; i++) { p = (BUN) (((double) rand() / RAND_MAX) * (cnt - 1)); - p = canditer_idx(, p) - n->hseqbase; + p = canditer_idx(ci, p) - n->hseqbase; off = BUNtvaroff(ni, p); if (off < b->tvheap->free && strcmp(b->tvheap->base + off, n->tvheap->base + off) == 0 && @@ -198,10 +194,10 @@ insert_string_bat(BAT *b, BAT *n, BAT *s } } else if (unshare_string_heap(b) != GDK_SUCCEED) return GDK_FAIL; -
MonetDB: Jun2020 - merged
Changeset: e9abf1cc2eaf for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e9abf1cc2eaf Modified Files: sql/server/rel_select.c sql/server/rel_unnest.c sql/server/rel_unnest.h sql/test/subquery/Tests/subquery5.sql sql/test/subquery/Tests/subquery5.stable.err Branch: Jun2020 Log Message: merged diffs (181 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 @@ -3341,7 +3341,7 @@ static sql_exp * exps = sa_list(sql->sa); if (args && args->data.sym) { int i, all_aggr = query_has_outer(query); - bool found_nested_aggr = false; + bool found_nested_aggr = false, arguments_correlated = true; list *ungrouped_cols = NULL; all_freevar = 1; @@ -3378,11 +3378,11 @@ static sql_exp * } all_aggr &= (exp_card(e) <= CARD_AGGR && !exp_is_atom(e) && is_aggr(e->type) && !is_func(e->type) && (!groupby || !is_groupby(groupby->op) || !groupby->r || !exps_find_exp(groupby->r, e))); - exp_only_freevar(query, e, _freevar, _one_freevar, _nested_aggr, _cols); - all_freevar &= found_one_freevar; /* no uncorrelated variables must be found, plus at least one correlated variable to push this aggregate to an outer query */ + exp_only_freevar(query, e, _correlated, _one_freevar, _nested_aggr, _cols); + all_freevar &= arguments_correlated && found_one_freevar; /* no uncorrelated variables must be found, plus at least one correlated variable to push this aggregate to an outer query */ list_append(exps, e); } - if (all_aggr || (all_freevar && found_nested_aggr)) + if (all_aggr || ((arguments_correlated || all_freevar) && found_nested_aggr)) return sql_error(sql, 05, SQLSTATE(42000) "SELECT: aggregate function calls cannot be nested"); if (!all_freevar) { if (is_sql_groupby(f)) { 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 @@ -171,11 +171,11 @@ rel_has_freevar(mvc *sql, sql_rel *rel) return 0; } -static void exps_only_freevar(sql_query *query, list *exps, unsigned int *all_freevar, bool *found_one_freevar, bool *found_aggr, list **ungrouped_cols); -static void rel_only_freevar(sql_query *query, sql_rel *rel, unsigned int *all_freevar, bool *found_one_freevar, bool *found_aggr, list **ungrouped_cols); +static void exps_only_freevar(sql_query *query, list *exps, bool *arguments_correlated, bool *found_one_freevar, bool *found_aggr, list **ungrouped_cols); +static void rel_only_freevar(sql_query *query, sql_rel *rel, bool *arguments_correlated, bool *found_one_freevar, bool *found_aggr, list **ungrouped_cols); void /* look for expressions with either only freevars or atoms */ -exp_only_freevar(sql_query *query, sql_exp *e, unsigned int *all_freevar, bool *found_one_freevar, bool *found_aggr, list **ungrouped_cols) +exp_only_freevar(sql_query *query, sql_exp *e, bool *arguments_correlated, bool *found_one_freevar, bool *found_aggr, list **ungrouped_cols) { if (THRhighwater()) { (void) sql_error(query->sql, 10, SQLSTATE(42000) "Query too complex: running out of stack space"); @@ -203,40 +203,40 @@ exp_only_freevar(sql_query *query, sql_e switch(e->type) { case e_cmp: if (e->flag == cmp_or || e->flag == cmp_filter) { - exps_only_freevar(query, e->l, all_freevar, found_one_freevar, found_aggr, ungrouped_cols); - exps_only_freevar(query, e->r, all_freevar, found_one_freevar, found_aggr, ungrouped_cols); + exps_only_freevar(query, e->l, arguments_correlated, found_one_freevar, found_aggr, ungrouped_cols); + exps_only_freevar(query, e->r, arguments_correlated, found_one_freevar, found_aggr, ungrouped_cols); } else if (e->flag == cmp_in || e->flag == cmp_notin) { - exp_only_freevar(query, e->l, all_freevar, found_one_freevar, found_aggr, ungrouped_cols); - exps_only_freevar(query, e->r, all_freevar, found_one_freevar, found_aggr, ungrouped_cols); + exp_only_freevar(query, e->l, arguments_correlated, found_one_freevar, found_aggr, ungrouped_cols); + exps_only_freevar(query, e->r, arguments_correlated, found_one_freevar, found_aggr, ungrouped_cols); } else { - exp_only_freevar(query, e->l, all_freevar, found_one_freevar, found_aggr, ungrouped_cols); - exp_only_freevar(query, e->r, all_freevar, found_one_freevar, found_aggr,
MonetDB: Jun2020 - merged
Changeset: a6ade5322a75 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a6ade5322a75 Modified Files: sql/server/rel_optimizer.c Branch: Jun2020 Log Message: merged diffs (102 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 @@ -2977,37 +2977,57 @@ rel_case_fixup_top(mvc *sql, sql_rel *re static list * rewrite_case_exps(mvc *sql, list *l, int *has_changes) { - node *n; - if (!l) return l; - for(n = l->h; n; n = n->next) + for (node *n = l->h; n; n = n->next) n->data = rewrite_case_exp(sql, n->data, has_changes); return l; } - static sql_exp * rewrite_case_exp(mvc *sql, sql_exp *e, int *has_changes) { - if (e->type != e_psm) - return e; - if (e->flag & PSM_VAR) - return e; - if (e->flag & PSM_SET || e->flag & PSM_RETURN) { - e->l = rewrite_case_exp(sql, e->l, has_changes); - } - if (e->flag & PSM_WHILE || e->flag & PSM_IF) { + switch(e->type) { + case e_atom: + case e_column: + break; + case e_convert: e->l = rewrite_case_exp(sql, e->l, has_changes); + break; + case e_aggr: + case e_func: + e->l = rewrite_case_exps(sql, e->l, has_changes); e->r = rewrite_case_exps(sql, e->r, has_changes); - if (e->f) - e->f = rewrite_case_exps(sql, e->f, has_changes); - return e; - } - if ((e->flag & PSM_REL) && e->l) - e->l = rel_case_fixup_top(sql, e->l, has_changes); - if (e->flag & PSM_EXCEPTION) - e->l = rewrite_case_exp(sql, e->l, has_changes); + break; + case e_cmp: + if (e->flag == cmp_or || e->flag == cmp_filter) { + e->l = rewrite_case_exps(sql, e->l, has_changes); + e->r = rewrite_case_exps(sql, e->r, has_changes); + } else if (e->flag == cmp_in || e->flag == cmp_notin) { + e->l = rewrite_case_exp(sql, e->l, has_changes); + e->r = rewrite_case_exps(sql, e->r, has_changes); + } else { + e->l = rewrite_case_exp(sql, e->l, has_changes); + e->r = rewrite_case_exp(sql, e->r, has_changes); + if (e->f) + e->f = rewrite_case_exp(sql, e->f, has_changes); + } + break; + case e_psm: + if (e->flag & PSM_SET || e->flag & PSM_RETURN || e->flag & PSM_EXCEPTION) { + e->l = rewrite_case_exp(sql, e->l, has_changes); + } else if (e->flag & PSM_VAR) { + return e; + } else if (e->flag & PSM_WHILE || e->flag & PSM_IF) { + e->l = rewrite_case_exp(sql, e->l, has_changes); + e->r = rewrite_case_exps(sql, e->r, has_changes); + if (e->flag == PSM_IF && e->f) + e->f = rewrite_case_exps(sql, e->f, has_changes); + } else if (e->flag & PSM_REL && e->l) { + e->l = rel_case_fixup_top(sql, e->l, has_changes); + } + break; + } return e; } @@ -3018,7 +3038,7 @@ rel_case_fixup(mvc *sql, sql_rel *rel, i if (!top && rel_is_ref(rel)) return rel; - if ((is_project(rel->op) || (rel->op == op_ddl && rel->flag == ddl_psm)) && rel->exps) { + if ((is_project(rel->op) || (is_ddl(rel->op) && rel->flag == ddl_psm)) && rel->exps) { list *exps = rel->exps; node *n; int needed = 0; @@ -3059,9 +3079,9 @@ rel_case_fixup(mvc *sql, sql_rel *rel, i } if (is_ddl(rel->op) && rel->flag == ddl_psm) rel->exps = rewrite_case_exps(sql, rel->exps, changes); - if (rel->l) + if ((!is_ddl(rel->op) || (is_ddl(rel->op) && (rel->flag == ddl_output || rel->flag == ddl_create_seq || rel->flag == ddl_alter_seq))) && rel->l) rel->l = rel_case_fixup(sql, rel->l, is_topn(rel->op)?top:0, changes); - if (is_ddl(rel->op) && rel->r) + if (is_ddl(rel->op) && (rel->flag == ddl_list || rel->flag == ddl_exception) && rel->r) rel->r = rel_case_fixup(sql, rel->r, is_ddl(rel->op)?top:0, changes); return res; } ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: Jun2020 - merged
Changeset: e3258a13b708 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e3258a13b708 Modified Files: sql/test/Tests/hot-snapshot.py Branch: Jun2020 Log Message: merged diffs (38 lines): diff --git a/sql/test/Tests/hot-snapshot.py b/sql/test/Tests/hot-snapshot.py --- a/sql/test/Tests/hot-snapshot.py +++ b/sql/test/Tests/hot-snapshot.py @@ -18,7 +18,6 @@ except ImportError: import os import shutil import socket -import time import tarfile import pymonetdb @@ -50,8 +49,6 @@ def main(): # start the server with process.server(dbname=mydb, mapiport = mapi_port, stdin=process.PIPE) as server: -time.sleep(2) - # connection 1 creates, inserts, commits and inserts uncommitted conn1 = pymonetdb.connect( database=server.dbname, hostname='localhost', @@ -84,7 +81,8 @@ def main(): cur2.close() conn2.close() server.terminate() -time.sleep(1) +server.wait() + shutil.rmtree(mydbdir) # and extract the tarname @@ -111,6 +109,7 @@ def main(): cur3.close() conn3.close() server.terminate() +server.wait() finally: if os.path.exists(mydbdir): ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: Jun2020 - Merged with linear-hashing
Changeset: 266ffd6ecc84 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=266ffd6ecc84 Modified Files: sql/server/rel_propagate.c sql/server/rel_psm.c sql/server/rel_select.c sql/server/rel_updates.c sql/test/pg_regress/Tests/alter_table.stable.err Branch: Jun2020 Log Message: Merged with linear-hashing diffs (121 lines): diff --git a/sql/server/rel_propagate.c b/sql/server/rel_propagate.c --- a/sql/server/rel_propagate.c +++ b/sql/server/rel_propagate.c @@ -34,11 +34,12 @@ rel_generate_anti_expression(mvc *sql, s *anti_rel = rel_project(sql->sa, *anti_rel, NULL); if (!(res = rel_parse_val(sql, sa_message(sql->sa, "select %s;", mt->part.pexp->exp), sql->emode, (*anti_rel)->l))) return NULL; - exp_label(sql->sa, res, ++sql->label); } else { assert(0); } (*anti_rel)->exps = new_exp_list(sql->sa); + if (!exp_name(res)) + exp_label(sql->sa, res, ++sql->label); append((*anti_rel)->exps, res); res = exp_ref(sql->sa, res); return res; @@ -58,9 +59,11 @@ rel_create_common_relation(mvc *sql, sql inserts = ((sql_rel*)(rel->r))->l; for (node *n = t->columns.set->h, *m = inserts->exps->h; n && m; n = n->next, m = m->next) { sql_column *col = n->data; - sql_exp *before = m->data; - sql_exp *help = exp_ref(sql->sa, before); + sql_exp *before = m->data, *help; + if (!exp_name(before)) + exp_label(sql->sa, before, ++sql->label); + help = exp_ref(sql->sa, before); exp_setname(sql->sa, help, t->base.name, col->base.name); list_append(l, help); } @@ -86,9 +89,11 @@ rel_generate_anti_insert_expression(mvc inserts = inserts->l; for (node *n = t->columns.set->h, *m = inserts->exps->h; n && m; n = n->next, m = m->next) { sql_column *col = n->data; - sql_exp *before = m->data; - sql_exp *help = exp_ref(sql->sa, before); + sql_exp *before = m->data, *help; + if (!exp_name(before)) + exp_label(sql->sa, before, ++sql->label); + help = exp_ref(sql->sa, before); exp_setname(sql->sa, help, t->base.name, col->base.name); list_append(l, help); } @@ -106,6 +111,8 @@ rel_generate_anti_insert_expression(mvc } else { assert(0); } + if (!exp_name(res)) + exp_label(sql->sa, res, ++sql->label); res = exp_ref(sql->sa, res); return res; } diff --git a/sql/server/rel_psm.c b/sql/server/rel_psm.c --- a/sql/server/rel_psm.c +++ b/sql/server/rel_psm.c @@ -478,8 +478,11 @@ rel_psm_return( sql_query *query, sql_su if (!cname) cname = sa_strdup(sql->sa, number2name(name, sizeof(name), ++sql->label)); - if (!isproject) + if (!isproject) { + if (!exp_name(e)) + exp_label(sql->sa, e, ++sql->label); e = exp_ref(sql->sa, e); + } e = rel_check_type(sql, >type, oexps_rel, e, type_equal); if (!e) return NULL; 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 @@ -4385,6 +4385,8 @@ rel_order_by(sql_query *query, sql_rel * e = exps_get_exp(rel->exps, nr); if (!e) return sql_error(sql, 02, SQLSTATE(42000) "SELECT: the order by column number (%d) is not in the number of projections range (%d)", nr, list_length(rel->exps)); + if (!exp_name(e)) + exp_label(sql->sa, e, ++sql->label); e = exp_ref(sql->sa, e); /* do not cache this query */ if (e) @@ -5094,7 +5096,7 @@ rel_value_exp2(sql_query *query, sql_rel if (!exp_name(exp)) exp_label(sql->sa, exp, ++sql->label); - res = exp_ref(sql->sa, exp); + res = exp_ref(sql->sa, exp); res->card = (*rel)->card;
MonetDB: Jun2020 - Merged with linear-hashing
Changeset: 3d58e1ccd3f8 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3d58e1ccd3f8 Added Files: sql/test/merge-partitions/Tests/mergepart30.sql sql/test/merge-partitions/Tests/mergepart30.stable.err sql/test/merge-partitions/Tests/mergepart30.stable.out Modified Files: sql/backends/monet5/sql_cat.c sql/server/rel_schema.c sql/test/merge-partitions/Tests/All sql/test/merge-partitions/Tests/mergepart23.stable.err Branch: Jun2020 Log Message: Merged with linear-hashing diffs (175 lines): diff --git a/sql/backends/monet5/sql_cat.c b/sql/backends/monet5/sql_cat.c --- a/sql/backends/monet5/sql_cat.c +++ b/sql/backends/monet5/sql_cat.c @@ -162,6 +162,8 @@ validate_alter_table_add_table(mvc *sql, node *n = cs_find_id(>members, rpt->base.id); if (isView(rpt)) throw(SQL,call,SQLSTATE(42000) "ALTER TABLE: can't add a view into a %s", errtable); + if (isDeclaredTable(rpt)) + throw(SQL,call,SQLSTATE(42000) "ALTER TABLE: can't add a declared table into a %s", errtable); if (ms->base.id != ps->base.id) throw(SQL,call,SQLSTATE(42000) "ALTER TABLE: all children tables of '%s.%s' must be part of schema '%s'", msname, mtname, msname); if (n && !update) @@ -182,9 +184,13 @@ alter_table_add_table(mvc *sql, char *ms sql_table *mt = NULL, *pt = NULL; str msg = validate_alter_table_add_table(sql, "sql.alter_table_add_table", msname, mtname, psname, ptname, , , 0); - if (msg == MAL_SUCCEED) + if (msg == MAL_SUCCEED) { + if (isRangePartitionTable(mt)) + return createException(SQL, "sql.alter_table_add_table",SQLSTATE(42000) "ALTER TABLE: a range partition is required while adding under a range partition table"); + if (isListPartitionTable(mt)) + return createException(SQL, "sql.alter_table_add_table",SQLSTATE(42000) "ALTER TABLE: a value partition is required while adding under a list partition table"); sql_trans_add_table(sql->session->tr, mt, pt); - + } return msg; } @@ -206,11 +212,11 @@ alter_table_add_range_partition(mvc *sql } else if (!isRangePartitionTable(mt)) { msg = createException(SQL,"sql.alter_table_add_range_partition",SQLSTATE(42000) "ALTER TABLE: cannot add range partition into a %s table", - (mt->type == tt_merge_table)?"merge":"list partition"); + (isListPartitionTable(mt))?"list partition":"merge"); goto finish; } else if (!update && pt->p) { msg = createException(SQL,"sql.alter_table_add_range_partition",SQLSTATE(42000) - "ALTER TABLE: table %s.%s is already part of another range partition table", + "ALTER TABLE: table '%s.%s' is already part of another table", psname, ptname); goto finish; } @@ -302,11 +308,11 @@ alter_table_add_value_partition(mvc *sql } else if (!isListPartitionTable(mt)) { msg = createException(SQL,"sql.alter_table_add_value_partition",SQLSTATE(42000) "ALTER TABLE: cannot add value partition into a %s table", - (mt->type == tt_merge_table)?"merge":"range partition"); + (isRangePartitionTable(mt))?"range partition":"merge"); goto finish; } else if (!update && pt->p) { msg = createException(SQL,"sql.alter_table_add_value_partition",SQLSTATE(42000) - "ALTER TABLE: table %s.%s is already part of another list partition table", + "ALTER TABLE: table '%s.%s' is already part of another table", psname, ptname); goto finish; } diff --git a/sql/server/rel_schema.c b/sql/server/rel_schema.c --- a/sql/server/rel_schema.c +++ b/sql/server/rel_schema.c @@ -1475,12 +1475,22 @@ sql_alter_table(sql_query *query, dlist if (isView(pt)) return sql_error(sql, 02, SQLSTATE(42000) "ALTER TABLE: can't add a view into a %s", TABLE_TYPE_DESCRIPTION(t->type, t->properties)); + if (isDeclaredTable(pt))
MonetDB: Jun2020 - Merged with linear-hashing
Changeset: b025af69aa7d for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b025af69aa7d Modified Files: sql/backends/monet5/sql_gencode.c Branch: Jun2020 Log Message: Merged with linear-hashing diffs (78 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 @@ -689,9 +689,10 @@ backend_dumpstmt(backend *be, MalBlkPtr MalBlkPtr old_mb = be->mb; stmt *s; - // Always keep the SQL query around for monitoring + /* Always keep the SQL query around for monitoring */ + if (query) { + char *escaped_q; - if (query) { while (*query && isspace((unsigned char) *query)) query++; @@ -702,25 +703,21 @@ backend_dumpstmt(backend *be, MalBlkPtr } setVarType(mb, getArg(q, 0), TYPE_void); setVarUDFtype(mb, getArg(q, 0)); - q = pushStr(mb, q, query); + if (!(escaped_q = sql_escape_str((char*) query))) { + sql_error(m, 001, SQLSTATE(HY013) MAL_MALLOC_FAIL); + return -1; + } + q = pushStr(mb, q, escaped_q); + GDKfree(escaped_q); + if (q == NULL) { + sql_error(m, 001, SQLSTATE(HY013) MAL_MALLOC_FAIL); + return -1; + } q = pushStr(mb, q, getSQLoptimizer(be->mvc)); if (q == NULL) { sql_error(m, 001, SQLSTATE(HY013) MAL_MALLOC_FAIL); return -1; } - -/* Crashes - q = newStmt(mb, querylogRef, contextRef); - if (q == NULL) { - return -1; - } - setVarType(mb, getArg(q, 0), TYPE_void); - setVarUDFtype(mb, getArg(q, 0)); - q = pushStr(mb, q, GDKgetenv("monet_release")); - q = pushStr(mb, q, GDKgetenv("monet_version")); - q = pushStr(mb, q, GDKgetenv("revision")); - q = pushStr(mb, q, GDKgetenv("merovingian_uri")); -*/ } /* announce the transaction mode */ @@ -820,7 +817,7 @@ backend_dumpproc(backend *be, Client c, Symbol curPrg = 0, backup = NULL; InstrPtr curInstr = 0; int argc = 0, res; - char arg[IDLENGTH], *escaped_q = NULL; + char arg[IDLENGTH]; node *n; backup = c->curprg; @@ -895,15 +892,7 @@ backend_dumpproc(backend *be, Client c, } } - if (be->q) { - if (!(escaped_q = sql_escape_str(be->q->codestring))) { - sql_error(m, 001, SQLSTATE(HY013) MAL_MALLOC_FAIL); - goto cleanup; - } - } - res = backend_dumpstmt(be, mb, r, 1, 1, escaped_q); - GDKfree(escaped_q); - if (res < 0) + if ((res = backend_dumpstmt(be, mb, r, 1, 1, be->q ? be->q->codestring : NULL)) < 0) goto cleanup; if (cq) { ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list