MonetDB: default - Merged with Jun2020
Changeset: 96de754a8e1d for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=96de754a8e1d Modified Files: sql/server/rel_select.c sql/server/rel_unnest.c sql/test/subquery/Tests/subquery4.stable.out Branch: default Log Message: Merged with Jun2020 ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: Jun2020 - Approved output
Changeset: 6d7388f68bff for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6d7388f68bff Modified Files: sql/test/subquery/Tests/subquery4.stable.out Branch: Jun2020 Log Message: Approved output diffs (16 lines): diff --git a/sql/test/subquery/Tests/subquery4.stable.out b/sql/test/subquery/Tests/subquery4.stable.out --- a/sql/test/subquery/Tests/subquery4.stable.out +++ b/sql/test/subquery/Tests/subquery4.stable.out @@ -300,6 +300,12 @@ stdout of test 'subquery4` in directory [ 3, 2 ] [ 3, 3 ] [ 3, NULL] +#SELECT 1 IN ((SELECT MIN(col2)), (SELECT SUM(col4))) FROM another_t; +% .%20 # table_name +% %20 # name +% boolean # type +% 5 # length +[ false] #DECLARE myvar INT; #DECLARE ovar INT; #DECLARE abc,def INT; ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: Jun2020 - fixed problem with unnesting of in expression...
Changeset: d7746408f269 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d7746408f269 Modified Files: sql/server/rel_select.c sql/server/rel_unnest.c sql/test/BugTracker-2009/Tests/assert_in_update.SF-2807336.stable.err sql/test/mergetables/Tests/part-elim.stable.out Branch: Jun2020 Log Message: fixed problem with unnesting of in expressions with multiple correlated subqueries diffs (124 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 @@ -745,7 +745,8 @@ exp_values_set_supertype(mvc *sql, sql_e e = rel_check_type(sql, &values->tpe, NULL, e, type_equal); if (!e) return NULL; - append(nexps, e); + exp_label(sql->sa, e, ++sql->label); + append(nexps, e); } values->f = nexps; } @@ -2045,7 +2046,6 @@ rel_in_value_exp(sql_query *query, sql_r } } else { /* if it's not a tuple, enforce coersion on the type for every element on the list */ values = exp_values_set_supertype(sql, values); - if (rel_binop_check_types(sql, rel ? *rel : NULL, le, values, 0) < 0) 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 @@ -1786,7 +1786,7 @@ rel_union_exps(mvc *sql, sql_exp **l, li sql_exp *ve = n->data, *r, *s; sql_rel *sq = NULL; - if (exp_has_rel(ve)) + if (exp_has_rel(ve)) sq = exp_rel_get_rel(sql->sa, ve); /* get subquery */ else sq = rel_project(sql->sa, NULL, append(sa_list(sql->sa), ve)); @@ -1799,20 +1799,21 @@ rel_union_exps(mvc *sql, sql_exp **l, li m->data = r; } } else { - r = sq->exps->t->data; - if (rel_convert_types(sql, NULL, NULL, l, &r, 1, type_equal) < 0) + sq->nrcols = list_length(sq->exps); + if (rel_convert_types(sql, NULL, NULL, l, &ve, 1, type_equal) < 0) return NULL; - sq->exps->t->data = r; - sq->nrcols = list_length(sq->exps); + /* flatten expressions */ + if (exp_has_rel(ve)) + ve = exp_rel_update_exp(sql->sa, ve); + sq = rel_project(sql->sa, sq, append(sa_list(sql->sa), ve)); } if (!u) { u = sq; - exps = rel_projections(sql, sq, NULL, 1/*keep names */, 1); } else { u = rel_setop(sql->sa, u, sq, op_union); rel_set_exps(u, exps); - exps = rel_projections(sql, sq, NULL, 1/*keep names */, 1); } + exps = rel_projections(sql, sq, NULL, 1/*keep names */, 1); } return u; } @@ -1906,6 +1907,8 @@ rewrite_anyequal(mvc *sql, sql_rel *rel, if (is_atom(re->type) && re->f) { /* exp_values */ /* flatten using unions */ rsq = rel_union_exps(sql, &le, re->f, is_tuple); + if (!rsq) + return NULL; re = rsq->exps->t->data; if (!is_tuple && !is_freevar(re)) { @@ -2094,6 +2097,8 @@ rewrite_compare(mvc *sql, sql_rel *rel, if (is_values(re)) { /* exp_values */ /* flatten using unions */ rsq = rel_union_exps(sql, &le, re->f, is_tuple); + if (!rsq) + return NULL; re = rsq->exps->t->data; if (!is_tuple) { diff --git a/sql/test/BugTracker-2009/Tests/assert_in_update.SF-2807336.stable.err b/sql/test/BugTracker-2009/Tests/assert_in_update.SF-2807336.stable.err --- a/sql/test/BugTracker-2009/Tests/assert_in_update.SF-2807336.stable.err +++ b/sql/test/BugTracker-2009/Tests/assert_in_update.SF-2807336.stable.err @@ -65,7 +65,7 @@ stderr of test 'assert_in_update.SF-2807 #warning: please don't forget to set your vault key! #(see /ufs/niels/scratch/rc/Linux-x86_64/etc/monetdb5.conf) -# 15:04:33 > -# 15:04:33 > "Done." -# 15:04:33 > +# 13:17:20 > +# 13:17:20 > "Done." +# 13:17:20 > diff --git a/sql/test/mergetables/Tests/part-elim.stable.out b/sql/test/mergetables/Tests/pa
MonetDB: default - Merged with Jun2020
Changeset: 0c865bfdba81 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0c865bfdba81 Modified Files: sql/server/rel_psm.c sql/server/rel_rel.c sql/server/rel_rel.h sql/server/rel_select.c sql/server/rel_unnest.c sql/test/miscellaneous/Tests/simple_selects.sql sql/test/miscellaneous/Tests/simple_selects.stable.err sql/test/pg_regress/Tests/alter_table.stable.err sql/test/subquery/Tests/subquery4.sql sql/test/subquery/Tests/subquery4.stable.err sql/test/subquery/Tests/subquery4.stable.out tools/merovingian/daemon/argvcmds.c tools/merovingian/daemon/controlrunner.c tools/merovingian/daemon/discoveryrunner.c tools/merovingian/daemon/merovingian.c tools/merovingian/daemon/multiplex-funnel.c tools/merovingian/daemon/multiplex-funnel.h Branch: default Log Message: Merged with Jun2020 diffs (truncated from 685 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 @@ -105,8 +105,11 @@ psm_set_exp(sql_query *query, dnode *n) if (!rel_val) return NULL; - if (!is_project(rel_val->op) || dlist_length(vars) != list_length(rel_val->exps)) + if (!is_project(rel_val->op)) + return sql_error(sql, 02, SQLSTATE(42000) "SET: The subquery is not a projection"); + if (dlist_length(vars) != list_length(rel_val->exps)) return sql_error(sql, 02, SQLSTATE(42000) "SET: Number of variables not equal to number of supplied values"); + rel_val = rel_zero_or_one(sql, rel_val, ek); b = sa_list(sql->sa); append(b, exp_rel(sql, rel_val)); @@ -125,19 +128,12 @@ psm_set_exp(sql_query *query, dnode *n) tpe = stack_find_type(sql, vname); } - if (!exp_name(v)) + level = stack_find_frame(sql, vname); + if (!exp_name(v)) exp_label(sql->sa, v, ++sql->label); v = exp_ref(sql->sa, v); - - level = stack_find_frame(sql, vname); - v = rel_check_type(sql, tpe, rel_val, v, type_cast); - if (!v) + if (!(v = rel_check_type(sql, tpe, rel_val, v, type_cast))) return NULL; - if (v->card > CARD_AGGR) { - sql_subfunc *zero_or_one = sql_bind_func(sql->sa, sql->session->schema, "zero_or_one", exp_subtype(v), NULL, F_AGGR); - assert(zero_or_one); - v = exp_aggr1(sql->sa, v, zero_or_one, 0, 0, CARD_ATOM, has_nil(v)); - } append(b, exp_set(sql->sa, vname, v, level)); } res = exp_rel(sql, rel_psm_block(sql->sa, b)); @@ -520,6 +516,11 @@ rel_select_into( sql_query *query, symbo r = rel_subquery(query, NULL, sq, ek); if (!r) return NULL; + if (!is_project(r->op)) + return sql_error(sql, 02, SQLSTATE(42000) "SELECT INTO: The subquery is not a projection"); + if (list_length(r->exps) != dlist_length(into)) + return sql_error(sql, 02, SQLSTATE(21S01) "SELECT INTO: number of values doesn't match number of variables to set"); + r = rel_zero_or_one(sql, r, ek); nl = sa_list(sql->sa); append(nl, exp_rel(sql, r)); for (m = r->exps->h, n = into->h; m && n; m = m->next, n = n->next) { @@ -530,15 +531,12 @@ rel_select_into( sql_query *query, symbo if (!stack_find_var(sql, nme)) return sql_error(sql, 02, SQLSTATE(42000) "SELECT INTO: variable '%s' unknown", nme); - /* dynamic check for single values */ - if (v->card > CARD_AGGR) { - sql_subfunc *zero_or_one = sql_bind_func(sql->sa, sql->session->schema, "zero_or_one", exp_subtype(v), NULL, F_AGGR); - assert(zero_or_one); - v = exp_aggr1(sql->sa, v, zero_or_one, 0, 0, CARD_ATOM, has_nil(v)); - } tpe = stack_find_type(sql, nme); level = stack_find_frame(sql, nme); - if (!v || !(v = rel_check_type(sql, tpe, r, v, type_equal))) + if (!exp_name(v)) + exp_label(sql->sa, v, ++sql->label); + v = exp_ref(sql->sa, v); + if (!(v = rel_check_type(sql, tpe, r, v, type_equal))) return NULL; v = exp_set(sql->sa, nme, v, level); list_append(nl, v); diff --git a/sql/server/rel_rel.c b/sql/server/rel_rel.c --- a/sql/server/rel_rel.c +++ b/
MonetDB: default - Comment.
Changeset: d13ab98ddb09 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d13ab98ddb09 Modified Files: gdk/gdk_qsort.c Branch: default Log Message: Comment. diffs (22 lines): diff --git a/gdk/gdk_qsort.c b/gdk/gdk_qsort.c --- a/gdk/gdk_qsort.c +++ b/gdk/gdk_qsort.c @@ -340,7 +340,17 @@ struct qsort_t { #undef SUFF #undef TPE -/* the interface functions */ +/* Sort the array `h' of `n' elements with size `hs' each and type + * `ts' in ascending or descending (if `reverse' is true) order. If + * the type `tpe' indicates a variable-sized type, `h' contains + * offsets into the `base' array which should be NULL otherwise. The + * array `t', if not NULL, contains `n' values of size `ts' each which + * will be moved around together with the corresponding elements in + * `h' (i.e. `t' is the payload). If `nilslast' is true, nils sort at + * the end, otherwise at the beginning of the result. + * + * This function uses a variant of quicksort and is thus not a stable + * sort. */ void GDKqsort(void *restrict h, void *restrict t, const void *restrict base, size_t n, int hs, int ts, int tpe, bool reverse, bool nilslast) ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: default - Approve.
Changeset: 45c85efe5eb3 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=45c85efe5eb3 Modified Files: clients/Tests/exports.stable.out Branch: default Log Message: Approve. diffs (12 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 @@ -485,7 +485,7 @@ geomcatalogfix_fptr geomcatalogfix_get(v void geomcatalogfix_set(geomcatalogfix_fptr); geomsqlfix_fptr geomsqlfix_get(void); void geomsqlfix_set(geomsqlfix_fptr); -int geomversion_get(void); +bool geomversion_get(void); void geomversion_set(void); bat getBBPsize(void); char *get_bin_path(void); ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: default - fixed problem with unnesting of in expression...
Changeset: 3e225c5db6cc for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3e225c5db6cc Modified Files: sql/server/rel_select.c sql/server/rel_unnest.c sql/test/BugTracker-2009/Tests/assert_in_update.SF-2807336.stable.err sql/test/mergetables/Tests/part-elim.stable.out sql/test/subquery/Tests/subquery4.stable.out Branch: default Log Message: fixed problem with unnesting of in expressions with multiple correlated subqueries diffs (140 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 @@ -794,7 +794,8 @@ exp_values_set_supertype(mvc *sql, sql_e e = rel_check_type(sql, &values->tpe, NULL, e, type_equal); if (!e) return NULL; - append(nexps, e); + exp_label(sql->sa, e, ++sql->label); + append(nexps, e); } values->f = nexps; } @@ -2094,7 +2095,6 @@ rel_in_value_exp(sql_query *query, sql_r } } else { /* if it's not a tuple, enforce coersion on the type for every element on the list */ values = exp_values_set_supertype(sql, values); - if (rel_binop_check_types(sql, rel ? *rel : NULL, le, values, 0) < 0) 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 @@ -1875,7 +1875,7 @@ rel_union_exps(mvc *sql, sql_exp **l, li sql_exp *ve = n->data, *r, *s; sql_rel *sq = NULL; - if (exp_has_rel(ve)) + if (exp_has_rel(ve)) sq = exp_rel_get_rel(sql->sa, ve); /* get subquery */ else sq = rel_project(sql->sa, NULL, append(sa_list(sql->sa), ve)); @@ -1888,20 +1888,21 @@ rel_union_exps(mvc *sql, sql_exp **l, li m->data = r; } } else { - r = sq->exps->t->data; - if (rel_convert_types(sql, NULL, NULL, l, &r, 1, type_equal) < 0) + sq->nrcols = list_length(sq->exps); + if (rel_convert_types(sql, NULL, NULL, l, &ve, 1, type_equal) < 0) return NULL; - sq->exps->t->data = r; - sq->nrcols = list_length(sq->exps); + /* flatten expressions */ + if (exp_has_rel(ve)) + ve = exp_rel_update_exp(sql->sa, ve); + sq = rel_project(sql->sa, sq, append(sa_list(sql->sa), ve)); } if (!u) { u = sq; - exps = rel_projections(sql, sq, NULL, 1/*keep names */, 1); } else { u = rel_setop(sql->sa, u, sq, op_union); rel_set_exps(u, exps); - exps = rel_projections(sql, sq, NULL, 1/*keep names */, 1); } + exps = rel_projections(sql, sq, NULL, 1/*keep names */, 1); } return u; } @@ -1995,6 +1996,8 @@ rewrite_anyequal(mvc *sql, sql_rel *rel, if (is_atom(re->type) && re->f) { /* exp_values */ /* flatten using unions */ rsq = rel_union_exps(sql, &le, re->f, is_tuple); + if (!rsq) + return NULL; re = rsq->exps->t->data; if (!is_tuple && !is_freevar(re)) { @@ -2183,6 +2186,8 @@ rewrite_compare(mvc *sql, sql_rel *rel, if (is_values(re)) { /* exp_values */ /* flatten using unions */ rsq = rel_union_exps(sql, &le, re->f, is_tuple); + if (!rsq) + return NULL; re = rsq->exps->t->data; if (!is_tuple) { diff --git a/sql/test/BugTracker-2009/Tests/assert_in_update.SF-2807336.stable.err b/sql/test/BugTracker-2009/Tests/assert_in_update.SF-2807336.stable.err --- a/sql/test/BugTracker-2009/Tests/assert_in_update.SF-2807336.stable.err +++ b/sql/test/BugTracker-2009/Tests/assert_in_update.SF-2807336.stable.err @@ -65,7 +65,7 @@ stderr of test 'assert_in_update.SF-2807 #warning: please don't forget to set your vault key! #(see /ufs/niels/scratch/rc/Linux-x86_64/etc/monetdb5.conf) -# 15:04:33 > -# 15:04:33 > "Done." -# 15:04:33 > +# 13:17:20 > +# 13:17:20 > "Done." +# 13:17:20 > diff --git a/sql/test/mergetables/Tests/
MonetDB: Jun2020 - Added labels if expressions don't have a name
Changeset: 3b173df1aa96 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3b173df1aa96 Modified Files: sql/server/rel_psm.c sql/test/subquery/Tests/subquery4.sql sql/test/subquery/Tests/subquery4.stable.out Branch: Jun2020 Log Message: Added labels if expressions don't have a name diffs (55 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 @@ -129,6 +129,8 @@ psm_set_exp(sql_query *query, dnode *n) } level = stack_find_frame(sql, vname); + if (!exp_name(v)) + exp_label(sql->sa, v, ++sql->label); v = exp_ref(sql->sa, v); if (!(v = rel_check_type(sql, tpe, rel_val, v, type_cast))) return NULL; @@ -531,6 +533,8 @@ rel_select_into( sql_query *query, symbo return sql_error(sql, 02, SQLSTATE(42000) "SELECT INTO: variable '%s' unknown", nme); tpe = stack_find_type(sql, nme); level = stack_find_frame(sql, nme); + if (!exp_name(v)) + exp_label(sql->sa, v, ++sql->label); v = exp_ref(sql->sa, v); if (!(v = rel_check_type(sql, tpe, r, v, type_equal))) return NULL; diff --git a/sql/test/subquery/Tests/subquery4.sql b/sql/test/subquery/Tests/subquery4.sql --- a/sql/test/subquery/Tests/subquery4.sql +++ b/sql/test/subquery/Tests/subquery4.sql @@ -197,6 +197,10 @@ SELECT (SELECT i) INTO myvar FROM intege DECLARE ovar INT; SET ovar = (SELECT (SELECT i) FROM integers); --error, one row max +DECLARE abc,def INT; +SET (abc, def) = (SELECT 1, 2); +SELECT abc, def; + UPDATE another_T SET col1 = MIN(col1); --error, aggregates not allowed in update set clause UPDATE another_T SET col2 = 1 WHERE col1 = SUM(col2); --error, aggregates not allowed in update set clause UPDATE another_T SET col3 = (SELECT MAX(col5)); --error, aggregates not allowed in update set clause diff --git a/sql/test/subquery/Tests/subquery4.stable.out b/sql/test/subquery/Tests/subquery4.stable.out --- a/sql/test/subquery/Tests/subquery4.stable.out +++ b/sql/test/subquery/Tests/subquery4.stable.out @@ -300,6 +300,16 @@ stdout of test 'subquery4` in directory [ 3, 2 ] [ 3, 3 ] [ 3, NULL] +#DECLARE myvar INT; +#DECLARE ovar INT; +#DECLARE abc,def INT; +#SET (abc, def) = (SELECT 1, 2); +#SELECT abc, def; +% ., . # table_name +% single_value,single_value # name +% int, int # type +% 1, 1 # length +[ 1, 2 ] #UPDATE another_T SET col4 = (SELECT SUM(col4 + ColID) FROM tbl_ProductSales); --4 rows affected [ 4] #SELECT col4 FROM another_T; ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: Jun2020 - Use rel_zero_or_one at SELECT INTO and SET (m...
Changeset: d39c09363478 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d39c09363478 Modified Files: sql/server/rel_psm.c sql/server/rel_rel.c sql/server/rel_rel.h sql/server/rel_select.c sql/server/rel_unnest.c sql/test/subquery/Tests/subquery4.stable.err Branch: Jun2020 Log Message: Use rel_zero_or_one at SELECT INTO and SET (multiple variable case). This fixes the crashes diffs (235 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 @@ -105,8 +105,11 @@ psm_set_exp(sql_query *query, dnode *n) if (!rel_val) return NULL; - if (!is_project(rel_val->op) || dlist_length(vars) != list_length(rel_val->exps)) + if (!is_project(rel_val->op)) + return sql_error(sql, 02, SQLSTATE(42000) "SET: The subquery is not a projection"); + if (dlist_length(vars) != list_length(rel_val->exps)) return sql_error(sql, 02, SQLSTATE(42000) "SET: Number of variables not equal to number of supplied values"); + rel_val = rel_zero_or_one(sql, rel_val, ek); b = sa_list(sql->sa); append(b, exp_rel(sql, rel_val)); @@ -125,19 +128,10 @@ psm_set_exp(sql_query *query, dnode *n) tpe = stack_find_type(sql, vname); } - if (!exp_name(v)) - exp_label(sql->sa, v, ++sql->label); + level = stack_find_frame(sql, vname); v = exp_ref(sql->sa, v); - - level = stack_find_frame(sql, vname); - v = rel_check_type(sql, tpe, rel_val, v, type_cast); - if (!v) + if (!(v = rel_check_type(sql, tpe, rel_val, v, type_cast))) return NULL; - if (v->card > CARD_AGGR) { - sql_subfunc *zero_or_one = sql_bind_func(sql->sa, sql->session->schema, "zero_or_one", exp_subtype(v), NULL, F_AGGR); - assert(zero_or_one); - v = exp_aggr1(sql->sa, v, zero_or_one, 0, 0, CARD_ATOM, has_nil(v)); - } append(b, exp_set(sql->sa, vname, v, level)); } res = exp_rel(sql, rel_psm_block(sql->sa, b)); @@ -520,8 +514,11 @@ rel_select_into( sql_query *query, symbo r = rel_subquery(query, NULL, sq, ek); if (!r) return NULL; + if (!is_project(r->op)) + return sql_error(sql, 02, SQLSTATE(42000) "SELECT INTO: The subquery is not a projection"); if (list_length(r->exps) != dlist_length(into)) return sql_error(sql, 02, SQLSTATE(21S01) "SELECT INTO: number of values doesn't match number of variables to set"); + r = rel_zero_or_one(sql, r, ek); nl = sa_list(sql->sa); append(nl, exp_rel(sql, r)); for (m = r->exps->h, n = into->h; m && n; m = m->next, n = n->next) { @@ -532,15 +529,10 @@ rel_select_into( sql_query *query, symbo if (!stack_find_var(sql, nme)) return sql_error(sql, 02, SQLSTATE(42000) "SELECT INTO: variable '%s' unknown", nme); - /* dynamic check for single values */ - if (v->card > CARD_AGGR) { - sql_subfunc *zero_or_one = sql_bind_func(sql->sa, sql->session->schema, "zero_or_one", exp_subtype(v), NULL, F_AGGR); - assert(zero_or_one); - v = exp_aggr1(sql->sa, v, zero_or_one, 0, 0, CARD_ATOM, has_nil(v)); - } tpe = stack_find_type(sql, nme); level = stack_find_frame(sql, nme); - if (!v || !(v = rel_check_type(sql, tpe, r, v, type_equal))) + v = exp_ref(sql->sa, v); + if (!(v = rel_check_type(sql, tpe, r, v, type_equal))) return NULL; v = exp_set(sql->sa, nme, v, level); list_append(nl, v); 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 @@ -1572,6 +1572,55 @@ rel_in_rel(sql_rel *super, sql_rel *sub) return 0; } +sql_rel* +rel_parent(sql_rel *rel) +{ + if (rel->l && (is_project(rel->op) || rel->op == op_topn || rel->op == op_sample)) { + sql_rel *l = rel->l; + if (is_project(l->op)) + return l; + } + return rel; +} + +sql_exp * +lastexp(sql_rel *rel) +{ + if (!is_processed(rel) || is_topn(rel->op) || is_sample(rel->op)) + rel = rel_parent(rel); + assert(list_length(rel->exps)); + assert(is_project(rel->op)); + return rel->exps->t->data; +} + +sql
MonetDB: default - Information hiding: remove stuff from gdk_log...
Changeset: cb1a73c85c25 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=cb1a73c85c25 Added Files: gdk/gdk_logger_internals.h Modified Files: gdk/Makefile.ag gdk/gdk_logger.c gdk/gdk_logger.h sql/server/sql_mvc.c sql/storage/bat/bat_logger.c sql/storage/sql_storage.h sql/storage/store_sequence.c Branch: default Log Message: Information hiding: remove stuff from gdk_logger.h and don't include it when not needed. diffs (243 lines): diff --git a/gdk/Makefile.ag b/gdk/Makefile.ag --- a/gdk/Makefile.ag +++ b/gdk/Makefile.ag @@ -29,7 +29,7 @@ lib_gdk = { gdk_posix.c gdk_logger.c gdk_sample.c xoshiro256starstar.h \ gdk_private.h gdk_delta.h gdk_logger.h gdk_posix.h \ gdk_system.h gdk_system_private.h gdk_tm.h gdk_storage.h \ - gdk_geomlogger.h \ + gdk_geomlogger.h gdk_logger_internals.h \ gdk_group.c \ gdk_imprints.c gdk_imprints.h \ gdk_join.c gdk_project.c \ diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c --- a/gdk/gdk_logger.c +++ b/gdk/gdk_logger.c @@ -57,6 +57,7 @@ #include "gdk.h" #include "gdk_private.h" #include "gdk_logger.h" +#include "gdk_logger_internals.h" #include /* @@ -92,6 +93,8 @@ #endif #endif +#define BATSIZE 0 + #define NAME(name,tpe,id) (name?name:"tpe id") #define LOG_DISABLED(lg) ((lg)->debug&128) @@ -118,6 +121,30 @@ static const char *log_commands[] = { "LOG_UPDATE_PAX", }; +typedef struct logaction { + int type; /* type of change */ + lng nr; + int ht; /* vid(-1),void etc */ + int tt; + lng id; + char *name; /* optional */ + char tpe; /* tpe of column */ + oid cid;/* id of object */ + BAT *b; /* temporary bat with changes */ + BAT *uid; /* temporary bat with bun positions to update */ +} logaction; + +/* during the recover process a number of transactions could be active */ +typedef struct trans { + int tid;/* transaction id */ + int sz; /* sz of the changes array */ + int nr; /* nr of changes */ + + logaction *changes; + + struct trans *tr; +} trans; + typedef struct logformat_t { char flag; int tid; diff --git a/gdk/gdk_logger.h b/gdk/gdk_logger.h --- a/gdk/gdk_logger.h +++ b/gdk/gdk_logger.h @@ -11,74 +11,10 @@ #define LOGFILE "log" -typedef struct logaction { - int type; /* type of change */ - lng nr; - int ht; /* vid(-1),void etc */ - int tt; - lng id; - char *name; /* optional */ - char tpe; /* tpe of column */ - oid cid;/* id of object */ - BAT *b; /* temporary bat with changes */ - BAT *uid; /* temporary bat with bun positions to update */ -} logaction; - -/* during the recover process a number of transactions could be active */ -typedef struct trans { - int tid;/* transaction id */ - int sz; /* sz of the changes array */ - int nr; /* nr of changes */ - - logaction *changes; - - struct trans *tr; -} trans; - typedef gdk_return (*preversionfix_fptr)(int oldversion, int newversion); typedef gdk_return (*postversionfix_fptr)(void *lg); -typedef struct logger { - int debug; - int version; - lng changes; - lng id; - int tid; - bool with_ids; - bool inmemory; -#ifdef GDKLIBRARY_OLDDATE - /* convert old date values to new */ - bool convert_date; -#endif - char *fn; - char *dir; - char *local_dir; /* the directory in which the log is written */ - preversionfix_fptr prefuncp; - postversionfix_fptr postfuncp; - stream *log; - lng end;/* end of pre-allocated blocks for faster f(data)sync */ - /* Store log_bids (int) to circumvent trouble with reference counting */ - BAT *catalog_bid; /* int bid column */ - BAT *catalog_nme; /* str name column */ - BAT *catalog_tpe; /* type of column */ - BAT *catalog_oid; /* object identifier of column (the pair type,oid is unique) */ - BAT *dcatalog; /* deleted from catalog table */ - BAT *seqs_id; /* int id column */ - BAT *seqs_val; /* lng value column */ - BAT *dseqs; /* deleted from seqs table */ - BAT *snapshots_bid; /* int bid column */ - BAT *snapshots_tid; /* int tid column */ - BAT *dsnapshots;/* deleted from snapshots table */ - BAT *freed; /* snapshots can be created and destroyed, - in a single log
MonetDB: default - Move geom-specific logger declarations to sep...
Changeset: 674895f8e497 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=674895f8e497 Added Files: gdk/gdk_geomlogger.h Modified Files: gdk/Makefile.ag gdk/gdk_logger.c gdk/gdk_logger.h geom/monetdb5/geom.c geom/monetdb5/geom.h geom/monetdb5/geom_upgrade.c sql/backends/monet5/sql_upgrades.c sql/common/sql_types.c Branch: default Log Message: Move geom-specific logger declarations to separate include file. diffs (163 lines): diff --git a/gdk/Makefile.ag b/gdk/Makefile.ag --- a/gdk/Makefile.ag +++ b/gdk/Makefile.ag @@ -29,6 +29,7 @@ lib_gdk = { gdk_posix.c gdk_logger.c gdk_sample.c xoshiro256starstar.h \ gdk_private.h gdk_delta.h gdk_logger.h gdk_posix.h \ gdk_system.h gdk_system_private.h gdk_tm.h gdk_storage.h \ + gdk_geomlogger.h \ gdk_group.c \ gdk_imprints.c gdk_imprints.h \ gdk_join.c gdk_project.c \ diff --git a/gdk/gdk_geomlogger.h b/gdk/gdk_geomlogger.h new file mode 100644 --- /dev/null +++ b/gdk/gdk_geomlogger.h @@ -0,0 +1,23 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. + */ + +#ifndef _GEOMLOGGER_H_ +#define _GEOMLOGGER_H_ + +typedef int (*geomcatalogfix_fptr)(void *, int); +gdk_export void geomcatalogfix_set(geomcatalogfix_fptr); +gdk_export geomcatalogfix_fptr geomcatalogfix_get(void); + +typedef str (*geomsqlfix_fptr)(int); +gdk_export void geomsqlfix_set(geomsqlfix_fptr); +gdk_export geomsqlfix_fptr geomsqlfix_get(void); + +gdk_export void geomversion_set(void); +gdk_export bool geomversion_get(void); + +#endif /* _GEOMLOGGER_H_ */ diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c --- a/gdk/gdk_logger.c +++ b/gdk/gdk_logger.c @@ -126,10 +126,12 @@ typedef struct logformat_t { typedef enum {LOG_OK, LOG_EOF, LOG_ERR} log_return; +#include "gdk_geomlogger.h" + /* When reading an old format database, we may need to read the geom * Well-known Binary (WKB) type differently. This variable is used to * indicate that to the function wkbREAD during reading of the log. */ -static int geomisoldversion; +static bool geomisoldversion; static gdk_return bm_commit(logger *lg); static gdk_return tr_grow(trans *tr); @@ -2239,7 +2241,7 @@ logger_load(int debug, const char *fn, c goto error; /* done reading the log, revert to "normal" behavior */ - geomisoldversion = 0; + geomisoldversion = false; } return GDK_SUCCEED; @@ -3314,9 +3316,11 @@ geomsqlfix_get(void) void geomversion_set(void) { - geomisoldversion = 1; + geomisoldversion = true; } -int geomversion_get(void) + +bool +geomversion_get(void) { return geomisoldversion; } diff --git a/gdk/gdk_logger.h b/gdk/gdk_logger.h --- a/gdk/gdk_logger.h +++ b/gdk/gdk_logger.h @@ -132,15 +132,4 @@ gdk_export log_bid logger_find_bat(logge gdk_export gdk_return logger_upgrade_bat(logger *lg, const char *name, char tpe, oid id) __attribute__ ((__warn_unused_result__)); -typedef int (*geomcatalogfix_fptr)(void *, int); -gdk_export void geomcatalogfix_set(geomcatalogfix_fptr); -gdk_export geomcatalogfix_fptr geomcatalogfix_get(void); - -typedef str (*geomsqlfix_fptr)(int); -gdk_export void geomsqlfix_set(geomsqlfix_fptr); -gdk_export geomsqlfix_fptr geomsqlfix_get(void); - -gdk_export void geomversion_set(void); -gdk_export int geomversion_get(void); - #endif /*_LOGGER_H_*/ diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c --- a/geom/monetdb5/geom.c +++ b/geom/monetdb5/geom.c @@ -12,6 +12,7 @@ */ #include "geom.h" +#include "gdk_logger.h" #include "mal_exception.h" int TYPE_mbr; @@ -2064,6 +2065,8 @@ geoGetType(char **res, int *info, int *f /* returns a pointer to a nil-mbr. */ static mbr mbrNIL; /* to be filled in */ +#include "gdk_geomlogger.h" + str geom_prelude(void *ret) { diff --git a/geom/monetdb5/geom.h b/geom/monetdb5/geom.h --- a/geom/monetdb5/geom.h +++ b/geom/monetdb5/geom.h @@ -23,8 +23,6 @@ #include #include -#include "gdk_logger.h" - #ifdef WIN32 #ifndef LIBGEOM #define geom_export extern __declspec(dllimport) diff --git a/geom/monetdb5/geom_upgrade.c b/geom/monetdb5/geom_upgrade.c --- a/geom/monetdb5/geom_upgrade.c +++ b/geom/monetdb5/geom_upgrade.c @@ -12,6 +12,7 @@ #include "geom.h" +#include "gdk_logger.h" static char * N(char *buf, const char *pre, const char *schema, const char *post) diff --git a/sql/backends/monet5/sql_upgrades.c b/sql/backends/monet5/sql_upgrades.c --- a/sql/backends/monet5/sql_upgrades.c +++ b/sql/backends/monet5/sql_upgrades.c @@ -21,6 +21,7 @@ #include "rel_semantic.h" #include "rel_unnest.h" #in
MonetDB: Jun2020 - Run rel_reset_subquery and _rel_unnest under ...
Changeset: 2e9f6c7ee5f6 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2e9f6c7ee5f6 Modified Files: sql/server/rel_rel.c sql/server/rel_unnest.c Branch: Jun2020 Log Message: Run rel_reset_subquery and _rel_unnest under rel_visitors, so psm statments under op_ddl are unnested diffs (165 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 @@ -1786,8 +1786,6 @@ rel_deps(mvc *sql, sql_rel *r, list *ref return rel_deps(sql, r->l, refs, l); if (r->r) return rel_deps(sql, r->r, refs, l); - } else if (r->flag == ddl_psm) { - break; } else if (r->flag == ddl_create_seq || r->flag == ddl_alter_seq) { if (r->l) return rel_deps(sql, r->l, refs, l); @@ -1962,8 +1960,6 @@ rel_exp_visitor(mvc *sql, sql_rel *rel, if (rel->r) if ((rel->r = rel_exp_visitor(sql, rel->r, exp_rewriter, topdown)) == NULL) return NULL; - } else if (rel->flag == ddl_psm) { - break; } break; case op_insert: 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 @@ -1403,112 +1403,23 @@ rel_unnest_dependent(mvc *sql, sql_rel * } static sql_rel * -_rel_unnest(mvc *sql, sql_rel *rel) +_rel_unnest(mvc *sql, sql_rel *rel, int *changes) { - if (THRhighwater()) - return sql_error(sql, 10, SQLSTATE(42000) "Query too complex: running out of stack space"); - if (!rel) - return rel; - - switch (rel->op) { - case op_basetable: - break; - case op_table: - if (IS_TABLE_PROD_FUNC(rel->flag) || rel->flag == TABLE_FROM_RELATION) - rel->l = _rel_unnest(sql, rel->l); - break; - case op_join: - case op_left: - case op_right: - case op_full: - - case op_semi: - case op_anti: - - case op_union: - case op_inter: - case op_except: - rel->l = _rel_unnest(sql, rel->l); - rel->r = _rel_unnest(sql, rel->r); - break; - case op_project: - case op_select: - case op_groupby: - case op_topn: - case op_sample: - rel->l = _rel_unnest(sql, rel->l); - break; - case op_ddl: - rel->l = _rel_unnest(sql, rel->l); - if (rel->r) - rel->r = _rel_unnest(sql, rel->r); - break; - case op_insert: - case op_update: - case op_delete: - case op_truncate: - rel->l = _rel_unnest(sql, rel->l); - rel->r = _rel_unnest(sql, rel->r); - break; + if (is_dependent(rel)) { + rel = rel_unnest_dependent(sql, rel); + (*changes)++; } - if (is_dependent(rel)) - rel = rel_unnest_dependent(sql, rel); return rel; } -static void -rel_reset_subquery(sql_rel *rel) +static sql_rel * +rel_reset_subquery(mvc *sql, sql_rel *rel, int *changes) { - if (!rel) - return; - + (void) sql; + if (rel->subquery) + (*changes)++; rel->subquery = 0; - switch(rel->op){ - case op_basetable: - break; - case op_table: - if ((IS_TABLE_PROD_FUNC(rel->flag) || rel->flag == TABLE_FROM_RELATION) && rel->l) - rel_reset_subquery(rel->l); - break; - case op_ddl: - rel_reset_subquery(rel->l); - if (rel->r) - rel_reset_subquery(rel->r); - break; - case op_insert: - case op_update: - case op_delete: - case op_truncate: - if (rel->l) - rel_reset_subquery(rel->l); - if (rel->r) - rel_reset_subquery(rel->r); - break; - case op_select: - case op_topn: - case op_sample: - - case op_project: - case op_groupby: - if (rel->l) - rel_reset_subquery(rel->l); - break; - case op_join: - case op_left: - case op_right: - case op_full: - case op_semi: - case op_anti: - - case op_union: - case op_inter: - case op_except: - if (rel->l) - rel_reset_subquery(rel->l); - if (rel->r) - rel_reset_subquery(rel->r); - } - + return rel; } static sql_exp * @@ -2752,7 +2663,7 @@ rel_unnest(mvc *sql, sql_rel *rel)
MonetDB: mosaic - Testweb compilation fixes.
Changeset: 8212db9b46ed for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8212db9b46ed Modified Files: monetdb5/modules/mosaic/mosaic_join_templates.h Branch: mosaic Log Message: Testweb compilation fixes. diffs (31 lines): diff --git a/monetdb5/modules/mosaic/mosaic_join_templates.h b/monetdb5/modules/mosaic/mosaic_join_templates.h --- a/monetdb5/modules/mosaic/mosaic_join_templates.h +++ b/monetdb5/modules/mosaic/mosaic_join_templates.h @@ -134,11 +134,10 @@ static inline str MOSjoinWithNilInfo_ID( if( (lci->tpe == cand_dense) && (rci->tpe != cand_dense)){ return MOSouterloopUncompressed_ID(TPE, NIL, NIL_SEMANTICS, canditer_next_dense, canditer_next)(task, l, lci, rci); } - if( (lci->tpe != cand_dense) && (rci->tpe != cand_dense)){ + else { + assert((lci->tpe != cand_dense) && (rci->tpe != cand_dense)); return MOSouterloopUncompressed_ID(TPE, NIL, NIL_SEMANTICS, canditer_next, canditer_next)(task, l, lci, rci); } - - assert(0); } #elif defined MOSjoin_DEFINITION @@ -156,11 +155,10 @@ static str MOSjoin_ID(TPE) (MOStask* tas if( maybe_nil && !nil_matches){ return MOSjoinWithNilInfo_ID(TPE, _maybeHasNil, _nilsDoNotMatch) (task, l, lci); } - if( !maybe_nil && !nil_matches){ + else { + assert (!maybe_nil && !nil_matches); return MOSjoinWithNilInfo_ID(TPE, _hasNoNil, _nilsDoNotMatch) (task, l, lci); } - - return MAL_SUCCEED; } // macro adiministration ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: default - Remove support for upgrading from pre-Mar2018...
Changeset: 1b5116853eb7 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1b5116853eb7 Modified Files: gdk/gdk.h gdk/gdk_bbp.c gdk/gdk_logger.c gdk/gdk_logger.h sql/backends/monet5/sql_upgrades.c Branch: default Log Message: Remove support for upgrading from pre-Mar2018 databases. diffs (truncated from 794 to 300 lines): diff --git a/gdk/gdk.h b/gdk/gdk.h --- a/gdk/gdk.h +++ b/gdk/gdk.h @@ -711,10 +711,8 @@ typedef struct { /* assert that atom width is power of 2, i.e., width == 1theap.farmid, srcdir, bnme, "tail", BAKDIR, bnme, "tail") != GDK_SUCCEED) { - GDKfree(srcdir); - TRC_CRITICAL(GDK, "cannot make backup of %s.tail\n", nme); - return GDK_FAIL; - } - /* load old heap */ - h1 = b->theap; - strconcat_len(h1.filename, sizeof(h1.filename), - filename, ".tail", NULL); - h1.base = NULL; - h1.dirty = false; - if (HEAPload(&h1, filename, "tail", false) != GDK_SUCCEED) { - GDKfree(srcdir); - TRC_CRITICAL(GDK, "loading old tail heap " -"for BAT %d failed\n", b->batCacheid); - return GDK_FAIL; - } - - /* create new heap */ - h2 = b->theap; - strconcat_len(h2.filename, sizeof(h2.filename), nme, ".tail", NULL); - if (HEAPalloc(&h2, b->batCapacity, b->twidth) != GDK_SUCCEED) { - GDKfree(srcdir); - HEAPfree(&h1, false); - TRC_CRITICAL(GDK, "allocating new tail heap " -"for BAT %d failed\n", b->batCacheid); - return GDK_FAIL; - } - h2.dirty = true; - h2.free = h1.free; - - switch (b->ttype) { - case TYPE_flt: { - const flt *restrict o = (const flt *) h1.base; - flt *restrict n = (flt *) h2.base; - - for (i = 0; i < b->batCount; i++) { - if (o[i] == GDK_flt_min) { - b->tnil = true; - n[i] = flt_nil; - nofix = false; - } else { - n[i] = o[i]; - } - } - break; - } - case TYPE_dbl: { - const dbl *restrict o = (const dbl *) h1.base; - dbl *restrict n = (dbl *) h2.base; - - for (i = 0; i < b->batCount; i++) { - if (o[i] == GDK_dbl_min) { - b->tnil = true; - n[i] = dbl_nil; - nofix = false; - } else { - n[i] = o[i]; - } - } - break; - } - default: { - struct mbr { - float xmin, ymin, xmax, ymax; - }; - const struct mbr *restrict o = (const struct mbr *) h1.base; - struct mbr *restrict n = (struct mbr *) h2.base; - - assert(strcmp(ATOMunknown_name(b->ttype), "mbr") == 0); - assert(b->twidth == 4 * sizeof(flt)); - - for (i = 0; i < b->batCount; i++) { - if (o[i].xmin == GDK_flt_min || - o[i].xmax == GDK_flt_min || - o[i].ymin == GDK_flt_min || - o[i].ymax == GDK_flt_min) { - b->tnil = true; - n[i].xmin = n[i].xmax = n[i].ymin = n[i].ymax = flt_nil; - nofix = false; - } else { - n[i] = o[i]; - } - } - break; - } - } - - /* cleanup */ - HEAPfree(&h1, false); - if (nofix) { - /* didn't fix anything, move backup back */ - HEAPfree(&h2, true); - if (GDKmove(b->theap.farmid, BAKDIR, bnme, "tail", srcdir, bnme, "tail") != GDK_SUCCEED) { - GDKfree(srcdir); - TRC_CRITICAL(GDK, "cannot restore backup of %s.tail\n", nme); - return GDK_FAIL; - } - } else { - /* heap was fixed */ - b->batDirtydesc = true; - if (HEAPsave(&h2, nm
MonetDB: Jun2020 - Related crash
Changeset: 6b2bda171a14 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6b2bda171a14 Modified Files: sql/test/subquery/Tests/subquery4.sql Branch: Jun2020 Log Message: Related crash diffs (12 lines): diff --git a/sql/test/subquery/Tests/subquery4.sql b/sql/test/subquery/Tests/subquery4.sql --- a/sql/test/subquery/Tests/subquery4.sql +++ b/sql/test/subquery/Tests/subquery4.sql @@ -194,6 +194,8 @@ SELECT 1 IN ((SELECT MIN(col2)), (SELECT DECLARE myvar INT; SELECT (SELECT i) INTO myvar FROM integers; --error, one row max +DECLARE ovar INT; +SET ovar = (SELECT (SELECT i) FROM integers); --error, one row max UPDATE another_T SET col1 = MIN(col1); --error, aggregates not allowed in update set clause UPDATE another_T SET col2 = 1 WHERE col1 = SUM(col2); --error, aggregates not allowed in update set clause ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: Jun2020 - Small bug fix, on SELECT INTO, the number of ...
Changeset: d38466ad88b6 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d38466ad88b6 Modified Files: sql/server/rel_psm.c sql/test/miscellaneous/Tests/simple_selects.sql sql/test/miscellaneous/Tests/simple_selects.stable.err sql/test/pg_regress/Tests/alter_table.stable.err sql/test/subquery/Tests/subquery4.sql Branch: Jun2020 Log Message: Small bug fix, on SELECT INTO, the number of variables must match the projected columns. I found another crash as well diffs (64 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 @@ -520,6 +520,8 @@ rel_select_into( sql_query *query, symbo r = rel_subquery(query, NULL, sq, ek); if (!r) return NULL; + if (list_length(r->exps) != dlist_length(into)) + return sql_error(sql, 02, SQLSTATE(21S01) "SELECT INTO: number of values doesn't match number of variables to set"); nl = sa_list(sql->sa); append(nl, exp_rel(sql, r)); for (m = r->exps->h, n = into->h; m && n; m = m->next, n = n->next) { diff --git a/sql/test/miscellaneous/Tests/simple_selects.sql b/sql/test/miscellaneous/Tests/simple_selects.sql --- a/sql/test/miscellaneous/Tests/simple_selects.sql +++ b/sql/test/miscellaneous/Tests/simple_selects.sql @@ -133,3 +133,5 @@ create table x (a int GENERATED ALWAYS A alter table x alter a drop default; --ok, remove sequence SELECT CAST(COUNT(*) - myvar AS BIGINT) FROM sequences; --the total count, cannot change drop table x; + +SELECT 1, 2 INTO myvar; --error, number of variables don't match diff --git a/sql/test/miscellaneous/Tests/simple_selects.stable.err b/sql/test/miscellaneous/Tests/simple_selects.stable.err --- a/sql/test/miscellaneous/Tests/simple_selects.stable.err +++ b/sql/test/miscellaneous/Tests/simple_selects.stable.err @@ -161,6 +161,10 @@ MAPI = (monetdb) /var/tmp/mtest-374801/ QUERY = create table x (a int default '1' GENERATED ALWAYS AS IDENTITY); --error, multiple default values ERROR = !The default value for a column should be passed as most once CODE = 42000 +MAPI = (monetdb) /var/tmp/mtest-106925/.s.monetdb.39578 +QUERY = SELECT 1, 2 INTO myvar; --error, number of variables don't match +ERROR = !SELECT INTO: number of values doesn't match number of variables to set +CODE = 21S01 # 17:31:38 > # 17:31:38 > "Done." diff --git a/sql/test/pg_regress/Tests/alter_table.stable.err b/sql/test/pg_regress/Tests/alter_table.stable.err --- a/sql/test/pg_regress/Tests/alter_table.stable.err +++ b/sql/test/pg_regress/Tests/alter_table.stable.err @@ -593,9 +593,9 @@ ERROR = !CREATE INDEX: no such column '. CODE = 42S22 MAPI = (monetdb) /var/tmp/mtest-30274/.s.monetdb.37685 QUERY = select * into test2 from atacc1; -ERROR = !SELECT INTO: variable 'test2' unknown -CODE = 42000 -MAPI = (monetdb) /var/tmp/mtest-30274/.s.monetdb.37685 +ERROR = !SELECT INTO: number of values doesn't match number of variables to set +CODE = 21S01 +MAPI = (monetdb) /var/tmp/mtest-106925/.s.monetdb.39578 QUERY = select * from test2; ERROR = !SELECT: no such table 'test2' CODE = 42S02 diff --git a/sql/test/subquery/Tests/subquery4.sql b/sql/test/subquery/Tests/subquery4.sql --- a/sql/test/subquery/Tests/subquery4.sql +++ b/sql/test/subquery/Tests/subquery4.sql @@ -192,6 +192,9 @@ SELECT i1.i, i2.i FROM integers i1, inte SELECT 1 IN ((SELECT MIN(col2)), (SELECT SUM(col4))) FROM another_t; -- False +DECLARE myvar INT; +SELECT (SELECT i) INTO myvar FROM integers; --error, one row max + UPDATE another_T SET col1 = MIN(col1); --error, aggregates not allowed in update set clause UPDATE another_T SET col2 = 1 WHERE col1 = SUM(col2); --error, aggregates not allowed in update set clause UPDATE another_T SET col3 = (SELECT MAX(col5)); --error, aggregates not allowed in update set clause ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: Jun2020 - Use bool.
Changeset: 3cc700876422 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3cc700876422 Modified Files: tools/merovingian/daemon/argvcmds.c tools/merovingian/daemon/controlrunner.c tools/merovingian/daemon/discoveryrunner.c tools/merovingian/daemon/merovingian.c tools/merovingian/daemon/multiplex-funnel.c tools/merovingian/daemon/multiplex-funnel.h Branch: Jun2020 Log Message: Use bool. diffs (217 lines): diff --git a/tools/merovingian/daemon/argvcmds.c b/tools/merovingian/daemon/argvcmds.c --- a/tools/merovingian/daemon/argvcmds.c +++ b/tools/merovingian/daemon/argvcmds.c @@ -387,7 +387,7 @@ command_set(confkeyval *ckv, int argc, c return(1); } if (strcmp(property, "passphrase") == 0) { - char dohash = 1; + bool dohash = true; /* allow to either set a hash ({X}xxx), or convert the given * string to its hash */ if (*p == '{') { @@ -401,10 +401,10 @@ command_set(confkeyval *ckv, int argc, c return(1); } *q = '}'; - dohash = 0; + dohash = false; } } - if (dohash == 1) { + if (dohash) { p = mcrypt_BackendSum(p, strlen(p)); if(p) { snprintf(h, sizeof(h), "{%s}%s", MONETDB5_PASSWDHASH, p); diff --git a/tools/merovingian/daemon/controlrunner.c b/tools/merovingian/daemon/controlrunner.c --- a/tools/merovingian/daemon/controlrunner.c +++ b/tools/merovingian/daemon/controlrunner.c @@ -724,7 +724,7 @@ static void ctl_handle_client( } } else if (strchr(p, '=') != NULL) { /* set */ char *val; - char doshare = 0; + bool doshare = false; if ((e = msab_getStatus(&stats, q)) != NULL) { len = snprintf(buf2, sizeof(buf2), @@ -750,7 +750,7 @@ static void ctl_handle_client( if (*val == '\0') val = NULL; - if ((doshare = !strcmp(p, "shared"))) { + if ((doshare = strcmp(p, "shared") == 0)) { /* bail out if we don't do discovery at all */ if (getConfNum(_mero_props, "discovery") == 0) { len = snprintf(buf2, sizeof(buf2), diff --git a/tools/merovingian/daemon/discoveryrunner.c b/tools/merovingian/daemon/discoveryrunner.c --- a/tools/merovingian/daemon/discoveryrunner.c +++ b/tools/merovingian/daemon/discoveryrunner.c @@ -45,12 +45,12 @@ broadcast(char *msg) "message: %s\n", strerror(errno)); } -static int +static bool removeRemoteDB(const char *dbname, const char *conn) { remotedb rdb; remotedb prv; - char hadmatch = 0; + bool hadmatch = false; pthread_mutex_lock(&_mero_remotedb_lock); @@ -80,7 +80,7 @@ removeRemoteDB(const char *dbname, const free(rdb->fullname); free(rdb); rdb = prv; - hadmatch = 1; + hadmatch = true; /* in the future, there may be more, so keep looking */ } prv = rdb; @@ -475,7 +475,7 @@ discoveryRunner(void *d) if (dbname == NULL || conn == NULL) continue; - if (removeRemoteDB(dbname, conn) == 0) + if (!removeRemoteDB(dbname, conn)) Mfprintf(_mero_discout, "received leave request for unknown database " "%s%s from %s\n", conn, dbname, host); diff --git a/tools/merovingian/daemon/merovingian.c b/tools/merovingian/daemon/merovingian.c --- a/tools/merovingian/daemon/merovingian.c +++ b/tools/merovingian/daemon/merovingian.c @@ -563,7 +563,7 @@ main(int argc, char *argv[]) #define MERO_EXIT(status) \ do { \ if (!merodontfork) { \ - char s = status;
MonetDB: hot-snapshot - Plug one memory leak
Changeset: bbff7344302c for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=bbff7344302c Modified Files: tools/merovingian/client/monetdb.c Branch: hot-snapshot Log Message: Plug one memory leak diffs (13 lines): diff --git a/tools/merovingian/client/monetdb.c b/tools/merovingian/client/monetdb.c --- a/tools/merovingian/client/monetdb.c +++ b/tools/merovingian/client/monetdb.c @@ -2107,7 +2107,8 @@ command_snapshot_restore(int argc, char // check if the database exists sabdb *db = NULL; - MEROgetStatus(&db, dbname); // ignore errors + char *e = MEROgetStatus(&db, dbname); // ignore errors + free(e); if (db != NULL && !force) { char answ; ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: default - Merge with Jun2020 branch.
Changeset: 0bcd8eb11a87 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0bcd8eb11a87 Added Files: sql/test/BugTracker-2016/Tests/decimal_vs_integer.Bug-3941.stable.out.single Modified Files: common/utils/msabaoth.c monetdb5/optimizer/opt_mergetable.c sql/test/BugTracker-2016/Tests/decimal_vs_integer.Bug-3941.stable.out sql/test/subquery/Tests/subquery4.sql tools/merovingian/daemon/client.c tools/merovingian/daemon/controlrunner.c tools/merovingian/daemon/forkmserver.c tools/merovingian/daemon/handlers.c tools/merovingian/daemon/merovingian.c tools/merovingian/daemon/merovingian.h tools/merovingian/daemon/multiplex-funnel.c Branch: default Log Message: Merge with Jun2020 branch. diffs (truncated from 1392 to 300 lines): diff --git a/common/utils/msabaoth.c b/common/utils/msabaoth.c --- a/common/utils/msabaoth.c +++ b/common/utils/msabaoth.c @@ -617,7 +617,7 @@ msab_getSingleStatus(const char *pathbuf */ snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname, _sabaoth_internal_uuid); - if (stat(buf, &statbuf) != -1) { + if (stat(buf, &statbuf) == 0) { /* database has the same process signature as ours, which * means, it must be us, rely on the uplog state */ snprintf(log, sizeof(log), "%s/%s/%s", pathbuf, dbname, UPLOGFILE); @@ -641,7 +641,7 @@ msab_getSingleStatus(const char *pathbuf (void)fclose(f); } } else if (snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname, ".gdk_lock"), - ((fd = MT_lockf(buf, F_TEST)) == -2)) { + ((fd = MT_lockf(buf, F_TLOCK)) == -2)) { /* Locking failed; this can be because the lockfile couldn't * be created. Probably there is no Mserver running for * that case also. @@ -650,15 +650,18 @@ msab_getSingleStatus(const char *pathbuf } else if (fd == -1) { /* file is locked, so mserver is running, see if the database * has finished starting */ - snprintf(buf, sizeof(buf), "%s/%s/%s", -pathbuf, dbname, STARTEDFILE); + snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname, STARTEDFILE); if (stat(buf, &statbuf) == -1) { sdb->state = SABdbStarting; } else { sdb->state = SABdbRunning; } } else { - /* file is not locked, check for a crash in the uplog */ + /* file was not locked (we just locked it), check for a crash +* in the uplog */ + snprintf(log, sizeof(log), "%s/%s/%s", pathbuf, dbname, STARTEDFILE); + /* just to be sure, remove the .started file */ + (void) remove(log); /* may fail, that's fine */ snprintf(log, sizeof(log), "%s/%s/%s", pathbuf, dbname, UPLOGFILE); if ((f = fopen(log, "r")) != NULL) { (void)fseek(f, -1, SEEK_END); @@ -675,28 +678,27 @@ msab_getSingleStatus(const char *pathbuf /* no uplog, so presumably never started */ sdb->state = SABdbInactive; } + MT_lockf(buf, F_ULOCK); + close(fd); } snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname, MAINTENANCEFILE); - sdb->locked = stat(buf, &statbuf) != -1; + sdb->locked = stat(buf, &statbuf) == 0; /* add scenarios that are supported */ sdb->scens = NULL; snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname, SCENARIOFILE); if ((f = fopen(buf, "r")) != NULL) { sablist* np = NULL; - while (fgets(data, 8095, f) != NULL) { + while (fgets(data, (int) sizeof(data), f) != NULL) { if (*data != '\0' && data[strlen(data) - 1] == '\n') data[strlen(data) - 1] = '\0'; if (sdb->scens == NULL) { - sdb->scens = malloc(sizeof(sablist)); - sdb->scens->val = strdup(data); - sdb->scens->next = NULL; - np = sdb->scens; + np = sdb->scens = malloc(sizeof(sablist)); } else { np = np->next = malloc(sizeof(sablist)); - np->val = strdup(data); - np->next = NULL; } + np->val = strdup(data); + np->next = NULL; } (void)fclose(f); } @@ -706,19 +708,16 @@ msab_getSingleStatus(const
MonetDB: Jun2020 - Merge with linear-hashing branch.
Changeset: c57cfbc65dac for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c57cfbc65dac Modified Files: common/utils/msabaoth.c tools/merovingian/daemon/client.c tools/merovingian/daemon/controlrunner.c tools/merovingian/daemon/forkmserver.c tools/merovingian/daemon/handlers.c tools/merovingian/daemon/merovingian.c tools/merovingian/daemon/merovingian.h tools/merovingian/daemon/multiplex-funnel.c Branch: Jun2020 Log Message: Merge with linear-hashing branch. diffs (truncated from 1068 to 300 lines): diff --git a/common/utils/msabaoth.c b/common/utils/msabaoth.c --- a/common/utils/msabaoth.c +++ b/common/utils/msabaoth.c @@ -617,7 +617,7 @@ msab_getSingleStatus(const char *pathbuf */ snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname, _sabaoth_internal_uuid); - if (stat(buf, &statbuf) != -1) { + if (stat(buf, &statbuf) == 0) { /* database has the same process signature as ours, which * means, it must be us, rely on the uplog state */ snprintf(log, sizeof(log), "%s/%s/%s", pathbuf, dbname, UPLOGFILE); @@ -641,7 +641,7 @@ msab_getSingleStatus(const char *pathbuf (void)fclose(f); } } else if (snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname, ".gdk_lock"), - ((fd = MT_lockf(buf, F_TEST)) == -2)) { + ((fd = MT_lockf(buf, F_TLOCK)) == -2)) { /* Locking failed; this can be because the lockfile couldn't * be created. Probably there is no Mserver running for * that case also. @@ -650,15 +650,18 @@ msab_getSingleStatus(const char *pathbuf } else if (fd == -1) { /* file is locked, so mserver is running, see if the database * has finished starting */ - snprintf(buf, sizeof(buf), "%s/%s/%s", -pathbuf, dbname, STARTEDFILE); + snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname, STARTEDFILE); if (stat(buf, &statbuf) == -1) { sdb->state = SABdbStarting; } else { sdb->state = SABdbRunning; } } else { - /* file is not locked, check for a crash in the uplog */ + /* file was not locked (we just locked it), check for a crash +* in the uplog */ + snprintf(log, sizeof(log), "%s/%s/%s", pathbuf, dbname, STARTEDFILE); + /* just to be sure, remove the .started file */ + (void) remove(log); /* may fail, that's fine */ snprintf(log, sizeof(log), "%s/%s/%s", pathbuf, dbname, UPLOGFILE); if ((f = fopen(log, "r")) != NULL) { (void)fseek(f, -1, SEEK_END); @@ -675,28 +678,27 @@ msab_getSingleStatus(const char *pathbuf /* no uplog, so presumably never started */ sdb->state = SABdbInactive; } + MT_lockf(buf, F_ULOCK); + close(fd); } snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname, MAINTENANCEFILE); - sdb->locked = stat(buf, &statbuf) != -1; + sdb->locked = stat(buf, &statbuf) == 0; /* add scenarios that are supported */ sdb->scens = NULL; snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname, SCENARIOFILE); if ((f = fopen(buf, "r")) != NULL) { sablist* np = NULL; - while (fgets(data, 8095, f) != NULL) { + while (fgets(data, (int) sizeof(data), f) != NULL) { if (*data != '\0' && data[strlen(data) - 1] == '\n') data[strlen(data) - 1] = '\0'; if (sdb->scens == NULL) { - sdb->scens = malloc(sizeof(sablist)); - sdb->scens->val = strdup(data); - sdb->scens->next = NULL; - np = sdb->scens; + np = sdb->scens = malloc(sizeof(sablist)); } else { np = np->next = malloc(sizeof(sablist)); - np->val = strdup(data); - np->next = NULL; } + np->val = strdup(data); + np->next = NULL; } (void)fclose(f); } @@ -706,19 +708,16 @@ msab_getSingleStatus(const char *pathbuf snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname, CONNECTIONFILE); if ((f = fopen(buf, "r")) != NULL) { sablist* np = NULL; - while (fgets(data, 8095, f) != NULL) { + while (fgets(
MonetDB: linear-hashing - Merge with Nov2019 branch.
Changeset: 1743f91141a6 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1743f91141a6 Modified Files: common/utils/msabaoth.c tools/merovingian/daemon/client.c tools/merovingian/daemon/controlrunner.c tools/merovingian/daemon/forkmserver.c tools/merovingian/daemon/handlers.c tools/merovingian/daemon/merovingian.c tools/merovingian/daemon/merovingian.h tools/merovingian/daemon/multiplex-funnel.c Branch: linear-hashing Log Message: Merge with Nov2019 branch. diffs (truncated from 1068 to 300 lines): diff --git a/common/utils/msabaoth.c b/common/utils/msabaoth.c --- a/common/utils/msabaoth.c +++ b/common/utils/msabaoth.c @@ -617,7 +617,7 @@ msab_getSingleStatus(const char *pathbuf */ snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname, _sabaoth_internal_uuid); - if (stat(buf, &statbuf) != -1) { + if (stat(buf, &statbuf) == 0) { /* database has the same process signature as ours, which * means, it must be us, rely on the uplog state */ snprintf(log, sizeof(log), "%s/%s/%s", pathbuf, dbname, UPLOGFILE); @@ -641,7 +641,7 @@ msab_getSingleStatus(const char *pathbuf (void)fclose(f); } } else if (snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname, ".gdk_lock"), - ((fd = MT_lockf(buf, F_TEST)) == -2)) { + ((fd = MT_lockf(buf, F_TLOCK)) == -2)) { /* Locking failed; this can be because the lockfile couldn't * be created. Probably there is no Mserver running for * that case also. @@ -650,15 +650,18 @@ msab_getSingleStatus(const char *pathbuf } else if (fd == -1) { /* file is locked, so mserver is running, see if the database * has finished starting */ - snprintf(buf, sizeof(buf), "%s/%s/%s", -pathbuf, dbname, STARTEDFILE); + snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname, STARTEDFILE); if (stat(buf, &statbuf) == -1) { sdb->state = SABdbStarting; } else { sdb->state = SABdbRunning; } } else { - /* file is not locked, check for a crash in the uplog */ + /* file was not locked (we just locked it), check for a crash +* in the uplog */ + snprintf(log, sizeof(log), "%s/%s/%s", pathbuf, dbname, STARTEDFILE); + /* just to be sure, remove the .started file */ + (void) remove(log); /* may fail, that's fine */ snprintf(log, sizeof(log), "%s/%s/%s", pathbuf, dbname, UPLOGFILE); if ((f = fopen(log, "r")) != NULL) { (void)fseek(f, -1, SEEK_END); @@ -675,28 +678,27 @@ msab_getSingleStatus(const char *pathbuf /* no uplog, so presumably never started */ sdb->state = SABdbInactive; } + MT_lockf(buf, F_ULOCK); + close(fd); } snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname, MAINTENANCEFILE); - sdb->locked = stat(buf, &statbuf) != -1; + sdb->locked = stat(buf, &statbuf) == 0; /* add scenarios that are supported */ sdb->scens = NULL; snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname, SCENARIOFILE); if ((f = fopen(buf, "r")) != NULL) { sablist* np = NULL; - while (fgets(data, 8095, f) != NULL) { + while (fgets(data, (int) sizeof(data), f) != NULL) { if (*data != '\0' && data[strlen(data) - 1] == '\n') data[strlen(data) - 1] = '\0'; if (sdb->scens == NULL) { - sdb->scens = malloc(sizeof(sablist)); - sdb->scens->val = strdup(data); - sdb->scens->next = NULL; - np = sdb->scens; + np = sdb->scens = malloc(sizeof(sablist)); } else { np = np->next = malloc(sizeof(sablist)); - np->val = strdup(data); - np->next = NULL; } + np->val = strdup(data); + np->next = NULL; } (void)fclose(f); } @@ -706,19 +708,16 @@ msab_getSingleStatus(const char *pathbuf snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname, CONNECTIONFILE); if ((f = fopen(buf, "r")) != NULL) { sablist* np = NULL; - while (fgets(data, 8095, f) != NULL) { + while (fgets(
MonetDB: Nov2019 - Fixed a bunch of race conditions + some code ...
Changeset: 9d2c0c613846 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9d2c0c613846 Modified Files: common/utils/msabaoth.c tools/merovingian/daemon/client.c tools/merovingian/daemon/controlrunner.c tools/merovingian/daemon/forkmserver.c tools/merovingian/daemon/handlers.c tools/merovingian/daemon/merovingian.c tools/merovingian/daemon/merovingian.h tools/merovingian/daemon/multiplex-funnel.c Branch: Nov2019 Log Message: Fixed a bunch of race conditions + some code cleanup. When an mserver crashes, it leaves behind the .started file. If a new mserver is then started, it first locks the database and then, later, removes the .started file. In the intervening time, the database seems up (locked and .started file present) but isn't yet, causing errors for new connections. Apparently other things could go wrong as well causing the internal state of monetdbd to become confused and causing messages about an "impossible state". We now use a per database lock inside monetdbd when checking whether a server is up. This means that if there are multiple clients connecting, they all have to wait until the server is back up. We also remove the .started file before starting the server. The only drawback is that the internal list of databases past and present is never cleaned up. If this becomes a problem, we need to implement a fix for that. This needs more testing. diffs (truncated from 1068 to 300 lines): diff --git a/common/utils/msabaoth.c b/common/utils/msabaoth.c --- a/common/utils/msabaoth.c +++ b/common/utils/msabaoth.c @@ -611,7 +611,7 @@ msab_getSingleStatus(const char *pathbuf */ snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname, _sabaoth_internal_uuid); - if (stat(buf, &statbuf) != -1) { + if (stat(buf, &statbuf) == 0) { /* database has the same process signature as ours, which * means, it must be us, rely on the uplog state */ snprintf(log, sizeof(log), "%s/%s/%s", pathbuf, dbname, UPLOGFILE); @@ -635,7 +635,7 @@ msab_getSingleStatus(const char *pathbuf (void)fclose(f); } } else if (snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname, ".gdk_lock"), - ((fd = MT_lockf(buf, F_TEST, 4, 1)) == -2)) { + ((fd = MT_lockf(buf, F_TLOCK, 4, 1)) == -2)) { /* Locking failed; this can be because the lockfile couldn't * be created. Probably there is no Mserver running for * that case also. @@ -644,15 +644,18 @@ msab_getSingleStatus(const char *pathbuf } else if (fd == -1) { /* file is locked, so mserver is running, see if the database * has finished starting */ - snprintf(buf, sizeof(buf), "%s/%s/%s", -pathbuf, dbname, STARTEDFILE); + snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname, STARTEDFILE); if (stat(buf, &statbuf) == -1) { sdb->state = SABdbStarting; } else { sdb->state = SABdbRunning; } } else { - /* file is not locked, check for a crash in the uplog */ + /* file was not locked (we just locked it), check for a crash +* in the uplog */ + snprintf(log, sizeof(log), "%s/%s/%s", pathbuf, dbname, STARTEDFILE); + /* just to be sure, remove the .started file */ + (void) remove(log); /* may fail, that's fine */ snprintf(log, sizeof(log), "%s/%s/%s", pathbuf, dbname, UPLOGFILE); if ((f = fopen(log, "r")) != NULL) { (void)fseek(f, -1, SEEK_END); @@ -669,28 +672,27 @@ msab_getSingleStatus(const char *pathbuf /* no uplog, so presumably never started */ sdb->state = SABdbInactive; } + MT_lockf(buf, F_ULOCK, 4, 1); + close(fd); } snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname, MAINTENANCEFILE); - sdb->locked = stat(buf, &statbuf) != -1; + sdb->locked = stat(buf, &statbuf) == 0; /* add scenarios that are supported */ sdb->scens = NULL; snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname, SCENARIOFILE); if ((f = fopen(buf, "r")) != NULL) { sablist* np = NULL; - while (fgets(data, 8095, f) != NULL) { + while (fgets(data, (int) sizeof(data), f) != NULL) { if (*data != '\0' && data[strlen(data) - 1] == '\n') data[strlen(data) - 1] = '\0'; if (sdb->scens == NULL) { - sdb->scens = malloc(sizeof(sablist)); -
MonetDB: scoping - Simplify
Changeset: dcf2f691dae5 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=dcf2f691dae5 Modified Files: sql/server/rel_select.c Branch: scoping Log Message: Simplify diffs (18 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 @@ -1158,11 +1158,9 @@ rel_column_ref(sql_query *query, sql_rel } if (!exp) { /* If no column was found, try a variable */ sql_schema *s = cur_schema(sql); - if (s) { - int var = stack_find_var(sql, s, name); /* find one */ - if (var) - return rel_var_ref(sql, s->base.name, name); - } + int var = stack_find_var(sql, s, name); /* find one */ + if (var) + return rel_var_ref(sql, s->base.name, name); } if (!exp) ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: hot-snapshot - Snapshots were not being compressed
Changeset: c0776e55e13c for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c0776e55e13c Modified Files: sql/storage/store.c Branch: hot-snapshot Log Message: Snapshots were not being compressed Because the streams library compresses based on the file extension and our temporary files had extension .tmp. diffs (91 lines): diff --git a/sql/storage/store.c b/sql/storage/store.c --- a/sql/storage/store.c +++ b/sql/storage/store.c @@ -2567,13 +2567,50 @@ end: return ret; } +/* Pick a name for the temporary tar file. Make sure it has the same extension + * so as not to confuse the streams library. + * + * This function is not entirely safe as compare to for example mkstemp. + */ +static str pick_tmp_name(str filename) +{ + str name = GDKmalloc(strlen(filename) + 10); + if (name == NULL) { + GDKerror("malloc failed"); + return NULL; + } + strcpy(name, filename); + + // Look for an extension. + // Make sure it's part of the basename + + char *ext = strrchr(name, '.'); + char *sep = strrchr(name, DIR_SEP); + char *slash = strrchr(name, '/'); // on Windows, / and \ both work + if (ext != NULL && sep != NULL && sep > ext) + ext = NULL; + else if (ext != NULL && slash != NULL && slash > ext) + ext = NULL; + + if (ext == NULL) { + return strcat(name, "..tmp"); + } else { + char *tmp = "..tmp."; + size_t tmplen = strlen(tmp); + memmove(ext + tmplen, ext, strlen(ext) + 1); + memmove(ext, tmp, tmplen); + } + + return name; +} + extern lng store_hot_snapshot(str tarfile) { int locked = 0; lng result = 0; - char tmppath[FILENAME_MAX]; - char dirpath[FILENAME_MAX]; + char *tmppath = NULL; + char *dirpath = NULL; int do_remove = 0; int dir_fd = -1; stream *tar_stream = NULL; @@ -2586,7 +2623,10 @@ store_hot_snapshot(str tarfile) goto end; } - snprintf(tmppath, sizeof(tmppath), "%s.tmp", tarfile); + tmppath = pick_tmp_name(tarfile); + if (tmppath == NULL) { + goto end; + } tar_stream = open_wstream(tmppath); if (!tar_stream) { GDKerror("Failed to open %s for writing", tmppath); @@ -2604,7 +2644,12 @@ store_hot_snapshot(str tarfile) // Call realpath(2) to make the path absolute so it has at least // one DIR_SEP in it. Realpath requires the file to exist so // we feed it tmppath rather than tarfile. - if (realpath(tmppath, dirpath) == NULL) { // ERROR no realpath + dirpath = GDKmalloc(PATH_MAX); + if (dirpath == NULL) { + GDKerror("malloc failed"); + goto end; + } + if (realpath(tmppath, dirpath) == NULL) { GDKerror("couldn't resolve path %s: %s", tarfile, strerror(errno)); goto end; } @@ -2682,6 +2727,8 @@ store_hot_snapshot(str tarfile) result = 42; end: + GDKfree(tmppath); + GDKfree(dirpath); if (dir_fd >= 0) close(dir_fd); if (locked) ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: hot-snapshot - Properly emit zeros-block at end of tar ...
Changeset: e9a9ff62df4b for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e9a9ff62df4b Modified Files: sql/storage/store.c Branch: hot-snapshot Log Message: Properly emit zeros-block at end of tar file diffs (16 lines): diff --git a/sql/storage/store.c b/sql/storage/store.c --- a/sql/storage/store.c +++ b/sql/storage/store.c @@ -2554,7 +2554,11 @@ hot_snapshot_write_tar(stream *out, cons goto end; } } - ret = GDK_SUCCEED; + + // write a trailing block of zeros. If it succeeds, this function succeeds. + char a; + a = '\0'; + ret = tar_write(out, &a, 1); end: free(plan); ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: hot-snapshot - Fsync appropriately when restoring a sna...
Changeset: 848010420450 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=848010420450 Modified Files: tools/merovingian/daemon/snapshot.c Branch: hot-snapshot Log Message: Fsync appropriately when restoring a snapshot diffs (176 lines): diff --git a/tools/merovingian/daemon/snapshot.c b/tools/merovingian/daemon/snapshot.c --- a/tools/merovingian/daemon/snapshot.c +++ b/tools/merovingian/daemon/snapshot.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -24,6 +25,12 @@ #include "stream.h" #include "utils/database.h" +struct dir_helper { + char *dir; + int fd; +}; + +static err prepare_directory(struct dir_helper *state, char *prefix_dir, char *dir); static bool parse_snapshot_name(const char *filename, char **dbname, time_t *timestamp); static err validate_location(const char *path); static err unpack_tarstream(stream *tarstream, char *destdir, int skipcomponents); @@ -408,6 +415,106 @@ bailout: return e; } +/* Create the directory 'filename' is in, if necessary, and take care + * of fsync'ing it first when called with a different `dir`. Wrap up if + * filename is set to NULL. + */ +static err +prepare_directory(struct dir_helper *state, char *prefix_dir, char *filename) +{ + char *e = NO_ERR; + size_t file_len; + size_t prefix_len; + int ret; + int fd; + char *dir_buf = NULL; + char *dir = NULL; + + if (filename != NULL) { + dir_buf = strdup(filename); + dir = dirname(dir_buf); + } + + // If we are already tracking a directory and this one is the same, + // there's no need to do anything. + if (dir != NULL && state->dir != NULL && strcmp(state->dir, dir) == 0) { + free(dir_buf); + return NULL; + } + + // Before switching to the new directory, first fsync the old one, if any. + if (state->dir != NULL) { + if (fsync(state->fd) < 0) { + e = newErr("fsync %s: %s", state->dir, strerror(errno)); + goto bailout; + } + if (close(state->fd) < 0) { + e = newErr("close %s: %s", state->dir, strerror(errno)); + state->fd = 0; + goto bailout; + } + state->fd = -1; + free(state->dir); + state->dir = NULL; + } + + if (dir == NULL) { + // no new directory to set up, we just had to sync the current one + return NO_ERR; + } + + // Error checking on the new file. + file_len = strlen(filename); + prefix_len = strlen(prefix_dir); + if (prefix_len > file_len || strncmp(filename, prefix_dir, prefix_len) != 0) { + e = newErr("File '%s' is not inside prefix '%s'", filename, prefix_dir); + goto bailout; + } + + // Create any missing directories beyond the prefix. + for (char *p = dir + prefix_len + 1; *p != '\0'; p++) { + if (*p == '/') { + *p = '\0'; + ret = mkdir(dir, 0755); + if (ret < 0 && errno != EEXIST) { + e = newErr("Could not create directory %s: %s", dir, strerror(errno)); + *p = '/'; + goto bailout; + } + *p = '/'; + } + } + // The final part of the directory is not covered by the loop above + ret = mkdir(dir, 0755); + if (ret < 0 && errno != EEXIST) { + e = newErr("Could not create directory %s: %s", dir, strerror(errno)); + goto bailout; + } + + // Open the directory so we can fsync it later + fd = open(dir, O_RDONLY); + if (fd < 0) { + e = newErr("couldn't open directory %s: %s", dir, strerror(errno)); + goto bailout; + } + + state->fd = fd; + state->dir = strdup(dir); + + free(dir_buf); + return NULL; +bailout: + free(dir_buf); + if (state->fd > 0) { + close(state->fd); + state->fd = -1; + } + free(state->dir); + state->dir = NULL; + return e; +} + + #define TAR_BLOCK_SIZE (512) /* Read a full block from the stream. @@ -488,6 +595,7 @@ unpack_tarstream(stream *tarstream, char char *whole_filename = NULL; char *destfile = NULL; FILE *outfile = NULL; + struct dir_helper dirhelper = {NULL}; while (read_tar_block(tarstream, block, &e) >= 0) { if (e != NO_ERR) @@ -513,18 +621,8 @@ unpack_tarstream(stream *tarstream, char destfile = realloc(destfile, strlen(destdir) + 1 + strlen(useful_part) + 1); sprintf(destfile, "%s/%s", destdir
MonetDB: hot-snapshot - Retain ability to restore to nonexistent...
Changeset: 0cdd0ba6a014 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0cdd0ba6a014 Modified Files: tools/merovingian/client/monetdb.c Branch: hot-snapshot Log Message: Retain ability to restore to nonexistent database diffs (17 lines): diff --git a/tools/merovingian/client/monetdb.c b/tools/merovingian/client/monetdb.c --- a/tools/merovingian/client/monetdb.c +++ b/tools/merovingian/client/monetdb.c @@ -2107,11 +2107,8 @@ command_snapshot_restore(int argc, char // check if the database exists sabdb *db = NULL; - char *err = MEROgetStatus(&db, dbname); - if (err != NULL) { - fprintf(stderr, "snapshot restore: could not look up database '%s': %s", dbname, err); - exit(2); - } + MEROgetStatus(&db, dbname); // ignore errors + if (db != NULL && !force) { char answ; printf("you are about to overwrite database '%s'.\n", db->dbname); ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: scoping - Server runs sql/test directory. Declared vari...
Changeset: fd5cc9b32190 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=fd5cc9b32190 Modified Files: sql/backends/monet5/rel_bin.c sql/backends/monet5/sql.c sql/backends/monet5/sql_statement.c sql/backends/monet5/sql_statement.h sql/rel.txt sql/server/rel_exp.c sql/server/rel_exp.h sql/server/rel_psm.c sql/server/rel_select.c sql/test/miscellaneous/Tests/scoping.sql Branch: scoping Log Message: Server runs sql/test directory. Declared variables now have a schema. Next step, fix frame level and variable resolution order diffs (truncated from 361 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 @@ -543,12 +543,12 @@ exp_bin(backend *be, sql_exp *e, stmt *l return NULL; if (e->card <= CARD_ATOM && r->nrcols > 0) /* single value, get result from bat */ r = stmt_fetch(be, r); - return stmt_assign(be, exp_name(e), r, GET_PSM_LEVEL(e->flag)); + return stmt_assign(be, exp_relname(e), exp_name(e), r, GET_PSM_LEVEL(e->flag)); } else if (e->flag & PSM_VAR) { if (e->f) - return stmt_vars(be, exp_name(e), e->f, 1, GET_PSM_LEVEL(e->flag)); + return stmt_vars(be, exp_relname(e), exp_name(e), e->f, 1, GET_PSM_LEVEL(e->flag)); else - return stmt_var(be, exp_name(e), &e->tpe, 1, GET_PSM_LEVEL(e->flag)); + return stmt_var(be, exp_relname(e), exp_name(e), &e->tpe, 1, GET_PSM_LEVEL(e->flag)); } else if (e->flag & PSM_RETURN) { sql_exp *l = e->l; stmt *r = exp_bin(be, l, left, right, grp, ext, cnt, sel); @@ -628,7 +628,7 @@ exp_bin(backend *be, sql_exp *e, stmt *l atom *a = e->l; s = stmt_atom(be, atom_dup(sql->sa, a)); } else if (e->r) { /* parameters */ - s = stmt_var(be, sa_strdup(sql->sa, e->r), e->tpe.type?&e->tpe:NULL, 0, e->flag); + s = stmt_var(be, e->alias.rname ? sa_strdup(sql->sa, e->alias.rname) : NULL, sa_strdup(sql->sa, e->alias.name), e->tpe.type?&e->tpe:NULL, 0, e->flag); } else if (e->f) { /* values */ s = value_list(be, e->f, left, sel); } else {/* arguments */ @@ -674,7 +674,7 @@ exp_bin(backend *be, sql_exp *e, stmt *l if (exps) { int nrcols = 0; -if (sel && strcmp(sql_func_mod(f->func), "calc") == 0 && strcmp(sql_func_imp(f->func), "ifthenelse") != 0) + if (sel && strcmp(sql_func_mod(f->func), "calc") == 0 && strcmp(sql_func_imp(f->func), "ifthenelse") != 0) push_cands = 1; for (en = exps->h; en; en = en->next) { @@ -741,7 +741,7 @@ exp_bin(backend *be, sql_exp *e, stmt *l if (cond_execution) { /* var_x = nil; */ nme = number2name(name, sizeof(name), ++sql->label); - (void)stmt_var(be, nme, exp_subtype(e), 1, 2); + (void)stmt_var(be, NULL, nme, exp_subtype(e), 1, 2); /* if_barrier ... */ cond_execution = stmt_cond(be, cond_execution, NULL, 0, 0); } @@ -755,10 +755,10 @@ exp_bin(backend *be, sql_exp *e, stmt *l s->cand = sel; if (cond_execution) { /* var_x = s */ - (void)stmt_assign(be, nme, s, 2); + (void)stmt_assign(be, NULL, nme, s, 2); /* endif_barrier */ (void)stmt_control_end(be, cond_execution); - s = stmt_var(be, nme, exp_subtype(e), 0, 2); + s = stmt_var(be, NULL, nme, exp_subtype(e), 0, 2); } } break; case e_aggr: { @@ -1622,7 +1622,7 @@ exp2bin_args(backend *be, sql_exp *e, li snprintf(nme, sizeof(nme), "A%s", (char*)e->r); if (!list_find(args, nme, (fcmp)&alias_cmp)) { - stmt *s = stmt_var(be, e->r, &e->tpe, 0, 0); + stmt *s = stmt_var(be, NULL, e->r, &e->tpe, 0, 0); s = stmt_alias(be, s, NULL, sa_strdup(sql->sa, nme)); list_append(args, s); diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c --- a/sql/backends/monet5/sql.c +++ b/sql/backends/mone
MonetDB: Jun2020 - Query giving MAL error. I think we have to ch...
Changeset: e745682c66a1 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e745682c66a1 Modified Files: sql/test/subquery/Tests/subquery4.sql Branch: Jun2020 Log Message: Query giving MAL error. I think we have to check for type coercion for the IN elements in case of subqueries. My routine everyday starts by writing random queries for 15 minutes, in order to find bugs :) diffs (13 lines): diff --git a/sql/test/subquery/Tests/subquery4.sql b/sql/test/subquery/Tests/subquery4.sql --- a/sql/test/subquery/Tests/subquery4.sql +++ b/sql/test/subquery/Tests/subquery4.sql @@ -189,6 +189,9 @@ SELECT i1.i, i2.i FROM integers i1, inte -- 33 -- 3NULL +SELECT 1 IN ((SELECT MIN(col2)), (SELECT SUM(col4))) FROM another_t; + -- False + UPDATE another_T SET col1 = MIN(col1); --error, aggregates not allowed in update set clause UPDATE another_T SET col2 = 1 WHERE col1 = SUM(col2); --error, aggregates not allowed in update set clause UPDATE another_T SET col3 = (SELECT MAX(col5)); --error, aggregates not allowed in update set clause ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: Jun2020 - Approved single threaded output
Changeset: 07edf1b0d963 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=07edf1b0d963 Added Files: sql/test/BugTracker-2016/Tests/decimal_vs_integer.Bug-3941.stable.out.single Modified Files: sql/test/BugTracker-2016/Tests/decimal_vs_integer.Bug-3941.stable.out Branch: Jun2020 Log Message: Approved single threaded output diffs (299 lines): diff --git a/sql/test/BugTracker-2016/Tests/decimal_vs_integer.Bug-3941.stable.out b/sql/test/BugTracker-2016/Tests/decimal_vs_integer.Bug-3941.stable.out --- a/sql/test/BugTracker-2016/Tests/decimal_vs_integer.Bug-3941.stable.out +++ b/sql/test/BugTracker-2016/Tests/decimal_vs_integer.Bug-3941.stable.out @@ -1,32 +1,9 @@ stdout of test 'decimal_vs_integer.Bug-3941` in directory 'sql/test/BugTracker-2016` itself: -# 15:01:29 > -# 15:01:29 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" "mapi_open=true" "--set" "mapi_port=37542" "--set" "mapi_usock=/var/tmp/mtest-23330/.s.monetdb.37542" "--set" "monet_prompt=" "--forcemito" "--set" "mal_listing=2" "--dbpath=/home/niels/scratch/rc-monetdb/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2016" "--set" "mal_listing=0" "--set" "embedded_r=yes" -# 15:01:29 > - -# MonetDB 5 server v11.21.12 -# This is an unreleased version -# Serving database 'mTests_sql_test_BugTracker-2016', using 4 threads -# Compiled for x86_64-unknown-linux-gnu/64bit with 64bit OIDs and 128bit integers dynamically linked -# Found 7.332 GiB available main-memory. -# Copyright (c) 1993-July 2008 CWI. -# Copyright (c) August 2008-2015 MonetDB B.V., all rights reserved -# Visit http://www.monetdb.org/ for further information -# Listening for connection requests on mapi:monetdb://localhost.nes.nl:37542/ -# Listening for UNIX domain connection requests on mapi:monetdb:///var/tmp/mtest-23330/.s.monetdb.37542 -# MonetDB/GIS module loaded -# Start processing logs sql/sql_logs version 52200 -# Start reading the write-ahead log 'sql_logs/sql/log.11' -# Finished reading the write-ahead log 'sql_logs/sql/log.11' -# Finished processing logs sql/sql_logs -# MonetDB/SQL module loaded -# MonetDB/R module loaded - - -# 15:01:30 > -# 15:01:30 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" "--host=/var/tmp/mtest-23330" "--port=37542" -# 15:01:30 > +# 09:23:08 > +# 09:23:08 > "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" "--host=/var/tmp/mtest-21127" "--port=34996" +# 09:23:08 > #start transaction; #create table tmp(i decimal(8)); @@ -43,30 +20,32 @@ function user.s4_0():void; end user.s4_0; #inline actions= 0 time=1 usec #remapactions= 0 time=1 usec -#costmodelactions= 1 time=0 usec +#costmodelactions= 1 time=1 usec #coercion actions= 0 time=1 usec -#aliases actions= 1 time=3 usec -#evaluate actions= 1 time=11 usec -#emptybindactions= 3 time=9 usec +#aliases actions= 1 time=4 usec +#evaluate actions= 1 time=12 usec +#emptybindactions= 2 time=10 usec #pushselect actions= 0 time=2 usec #aliases actions= 1 time=3 usec -#mergetable actions= 0 time=15 usec -#deadcode actions= 5 time=5 usec +#mitosis actions=1 time=0 usec +#mergetable actions= 0 time=18 usec +#deadcode actions= 5 time=7 usec #aliases actions= 0 time=0 usec -#constantsactions= 1 time=4 usec -#commonTerms actions= 0 time=1 usec -#projectionpath actions= 0 time=1 usec -#deadcode actions= 0 time=3 usec -#reorder actions= 1 time=8 usec +#constantsactions= 1 time=6 usec +#commonTerms actions= 0 time=3 usec +#projectionpath actions= 0 time=2 usec +#deadcode actions= 0 time=6 usec +#reorder actions= 1 time=16 usec #matpack actions= 0 time=0 usec -#dataflow actions= 0 time=4 usec +#dataflow actions= 0 time=5 usec #multiplexactions= 0 time=1 usec #profiler actions= 1 time=0 usec -#candidates actions= 1 time=0 usec -#deadcode actions= 0 time=2 usec +#candidates actions= 1 time=1 usec +#deadcode actions= 0 time=4 usec +#postfix actions= 0 time=2 usec #wlc actions= 0 time=0 usec -#garbagecollector actions= 1 time=5 usec -#totalactions=29 time=155 usec +#garbagecollector actions= 1 time=34 usec +#totalactions=29 time=239 usec #explain select count(*) from tmp where i = '20160222'; % .explain # table_name % mal # name @@ -78,32 +57,34 @@ function user.s6_0():void; X_19:lng := aggr.count(X_16:bat[:oid]); sql.resultSet("sys.%1":str, "%1":str, "bigint":str, 64:int, 0:int, 7:int, X_19:lng); end user.s6_0; -#inline actions= 0 time=0 usec +#in