MonetDB: Sep2022 - Window functions cannot be nested
Changeset: 8edc8c29c063 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/8edc8c29c063 Modified Files: sql/server/rel_select.c sql/test/BugTracker-2022/Tests/single_row_in_rel_order_by_column.Bug-7306.test sql/test/analytics/Tests/analytics00.test Branch: Sep2022 Log Message: Window functions cannot be nested I have the setup done, so I can do more stuff now. diffs (66 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 @@ -4498,13 +4498,15 @@ rel_order_by_column_exp(sql_query *query if (needs_distinct) return sql_error(sql, 02, SQLSTATE(42000) "SELECT: with DISTINCT ORDER BY expressions must appear in select list"); e = rel_project_add_exp(sql, p, e); - for (node *n = p->exps->h ; n ; n = n->next) { - sql_exp *ee = n->data; - - if (ee->card > r->card) { - if (exp_name(ee) && !has_label(ee)) - return sql_error(sql, ERR_GROUPBY, SQLSTATE(42000) "SELECT: cannot use non GROUP BY column '%s' in query results without an aggregate function", exp_name(ee)); - return sql_error(sql, ERR_GROUPBY, SQLSTATE(42000) "SELECT: cannot use non GROUP BY column in query results without an aggregate function"); + if (r) { + for (node *n = p->exps->h ; n ; n = n->next) { + sql_exp *ee = n->data; + + if (ee->card > r->card) { + if (exp_name(ee) && !has_label(ee)) + return sql_error(sql, ERR_GROUPBY, SQLSTATE(42000) "SELECT: cannot use non GROUP BY column '%s' in query results without an aggregate function", exp_name(ee)); + return sql_error(sql, ERR_GROUPBY, SQLSTATE(42000) "SELECT: cannot use non GROUP BY column in query results without an aggregate function"); + } } } } @@ -4613,7 +4615,7 @@ rel_order_by(sql_query *query, sql_rel * sql->session->status = 0; sql->errstr[0] = '\0'; - e = rel_order_by_column_exp(query, &rel, col, needs_distinct, sql_sel | sql_orderby | (f & sql_group_totals)); + e = rel_order_by_column_exp(query, &rel, col, needs_distinct, sql_sel | sql_orderby | (f & sql_group_totals) | (f & sql_window)); } if (!e) return NULL; diff --git a/sql/test/BugTracker-2022/Tests/single_row_in_rel_order_by_column.Bug-7306.test b/sql/test/BugTracker-2022/Tests/single_row_in_rel_order_by_column.Bug-7306.test --- a/sql/test/BugTracker-2022/Tests/single_row_in_rel_order_by_column.Bug-7306.test +++ b/sql/test/BugTracker-2022/Tests/single_row_in_rel_order_by_column.Bug-7306.test @@ -18,13 +18,9 @@ SELECT avg(42) over (order by 2); 42.000 -query I +statement error 42000!ROW_NUMBER: window functions cannot be nested SELECT count(*) over (order by row_number() over ()); - -1 -query R +statement error 42000!ROW_NUMBER: window functions cannot be nested SELECT avg(42) over (order by row_number() over ()); - -42.000 diff --git a/sql/test/analytics/Tests/analytics00.test b/sql/test/analytics/Tests/analytics00.test --- a/sql/test/analytics/Tests/analytics00.test +++ b/sql/test/analytics/Tests/analytics00.test @@ -1922,3 +1922,8 @@ 2 statement ok rollback +statement error 42000!ROW_NUMBER: window functions cannot be nested +SELECT avg(42) over (order by row_number() over ()) + +statement error 42000!ROW_NUMBER: window functions cannot be nested +SELECT avg(42) over (partition by row_number() over ()) ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - Propagate min/max for average
Changeset: bd76513dd21a for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/bd76513dd21a Modified Files: sql/server/rel_statistics_functions.c Branch: default Log Message: Propagate min/max for average diffs (50 lines): diff --git a/sql/server/rel_statistics_functions.c b/sql/server/rel_statistics_functions.c --- a/sql/server/rel_statistics_functions.c +++ b/sql/server/rel_statistics_functions.c @@ -727,6 +727,29 @@ sql_min_max_propagate_statistics(mvc *sq } static void +sql_avg_propagate_statistics(mvc *sql, sql_exp *e) +{ + list *l = e->l; + sql_exp *first = l->h->data; + atom *omin, *omax; + + if ((omin = find_prop_and_get(first->p, PROP_MIN)) && (omax = find_prop_and_get(first->p, PROP_MAX))) { + sql_subtype *etype = exp_subtype(e), *ftype = exp_subtype(first); + if (ftype && etype->type->base.id == ftype->type->base.id) { /* average on decimals or intervals */ + set_minmax_property(sql, e, PROP_MAX, omax); + set_minmax_property(sql, e, PROP_MIN, omin); + } else if (ftype && etype) { /* average on integer types */ + assert(etype->type->eclass == EC_FLT); + atom *min_cast = atom_copy(sql->sa, omin), *max_cast = atom_copy(sql->sa, omax); + if ((min_cast = atom_cast(sql->sa, min_cast, etype)) && (max_cast = atom_cast(sql->sa, max_cast, etype))) { + set_minmax_property(sql, e, PROP_MAX, max_cast); + set_minmax_property(sql, e, PROP_MIN, min_cast); + } + } + } +} + +static void sql_zero_or_one_propagate_statistics(mvc *sql, sql_exp *e) { list *l = e->l; @@ -739,7 +762,7 @@ sql_zero_or_one_propagate_statistics(mvc } } -static struct function_properties functions_list[34] = { +static struct function_properties functions_list[35] = { /* arithmetic functions */ {"sql_add", &sql_add_propagate_statistics}, {"sql_sub", &sql_sub_propagate_statistics}, @@ -780,6 +803,7 @@ static struct function_properties functi /* aggregates */ {"min", &sql_min_max_propagate_statistics}, {"max", &sql_min_max_propagate_statistics}, + {"avg", &sql_avg_propagate_statistics}, {"zero_or_one", &sql_zero_or_one_propagate_statistics} }; ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - Approved output
Changeset: ac72a6d2af2c for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/ac72a6d2af2c Modified Files: sql/test/BugTracker-2017/Tests/sqlitelogictest-aggregation-having-avg.Bug-6428.test Branch: default Log Message: Approved output diffs (20 lines): diff --git a/sql/test/BugTracker-2017/Tests/sqlitelogictest-aggregation-having-avg.Bug-6428.test b/sql/test/BugTracker-2017/Tests/sqlitelogictest-aggregation-having-avg.Bug-6428.test --- a/sql/test/BugTracker-2017/Tests/sqlitelogictest-aggregation-having-avg.Bug-6428.test +++ b/sql/test/BugTracker-2017/Tests/sqlitelogictest-aggregation-having-avg.Bug-6428.test @@ -17,10 +17,12 @@ PLAN SELECT - col0 AS col1 FROM tab0 AS project ( | select ( | | group by ( -| | | select ( -| | | | table("sys"."tab0") [ "tab0"."col0" UNIQUE as "cor0"."col0", "tab0"."col1" UNIQUE as "cor0"."col1" ] -| | | ) [ ("cor0"."col0" UNIQUE) * = (int(32) NULL) ] -| | ) [ "cor0"."col1" UNIQUE, "cor0"."col0" UNIQUE ] [ "cor0"."col1" UNIQUE, "cor0"."col0" UNIQUE, "sys"."avg" unique no nil ("cor0"."col0" UNIQUE) as "%1"."%1" ] +| | | group by ( +| | | | select ( +| | | | | table("sys"."tab0") [ "tab0"."col0" UNIQUE as "cor0"."col0", "tab0"."col1" UNIQUE as "cor0"."col1" ] +| | | | ) [ ("cor0"."col0" UNIQUE) * = (int(32) NULL) ] +| | | ) [ "cor0"."col1" UNIQUE, "cor0"."col0" UNIQUE ] [ "cor0"."col1" UNIQUE, "cor0"."col0" UNIQUE ] +| | ) [ "cor0"."col1" UNIQUE, "cor0"."col0" UNIQUE ] [ "cor0"."col1" UNIQUE, "cor0"."col0" UNIQUE, "sys"."avg" no nil ("cor0"."col0" UNIQUE) as "%1"."%1" ] | ) [ ("sys"."sql_add"(double(53)["sys"."sql_neg"("cor0"."col1" UNIQUE)], "%1"."%1")) ! * = (double(53) NULL) ] ) [ "sys"."sql_neg"("cor0"."col0" UNIQUE) as "col1" ] ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - Re-enable rel_groupby_distinct (bad backport)
Changeset: fc0d2007ecf6 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/fc0d2007ecf6 Modified Files: sql/server/rel_optimize_proj.c Branch: default Log Message: Re-enable rel_groupby_distinct (bad backport) diffs (12 lines): diff --git a/sql/server/rel_optimize_proj.c b/sql/server/rel_optimize_proj.c --- a/sql/server/rel_optimize_proj.c +++ b/sql/server/rel_optimize_proj.c @@ -2883,7 +2883,7 @@ rel_optimize_projections_(visitor *v, sq rel = rel_push_groupby_down(v, rel); rel = rel_reduce_groupby_exps(v, rel); rel = rel_distinct_aggregate_on_unique_values(v, rel); - if (0) rel = rel_groupby_distinct(v, rel); + rel = rel_groupby_distinct(v, rel); rel = rel_push_count_down(v, rel); /* only when value_based_opt is on, ie not for dependency resolution */ if (v->value_based_opt) { ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: properties - Closed properties branch once merged into ...
Changeset: 2ce9eb6eb2d3 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/2ce9eb6eb2d3 Branch: properties Log Message: Closed properties branch once merged into default ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - Merged properties into default
Changeset: 9ec792882357 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/9ec792882357 Branch: default Log Message: Merged properties into default diffs (truncated from 8518 to 300 lines): diff --git a/monetdb5/modules/atoms/CMakeLists.txt b/monetdb5/modules/atoms/CMakeLists.txt --- a/monetdb5/modules/atoms/CMakeLists.txt +++ b/monetdb5/modules/atoms/CMakeLists.txt @@ -18,7 +18,7 @@ target_sources(atoms url.c uuid.c json.c - mtime.c + mtime.c mtime.h inet.c identifier.c xml.c xml.h 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 @@ -29,11 +29,9 @@ */ #include "monetdb_config.h" -#include "gdk.h" -#include "gdk_time.h" +#include "mtime.h" #include "mal_client.h" -#include "mal_interpreter.h" -#include "mal_exception.h" + #ifndef HAVE_STRPTIME extern char *strptime(const char *, const char *, struct tm *); @@ -486,13 +484,6 @@ bailout: \ #define func2_noexcept(FUNC, RET, PARAM1, PARAM2) RET = FUNC(PARAM1, PARAM2) #define func2_except(FUNC, RET, PARAM1, PARAM2) msg = FUNC(&RET, PARAM1, PARAM2); if (msg) break -/* TODO change dayint again into an int instead of lng */ -static inline lng -date_diff_imp(const date d1, const date d2) -{ - int diff = date_diff(d1, d2); - return is_int_nil(diff) ? lng_nil : (lng) diff * (lng) (24*60*60*1000); -} func2(MTIMEdate_diff, "diff", date, date, lng, date_diff_imp, func2_noexcept, DEC_VAR, DEC_VAR, DEC_VAR_R, DEC_INT, @@ -506,28 +497,6 @@ func2(MTIMEdaytime_diff_msec, "diff", GET_NEXT_VAR, GET_NEXT_VAR, APPEND_VAR, FINISH_INT_SINGLE, CLEAR_NOTHING) -static inline str -date_sub_msec_interval(date *ret, date d, lng ms) -{ - if (is_date_nil(d) || is_lng_nil(ms)) { - *ret = date_nil; - return MAL_SUCCEED; - } - if (is_date_nil((*ret = date_add_day(d, (int) (-ms / (24*60*60*1000)) - throw(MAL, "mtime.date_sub_msec_interval", SQLSTATE(22003) "overflow in calculation"); - return MAL_SUCCEED; -} -static inline str -date_add_msec_interval(date *ret, date d, lng ms) -{ - if (is_date_nil(d) || is_lng_nil(ms)) { - *ret = date_nil; - return MAL_SUCCEED; - } - if (is_date_nil((*ret = date_add_day(d, (int) (ms / (24*60*60*1000)) - throw(MAL, "mtime.date_add_msec_interval", SQLSTATE(22003) "overflow in calculation"); - return MAL_SUCCEED; -} func2(MTIMEdate_sub_msec_interval, "date_sub_msec_interval", date, lng, date, date_sub_msec_interval, func2_except, DEC_VAR_R, DEC_VAR_R, DEC_VAR_R, DEC_INT, @@ -541,28 +510,6 @@ func2(MTIMEdate_add_msec_interval, "date GET_NEXT_VAR, GET_NEXT_VAR, APPEND_VAR, FINISH_INT_SINGLE, CLEAR_NOTHING) -static inline str -timestamp_sub_msec_interval(timestamp *ret, timestamp ts, lng ms) -{ - if (is_timestamp_nil(ts) || is_lng_nil(ms)) { - *ret = timestamp_nil; - return MAL_SUCCEED; - } - if (is_timestamp_nil((*ret = timestamp_add_usec(ts, -ms * 1000 - throw(MAL, "mtime.timestamp_sub_msec_interval", SQLSTATE(22003) "overflow in calculation"); - return MAL_SUCCEED; -} -static inline str -timestamp_add_msec_interval(timestamp *ret, timestamp ts, lng ms) -{ - if (is_timestamp_nil(ts) || is_lng_nil(ms)) { - *ret = timestamp_nil; - return MAL_SUCCEED; - } - if (is_timestamp_nil((*ret = timestamp_add_usec(ts, ms * 1000 - throw(MAL, "mtime.timestamp_add_msec_interval", SQLSTATE(22003) "overflow in calculation"); - return MAL_SUCCEED; -} func2(MTIMEtimestamp_sub_msec_interval, "timestamp_sub_msec_interval", timestamp, lng, timestamp, timestamp_sub_msec_interval, func2_except, DEC_VAR_R, DEC_VAR_R, DEC_VAR_R, DEC_INT, @@ -576,28 +523,6 @@ func2(MTIMEtimestamp_add_msec_interval, GET_NEXT_VAR, GET_NEXT_VAR, APPEND_VAR, FINISH_INT_SINGLE, CLEAR_NOTHING) -static inline str -timestamp_sub_month_interval(timestamp *ret, timestamp ts, int m) -{ - if (is_timestamp_nil(ts) || is_int_nil(m)) { - *ret = timestamp_nil; - return MAL_SUCCEED; - } - if (is_timestamp_nil((*ret = timestamp_add_month(ts, -m - throw(MAL, "mtime.timestamp_sub_month_interval", SQLSTATE(22003) "overflow in calculation"); - return MAL_SUCCEED; -} -static inline str -timestamp_add_month_interval(timestamp *ret, timestamp ts, int m) -{ - if (is_timestamp_nil(ts) || is_int_nil(m)) { - *ret = timestamp_nil; - return MAL_SUCCEED; - } - if (is_timestamp_nil((*ret = timestamp_add_month(ts, m - throw(
MonetDB: properties - Merged with default
Changeset: c5e62504f467 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/c5e62504f467 Branch: properties Log Message: Merged with default diffs (13 lines): diff --git a/sql/backends/monet5/dict.c b/sql/backends/monet5/dict.c --- a/sql/backends/monet5/dict.c +++ b/sql/backends/monet5/dict.c @@ -728,6 +728,9 @@ DICTthetaselect(Client cntxt, MalBlkPtr if (p != BUN_NONE && op[0] == '<' && op[1] == '=') { if (ATOMcmp(lvi.type, v, BUNtail(lvi, p)) != 0) p--; + } else if (p != BUN_NONE && op[0] == '>' && !op[1]) { +if (ATOMcmp(lvi.type, v, BUNtail(lvi, p)) != 0) +op = ">="; } } if (p != BUN_NONE) { ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: subqueryfun - Another missing digits propagation issue
Changeset: 40cf093c4443 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/40cf093c4443 Modified Files: sql/test/SQLancer/Tests/sqlancer19.SQL.py Branch: subqueryfun Log Message: Another missing digits propagation issue diffs (14 lines): diff --git a/sql/test/SQLancer/Tests/sqlancer19.SQL.py b/sql/test/SQLancer/Tests/sqlancer19.SQL.py --- a/sql/test/SQLancer/Tests/sqlancer19.SQL.py +++ b/sql/test/SQLancer/Tests/sqlancer19.SQL.py @@ -373,6 +373,10 @@ with SQLTestCase() as cli: .assertSucceeded().assertDataResultMatch([(1,)]) cli.execute("SELECT 1 FROM rt3 LEFT OUTER JOIN (SELECT 1) x(x) ON 1 <> ALL(VALUES (rt3.c0)) where rt3.c0 = 1;") \ .assertSucceeded().assertDataResultMatch([(1,)]) +cli.execute("SELECT splitpart(CAST('c' AS STRING(12)), 'a', length('c')) FROM t3 where t3.c0 = 1;") \ +.assertSucceeded().assertDataResultMatch([("c",)]) +cli.execute("SELECT splitpart(CAST('c' AS STRING(12)), 'a', length('c')) FROM rt3 where rt3.c0 = 1;") \ +.assertSucceeded().assertDataResultMatch([("c",)]) cli.execute("ROLLBACK;") cli.execute("SELECT CASE 1 WHEN 5 THEN ((SELECT t3.c0) INTERSECT (SELECT 9)) ELSE (VALUES (t3.c0), (1)) END FROM t3;") \ ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: properties - Don't be that restrictive on the existence...
Changeset: 5c0fa067eb7f for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/5c0fa067eb7f Modified Files: sql/server/rel_optimize_exps.c sql/server/rel_optimize_proj.c Branch: properties Log Message: Don't be that restrictive on the existence of null values diffs (42 lines): diff --git a/sql/server/rel_optimize_exps.c b/sql/server/rel_optimize_exps.c --- a/sql/server/rel_optimize_exps.c +++ b/sql/server/rel_optimize_exps.c @@ -80,7 +80,7 @@ exp_simplify_math( mvc *sql, sql_exp *e, sql_subtype *et = exp_subtype(e); /* 0*a = 0 */ - if (exp_is_atom(le) && exp_is_zero(le) && exp_is_atom(re) && exp_is_not_null(re)) { + if (exp_is_atom(le) && exp_is_zero(le) && exp_is_atom(re) && !has_nil(re)) { (*changes)++; le = exp_zero(sql->sa, et); if (subtype_cmp(exp_subtype(e), exp_subtype(le)) != 0) @@ -90,7 +90,7 @@ exp_simplify_math( mvc *sql, sql_exp *e, return le; } /* a*0 = 0 */ - if (exp_is_atom(re) && exp_is_zero(re) && exp_is_atom(le) && exp_is_not_null(le)) { + if (exp_is_atom(re) && exp_is_zero(re) && exp_is_atom(le) && !has_nil(le)) { (*changes)++; re = exp_zero(sql->sa, et); if (subtype_cmp(exp_subtype(e), exp_subtype(re)) != 0) @@ -255,7 +255,7 @@ exp_simplify_math( mvc *sql, sql_exp *e, } } } - if (exp_is_not_null(le) && exp_is_not_null(re) && exp_equal(le,re) == 0) { /* a - a = 0 */ + if (!has_nil(le) && !has_nil(re) && exp_equal(le,re) == 0) { /* a - a = 0 */ atom *a; sql_exp *ne; diff --git a/sql/server/rel_optimize_proj.c b/sql/server/rel_optimize_proj.c --- a/sql/server/rel_optimize_proj.c +++ b/sql/server/rel_optimize_proj.c @@ -2831,7 +2831,7 @@ rel_simplify_count(visitor *v, sql_rel * if (exp_aggr_is_count(e) && !need_distinct(e)) { if (list_length(e->l) == 0) { ncountstar++; - } else if (list_length(e->l) == 1 && exp_is_not_null((sql_exp*)((list*)e->l)->h->data)) { + } else if (list_length(e->l) == 1 && !has_nil((sql_exp*)((list*)e->l)->h->data)) { sql_subfunc *cf = sql_bind_func(sql, "sys", "count", sql_bind_localtype("void"), NULL, F_AGGR, true); sql_exp *ne = exp_aggr(sql->sa, NULL, cf, 0, 0, e->card, 0); if (exp_name(e)) ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: properties - Run join order optimizer at every loop at ...
Changeset: 312575917a9b for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/312575917a9b Modified Files: sql/server/rel_optimize_sel.c Branch: properties Log Message: Run join order optimizer at every loop at the moment. Fixes small performance degradation at tpch q18 diffs (12 lines): diff --git a/sql/server/rel_optimize_sel.c b/sql/server/rel_optimize_sel.c --- a/sql/server/rel_optimize_sel.c +++ b/sql/server/rel_optimize_sel.c @@ -2443,7 +2443,7 @@ run_optimizer bind_join_order(visitor *v, global_props *gp) { int flag = v->sql->sql_optimizer; - return gp->opt_level == 1 && gp->opt_cycle < 2 && !gp->cnt[op_update] && (gp->cnt[op_join] || gp->cnt[op_left] || + return gp->opt_level == 1 && !gp->cnt[op_update] && (gp->cnt[op_join] || gp->cnt[op_left] || gp->cnt[op_right] || gp->cnt[op_full]) && (flag & join_order) ? rel_join_order : NULL; } ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: properties - Merged with default
Changeset: dc618b7aeec7 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/dc618b7aeec7 Branch: properties Log Message: Merged with default diffs (120 lines): diff --git a/clients/Tests/MAL-signatures-hge.test b/clients/Tests/MAL-signatures-hge.test --- a/clients/Tests/MAL-signatures-hge.test +++ b/clients/Tests/MAL-signatures-hge.test @@ -62104,21 +62104,6 @@ pattern optimizer.strimps(X_0:str, X_1:s OPTwrapper; Use strimps index if appropriate optimizer -volcano -pattern optimizer.volcano():str -OPTwrapper; -(empty) -optimizer -volcano -pattern optimizer.volcano(X_0:str, X_1:str):str -OPTwrapper; -Simulate volcano style execution -optimizer -volcano_pipe -function optimizer.volcano_pipe():void; -(empty) -(empty) -optimizer wlc pattern optimizer.wlc():str OPTwrapper; diff --git a/clients/Tests/MAL-signatures.test b/clients/Tests/MAL-signatures.test --- a/clients/Tests/MAL-signatures.test +++ b/clients/Tests/MAL-signatures.test @@ -45619,21 +45619,6 @@ pattern optimizer.strimps(X_0:str, X_1:s OPTwrapper; Use strimps index if appropriate optimizer -volcano -pattern optimizer.volcano():str -OPTwrapper; -(empty) -optimizer -volcano -pattern optimizer.volcano(X_0:str, X_1:str):str -OPTwrapper; -Simulate volcano style execution -optimizer -volcano_pipe -function optimizer.volcano_pipe():void; -(empty) -(empty) -optimizer wlc pattern optimizer.wlc():str OPTwrapper; 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 @@ -356,6 +356,11 @@ void IMPSdestroy(BAT *b); lng IMPSimprintsize(BAT *b); int MT_access(const char *pathname, int mode); int MT_check_nr_cores(void); +void MT_cond_broadcast(MT_Cond *cond); +void MT_cond_destroy(MT_Cond *cond); +void MT_cond_init(MT_Cond *cond); +void MT_cond_signal(MT_Cond *cond); +void MT_cond_wait(MT_Cond *cond, MT_Lock *lock); int MT_create_thread(MT_Id *t, void (*function)(void *), void *arg, enum MT_thr_detach d, const char *threadname); void MT_exiting_thread(void); FILE *MT_fopen(const char *filename, const char *mode); diff --git a/monetdb5/ChangeLog b/monetdb5/ChangeLog --- a/monetdb5/ChangeLog +++ b/monetdb5/ChangeLog @@ -1,3 +1,6 @@ # ChangeLog file for MonetDB5 # This file is updated with Maddlog +* Thu Apr 28 2022 Pedro Ferreira +- Disabled volcano pipeline due to known issues. + diff --git a/monetdb5/optimizer/opt_pipes.c b/monetdb5/optimizer/opt_pipes.c --- a/monetdb5/optimizer/opt_pipes.c +++ b/monetdb5/optimizer/opt_pipes.c @@ -162,6 +162,8 @@ static struct PIPELINES { {"default_fast", "optimizer.defaultfast()", "stable", NULL, 1}, +/* Apr2022 update. I disabled the volcano_pipe because it has issues on it */ +#if 0 /* * Volcano style execution produces a sequence of blocks from the source relation */ @@ -200,6 +202,7 @@ static struct PIPELINES { "optimizer.garbageCollector();" "optimizer.profiler();", "stable", NULL, 1}, +#endif /* The no_mitosis pipe line is (and should be kept!) identical to the * default pipeline, except that optimizer mitosis is omitted. It is * used mainly to make some tests work deterministically, and to check diff --git a/monetdb5/optimizer/optimizer.c b/monetdb5/optimizer/optimizer.c --- a/monetdb5/optimizer/optimizer.c +++ b/monetdb5/optimizer/optimizer.c @@ -89,7 +89,7 @@ static mel_func optimizer_init_funcs[] = optwrapper_pattern("coercions", "Handle simple type coercions"), optwrapper_pattern("commonTerms", "Common sub-expression optimizer"), optwrapper_pattern("candidates", "Mark candidate list variables"), - optwrapper_pattern("volcano", "Simulate volcano style execution"), + /* optwrapper_pattern("volcano", "Simulate volcano style execution"), Apr2022 update. I disabled the volcano_pipe because it has issues on it */ optwrapper_pattern("constants", "Duplicate constant removal optimizer"), optwrapper_pattern("profiler", "Collect properties for the profiler"), optwrapper_pattern("costModel", "Estimate the cost of a relational expression"), diff --git a/sql/test/Tests/setoptimizer.test b/sql/test/Tests/setoptimizer.test --- a/sql/test/Tests/setoptimizer.test +++ b/sql/test/Tests/setoptimizer.test @@ -40,9 +40,6 @@ stable default_fast optimizer.defaultfast() stable -volcano_pipe -optimizer.inline();optimizer.remap();optimizer.costModel();optimizer.coercions();optimizer.aliases();optimizer.evaluate();optimizer.emptybind();optimizer.deadcode();optimizer.pushselect();optimizer.aliases();optimizer.mitosis();optimizer.mergetable();optimizer.bincopyfrom();optimizer.aliases();optimizer.constants();optimizer.commonTerms();optimizer.projectionpath();optimizer.deadcode();optimizer.matpack();optimizer.re
MonetDB: subqueryfun - Merged with default
Changeset: acc367c7f7c8 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/acc367c7f7c8 Branch: subqueryfun Log Message: Merged with default diffs (truncated from 3165 to 300 lines): diff --git a/.hgtags b/.hgtags --- a/.hgtags +++ b/.hgtags @@ -763,3 +763,4 @@ cab90a348501b045e19cee5cebcc44f3800bd0a8 5872f047d97c98d3a848514438b8f97fa446855d Jan2022_11 025239a5a6f122042798c0f1132a2c6298514e06 Jan2022_13 025239a5a6f122042798c0f1132a2c6298514e06 Jan2022_SP2_release +2e54857a91306cc6304825c5596f65d00595db6b Jul2021_23 diff --git a/MonetDB.spec b/MonetDB.spec --- a/MonetDB.spec +++ b/MonetDB.spec @@ -365,6 +365,7 @@ developer. %{_bindir}/smack00 %{_bindir}/smack01 %{_bindir}/streamcat +%{_bindir}/testcondvar %{_bindir}/testgetinfo %{_bindir}/testStmtAttr %{_bindir}/malsample.pl diff --git a/buildtools/conf/Maddlog b/buildtools/conf/Maddlog --- a/buildtools/conf/Maddlog +++ b/buildtools/conf/Maddlog @@ -189,6 +189,9 @@ fi file=ChangeLog.$RANDOM +# make sure we get the correct day and month names +export LC_ALL=en_US.utf-8 + case "$CL" in */*) cd "${CL%/*}" diff --git a/clients/Tests/All b/clients/Tests/All --- a/clients/Tests/All +++ b/clients/Tests/All @@ -3,3 +3,4 @@ HAVE_HGE&HAVE_FITS&HAVE_GEOM&HAVE_LIBR&H !HAVE_HGE&HAVE_FITS&HAVE_GEOM&HAVE_LIBR&HAVE_LIBPY3&HAVE_NETCDF&HAVE_SHP&NOT_WIN32?MAL-signatures NOT_WIN32&MERCURIAL?melcheck mclient-uri +testcondvar diff --git a/clients/Tests/MAL-signatures-hge.test b/clients/Tests/MAL-signatures-hge.test --- a/clients/Tests/MAL-signatures-hge.test +++ b/clients/Tests/MAL-signatures-hge.test @@ -62104,21 +62104,6 @@ pattern optimizer.strimps(X_0:str, X_1:s OPTwrapper; Use strimps index if appropriate optimizer -volcano -pattern optimizer.volcano():str -OPTwrapper; -(empty) -optimizer -volcano -pattern optimizer.volcano(X_0:str, X_1:str):str -OPTwrapper; -Simulate volcano style execution -optimizer -volcano_pipe -function optimizer.volcano_pipe():void; -(empty) -(empty) -optimizer wlc pattern optimizer.wlc():str OPTwrapper; diff --git a/clients/Tests/MAL-signatures.test b/clients/Tests/MAL-signatures.test --- a/clients/Tests/MAL-signatures.test +++ b/clients/Tests/MAL-signatures.test @@ -45619,21 +45619,6 @@ pattern optimizer.strimps(X_0:str, X_1:s OPTwrapper; Use strimps index if appropriate optimizer -volcano -pattern optimizer.volcano():str -OPTwrapper; -(empty) -optimizer -volcano -pattern optimizer.volcano(X_0:str, X_1:str):str -OPTwrapper; -Simulate volcano style execution -optimizer -volcano_pipe -function optimizer.volcano_pipe():void; -(empty) -(empty) -optimizer wlc pattern optimizer.wlc():str OPTwrapper; 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 @@ -356,6 +356,11 @@ void IMPSdestroy(BAT *b); lng IMPSimprintsize(BAT *b); int MT_access(const char *pathname, int mode); int MT_check_nr_cores(void); +void MT_cond_broadcast(MT_Cond *cond); +void MT_cond_destroy(MT_Cond *cond); +void MT_cond_init(MT_Cond *cond); +void MT_cond_signal(MT_Cond *cond); +void MT_cond_wait(MT_Cond *cond, MT_Lock *lock); int MT_create_thread(MT_Id *t, void (*function)(void *), void *arg, enum MT_thr_detach d, const char *threadname); void MT_exiting_thread(void); FILE *MT_fopen(const char *filename, const char *mode); @@ -536,23 +541,23 @@ ssize_t lngFromStr(const char *src, size ssize_t lngToStr(str *dst, size_t *len, const lng *src, bool external); const lng lng_nil; struct tm *localtime_r(const time_t *restrict, struct tm *restrict); +gdk_return log_activate(logger *lg); gdk_return log_bat(logger *lg, BAT *b, log_id id, lng offset, lng cnt); gdk_return log_bat_clear(logger *lg, log_id id); gdk_return log_bat_persists(logger *lg, BAT *b, log_id id); gdk_return log_bat_transient(logger *lg, log_id id); +lng log_changes(logger *lg); gdk_return log_constant(logger *lg, int type, ptr val, log_id id, lng offset, lng cnt); +logger *log_create(int debug, const char *fn, const char *logdir, int version, preversionfix_fptr prefuncp, postversionfix_fptr postfuncp, void *funcdata); gdk_return log_delta(logger *lg, BAT *uid, BAT *uval, log_id id); -gdk_return log_sequence(logger *lg, int seq, lng id); +void log_destroy(logger *lg); +log_bid log_find_bat(logger *lg, log_id id); +gdk_return log_flush(logger *lg, ulng saved_id); +int log_sequence(logger *lg, int seq, lng *id); gdk_return log_tend(logger *lg); gdk_return log_tflush(logger *lg, ulng log_file_id, ulng commit_ts); +gdk_return log_tsequence(logger *lg, int seq, lng id); gdk_return log_tstart(logger *lg, bool flushnow, ulng *log_file_id); -gdk_return logger_activate(logger *lg); -lng logger_changes(logger *lg); -logger *logger_create(int debug, const char *fn, const char *logdir, int version, preversionfix_fptr prefuncp, postversionfix_fptr postfuncp, void *funcdata); -void logger_destroy(logger *lg); -log_bid logger_find_bat(logger *lg, log_id id); -
MonetDB: default - Disable optimizer pattern
Changeset: e6e3601243c1 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/e6e3601243c1 Modified Files: clients/Tests/MAL-signatures-hge.test clients/Tests/MAL-signatures.test monetdb5/optimizer/optimizer.c Branch: default Log Message: Disable optimizer pattern diffs (62 lines): diff --git a/clients/Tests/MAL-signatures-hge.test b/clients/Tests/MAL-signatures-hge.test --- a/clients/Tests/MAL-signatures-hge.test +++ b/clients/Tests/MAL-signatures-hge.test @@ -62104,21 +62104,6 @@ pattern optimizer.strimps(X_0:str, X_1:s OPTwrapper; Use strimps index if appropriate optimizer -volcano -pattern optimizer.volcano():str -OPTwrapper; -(empty) -optimizer -volcano -pattern optimizer.volcano(X_0:str, X_1:str):str -OPTwrapper; -Simulate volcano style execution -optimizer -volcano_pipe -function optimizer.volcano_pipe():void; -(empty) -(empty) -optimizer wlc pattern optimizer.wlc():str OPTwrapper; diff --git a/clients/Tests/MAL-signatures.test b/clients/Tests/MAL-signatures.test --- a/clients/Tests/MAL-signatures.test +++ b/clients/Tests/MAL-signatures.test @@ -45619,21 +45619,6 @@ pattern optimizer.strimps(X_0:str, X_1:s OPTwrapper; Use strimps index if appropriate optimizer -volcano -pattern optimizer.volcano():str -OPTwrapper; -(empty) -optimizer -volcano -pattern optimizer.volcano(X_0:str, X_1:str):str -OPTwrapper; -Simulate volcano style execution -optimizer -volcano_pipe -function optimizer.volcano_pipe():void; -(empty) -(empty) -optimizer wlc pattern optimizer.wlc():str OPTwrapper; diff --git a/monetdb5/optimizer/optimizer.c b/monetdb5/optimizer/optimizer.c --- a/monetdb5/optimizer/optimizer.c +++ b/monetdb5/optimizer/optimizer.c @@ -89,7 +89,7 @@ static mel_func optimizer_init_funcs[] = optwrapper_pattern("coercions", "Handle simple type coercions"), optwrapper_pattern("commonTerms", "Common sub-expression optimizer"), optwrapper_pattern("candidates", "Mark candidate list variables"), - optwrapper_pattern("volcano", "Simulate volcano style execution"), + /* optwrapper_pattern("volcano", "Simulate volcano style execution"), Apr2022 update. I disabled the volcano_pipe because it has issues on it */ optwrapper_pattern("constants", "Duplicate constant removal optimizer"), optwrapper_pattern("profiler", "Collect properties for the profiler"), optwrapper_pattern("costModel", "Estimate the cost of a relational expression"), ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - Disabled volcano pipeline due to known issues
Changeset: c2c6aa1fb726 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/c2c6aa1fb726 Modified Files: monetdb5/ChangeLog monetdb5/optimizer/opt_pipes.c sql/test/Tests/setoptimizer.test Branch: default Log Message: Disabled volcano pipeline due to known issues diffs (43 lines): diff --git a/monetdb5/ChangeLog b/monetdb5/ChangeLog --- a/monetdb5/ChangeLog +++ b/monetdb5/ChangeLog @@ -1,3 +1,6 @@ # ChangeLog file for MonetDB5 # This file is updated with Maddlog +* Thu Apr 28 2022 Pedro Ferreira +- Disabled volcano pipeline due to known issues. + diff --git a/monetdb5/optimizer/opt_pipes.c b/monetdb5/optimizer/opt_pipes.c --- a/monetdb5/optimizer/opt_pipes.c +++ b/monetdb5/optimizer/opt_pipes.c @@ -162,6 +162,8 @@ static struct PIPELINES { {"default_fast", "optimizer.defaultfast()", "stable", NULL, 1}, +/* Apr2022 update. I disabled the volcano_pipe because it has issues on it */ +#if 0 /* * Volcano style execution produces a sequence of blocks from the source relation */ @@ -200,6 +202,7 @@ static struct PIPELINES { "optimizer.garbageCollector();" "optimizer.profiler();", "stable", NULL, 1}, +#endif /* The no_mitosis pipe line is (and should be kept!) identical to the * default pipeline, except that optimizer mitosis is omitted. It is * used mainly to make some tests work deterministically, and to check diff --git a/sql/test/Tests/setoptimizer.test b/sql/test/Tests/setoptimizer.test --- a/sql/test/Tests/setoptimizer.test +++ b/sql/test/Tests/setoptimizer.test @@ -40,9 +40,6 @@ stable default_fast optimizer.defaultfast() stable -volcano_pipe -optimizer.inline();optimizer.remap();optimizer.costModel();optimizer.coercions();optimizer.aliases();optimizer.evaluate();optimizer.emptybind();optimizer.deadcode();optimizer.pushselect();optimizer.aliases();optimizer.mitosis();optimizer.mergetable();optimizer.bincopyfrom();optimizer.aliases();optimizer.constants();optimizer.commonTerms();optimizer.projectionpath();optimizer.deadcode();optimizer.matpack();optimizer.reorder();optimizer.dataflow();optimizer.querylog();optimizer.multiplex();optimizer.generator();optimizer.volcano();optimizer.candidates();optimizer.deadcode();optimizer.postfix();optimizer.wlc();optimizer.garbageCollector();optimizer.profiler(); -stable no_mitosis_pipe optimizer.inline();optimizer.remap();optimizer.costModel();optimizer.coercions();optimizer.aliases();optimizer.evaluate();optimizer.emptybind();optimizer.deadcode();optimizer.pushselect();optimizer.aliases();optimizer.mergetable();optimizer.bincopyfrom();optimizer.aliases();optimizer.constants();optimizer.commonTerms();optimizer.projectionpath();optimizer.deadcode();optimizer.matpack();optimizer.reorder();optimizer.dataflow();optimizer.querylog();optimizer.multiplex();optimizer.generator();optimizer.candidates();optimizer.deadcode();optimizer.postfix();optimizer.wlc();optimizer.garbageCollector();optimizer.profiler(); stable ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - Approved output
Changeset: 1571e57720c2 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/1571e57720c2 Modified Files: clients/Tests/exports.stable.out Branch: default Log Message: Approved output diffs (15 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 @@ -356,6 +356,11 @@ void IMPSdestroy(BAT *b); lng IMPSimprintsize(BAT *b); int MT_access(const char *pathname, int mode); int MT_check_nr_cores(void); +void MT_cond_broadcast(MT_Cond *cond); +void MT_cond_destroy(MT_Cond *cond); +void MT_cond_init(MT_Cond *cond); +void MT_cond_signal(MT_Cond *cond); +void MT_cond_wait(MT_Cond *cond, MT_Lock *lock); int MT_create_thread(MT_Id *t, void (*function)(void *), void *arg, enum MT_thr_detach d, const char *threadname); void MT_exiting_thread(void); FILE *MT_fopen(const char *filename, const char *mode); ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: properties - Make sure storage is initialized when fetc...
Changeset: 098f16b88412 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/098f16b88412 Modified Files: sql/storage/bat/bat_storage.c sql/test/BugTracker-2009/Tests/copy_multiple_files.SF-2902320-Windows.test sql/test/BugTracker-2009/Tests/copy_multiple_files.SF-2902320.test sql/test/BugTracker-2013/Tests/rangejoin_optimizer.Bug-3411.test sql/test/BugTracker-2015/Tests/crash_in_reduce_groupby.Bug-3818.test sql/test/BugTracker-2015/Tests/quantile_function_resolution.Bug-3773.test sql/test/BugTracker-2015/Tests/schema_view.Bug-3708.test sql/test/BugTracker-2016/Tests/memory-consumption-query-PLAN-25joins.Bug-3972.test sql/test/BugTracker-2018/Tests/count_from_commented_function_signatures.Bug-6542.test sql/test/BugTracker/Tests/jdbc_no_debug.SF-1739356.test sql/test/SQLancer/Tests/sqlancer08.test sql/test/astro/Tests/astro.test sql/test/merge-partitions/Tests/mergepart31.test sql/test/miscellaneous/Tests/simple_plans.test Branch: properties Log Message: Make sure storage is initialized when fetching properties. Don't look at views. diffs (truncated from 474 to 300 lines): diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c --- a/sql/storage/bat/bat_storage.c +++ b/sql/storage/bat/bat_storage.c @@ -2728,12 +2728,12 @@ dcount_col(sql_trans *tr, sql_column *c) } static BAT * -bind_no_view(BAT *b) +bind_no_view(BAT *b, bool quick) { if (isVIEW(b)) { /* If it is a view get the parent BAT */ BAT *nb = BBP_cache(VIEWtparent(b)); bat_destroy(b); - if (!(b = temp_descriptor(nb->batCacheid))) + if (!(b = quick ? quick_descriptor(nb->batCacheid) : temp_descriptor(nb->batCacheid))) return NULL; } return b; @@ -2763,7 +2763,7 @@ min_max_col(sql_trans *tr, sql_column *c _DELETE(c->min); _DELETE(c->max); if ((b = bind_col(tr, c, access))) { - if (!(b = bind_no_view(b))) { + if (!(b = bind_no_view(b, false))) { unlock_column(tr->store, c->base.id); return 0; } @@ -2889,7 +2889,7 @@ static int col_stats(sql_trans *tr, sql_column *c, bool *nonil, bool *unique, double *unique_est, ValPtr min, ValPtr max) { int ok = 0; - BAT *b = NULL, *off = NULL; + BAT *b = NULL, *off = NULL, *upv = NULL; sql_delta *d = NULL; (void) tr; @@ -2905,9 +2905,11 @@ col_stats(sql_trans *tr, sql_column *c, *nonil = true; /* TODO for min/max. I will do it later */ return ok; } - bat bid = d->cs.st == ST_DICT ? d->cs.ebid : d->cs.bid; - if ((b = temp_descriptor(bid))) { - int eclass = c->type.type->eclass; + int eclass = c->type.type->eclass; + int access = d->cs.st == ST_DICT ? RD_EXT : RDONLY; + if ((b = bind_col(tr, c, access))) { + if (!(b = bind_no_view(b, false))) + return ok; BATiter bi = bat_iterator(b); *nonil = bi.nonil && !bi.nil; @@ -2918,27 +2920,29 @@ col_stats(sql_trans *tr, sql_column *c, if (bi.maxpos != BUN_NONE && VALinit(max, bi.type, BUNtail(bi, bi.maxpos))) ok |= 2; } - /* for dict, check the offsets bat for uniqueness */ - if (d->cs.ucnt == 0 && (d->cs.st == ST_DEFAULT || (off = quick_descriptor(d->cs.bid { - if (off) { + if (d->cs.ucnt == 0) { + if (d->cs.st == ST_DEFAULT) { + *unique = bi.key; + *unique_est = bi.unique_est; + } else if (d->cs.st == ST_DICT && (off = bind_col(tr, c, QUICK)) && (off = bind_no_view(off, true))) { + /* for dict, check the offsets bat for uniqueness */ MT_lock_set(&off->theaplock); *unique = off->tkey; *unique_est = off->tunique_est; MT_lock_unset(&off->theaplock); - } else { - *unique = bi.key; - *unique_est = bi.unique_est; } } bat_iterator_end(&bi); bat_destroy(b); if (*nonil && d->cs.ucnt > 0) { -
MonetDB: properties - Merged with default
Changeset: 07a5057139ce for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/07a5057139ce Modified Files: sql/storage/bat/bat_storage.c sql/storage/sql_storage.h sql/storage/store.c Branch: properties Log Message: Merged with default diffs (truncated from 1781 to 300 lines): diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out --- a/clients/Tests/exports.stable.out +++ b/clients/Tests/exports.stable.out @@ -536,23 +536,23 @@ ssize_t lngFromStr(const char *src, size ssize_t lngToStr(str *dst, size_t *len, const lng *src, bool external); const lng lng_nil; struct tm *localtime_r(const time_t *restrict, struct tm *restrict); +gdk_return log_activate(logger *lg); gdk_return log_bat(logger *lg, BAT *b, log_id id, lng offset, lng cnt); gdk_return log_bat_clear(logger *lg, log_id id); gdk_return log_bat_persists(logger *lg, BAT *b, log_id id); gdk_return log_bat_transient(logger *lg, log_id id); +lng log_changes(logger *lg); gdk_return log_constant(logger *lg, int type, ptr val, log_id id, lng offset, lng cnt); +logger *log_create(int debug, const char *fn, const char *logdir, int version, preversionfix_fptr prefuncp, postversionfix_fptr postfuncp, void *funcdata); gdk_return log_delta(logger *lg, BAT *uid, BAT *uval, log_id id); -gdk_return log_sequence(logger *lg, int seq, lng id); +void log_destroy(logger *lg); +log_bid log_find_bat(logger *lg, log_id id); +gdk_return log_flush(logger *lg, ulng saved_id); +int log_sequence(logger *lg, int seq, lng *id); gdk_return log_tend(logger *lg); gdk_return log_tflush(logger *lg, ulng log_file_id, ulng commit_ts); +gdk_return log_tsequence(logger *lg, int seq, lng id); gdk_return log_tstart(logger *lg, bool flushnow, ulng *log_file_id); -gdk_return logger_activate(logger *lg); -lng logger_changes(logger *lg); -logger *logger_create(int debug, const char *fn, const char *logdir, int version, preversionfix_fptr prefuncp, postversionfix_fptr postfuncp, void *funcdata); -void logger_destroy(logger *lg); -log_bid logger_find_bat(logger *lg, log_id id); -gdk_return logger_flush(logger *lg, ulng saved_id); -int logger_sequence(logger *lg, int seq, lng *id); log_level_t lvl_per_component[]; void *mdlopen(const char *library, int mode); const char *mercurial_revision(void) __attribute__((__const__)); diff --git a/gdk/gdk_cand.c b/gdk/gdk_cand.c --- a/gdk/gdk_cand.c +++ b/gdk/gdk_cand.c @@ -398,7 +398,7 @@ count_mask_bits(const struct canditer *c return n; } -/* initialize a candidate iterator, return number of iterations */ +/* initialize a candidate iterator */ void canditer_init(struct canditer *ci, BAT *b, BAT *s) { diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c --- a/gdk/gdk_logger.c +++ b/gdk/gdk_logger.c @@ -14,8 +14,8 @@ #include "mutils.h" #include -static gdk_return logger_add_bat(logger *lg, BAT *b, log_id id, int tid); -static gdk_return logger_del_bat(logger *lg, log_bid bid); +static gdk_return log_add_bat(logger *lg, BAT *b, log_id id, int tid); +static gdk_return log_del_bat(logger *lg, log_bid bid); /* * The logger uses a directory to store its log files. One master log * file stores information about the version of the logger and the @@ -96,13 +96,13 @@ static gdk_return bm_commit(logger *lg); static gdk_return tr_grow(trans *tr); static inline void -logger_lock(logger *lg) +log_lock(logger *lg) { MT_lock_set(&lg->lock); } static inline void -logger_unlock(logger *lg) +log_unlock(logger *lg) { MT_lock_unset(&lg->lock); } @@ -730,7 +730,7 @@ la_bat_destroy(logger *lg, logaction *la { log_bid bid = internal_find_bat(lg, la->cid, tid); - if (bid && logger_del_bat(lg, bid) != GDK_SUCCEED) + if (bid && log_del_bat(lg, bid) != GDK_SUCCEED) return GDK_FAIL; return GDK_SUCCEED; } @@ -773,7 +773,7 @@ la_bat_create(logger *lg, logaction *la, BATtseqbase(b, 0); if ((b = BATsetaccess(b, BAT_READ)) == NULL || - logger_add_bat(lg, b, la->cid, tid) != GDK_SUCCEED) { + log_add_bat(lg, b, la->cid, tid) != GDK_SUCCEED) { logbat_destroy(b); return GDK_FAIL; } @@ -782,7 +782,7 @@ la_bat_create(logger *lg, logaction *la, } static gdk_return -logger_write_new_types(logger *lg, FILE *fp, bool append) +log_write_new_types(logger *lg, FILE *fp, bool append) { bte id = 0; @@ -940,7 +940,7 @@ tr_commit(logger *lg, trans *tr) } static gdk_return -logger_read_types_file(logger *lg, FILE *fp) +log_read_types_file(logger *lg, FILE *fp) { int id = 0; char atom_name[IDLENGTH]; @@ -961,7 +961,7 @@ logger_read_types_file(logger *lg, FILE gdk_return -logger_create_types_file(logger *lg, const char *filename, bool append) +log_create_types_file(logger *lg, const char *filename, bool append) { FILE *fp; @@ -976,7 +976,7 @@ logger_create_types_file(logger *lg, con return GD
MonetDB: default - Make sure storage is initialized, when settin...
Changeset: 02a6f620963a for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/02a6f620963a Modified Files: sql/storage/bat/bat_storage.c Branch: default Log Message: Make sure storage is initialized, when setting min/max. Don't look at view bats diffs (43 lines): diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c --- a/sql/storage/bat/bat_storage.c +++ b/sql/storage/bat/bat_storage.c @@ -2727,6 +2727,18 @@ dcount_col(sql_trans *tr, sql_column *c) return cnt; } +static BAT * +bind_no_view(BAT *b) +{ + if (isVIEW(b)) { /* If it is a view get the parent BAT */ + BAT *nb = BBP_cache(VIEWtparent(b)); + bat_destroy(b); + if (!(b = temp_descriptor(nb->batCacheid))) + return NULL; + } + return b; +} + static int min_max_col(sql_trans *tr, sql_column *c) { @@ -2742,6 +2754,7 @@ min_max_col(sql_trans *tr, sql_column *c if ((d = ATOMIC_PTR_GET(&c->data))) { if (d->cs.st == ST_FOR) return 0; + int access = d->cs.st == ST_DICT ? RD_EXT : RDONLY; lock_column(tr->store, c->base.id); if (c->min && c->max) { unlock_column(tr->store, c->base.id); @@ -2749,7 +2762,11 @@ min_max_col(sql_trans *tr, sql_column *c } _DELETE(c->min); _DELETE(c->max); - if ((b = temp_descriptor(d->cs.st == ST_DICT ? d->cs.ebid : d->cs.bid))) { + if ((b = bind_col(tr, c, access))) { + if (!(b = bind_no_view(b))) { + unlock_column(tr->store, c->base.id); + return 0; + } BATiter bi = bat_iterator(b); if (bi.minpos != BUN_NONE && bi.maxpos != BUN_NONE) { const void *nmin = BUNtail(bi, bi.minpos), *nmax = BUNtail(bi, bi.maxpos); ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - Only load rdonly bat when there are updates t...
Changeset: ad47a42f5522 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/ad47a42f5522 Modified Files: sql/storage/bat/bat_storage.c Branch: default Log Message: Only load rdonly bat when there are updates to merge diffs (45 lines): diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c --- a/sql/storage/bat/bat_storage.c +++ b/sql/storage/bat/bat_storage.c @@ -3900,19 +3900,13 @@ static int merge_cs( column_storage *cs) { int ok = LOG_OK; - BAT *cur = NULL; - - if (cs->bid) { - cur = temp_descriptor(cs->bid); - if(!cur) - return LOG_ERR; - } - - if (cs->ucnt) { + + if (cs->bid && cs->ucnt) { + BAT *cur = temp_descriptor(cs->bid); BAT *ui = temp_descriptor(cs->uibid); BAT *uv = temp_descriptor(cs->uvbid); - if(!ui || !uv) { + if (!cur || !ui || !uv) { bat_destroy(ui); bat_destroy(uv); bat_destroy(cur); @@ -3933,15 +3927,15 @@ merge_cs( column_storage *cs) temp_destroy(cs->uvbid); cs->uibid = e_bat(TYPE_oid); cs->uvbid = e_bat(cur->ttype); - if(cs->uibid == BID_NIL || cs->uvbid == BID_NIL) + if (cs->uibid == BID_NIL || cs->uvbid == BID_NIL) ok = LOG_ERR; cs->ucnt = 0; bat_destroy(ui); bat_destroy(uv); + bat_destroy(cur); } cs->cleared = 0; cs->merged = 1; - bat_destroy(cur); return ok; } ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: properties - Better solution. Run remote/replica rewrit...
Changeset: 93d6c5bdeaa0 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/93d6c5bdeaa0 Modified Files: sql/server/rel_distribute.c sql/server/rel_optimizer.c sql/server/rel_statistics.c Branch: properties Log Message: Better solution. Run remote/replica rewriters before statistics diffs (86 lines): diff --git a/sql/server/rel_distribute.c b/sql/server/rel_distribute.c --- a/sql/server/rel_distribute.c +++ b/sql/server/rel_distribute.c @@ -10,7 +10,6 @@ #include "rel_optimizer_private.h" #include "rel_basetable.h" #include "rel_exp.h" -#include "rel_rewriter.h" #include "sql_privileges.h" static int @@ -69,7 +68,6 @@ rewrite_replica(mvc *sql, list *exps, sq node *n, *m; sql_rel *r = rel_basetable(sql, p, t->base.name); int allowed = 1; - sqlstore *store = sql->session->tr->store; if (!table_privs(sql, p, PRIV_SELECT)) /* Test for privileges */ allowed = 0; @@ -100,8 +98,6 @@ rewrite_replica(mvc *sql, list *exps, sq exp_prop_alias(sql->sa, ne, e); } list_hash_clear(r->exps); /* the child table may have different column names, so clear the hash */ - if (isTable(p) && p->s && !isDeclaredTable(p)) /* count active rows only */ - set_count_prop(sql->sa, r, (BUN)store->storage_api.count_col(sql->session->tr, ol_first_node(p->columns)->data, 10)); /* set_remote() */ if (remote_prop && p && isRemote(p)) { @@ -376,7 +372,6 @@ rel_remote_func_(visitor *v, sql_rel *re if (find_prop(rel->p, PROP_REMOTE) != NULL) { list *exps = rel_projections(v->sql, rel, NULL, 1, 1); rel = rel_relational_func(v->sql->sa, rel, exps); - set_count_prop(v->sql->sa, rel, get_rel_count(rel->l)); } return rel; } 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 @@ -656,14 +656,14 @@ const sql_optimizer pre_sql_optimizers[] /* these optimizers/rewriters only run once after the cycle loop */ const sql_optimizer post_sql_optimizers[] = { {22, "setjoins_2_joingroupby", bind_setjoins_2_joingroupby}, - {23, "get_statistics", bind_get_statistics}, /* gather statistics */ - {24, "join_order2", bind_join_order2}, /* run join order one more time with statistics */ - {25, "final_optimization_loop", bind_final_optimization_loop}, /* run select and group by order with statistics gathered */ /* Merge table rewrites may introduce remote or replica tables */ - /* At the moment, make sure the remote table rewriters always run last */ - {26, "rewrite_remote", bind_rewrite_remote}, - {27, "rewrite_replica", bind_rewrite_replica}, - {28, "remote_func", bind_remote_func}, + /* At the moment, make sure the remote table rewriters always run after the merge table one */ + {23, "rewrite_remote", bind_rewrite_remote}, + {24, "rewrite_replica", bind_rewrite_replica}, + {25, "remote_func", bind_remote_func}, + {26, "get_statistics", bind_get_statistics}, /* gather statistics */ + {27, "join_order2", bind_join_order2}, /* run join order one more time with statistics */ + {28, "final_optimization_loop", bind_final_optimization_loop}, /* run select and group by order with statistics gathered */ { 0, NULL, NULL} /* If an optimizer is going to be added, don't forget to update NSQLREWRITERS macro */ }; diff --git a/sql/server/rel_statistics.c b/sql/server/rel_statistics.c --- a/sql/server/rel_statistics.c +++ b/sql/server/rel_statistics.c @@ -679,7 +679,7 @@ rel_get_statistics_(visitor *v, sql_rel for (node *n = rel->exps->h ; n ; n = n->next) rel_basetable_column_get_statistics(v->sql, rel, n->data); } - /* Set table row count. TODO? look for remote/replica tables. Don't look at storage for declared tables, because it won't be cleaned */ + /* Set table row count. TODO? look for remote tables. Don't look at storage for declared tables, because it won't be cleaned */ if (isTable(t) && t->s && !isDeclaredTable(t)) /* count active rows only */ set_count_prop(v->sql->sa, rel, (BUN)store->storage_api.count_col(v->sql->session->tr, ol_first_node(t->columns)->data, 10)); } break; @@ -692,10 +692,10 @@ rel_get_statistics_(visitor *v, sql_rel while (is_sample(pl->op) || is_topn(pl->op)) /* skip topN and sample relations in the middle */ pl = pl->l; - while (is_sample(r->op) || is_topn(pr->op)) + while (is_sample(pr->op) || is_topn(pr->op)) pr = pr->l; /* if it's not a projection, then project and propagate statistics */ - if (!is_project(pl->op) && !is_base(l->o
MonetDB: properties - Propagate relation counts on remote/replic...
Changeset: 1612d4ada618 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/1612d4ada618 Modified Files: sql/server/rel_distribute.c Branch: properties Log Message: Propagate relation counts on remote/replica table rewrites diffs (36 lines): diff --git a/sql/server/rel_distribute.c b/sql/server/rel_distribute.c --- a/sql/server/rel_distribute.c +++ b/sql/server/rel_distribute.c @@ -10,6 +10,7 @@ #include "rel_optimizer_private.h" #include "rel_basetable.h" #include "rel_exp.h" +#include "rel_rewriter.h" #include "sql_privileges.h" static int @@ -68,6 +69,7 @@ rewrite_replica(mvc *sql, list *exps, sq node *n, *m; sql_rel *r = rel_basetable(sql, p, t->base.name); int allowed = 1; + sqlstore *store = sql->session->tr->store; if (!table_privs(sql, p, PRIV_SELECT)) /* Test for privileges */ allowed = 0; @@ -98,6 +100,8 @@ rewrite_replica(mvc *sql, list *exps, sq exp_prop_alias(sql->sa, ne, e); } list_hash_clear(r->exps); /* the child table may have different column names, so clear the hash */ + if (isTable(p) && p->s && !isDeclaredTable(p)) /* count active rows only */ + set_count_prop(sql->sa, r, (BUN)store->storage_api.count_col(sql->session->tr, ol_first_node(p->columns)->data, 10)); /* set_remote() */ if (remote_prop && p && isRemote(p)) { @@ -372,6 +376,7 @@ rel_remote_func_(visitor *v, sql_rel *re if (find_prop(rel->p, PROP_REMOTE) != NULL) { list *exps = rel_projections(v->sql, rel, NULL, 1, 1); rel = rel_relational_func(v->sql->sa, rel, exps); + set_count_prop(v->sql->sa, rel, get_rel_count(rel->l)); } return rel; } ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: properties - Merged with default
Changeset: 44168b1c3565 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/44168b1c3565 Modified Files: sql/server/rel_optimize_sel.c sql/server/rel_optimizer.c sql/server/rel_statistics.c Branch: properties Log Message: Merged with default diffs (181 lines): diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c --- a/gdk/gdk_aggr.c +++ b/gdk/gdk_aggr.c @@ -1815,7 +1815,17 @@ BATprod(void *res, int tp, BAT *b, BAT * } \ } while (0) -/* calculate group averages with optional candidates list */ +/* There are three functions that are used for calculating averages. + * The first one (BATgroupavg) returns averages as a floating point + * value, the other two (BATgroupavg3 and BATgroupavg3combine) work + * together to return averages in the domain type (which should be an + * integer type). */ + +/* Calculate group averages with optional candidates list. The average + * that is calculated is returned in a dbl, independent of the type of + * the input. The average is calculated exactly, so not in a floating + * point which could potentially losse bits during processing + * (e.g. average of 2**62 and a billion 1's). */ gdk_return BATgroupavg(BAT **bnp, BAT **cntsp, BAT *b, BAT *g, BAT *e, BAT *s, int tp, bool skip_nils, bool abort_on_error, int scale) { @@ -2008,13 +2018,14 @@ BATgroupavg(BAT **bnp, BAT **cntsp, BAT return GDK_FAIL; } -/* An exact numeric average of a bunch of values consists of three parts: the - * average rounded down (towards minus infinity), the number of values that - * participated in the calculation, and the remainder. The remainder is in the - * range 0 (inclusive) to count (not inclusive). BATgroupavg3 calculates these - * values for each given group. The function below, BATgroupavg3combine, - * combines averages calculated this way to correct, rounded or truncated - * towards zero (depending on the symbol TRUNCATE_NUMBERS) averages. */ +/* An exact numeric average of a bunch of values consists of three + * parts: the average rounded down (towards minus infinity), the number + * of values that participated in the calculation, and the remainder. + * The remainder is in the range 0 (inclusive) to count (not inclusive). + * BATgroupavg3 calculates these values for each given group. The + * function below, BATgroupavg3combine, combines averages calculated + * this way to correct averages by rounding or truncating towards zero + * (depending on the symbol TRUNCATE_NUMBERS). */ gdk_return BATgroupavg3(BAT **avgp, BAT **remp, BAT **cntp, BAT *b, BAT *g, BAT *e, BAT *s, bool skip_nils) { diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c --- a/gdk/gdk_logger.c +++ b/gdk/gdk_logger.c @@ -2367,12 +2367,6 @@ log_constant(logger *lg, int type, ptr v gdk_return ok = GDK_SUCCEED; logformat l; lng nr; - int is_row = 0; - - if (lg->row_insert_nrcols != 0) { - lg->row_insert_nrcols--; - is_row = 1; - } l.flag = LOG_UPDATE_CONST; l.id = id; nr = cnt; @@ -2389,12 +2383,10 @@ log_constant(logger *lg, int type, ptr v gdk_return (*wt) (const void *, stream *, size_t) = BATatoms[type].atomWrite; - if (is_row) - l.flag = tpe; if (log_write_format(lg, &l) != GDK_SUCCEED || - (!is_row && !mnstr_writeLng(lg->output_log, nr)) || - (!is_row && mnstr_write(lg->output_log, &tpe, 1, 1) != 1) || - (!is_row && !mnstr_writeLng(lg->output_log, offset))) { + !mnstr_writeLng(lg->output_log, nr) || + mnstr_write(lg->output_log, &tpe, 1, 1) != 1 || + !mnstr_writeLng(lg->output_log, offset)) { (void) ATOMIC_DEC(&lg->refcount); ok = GDK_FAIL; goto bailout; @@ -2467,12 +2459,6 @@ internal_log_bat(logger *lg, BAT *b, log logformat l; BUN p; lng nr; - int is_row = 0; - - if (lg->row_insert_nrcols != 0) { - lg->row_insert_nrcols--; - is_row = 1; - } l.flag = LOG_UPDATE_BULK; l.id = id; nr = cnt; @@ -2487,12 +2473,10 @@ internal_log_bat(logger *lg, BAT *b, log gdk_return (*wt) (const void *, stream *, size_t) = BATatoms[b->ttype].atomWrite; - if (is_row) - l.flag = tpe; if (log_write_format(lg, &l) != GDK_SUCCEED || - (!is_row && !mnstr_writeLng(lg->output_log, nr)) || - (!is_row && mnstr_write(lg->output_log, &tpe, 1, 1) != 1) || - (!is_row && !mnstr_writeLng(lg->output_log, offset))) { + !mnstr_writeLng(lg->output_log, nr) || + mnstr_write(lg->output_log, &tpe, 1, 1) != 1 || + !mnstr_writeLng(lg->output_log, offset)) { ok = GDK_FAIL; goto bailout; } diff --git a/gdk/gdk_logger_internals.h b/gdk/gdk_logger_internals.h --- a/gdk/gdk_logger_
MonetDB: default - Merged with Jan2022
Changeset: 9440025edd3d for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/9440025edd3d Modified Files: gdk/gdk_aggr.c sql/server/rel_optimize_sel.c sql/server/rel_optimizer.c sql/test/SQLancer/Tests/sqlancer08.test Branch: default Log Message: Merged with Jan2022 diffs (115 lines): diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c --- a/gdk/gdk_aggr.c +++ b/gdk/gdk_aggr.c @@ -1815,7 +1815,17 @@ BATprod(void *res, int tp, BAT *b, BAT * } \ } while (0) -/* calculate group averages with optional candidates list */ +/* There are three functions that are used for calculating averages. + * The first one (BATgroupavg) returns averages as a floating point + * value, the other two (BATgroupavg3 and BATgroupavg3combine) work + * together to return averages in the domain type (which should be an + * integer type). */ + +/* Calculate group averages with optional candidates list. The average + * that is calculated is returned in a dbl, independent of the type of + * the input. The average is calculated exactly, so not in a floating + * point which could potentially losse bits during processing + * (e.g. average of 2**62 and a billion 1's). */ gdk_return BATgroupavg(BAT **bnp, BAT **cntsp, BAT *b, BAT *g, BAT *e, BAT *s, int tp, bool skip_nils, bool abort_on_error, int scale) { @@ -2008,13 +2018,14 @@ BATgroupavg(BAT **bnp, BAT **cntsp, BAT return GDK_FAIL; } -/* An exact numeric average of a bunch of values consists of three parts: the - * average rounded down (towards minus infinity), the number of values that - * participated in the calculation, and the remainder. The remainder is in the - * range 0 (inclusive) to count (not inclusive). BATgroupavg3 calculates these - * values for each given group. The function below, BATgroupavg3combine, - * combines averages calculated this way to correct, rounded or truncated - * towards zero (depending on the symbol TRUNCATE_NUMBERS) averages. */ +/* An exact numeric average of a bunch of values consists of three + * parts: the average rounded down (towards minus infinity), the number + * of values that participated in the calculation, and the remainder. + * The remainder is in the range 0 (inclusive) to count (not inclusive). + * BATgroupavg3 calculates these values for each given group. The + * function below, BATgroupavg3combine, combines averages calculated + * this way to correct averages by rounding or truncating towards zero + * (depending on the symbol TRUNCATE_NUMBERS). */ gdk_return BATgroupavg3(BAT **avgp, BAT **remp, BAT **cntp, BAT *b, BAT *g, BAT *e, BAT *s, bool skip_nils) { diff --git a/sql/server/rel_optimize_sel.c b/sql/server/rel_optimize_sel.c --- a/sql/server/rel_optimize_sel.c +++ b/sql/server/rel_optimize_sel.c @@ -3835,10 +3835,10 @@ point_select_on_unique_column(sql_rel *r static sql_rel * rel_push_select_up_(visitor *v, sql_rel *rel) { - if ((is_join(rel->op) || is_semi(rel->op)) && !is_single(rel)) { + if ((is_innerjoin(rel->op) || is_left(rel->op) || is_right(rel->op) || is_semi(rel->op)) && !is_single(rel)) { sql_rel *l = rel->l, *r = rel->r; - bool can_pushup_left = is_select(l->op) && !rel_is_ref(l) && !is_single(l), -can_pushup_right = is_select(r->op) && !rel_is_ref(r) && !is_single(r) && !is_semi(rel->op); + bool can_pushup_left = is_select(l->op) && !rel_is_ref(l) && !is_single(l) && (is_innerjoin(rel->op) || is_left(rel->op) || is_semi(rel->op)), +can_pushup_right = is_select(r->op) && !rel_is_ref(r) && !is_single(r) && (is_innerjoin(rel->op) || is_right(rel->op)); if (can_pushup_left || can_pushup_right) { if (can_pushup_left) @@ -3877,5 +3877,5 @@ bind_push_select_up(visitor *v, global_p { int flag = v->sql->sql_optimizer; return gp->opt_level == 1 && gp->cnt[op_select] && (gp->cnt[op_join] || gp->cnt[op_left] || - gp->cnt[op_right] || gp->cnt[op_full] || gp->cnt[op_semi] || gp->cnt[op_anti]) && (flag & push_select_up) ? rel_push_select_up : NULL; + gp->cnt[op_right] || gp->cnt[op_semi] || gp->cnt[op_anti]) && (flag & push_select_up) ? rel_push_select_up : NULL; } diff --git a/sql/test/SQLancer/Tests/sqlancer08.test b/sql/test/SQLancer/Tests/sqlancer08.test --- a/sql/test/SQLancer/Tests/sqlancer08.test +++ b/sql/test/SQLancer/Tests/sqlancer08.test @@ -423,3 +423,43 @@ ROLLBACK statement error 22003!overflow in conversion of 789092170 to bte. SELECT round(- (((-443710828)||(1616633099))), 789092170) +statement ok +START TRANSACTION + +statement ok +CREATE TABLE "rt0" ("c0" BOOLEAN,"c1" BOOLEAN NOT NULL, CONSTRAINT "rt0_c1_pkey" PRIMARY KEY ("c1")) + +statement ok rowcount 2 +INSERT INTO "rt0" VALUES (NULL, false), (false, true) + +query I nosort +SELECT rt0.c1 FROM rt0 FULL OUTER JOIN (VALUE
MonetDB: Jan2022 - Don't push up selections on non-outer sides
Changeset: edbd77694605 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/edbd77694605 Modified Files: sql/server/rel_optimizer.c sql/test/SQLancer/Tests/sqlancer08.test Branch: Jan2022 Log Message: Don't push up selections on non-outer sides diffs (64 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 @@ -4708,10 +4708,10 @@ point_select_on_unique_column(sql_rel *r static sql_rel * rel_push_select_up(visitor *v, sql_rel *rel) { - if ((is_join(rel->op) || is_semi(rel->op)) && !rel_is_ref(rel) && !is_single(rel)) { + if ((is_innerjoin(rel->op) || is_left(rel->op) || is_right(rel->op) || is_semi(rel->op)) && !is_single(rel)) { sql_rel *l = rel->l, *r = rel->r; - bool can_pushup_left = is_select(l->op) && !rel_is_ref(l) && !is_single(l), -can_pushup_right = is_select(r->op) && !rel_is_ref(r) && !is_single(r) && !is_semi(rel->op); + bool can_pushup_left = is_select(l->op) && !rel_is_ref(l) && !is_single(l) && (is_innerjoin(rel->op) || is_left(rel->op) || is_semi(rel->op)), +can_pushup_right = is_select(r->op) && !rel_is_ref(r) && !is_single(r) && (is_innerjoin(rel->op) || is_right(rel->op)); if (can_pushup_left || can_pushup_right) { if (can_pushup_left) diff --git a/sql/test/SQLancer/Tests/sqlancer08.test b/sql/test/SQLancer/Tests/sqlancer08.test --- a/sql/test/SQLancer/Tests/sqlancer08.test +++ b/sql/test/SQLancer/Tests/sqlancer08.test @@ -430,3 +430,43 @@ ROLLBACK statement error 22003!overflow in conversion of 789092170 to bte. SELECT round(- (((-443710828)||(1616633099))), 789092170) +statement ok +START TRANSACTION + +statement ok +CREATE TABLE "rt0" ("c0" BOOLEAN,"c1" BOOLEAN NOT NULL, CONSTRAINT "rt0_c1_pkey" PRIMARY KEY ("c1")) + +statement ok rowcount 2 +INSERT INTO "rt0" VALUES (NULL, false), (false, true) + +query I nosort +SELECT rt0.c1 FROM rt0 FULL OUTER JOIN (VALUES (1)) x(x) ON TRUE AND 'a' = 'b' WHERE rt0.c1 + +1 + +query I nosort +SELECT rt0.c1 FROM rt0 RIGHT OUTER JOIN (VALUES (1)) x(x) ON TRUE AND 'a' = 'b' WHERE rt0.c1 + + +query I nosort +SELECT rt0.c1 FROM rt0 LEFT OUTER JOIN (VALUES (1)) x(x) ON TRUE AND 'a' = 'b' WHERE rt0.c1 + +1 + +query I nosort +SELECT CAST(SUM(count) AS BIGINT) FROM (SELECT CAST(rt0.c1 AS INT) as count FROM rt0 FULL OUTER JOIN (VALUES (1)) AS nort0(norc0) ON TRUE AND 'a' = 'b') as res + +1 + +query I nosort +SELECT CAST(SUM(count) AS BIGINT) FROM (SELECT CAST(rt0.c1 AS INT) as count FROM rt0 RIGHT OUTER JOIN (VALUES (1)) AS nort0(norc0) ON TRUE AND 'a' = 'b') as res + +NULL + +query I nosort +SELECT CAST(SUM(count) AS BIGINT) FROM (SELECT CAST(rt0.c1 AS INT) as count FROM rt0 LEFT OUTER JOIN (VALUES (1)) AS nort0(norc0) ON TRUE AND 'a' = 'b') as res + +1 + +statement ok +ROLLBACK ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: properties - Merged with default
Changeset: 99c9270bd729 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/99c9270bd729 Branch: properties Log Message: Merged with default diffs (truncated from 446 to 300 lines): diff --git a/MonetDB.spec b/MonetDB.spec --- a/MonetDB.spec +++ b/MonetDB.spec @@ -365,6 +365,7 @@ developer. %{_bindir}/smack00 %{_bindir}/smack01 %{_bindir}/streamcat +%{_bindir}/testcondvar %{_bindir}/testgetinfo %{_bindir}/testStmtAttr %{_bindir}/malsample.pl diff --git a/clients/Tests/All b/clients/Tests/All --- a/clients/Tests/All +++ b/clients/Tests/All @@ -3,3 +3,4 @@ HAVE_HGE&HAVE_FITS&HAVE_GEOM&HAVE_LIBR&H !HAVE_HGE&HAVE_FITS&HAVE_GEOM&HAVE_LIBR&HAVE_LIBPY3&HAVE_NETCDF&HAVE_SHP&NOT_WIN32?MAL-signatures NOT_WIN32&MERCURIAL?melcheck mclient-uri +testcondvar diff --git a/clients/Tests/testcondvar.py b/clients/Tests/testcondvar.py new file mode 100644 --- /dev/null +++ b/clients/Tests/testcondvar.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 + +import subprocess +import sys + +try: +subprocess.check_output("testcondvar", stderr=subprocess.STDOUT) +except subprocess.CalledProcessError as e: +output = str(e.stdout, 'utf-8') +if not output.endswith('\n'): +output += '\n' +print(f"Test program failed with the following output:\n--", file=sys.stderr) +print(f"{output}-", file=sys.stderr) +sys.exit('TEST FAILED') diff --git a/clients/examples/C/CMakeLists.txt b/clients/examples/C/CMakeLists.txt --- a/clients/examples/C/CMakeLists.txt +++ b/clients/examples/C/CMakeLists.txt @@ -45,6 +45,16 @@ if(TESTING) monetdb_config_header stream) + add_executable(testcondvar +testcondvar.c) + + target_link_libraries(testcondvar +PRIVATE +monetdb_config_header +bat +Threads::Threads + ) + add_executable(bincopydata bincopydata.c bincopydata.h @@ -75,6 +85,7 @@ if(TESTING) smack00 smack01 streamcat +testcondvar bincopydata RUNTIME DESTINATION @@ -89,6 +100,7 @@ if(TESTING) $ $ $ + $ $ $ DESTINATION ${CMAKE_INSTALL_BINDIR} diff --git a/clients/examples/C/testcondvar.c b/clients/examples/C/testcondvar.c new file mode 100644 --- /dev/null +++ b/clients/examples/C/testcondvar.c @@ -0,0 +1,183 @@ +/* + * 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 - 2022 MonetDB B.V. + */ + +#include "monetdb_config.h" +#include "gdk.h" +#include "gdk_system.h" + +#include + +#define NN (3) + +volatile int timeout = 100; // set this to 0 during interactive debugging + +/* global state protected by a lock: */ + +MT_Lock lock = MT_LOCK_INITIALIZER(lock); +MT_Cond condvar = MT_COND_INITIALIZER(the_condvar); +struct state { + MT_Id id; + int ticks; + int permits; + bool terminate; + bool terminated; +} states[NN] = { {0} }; + + +static void +let_run(void) +{ + MT_lock_unset(&lock); + + MT_sleep_ms(100); + + int attempts = 0; + while (!MT_lock_try(&lock)) { + if (timeout > 0 && ++attempts > timeout) { + fprintf(stderr, "Can't get hold of the lock after %d attempts\n", attempts); + abort(); + } + MT_sleep_ms(10); + } + + fprintf(stderr, "\n"); +} + + +static void +worker(void *arg) +{ + struct state *st = arg; + int id = (int)(st - &states[0]); + fprintf(stderr, "worker %d starting\n", id); + + MT_lock_set(&lock); + while (1) { + if (st->terminate) { + fprintf(stderr, "worker %d terminating\n", id); + break; + } + if (st->permits > 0) { + fprintf(stderr, "worker %d ticking\n", id); + st->ticks++; + st->permits--; + } + fprintf(stderr, "worker %d waiting\n", id); + MT_cond_wait(&condvar, &lock); + fprintf(stderr, "worker %d woke up\n", id); + } + st->terminated = true; + MT_lock_unset(&lock); +} + + +static void clear(void) +{ + for (int i = 0; i < NN; i++) { + struct state *st = &states[i]; + st->permits = 0; + st->ticks = 0; + } +} + + +static void +check_impl(int line, int expected_sum_ticks, int expected_max_ticks, int expected_sum_permits) +{ + int sum_ticks = 0; + int max_ticks = -1; + int sum_permits = 0; + + for (int i = 0; i < NN; i++) { + sum_permits += states[i].permits; + int ticks = states[i].ticks; + sum_ticks += ticks; + if (ticks > max_ticks) + max_ticks = ticks; + } + + bool good = true; + go
MonetDB: properties - For a grouping column, compute number of p...
Changeset: d9ec566d2152 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/d9ec566d2152 Modified Files: sql/server/rel_statistics.c Branch: properties Log Message: For a grouping column, compute number of possible groups/rows using (max-min+1) for numeric types. Then compute the result with MIN((max-min+1),nuniques) diffs (85 lines): diff --git a/sql/server/rel_statistics.c b/sql/server/rel_statistics.c --- a/sql/server/rel_statistics.c +++ b/sql/server/rel_statistics.c @@ -616,7 +616,7 @@ trivial_project_exp_card(sql_exp *e) } static BUN -rel_calc_nuniques(sql_rel *l, list *exps) +rel_calc_nuniques(mvc *sql, sql_rel *l, list *exps) { BUN lv = get_rel_count(l); @@ -629,14 +629,28 @@ rel_calc_nuniques(sql_rel *l, list *exps sql_exp *e = n->data; sql_rel *bt = NULL; prop *p = NULL; + BUN euniques = BUN_NONE; + atom *min, *max, *sub = NULL; + sql_subtype *tp = exp_subtype(e); + sql_class ec = tp ? tp->type->eclass : EC_STRING; /* if 'e' has no type (eg parameter), use a non-number type to fail condition */ if ((p = find_prop(e->p, PROP_NUNIQUES))) { - nuniques = MAX(nuniques, (BUN) p->value.dval); + euniques = (BUN) p->value.dval; } else if (e->type == e_column && rel_find_exp_and_corresponding_rel(l, e, false, &bt, NULL) && bt && (p = find_prop(bt->p, PROP_COUNT))) { - nuniques = MAX(nuniques, p->value.lval); - } else { + euniques = (BUN) p->value.lval; + } + /* use min to max range to compute number of possible values in the domain for number types */ + if ((EC_TEMP(ec)||ec==EC_NUM||ec==EC_MONTH||ec==EC_POS) && + (min = find_prop_and_get(e->p, PROP_MIN)) && (max = find_prop_and_get(e->p, PROP_MAX))) { + /* the range includes min and max, so the atom_inc call is needed */ + /* if 'euniques' has number of distinct values, compute min between both */ + if ((sub = atom_sub(sql->sa, max, min)) && (sub = atom_inc(sql->sa, sub)) && (sub = atom_cast(sql->sa, sub, sql_bind_localtype("oid" + euniques = MIN(euniques, (BUN) sub->data.val.oval); + } + if (euniques != BUN_NONE) + nuniques = MAX(nuniques, euniques); /* the highest cardinality sets the estimation */ + else nuniques = BUN_NONE; - } } if (nuniques != BUN_NONE) return nuniques; @@ -699,8 +713,8 @@ rel_get_statistics_(visitor *v, sql_rel /* propagate row count */ if (is_union(rel->op)) { - BUN lv = need_distinct(rel) ? rel_calc_nuniques(l, l->exps) : get_rel_count(l), - rv = need_distinct(rel) ? rel_calc_nuniques(r, r->exps) : get_rel_count(r); + BUN lv = need_distinct(rel) ? rel_calc_nuniques(v->sql, l, l->exps) : get_rel_count(l), + rv = need_distinct(rel) ? rel_calc_nuniques(v->sql, r, r->exps) : get_rel_count(r); if (lv == 0 && rv == 0) { /* both sides empty */ if (can_be_pruned) @@ -717,8 +731,8 @@ rel_get_statistics_(visitor *v, sql_rel set_count_prop(v->sql->sa, rel, (rv > (BUN_MAX - lv)) ? BUN_MAX : (lv + rv)); /* overflow check */ } } else if (is_inter(rel->op) || is_except(rel->op)) { - BUN lv = need_distinct(rel) ? rel_calc_nuniques(l, l->exps) : get_rel_count(l), - rv = need_distinct(rel) ? rel_calc_nuniques(r, r->exps) : get_rel_count(r); + BUN lv = need_distinct(rel) ? rel_calc_nuniques(v->sql, l, l->exps) : get_rel_count(l), + rv = need_distinct(rel) ? rel_calc_nuniques(v->sql, r, r->exps) : get_rel_count(r); if (lv == 0) { /* left side empty */ if (can_be_pruned) @@ -855,7 +869,7 @@ rel_get_statistics_(visitor *v, sql_rel case op_project: { if (l) { if (need_distinct(rel)) { - set_count_prop(v->sql->sa, rel, rel_calc_nuniques(l, rel->exps)); + set_count_prop(v->sql->sa, rel, rel_calc_nuniques(v->sql, l, rel->exps));
MonetDB: histograms - Extract variable from macro
Changeset: b11a3e64fa29 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/b11a3e64fa29 Modified Files: gdk/gdk_histogram.c Branch: histograms Log Message: Extract variable from macro diffs (19 lines): diff --git a/gdk/gdk_histogram.c b/gdk/gdk_histogram.c --- a/gdk/gdk_histogram.c +++ b/gdk/gdk_histogram.c @@ -431,7 +431,6 @@ HISTOGRAMcreate(BAT *b) #define histogram_print_loop(TPE) \ do { \ - ssize_t (*atomtostr)(str *, size_t *, const void *, bool) = BATatoms[ptype].atomToStr; \ const HistogramBucket_##TPE *restrict hist = (HistogramBucket_##TPE *) b->thistogram->histogram; \ for (int i = 0 ; i < nbuckets ; i++) { \ const HistogramBucket_##TPE *restrict hb = &(hist[i]); \ @@ -490,6 +489,7 @@ HISTOGRAMprint(BAT *b) if (tpe == TYPE_str) /* strings use integer size buckets */ ptype = TYPE_int; + ssize_t (*atomtostr)(str *, size_t *, const void *, bool) = BATatoms[ptype].atomToStr; nbuckets = b->thistogram->nbuckets; switch (tpe) { case TYPE_bte: ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: histograms - Use right type to print histogram
Changeset: 0220c3612bba for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/0220c3612bba Modified Files: gdk/gdk_histogram.c Branch: histograms Log Message: Use right type to print histogram diffs (30 lines): diff --git a/gdk/gdk_histogram.c b/gdk/gdk_histogram.c --- a/gdk/gdk_histogram.c +++ b/gdk/gdk_histogram.c @@ -431,7 +431,7 @@ HISTOGRAMcreate(BAT *b) #define histogram_print_loop(TPE) \ do { \ - ssize_t (*atomtostr)(str *, size_t *, const void *, bool) = BATatoms[TYPE_##TPE].atomToStr; \ + ssize_t (*atomtostr)(str *, size_t *, const void *, bool) = BATatoms[ptype].atomToStr; \ const HistogramBucket_##TPE *restrict hist = (HistogramBucket_##TPE *) b->thistogram->histogram; \ for (int i = 0 ; i < nbuckets ; i++) { \ const HistogramBucket_##TPE *restrict hb = &(hist[i]); \ @@ -465,7 +465,7 @@ HISTOGRAMprint(BAT *b) { size_t len = 0, rlen = 2048, minlen = 256, maxlen = 256; str res = NULL, minbuf = NULL, maxbuf = NULL; - int tpe = ATOMbasetype(b->ttype), nbuckets; + int tpe = ATOMbasetype(b->ttype), nbuckets, ptype = b->ttype; if (VIEWtparent(b)) /* don't look on views */ b = BBP_cache(VIEWtparent(b)); @@ -488,6 +488,8 @@ HISTOGRAMprint(BAT *b) len = sprintf(res, "Total entries: %d, buckets: %d\n", b->thistogram->size, b->thistogram->nbuckets); len += sprintf(res + len, "nulls -> %d\n", b->thistogram->nulls); + if (tpe == TYPE_str) /* strings use integer size buckets */ + ptype = TYPE_int; nbuckets = b->thistogram->nbuckets; switch (tpe) { case TYPE_bte: ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: histograms - Merged with default
Changeset: c17178356505 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/c17178356505 Modified Files: gdk/gdk.h gdk/gdk_bat.c gdk/gdk_bbp.c sql/backends/monet5/sql.c Branch: histograms Log Message: Merged with default diffs (truncated from 2176 to 300 lines): diff --git a/.hgtags b/.hgtags --- a/.hgtags +++ b/.hgtags @@ -763,3 +763,4 @@ cab90a348501b045e19cee5cebcc44f3800bd0a8 5872f047d97c98d3a848514438b8f97fa446855d Jan2022_11 025239a5a6f122042798c0f1132a2c6298514e06 Jan2022_13 025239a5a6f122042798c0f1132a2c6298514e06 Jan2022_SP2_release +2e54857a91306cc6304825c5596f65d00595db6b Jul2021_23 diff --git a/buildtools/conf/Maddlog b/buildtools/conf/Maddlog --- a/buildtools/conf/Maddlog +++ b/buildtools/conf/Maddlog @@ -189,6 +189,9 @@ fi file=ChangeLog.$RANDOM +# make sure we get the correct day and month names +export LC_ALL=en_US.utf-8 + case "$CL" in */*) cd "${CL%/*}" diff --git a/clients/Tests/MAL-signatures-hge.test b/clients/Tests/MAL-signatures-hge.test --- a/clients/Tests/MAL-signatures-hge.test +++ b/clients/Tests/MAL-signatures-hge.test @@ -58194,11 +58194,6 @@ pattern capi.eval_aggr(X_0:ptr, X_1:bit, CUDFevalAggr; grouped aggregates through CUDF capi -prelude -command capi.prelude():void -CUDFprelude; -(empty) -capi subeval_aggr pattern capi.subeval_aggr(X_0:ptr, X_1:bit, X_2:str, X_3:any...):any... CUDFevalAggr; @@ -59784,11 +59779,6 @@ command geom.mbrRight(X_0:wkb, X_1:wkb): mbrRight_wkb; Returns true if the mbr of geom1 is right of the mbr of geom2 geom -prelude -command geom.prelude():void -geom_prelude; -(empty) -geom setSRID command geom.setSRID(X_0:wkb, X_1:int):wkb wkbSetSRID; @@ -59983,11 +59973,6 @@ identifier command identifier.identifier(X_0:str):identifier IDentifier; Cast a string to an identifer -identifier -prelude -command identifier.prelude():void -IDprelude; -Initialize the module inet != command inet.!=(X_0:inet, X_1:inet):bit @@ -60429,11 +60414,6 @@ command json.number(X_0:json):dbl JSONjson2number; Convert simple JSON values to a double, return nil upon error. json -prelude -command json.prelude():void -JSONprelude; -(empty) -json renderarray pattern json.renderarray(X_0:any...):json JSONrenderarray; @@ -60819,11 +60799,6 @@ command mapi.ping(X_0:int):int SERVERping; Test availability of an Mserver. mapi -prelude -command mapi.prelude():int -SERVERlisten_default; -(empty) -mapi prepare command mapi.prepare(X_0:int, X_1:str):int SERVERprepare; @@ -61319,11 +61294,6 @@ command mmath.pow(X_0:flt, X_1:flt):flt MATHbinary_POWflt; (empty) mmath -prelude -command mmath.prelude():void -MATHprelude; -initilize mmath module -mmath radians command mmath.radians(X_0:dbl):dbl MATHunary_RADIANSdbl; @@ -62039,11 +62009,6 @@ pattern optimizer.postfix(X_0:str, X_1:s OPTwrapper; Postfix the plan,e.g. pushing projections optimizer -prelude -pattern optimizer.prelude():void -optimizer_prelude; -Initialize the optimizer -optimizer profiler pattern optimizer.profiler():str OPTwrapper; @@ -62199,11 +62164,6 @@ command pcre.pcre_quote(X_0:str):str PCREquote; Return a PCRE pattern string that matches the argument exactly. pcre -prelude -command pcre.prelude():void -pcre_init; -Initialize pcre -pcre replace command pcre.replace(X_0:str, X_1:str, X_2:str, X_3:str):str PCREreplace_wrap; @@ -62334,11 +62294,6 @@ unsafe pattern pyapi3.eval_loader(X_0:pt PYAPI3PyAPIevalLoader; loader functions through Python pyapi3 -prelude -command pyapi3.prelude():void -PYAPI3PyAPIprelude; -(empty) -pyapi3 subeval_aggr unsafe pattern pyapi3.subeval_aggr(X_0:ptr, X_1:str, X_2:any...):any... PYAPI3PyAPIevalAggr; @@ -62424,11 +62379,6 @@ pattern rapi.eval_aggr(X_0:ptr, X_1:str, RAPIevalAggr; grouped aggregates through R rapi -prelude -command rapi.prelude():void -RAPIprelude; -(empty) -rapi subeval_aggr pattern rapi.subeval_aggr(X_0:ptr, X_1:str, X_2:any...):any... RAPIevalAggr; @@ -62519,11 +62469,6 @@ command remote.isalive(X_0:str):int RMTisalive; check if conn is still valid and connected remote -prelude -command remote.prelude():void -RMTprelude; -initialise the remote module -remote put pattern remote.put(X_0:str, X_1:any):str RMTput; @@ -64224,11 +64169,6 @@ command str.prefix(X_0:str, X_1:int):str STRprefix; Extract the prefix of a given length str -prelude -command str.prelude():void -STRprelude; -(empty) -str r_search command str.r_search(X_0:str, X_1:str):int STRReverseStrSearch; @@ -65474,11 +65414,6 @@ command xml.pi(X_0:str, X_1:str):xml XMLpi; Construct a processing instruction xml -prelude -command xml.prelude():void -XMLprelude; -(empty) -xml root command xml.root(X_0:xml, X_1:str, X_2:str):xml XMLroot; diff --git a/clients/Tests/MAL-signatures.test b/clients/Tests/MAL-signatures.test --- a/clients/Tests/MAL-signatures.test +++ b/clients/Tests/MAL-signatures.test @@ -41779,11 +41779,6 @@ pattern capi.eval_aggr(X_0:ptr, X_1:bit, CUDFevalAggr;
MonetDB: properties - Check column expressions only
Changeset: 8d21b53d98b9 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/8d21b53d98b9 Modified Files: sql/server/rel_statistics.c Branch: properties Log Message: Check column expressions only diffs (12 lines): diff --git a/sql/server/rel_statistics.c b/sql/server/rel_statistics.c --- a/sql/server/rel_statistics.c +++ b/sql/server/rel_statistics.c @@ -632,7 +632,7 @@ rel_calc_nuniques(sql_rel *l, list *exps if ((p = find_prop(e->p, PROP_NUNIQUES))) { nuniques = MAX(nuniques, (BUN) p->value.dval); - } else if (rel_find_exp_and_corresponding_rel(l, e, false, &bt, NULL) && bt && (p = find_prop(bt->p, PROP_COUNT))) { + } else if (e->type == e_column && rel_find_exp_and_corresponding_rel(l, e, false, &bt, NULL) && bt && (p = find_prop(bt->p, PROP_COUNT))) { nuniques = MAX(nuniques, p->value.lval); } else { nuniques = BUN_NONE; ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: properties - My mistake, use right relations
Changeset: 8bc75e695e56 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/8bc75e695e56 Modified Files: sql/server/rel_statistics.c Branch: properties Log Message: My mistake, use right relations diffs (25 lines): diff --git a/sql/server/rel_statistics.c b/sql/server/rel_statistics.c --- a/sql/server/rel_statistics.c +++ b/sql/server/rel_statistics.c @@ -699,8 +699,8 @@ rel_get_statistics_(visitor *v, sql_rel /* propagate row count */ if (is_union(rel->op)) { - BUN lv = need_distinct(rel) ? rel_calc_nuniques(pl, pl->exps) : get_rel_count(pl), - rv = need_distinct(rel) ? rel_calc_nuniques(pr, pr->exps) : get_rel_count(pr); + BUN lv = need_distinct(rel) ? rel_calc_nuniques(l, l->exps) : get_rel_count(l), + rv = need_distinct(rel) ? rel_calc_nuniques(r, r->exps) : get_rel_count(r); if (lv == 0 && rv == 0) { /* both sides empty */ if (can_be_pruned) @@ -717,8 +717,8 @@ rel_get_statistics_(visitor *v, sql_rel set_count_prop(v->sql->sa, rel, (rv > (BUN_MAX - lv)) ? BUN_MAX : (lv + rv)); /* overflow check */ } } else if (is_inter(rel->op) || is_except(rel->op)) { - BUN lv = need_distinct(rel) ? rel_calc_nuniques(pl, pl->exps) : get_rel_count(pl), - rv = need_distinct(rel) ? rel_calc_nuniques(pr, pr->exps) : get_rel_count(pr); + BUN lv = need_distinct(rel) ? rel_calc_nuniques(l, l->exps) : get_rel_count(l), + rv = need_distinct(rel) ? rel_calc_nuniques(r, r->exps) : get_rel_count(r); if (lv == 0) { /* left side empty */ if (can_be_pruned) ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: properties - If the right side of an intersection is em...
Changeset: fcf36ca9522e for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/fcf36ca9522e Modified Files: sql/server/rel_statistics.c Branch: properties Log Message: If the right side of an intersection is empty, the result is empty. Also attempt to propagate counts at joins if one of the sides is unknown diffs (86 lines): diff --git a/sql/server/rel_statistics.c b/sql/server/rel_statistics.c --- a/sql/server/rel_statistics.c +++ b/sql/server/rel_statistics.c @@ -709,8 +709,10 @@ rel_get_statistics_(visitor *v, sql_rel set_count_prop(v->sql->sa, rel, 0); } else if (can_be_pruned && lv == 0 && !rel_is_ref(rel)) { /* left side empty */ rel = set_setop_side(v, rel, r); + empty_cross = false; /* don't rewrite again */ } else if (can_be_pruned && rv == 0 && !rel_is_ref(rel)) { /* right side empty */ rel = set_setop_side(v, rel, l); + empty_cross = false; /* don't rewrite again */ } else if (lv != BUN_NONE && rv != BUN_NONE) { set_count_prop(v->sql->sa, rel, (rv > (BUN_MAX - lv)) ? BUN_MAX : (lv + rv)); /* overflow check */ } @@ -723,8 +725,18 @@ rel_get_statistics_(visitor *v, sql_rel empty_cross = true; else set_count_prop(v->sql->sa, rel, 0); - } else if (can_be_pruned && !empty_cross && rv == 0 && !rel_is_ref(rel)) { /* right side empty */ - rel = set_setop_side(v, rel, l); + } else if (rv == 0) { /* right side empty */ + if (is_inter(rel->op)) { + if (can_be_pruned) + empty_cross = true; + else + set_count_prop(v->sql->sa, rel, 0); + } else if (can_be_pruned && !rel_is_ref(rel)) { + rel = set_setop_side(v, rel, l); + empty_cross = false; /* don't rewrite again */ + } else { + set_count_prop(v->sql->sa, rel, lv); + } } else { set_count_prop(v->sql->sa, rel, lv); } @@ -741,7 +753,7 @@ rel_get_statistics_(visitor *v, sql_rel } list_hash_clear(rel->exps); sql_rel *l = rel_project(v->sql->sa, NULL, rel->exps); - set_count_prop(v->sql->sa, l, 0); + set_count_prop(v->sql->sa, l, 1); l = rel_select(v->sql->sa, l, exp_atom_bool(v->sql->sa, 0)); set_count_prop(v->sql->sa, l, 0); rel->op = op_project; @@ -809,25 +821,23 @@ rel_get_statistics_(visitor *v, sql_rel set_count_prop(v->sql->sa, rel, join_idx_estimate); } else if (uniques_estimate != BUN_MAX) { set_count_prop(v->sql->sa, rel, uniques_estimate); + } else if (list_length(rel->exps) == 1 && (exp_is_false(rel->exps->h->data) || exp_is_null(rel->exps->h->data))) { + /* corner cases for outer joins */ + if (is_left(rel->op)) { + set_count_prop(v->sql->sa, rel, lv); + } else if (is_right(rel->op)) { + set_count_prop(v->sql->sa, rel, rv); + } else if (is_full(rel->op) && lv != BUN_NONE && rv != BUN_NONE) { + set_count_prop(v->sql->sa, rel, (rv > (BUN_MAX - lv)) ? BUN_MAX : (lv + rv)); /* overflow check */ + } else if (lv != BUN_NONE && rv != BUN_NONE) { + set_count_prop(v->sql->sa, rel, 0); + } + } else if (lv == 0) { + set_count_prop(v->sql->sa, rel, (is_right(rel->op) || is_full(rel->op)) ? rv : 0); + } else if (rv == 0) { + set_count_prop(v->sql->sa, rel, (is_left(rel->op) || is_full(rel->op)) ? lv : 0); } else if (lv != BUN_NONE && rv != BUN_NONE) { - if (list_length(rel->exps) == 1 && (exp_is_false(rel->exps->h->data) || exp_is_null(rel->exps->h->data))) { - /* corner cases
MonetDB: properties - Tunning grouping estimates
Changeset: ae4780eb3d9d for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/ae4780eb3d9d Modified Files: sql/server/rel_statistics.c Branch: properties Log Message: Tunning grouping estimates diffs (82 lines): diff --git a/sql/server/rel_statistics.c b/sql/server/rel_statistics.c --- a/sql/server/rel_statistics.c +++ b/sql/server/rel_statistics.c @@ -616,8 +616,12 @@ trivial_project_exp_card(sql_exp *e) } static BUN -rel_calc_nuniques(sql_rel *rel, sql_rel *l, list *exps) +rel_calc_nuniques(sql_rel *l, list *exps) { + BUN lv = get_rel_count(l); + + if (lv == 0) + return 0; if (!list_empty(exps)) { BUN nuniques = 0; /* compute the highest number of unique values */ @@ -626,18 +630,18 @@ rel_calc_nuniques(sql_rel *rel, sql_rel sql_rel *bt = NULL; prop *p = NULL; - if (e->type == e_column && is_unique(e) && - name_find_column(rel, e->l, e->r, -1, &bt) && bt && (p = find_prop(bt->p, PROP_COUNT))) { + if ((p = find_prop(e->p, PROP_NUNIQUES))) { + nuniques = MAX(nuniques, (BUN) p->value.dval); + } else if (rel_find_exp_and_corresponding_rel(l, e, false, &bt, NULL) && bt && (p = find_prop(bt->p, PROP_COUNT))) { nuniques = MAX(nuniques, p->value.lval); - } else if ((p = find_prop(e->p, PROP_NUNIQUES))) { - nuniques = MAX(nuniques, (BUN) p->value.dval); } else { nuniques = BUN_NONE; } } - return nuniques != BUN_NONE ? nuniques : get_rel_count(l); + if (nuniques != BUN_NONE) + return nuniques; } - return get_rel_count(l); + return lv; } static sql_rel * @@ -695,8 +699,8 @@ rel_get_statistics_(visitor *v, sql_rel /* propagate row count */ if (is_union(rel->op)) { - BUN lv = need_distinct(rel) ? rel_calc_nuniques(rel, pl, pl->exps) : get_rel_count(pl), - rv = need_distinct(rel) ? rel_calc_nuniques(rel, pr, pr->exps) : get_rel_count(pr); + BUN lv = need_distinct(rel) ? rel_calc_nuniques(pl, pl->exps) : get_rel_count(pl), + rv = need_distinct(rel) ? rel_calc_nuniques(pr, pr->exps) : get_rel_count(pr); if (lv == 0 && rv == 0) { /* both sides empty */ if (can_be_pruned) @@ -711,8 +715,8 @@ rel_get_statistics_(visitor *v, sql_rel set_count_prop(v->sql->sa, rel, (rv > (BUN_MAX - lv)) ? BUN_MAX : (lv + rv)); /* overflow check */ } } else if (is_inter(rel->op) || is_except(rel->op)) { - BUN lv = need_distinct(rel) ? rel_calc_nuniques(rel, pl, pl->exps) : get_rel_count(pl), - rv = need_distinct(rel) ? rel_calc_nuniques(rel, pr, pr->exps) : get_rel_count(pr); + BUN lv = need_distinct(rel) ? rel_calc_nuniques(pl, pl->exps) : get_rel_count(pl), + rv = need_distinct(rel) ? rel_calc_nuniques(pr, pr->exps) : get_rel_count(pr); if (lv == 0) { /* left side empty */ if (can_be_pruned) @@ -841,7 +845,7 @@ rel_get_statistics_(visitor *v, sql_rel case op_project: { if (l) { if (need_distinct(rel)) { - set_count_prop(v->sql->sa, rel, rel_calc_nuniques(rel, l, rel->exps)); + set_count_prop(v->sql->sa, rel, rel_calc_nuniques(l, rel->exps)); } else { set_count_prop(v->sql->sa, rel, get_rel_count(l)); } @@ -861,7 +865,7 @@ rel_get_statistics_(visitor *v, sql_rel if (list_empty(rel->r)) { set_count_prop(v->sql->sa, rel, 1); } else { - set_count_prop(v->sql->sa, rel, rel_calc_nuniques(rel, l, rel->r)); + set_count_prop(v->sql->sa, rel, rel_calc_nuniques(l, rel->r)); } } break; default: ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: properties - Merged with default
Changeset: 903e58fcc7aa for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/903e58fcc7aa Modified Files: sql/server/rel_optimizer.c Branch: properties Log Message: Merged with default diffs (85 lines): diff --git a/.hgtags b/.hgtags --- a/.hgtags +++ b/.hgtags @@ -763,3 +763,4 @@ cab90a348501b045e19cee5cebcc44f3800bd0a8 5872f047d97c98d3a848514438b8f97fa446855d Jan2022_11 025239a5a6f122042798c0f1132a2c6298514e06 Jan2022_13 025239a5a6f122042798c0f1132a2c6298514e06 Jan2022_SP2_release +2e54857a91306cc6304825c5596f65d00595db6b Jul2021_23 diff --git a/buildtools/conf/Maddlog b/buildtools/conf/Maddlog --- a/buildtools/conf/Maddlog +++ b/buildtools/conf/Maddlog @@ -189,6 +189,9 @@ fi file=ChangeLog.$RANDOM +# make sure we get the correct day and month names +export LC_ALL=en_US.utf-8 + case "$CL" in */*) cd "${CL%/*}" diff --git a/sql/ChangeLog b/sql/ChangeLog --- a/sql/ChangeLog +++ b/sql/ChangeLog @@ -1,7 +1,7 @@ # ChangeLog file for sql # This file is updated with Maddlog -* do apr 21 2022 Nuno Faria +* Thu Apr 21 2022 Nuno Faria - Added the UNLOGGED TABLE feature. * Fri Feb 4 2022 Sjoerd Mullender diff --git a/sql/ChangeLog.Jan2022 b/sql/ChangeLog.Jan2022 --- a/sql/ChangeLog.Jan2022 +++ b/sql/ChangeLog.Jan2022 @@ -1,6 +1,12 @@ # ChangeLog file for sql # This file is updated with Maddlog +* Mon Apr 25 2022 Sjoerd Mullender +- GLOBAL TEMPORARY tables are now treated like LOCAL TEMPORARY tables + as far as the table content is concerned. The schema information + stays global. This fixes an issue with concurrent access and cleanup + of stale data. + * Thu Apr 14 2022 Sjoerd Mullender - The NO CONSTRAINT option of the COPY INTO query has been removed. It didn't work and it was never a good idea anyway. 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 @@ -89,7 +89,7 @@ merge_table_prune_and_unionize(visitor * return sql_error(v->sql, 02, SQLSTATE(42000) "The %s '%s.%s' should have at least one table associated", TABLE_TYPE_DESCRIPTION(pt->type, pt->properties), pt->s->base.name, pt->base.name); /* Do not include empty partitions */ - if (isTable(pt) && pt->access == TABLE_READONLY && !store->storage_api.count_col(v->sql->session->tr, ol_first_node(pt->columns)->data, 0)) + if (isTable(pt) && pt->access == TABLE_READONLY && !store->storage_api.count_col(v->sql->session->tr, ol_first_node(pt->columns)->data, 10)) /* count active rows only */ continue; if (!table_privs(v->sql, pt, PRIV_SELECT)) /* Test for privileges */ diff --git a/sql/test/BugTracker-2021/Tests/All b/sql/test/BugTracker-2021/Tests/All --- a/sql/test/BugTracker-2021/Tests/All +++ b/sql/test/BugTracker-2021/Tests/All @@ -7,7 +7,7 @@ union-groupby.Bug-7108 merge-stmt.wrong-error.Bug-7109 remote-table-groupby.Bug-7110 conditional-execution-round.Bug-7125 -lowercase-cryllic.Bug-7126 +NOT_WIN32?lowercase-cryllic.Bug-7126 unnest-union.Bug-7127 subquery-missing.Bug-7128 batcalc-between-undefined.Bug-7129 diff --git a/sql/test/mapi/Tests/All b/sql/test/mapi/Tests/All --- a/sql/test/mapi/Tests/All +++ b/sql/test/mapi/Tests/All @@ -4,7 +4,7 @@ sample4 smack00 smack01 python3_dbapi -NOT_WIN32?utf8test +utf8test HAVE_HGE?mal_int128 HAVE_HGE?sql_int128 HAVE_HGE?python3_int128 ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - Merged with Jan2022
Changeset: 3e981b046658 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/3e981b046658 Modified Files: .bumpversion.cfg MonetDB.spec clients/mapilib/mapi.rc clients/odbc/driver/driver.rc clients/odbc/winsetup/setup.rc cmake/monetdb-versions.cmake gdk/libbat.rc monetdb5/tools/libmonetdb5.rc Branch: default Log Message: Merged with Jan2022 diffs (37 lines): diff --git a/.hgtags b/.hgtags --- a/.hgtags +++ b/.hgtags @@ -763,3 +763,4 @@ cab90a348501b045e19cee5cebcc44f3800bd0a8 5872f047d97c98d3a848514438b8f97fa446855d Jan2022_11 025239a5a6f122042798c0f1132a2c6298514e06 Jan2022_13 025239a5a6f122042798c0f1132a2c6298514e06 Jan2022_SP2_release +2e54857a91306cc6304825c5596f65d00595db6b Jul2021_23 diff --git a/buildtools/conf/Maddlog b/buildtools/conf/Maddlog --- a/buildtools/conf/Maddlog +++ b/buildtools/conf/Maddlog @@ -189,6 +189,9 @@ fi file=ChangeLog.$RANDOM +# make sure we get the correct day and month names +export LC_ALL=en_US.utf-8 + case "$CL" in */*) cd "${CL%/*}" diff --git a/sql/ChangeLog.Jan2022 b/sql/ChangeLog.Jan2022 --- a/sql/ChangeLog.Jan2022 +++ b/sql/ChangeLog.Jan2022 @@ -1,6 +1,12 @@ # ChangeLog file for sql # This file is updated with Maddlog +* Mon Apr 25 2022 Sjoerd Mullender +- GLOBAL TEMPORARY tables are now treated like LOCAL TEMPORARY tables + as far as the table content is concerned. The schema information + stays global. This fixes an issue with concurrent access and cleanup + of stale data. + * Thu Apr 14 2022 Sjoerd Mullender - The NO CONSTRAINT option of the COPY INTO query has been removed. It didn't work and it was never a good idea anyway. ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: properties - Propagate more statistics for global aggre...
Changeset: e18c0cb3ea1e for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/e18c0cb3ea1e Modified Files: sql/server/rel_rewriter.c sql/server/rel_statistics.c sql/server/rel_statistics_functions.c sql/test/BugTracker-2015/Tests/quantile_function_resolution.Bug-3773.test sql/test/BugTracker-2017/Tests/caching_stats_bug.6374.test sql/test/BugTracker-2018/Tests/count_from_commented_function_signatures.Bug-6542.test sql/test/BugTracker/Tests/jdbc_no_debug.SF-1739356.test sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-plan-0join-view.test sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-plan-3join-query.stable.out sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-plan-3join-query.stable.out.32bit sql/test/SQLancer/Tests/sqlancer09.test sql/test/SQLancer/Tests/sqlancer17.test sql/test/Tests/keys.test sql/test/miscellaneous/Tests/simple_plans.test sql/test/miscellaneous/Tests/simple_selects.test sql/test/miscellaneous/Tests/unique_keys.test Branch: properties Log Message: Propagate more statistics for global aggregates. Forgot to propagate NOT NULL flag on lists of values diffs (truncated from 546 to 300 lines): diff --git a/sql/server/rel_rewriter.c b/sql/server/rel_rewriter.c --- a/sql/server/rel_rewriter.c +++ b/sql/server/rel_rewriter.c @@ -225,6 +225,7 @@ rewrite_simplify(visitor *v, uint8_t cyc /* make sure the single expression is false, so the generate NULL values won't match */ rel->exps->h->data = exp_atom_bool(v->sql->sa, 0); rel->l = rel_project(v->sql->sa, NULL, nexps); + set_count_prop(v->sql->sa, rel->l, 1); set_count_prop(v->sql->sa, rel, 0); rel->card = CARD_ATOM; v->changes++; diff --git a/sql/server/rel_statistics.c b/sql/server/rel_statistics.c --- a/sql/server/rel_statistics.c +++ b/sql/server/rel_statistics.c @@ -178,7 +178,7 @@ rel_propagate_column_ref_statistics(mvc if (!has_nil(found)) set_has_no_nil(e); if (is_unique(found) || (need_distinct(rel) && list_length(rel->exps) == 1) || - (is_groupby(rel->op) && list_length(rel->r) == 1 && exps_find_exp(rel->r, e))) + (is_groupby(rel->op) && (list_empty(rel->r) || (list_length(rel->r) == 1 && exps_find_exp(rel->r, e) set_unique(e); /* propagate unique estimation for known cases */ if (is_groupby(rel->op) && list_empty(rel->r) && !find_prop(e->p, PROP_NUNIQUES)) { /* global aggregate case */ @@ -373,6 +373,7 @@ rel_propagate_statistics(visitor *v, sql } break; case e_aggr: case e_func: { + BUN lv; sql_subfunc *f = e->f; if (!f->func->s) { @@ -389,8 +390,18 @@ rel_propagate_statistics(visitor *v, sql if (look) look(sql, e); } - if (!is_semantics(e) && e->l && !have_nil(e->l) && (e->type != e_aggr || (is_groupby(rel->op) && list_length(rel->r + /* for global aggregates with no semantics, if the left relation has values, then the output won't be NULL */ + if (!is_semantics(e) && e->l && !have_nil(e->l) && + (e->type != e_aggr || (is_groupby(rel->op) && list_length(rel->r)) || ((lv = get_rel_count(rel->l)) != BUN_NONE && lv > 0))) set_has_no_nil(e); + /* set properties for global aggregates */ + if (e->type == e_aggr && is_groupby(rel->op) && list_empty(rel->r)) { + if (!find_prop(e->p, PROP_NUNIQUES)) { + prop *p = e->p = prop_create(sql->sa, PROP_NUNIQUES, e->p); + p->value.dval = 1; + } + set_unique(e); + } } break; case e_atom: { if (e->l) { @@ -405,10 +416,12 @@ rel_propagate_statistics(visitor *v, sql list *vals = (list *) e->f; sql_exp *first = vals->h ? vals->h->data : NULL; atom *max = NULL, *min = NULL; /* all child values must have a valid min/max */ + int has_nil = 0; if (first) { max = ((lval = find_prop_and_get(first->p, PROP_MAX))) ? lval : NULL; min = ((lval = find_prop_and_get(firs
MonetDB: properties - Propagate number of uniques over joins (my...
Changeset: 12daba096f46 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/12daba096f46 Modified Files: sql/server/rel_statistics.c Branch: properties Log Message: Propagate number of uniques over joins (my mistake) diffs (19 lines): diff --git a/sql/server/rel_statistics.c b/sql/server/rel_statistics.c --- a/sql/server/rel_statistics.c +++ b/sql/server/rel_statistics.c @@ -155,13 +155,8 @@ rel_propagate_column_ref_statistics(mvc set_has_nil(e); if (!is_outerjoin(rel->op) && found_without_semantics) /* at an outer join, null values pass */ set_has_no_nil(e); - if (is_join(rel->op)) { - prop *est; - if (is_unique(e) && !still_unique) - set_not_unique(e); - if ((est = find_prop(e->p, PROP_NUNIQUES))) /* remove unique estimation after a join */ - e->p = prop_remove(e->p, est); - } + if (is_join(rel->op) && is_unique(e) && !still_unique) + set_not_unique(e); return e; } case op_table: ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: properties - Count active rows only
Changeset: c77536b5aca6 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/c77536b5aca6 Modified Files: sql/server/rel_statistics.c Branch: properties Log Message: Count active rows only diffs (14 lines): diff --git a/sql/server/rel_statistics.c b/sql/server/rel_statistics.c --- a/sql/server/rel_statistics.c +++ b/sql/server/rel_statistics.c @@ -651,8 +651,8 @@ rel_get_statistics_(visitor *v, sql_rel rel_basetable_column_get_statistics(v->sql, rel, n->data); } /* Set table row count. TODO? look for remote/replica tables. Don't look at storage for declared tables, because it won't be cleaned */ - if (isTable(t) && t->s && !isDeclaredTable(t)) - set_count_prop(v->sql->sa, rel, (BUN)store->storage_api.count_col(v->sql->session->tr, ol_first_node(t->columns)->data, 0)); + if (isTable(t) && t->s && !isDeclaredTable(t)) /* count active rows only */ + set_count_prop(v->sql->sa, rel, (BUN)store->storage_api.count_col(v->sql->session->tr, ol_first_node(t->columns)->data, 10)); } break; case op_union: case op_inter: ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - Count active rows only
Changeset: 6f1b2a03dad5 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/6f1b2a03dad5 Modified Files: sql/server/rel_optimizer.c Branch: default Log Message: Count active rows only diffs (12 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 @@ -89,7 +89,7 @@ merge_table_prune_and_unionize(visitor * return sql_error(v->sql, 02, SQLSTATE(42000) "The %s '%s.%s' should have at least one table associated", TABLE_TYPE_DESCRIPTION(pt->type, pt->properties), pt->s->base.name, pt->base.name); /* Do not include empty partitions */ - if (isTable(pt) && pt->access == TABLE_READONLY && !store->storage_api.count_col(v->sql->session->tr, ol_first_node(pt->columns)->data, 0)) + if (isTable(pt) && pt->access == TABLE_READONLY && !store->storage_api.count_col(v->sql->session->tr, ol_first_node(pt->columns)->data, 10)) /* count active rows only */ continue; if (!table_privs(v->sql, pt, PRIV_SELECT)) /* Test for privileges */ ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: properties - Defensive lines
Changeset: 076f4226e181 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/076f4226e181 Modified Files: sql/server/rel_statistics.c Branch: properties Log Message: Defensive lines diffs (27 lines): diff --git a/sql/server/rel_statistics.c b/sql/server/rel_statistics.c --- a/sql/server/rel_statistics.c +++ b/sql/server/rel_statistics.c @@ -607,10 +607,9 @@ trivial_project_exp_card(sql_exp *e) static BUN rel_calc_nuniques(sql_rel *rel, sql_rel *l, list *exps) { - BUN nuniques = 0; - - /* compute the highest number of unique values */ if (!list_empty(exps)) { + BUN nuniques = 0; + /* compute the highest number of unique values */ for (node *n = exps->h ; n && nuniques != BUN_NONE ; n = n->next) { sql_exp *e = n->data; sql_rel *bt = NULL; @@ -625,8 +624,9 @@ rel_calc_nuniques(sql_rel *rel, sql_rel nuniques = BUN_NONE; } } + return nuniques != BUN_NONE ? nuniques : get_rel_count(l); } - return nuniques != BUN_NONE ? nuniques : get_rel_count(l); + return get_rel_count(l); } static sql_rel * ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: properties - Tunning cardinality estimation for distinc...
Changeset: c47cfa18f023 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/c47cfa18f023 Modified Files: sql/server/rel_statistics.c Branch: properties Log Message: Tunning cardinality estimation for distinct projections and single joins diffs (155 lines): diff --git a/sql/server/rel_statistics.c b/sql/server/rel_statistics.c --- a/sql/server/rel_statistics.c +++ b/sql/server/rel_statistics.c @@ -604,12 +604,36 @@ trivial_project_exp_card(sql_exp *e) return e->type == e_atom && e->f ? (BUN) list_length(e->f) : 1; } +static BUN +rel_calc_nuniques(sql_rel *rel, sql_rel *l, list *exps) +{ + BUN nuniques = 0; + + /* compute the highest number of unique values */ + if (!list_empty(exps)) { + for (node *n = exps->h ; n && nuniques != BUN_NONE ; n = n->next) { + sql_exp *e = n->data; + sql_rel *bt = NULL; + prop *p = NULL; + + if (e->type == e_column && is_unique(e) && + name_find_column(rel, e->l, e->r, -1, &bt) && bt && (p = find_prop(bt->p, PROP_COUNT))) { + nuniques = MAX(nuniques, p->value.lval); + } else if ((p = find_prop(e->p, PROP_NUNIQUES))) { + nuniques = MAX(nuniques, (BUN) p->value.dval); + } else { + nuniques = BUN_NONE; + } + } + } + return nuniques != BUN_NONE ? nuniques : get_rel_count(l); +} + static sql_rel * rel_get_statistics_(visitor *v, sql_rel *rel) { /* Don't prune updates as pruning will possibly result in removing the joins which therefore cannot be used for constraint checking */ uint8_t has_special_modify = *(uint8_t*) v->data; - prop *p; bool can_be_pruned = !has_special_modify && v->storage_based_opt; /* Don't look at the same relation twice */ @@ -635,34 +659,33 @@ rel_get_statistics_(visitor *v, sql_rel case op_except: { bool empty_cross = false; int i = 0; - sql_rel *l = rel->l, *r = rel->r; + sql_rel *l = rel->l, *pl = rel->l, *r = rel->r, *pr = rel->r; - while (is_sample(l->op) || is_topn(l->op)) /* skip topN and sample relations in the middle */ - l = l->l; - while (is_sample(r->op) || is_topn(r->op)) - r = r->l; + while (is_sample(pl->op) || is_topn(pl->op)) /* skip topN and sample relations in the middle */ + pl = pl->l; + while (is_sample(r->op) || is_topn(pr->op)) + pr = pr->l; /* if it's not a projection, then project and propagate statistics */ - if (!is_project(l->op) && !is_base(l->op)) { - l = rel_project(v->sql->sa, l, rel_projections(v->sql, l, NULL, 0, 1)); - set_count_prop(v->sql->sa, l, get_rel_count(l->l)); - l->exps = exps_exp_visitor_bottomup(v, l, l->exps, 0, &rel_propagate_statistics, false); + if (!is_project(pl->op) && !is_base(l->op)) { + pl = rel_project(v->sql->sa, pl, rel_projections(v->sql, pl, NULL, 0, 1)); + set_count_prop(v->sql->sa, pl, get_rel_count(pl->l)); + pl->exps = exps_exp_visitor_bottomup(v, pl, pl->exps, 0, &rel_propagate_statistics, false); } - if (!is_project(r->op) && !is_base(r->op)) { - r = rel_project(v->sql->sa, r, rel_projections(v->sql, r, NULL, 0, 1)); - set_count_prop(v->sql->sa, r, get_rel_count(r->l)); - r->exps = exps_exp_visitor_bottomup(v, r, r->exps, 0, &rel_propagate_statistics, false); + if (!is_project(pr->op) && !is_base(pr->op)) { + pr = rel_project(v->sql->sa, pr, rel_projections(v->sql, pr, NULL, 0, 1)); + set_count_prop(v->sql->sa, pr, get_rel_count(pr->l)); + pr->exps = exps_exp_visitor_bottomup(v, pr, pr->exps, 0, &rel_propagate_statistics, false); } for (node *n = rel->exps->h ; n ; n = n->next) { - empty_cross |= rel_setop_get_statistics(v->sql, rel, l->exps, r->exps, n->data, i); + empty_cross |= rel_setop_get_statistics(v->sql, rel, pl->exps, pr->exps, n->data, i); i++; } - l = rel->l; - r = rel->r; /* propagate row count */ if (is_union(rel->op)) { - BUN lv = get_rel_count(l), rv = get_rel_count(r); + BUN lv = need_distinct(rel) ? rel_calc_nuniques(rel, pl, pl->exps) : get_rel_count(pl), +
MonetDB: properties - Approved output
Changeset: fc394c11ede0 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/fc394c11ede0 Modified Files: sql/test/emptydb/Tests/check.stable.out sql/test/emptydb/Tests/check.stable.out.32bit sql/test/emptydb/Tests/check.stable.out.int128 Branch: properties Log Message: Approved output diffs (truncated from 603 to 300 lines): diff --git a/sql/test/emptydb/Tests/check.stable.out b/sql/test/emptydb/Tests/check.stable.out --- a/sql/test/emptydb/Tests/check.stable.out +++ b/sql/test/emptydb/Tests/check.stable.out @@ -4931,16 +4931,16 @@ select 'null in value_partitions.value', % %2, %1, id # name % char,bigint, int # type % 21, 1, 1 # length -% .%11,.%10, .tables # table_name -% %11, %10,id # name +% .%12,sys.%10,sys.tables # table_name +% %12, %10,id # name % char,bigint, int # type % 20, 1, 1 # length % .%2, sys.%1, sys._columns # table_name % %2, %1, id # name % char,bigint, int # type % 22, 1, 1 # length -% .%7, .%6,.columns # table_name -% %7, %6, id # name +% .%10,sys.%6, sys.columns # table_name +% %10, %6, id # name % char,bigint, int # type % 21, 1, 1 # length % .%2, sys.%1, sys.functions # table_name @@ -5071,8 +5071,8 @@ select 'null in value_partitions.value', % %2, %1, id # name % char,bigint, int # type % 22, 1, 1 # length -% .%171, .%170, .ids # table_name -% %171,%170, id # name +% .%176, .%170, .ids # table_name +% %176,%170, id # name % char,bigint, int # type % 17, 1, 1 # length % .%105, .%104, .var_values # table_name @@ -5107,32 +5107,32 @@ select 'null in value_partitions.value', % %2, %1, schema_id, name # name % char,bigint, int,varchar # type % 21, 1, 1, 0 # length -% .%11,.%10, .tables,.tables # table_name -% %11, %10,schema_id, name # name +% .%12,sys.%10,sys.tables, sys.tables # table_name +% %12, %10,schema_id, name # name % char,bigint, int,varchar # type % 20, 1, 1, 0 # length % .%2, sys.%1, sys._columns, sys._columns # table_name % %2, %1, table_id, name # name % char,bigint, int,varchar # type % 22, 1, 1, 0 # length -% .%7, .%6,.columns, .columns # table_name -% %7, %6, table_id, name # name +% .%10,sys.%6, sys.columns,sys.columns # table_name +% %10, %6, table_id, name # name % char,bigint, int,varchar # type % 21, 1, 1, 0 # length % .%2, sys.%1, sys._columns, sys._columns # table_name % %2, %1, table_id, number # name % char,bigint, int,int # type % 22, 1, 1, 1 # length -% .%7, .%6,.columns, .columns # table_name -% %7, %6, table_id, number # name +% .%10,sys.%6, sys.columns,sys.columns # table_name +% %10, %6, table_id, number # name % char,bigint, int,int # type % 21, 1, 1, 1 # length % .%21,.%20, .t # table_name % %21, %20,id # name % char,bigint, int # type % 161, 1, 1 # length -% .%35,.%34, .t # table_name -% %35, %34,id # name +% .%37,.%34, .t # table_name +% %37, %34,id # name % char,bigint, int # type % 159, 1, 1 # length % .%2, sys.%1, sys.f, sys.f, sys.f, sys.f, sys.f, sys.f, sys.f, sys.f, sys.f, sys.a # table_name @@ -5231,7 +5231,7 @@ select 'null in value_partitions.value', % %5, schema_id, id, name, schema_id, query, type, system, commit_action, access # name % char,int,int,varchar,int,varchar, smallint, boolean,smallint, smallint # type % 38, 1, 1, 0, 1, 0, 1, 5, 1, 1 # length -% .%14,.tables,.tables,.tables,.tables, .tables,.tables,.tables,.tables,.tables, .tables # table_name +% .%14,sys.tables, sys.tables, sys.tables, sys.tables, sys.tables, .tables,sys.tables, sys.tables, sys.tables, .tables # table_name % %14, schema_id, id, name, schema_id, query, type, system, commit_action, access, temporary # name % char,int,int,varchar,int,varchar, smallint, boolean,smallint, smallint, tinyint # type % 37, 1, 1, 0, 1, 0, 1, 5, 1, 1, 1 # length @@ -5239,7 +5239,7 @@ select 'null in value_partitions.value', % %5, type, id, name, schema_id, query, type, system, commit_action, access # name % char,smallint, int,varchar,int,varchar, smallint, boolean,smallint, smalli
MonetDB: properties - Two fixes. Make sure max is set before min...
Changeset: 0321c072c1ff for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/0321c072c1ff Modified Files: sql/server/rel_statistics.c Branch: properties Log Message: Two fixes. Make sure max is set before min (alignment on the plan). Also don't call storage function for declared table because it won't be cleared and it's not meaningful diffs (94 lines): diff --git a/sql/server/rel_statistics.c b/sql/server/rel_statistics.c --- a/sql/server/rel_statistics.c +++ b/sql/server/rel_statistics.c @@ -82,16 +82,16 @@ rel_propagate_column_ref_statistics(mvc if (symmetric) { prop *p1 = find_prop(e->p, PROP_MIN), *p2 = find_prop(e->p, PROP_MAX); atom *nmin = statistics_atom_min(sql, rval_min, fval_min), *nmax = statistics_atom_max(sql, rval_max, fval_max); - /* min is max from le and (min from re and fe min) */ - set_minmax_property(sql, e, PROP_MIN, p1 ? statistics_atom_max(sql, nmin, p1->value.pval) : nmin); /* max is min from le and (max from re and fe max) */ set_minmax_property(sql, e, PROP_MAX, p2 ? statistics_atom_min(sql, nmax, p2->value.pval) : nmax); + /* min is max from le and (min from re and fe min) */ + set_minmax_property(sql, e, PROP_MIN, p1 ? statistics_atom_max(sql, nmin, p1->value.pval) : nmin); } else { prop *p1 = find_prop(e->p, PROP_MIN), *p2 = find_prop(e->p, PROP_MAX); + /* max is min from le and fe max */ + set_minmax_property(sql, e, PROP_MAX, p2 ? statistics_atom_min(sql, fval_max, p2->value.pval) : fval_max); /* min is max from le and re min */ set_minmax_property(sql, e, PROP_MIN, p1 ? statistics_atom_max(sql, rval_min, p1->value.pval) : rval_min); - /* max is min from le and fe max */ - set_minmax_property(sql, e, PROP_MAX, p2 ? statistics_atom_min(sql, fval_max, p2->value.pval) : fval_max); } } else if (rne) { if (symmetric && int1 && int2) { /* min is max from le and (min from re and fe min) */ @@ -240,6 +240,13 @@ rel_basetable_column_get_statistics(mvc prop *p = e->p = prop_create(sql->sa, PROP_NUNIQUES, e->p); p->value.dval = unique_est; } + if ((ok & 2) == 2) { + if (!VALisnil(&max)) { + prop *p = e->p = prop_create(sql->sa, PROP_MAX, e->p); + p->value.pval = atom_from_valptr(sql->sa, &c->type, &max); + } + VALclear(&max); + } if ((ok & 1) == 1) { if (!VALisnil(&min)) { prop *p = e->p = prop_create(sql->sa, PROP_MIN, e->p); @@ -247,13 +254,6 @@ rel_basetable_column_get_statistics(mvc } VALclear(&min); } - if ((ok & 2) == 2) { - if (!VALisnil(&max)) { - prop *p = e->p = prop_create(sql->sa, PROP_MAX, e->p); - p->value.pval = atom_from_valptr(sql->sa, &c->type, &max); - } - VALclear(&max); - } } } @@ -270,6 +270,14 @@ rel_setop_get_statistics(mvc *sql, sql_r ((rval_max && lval_min && atom_cmp(rval_max, lval_min) < 0) || (rval_min && lval_max && atom_cmp(rval_min, lval_max) > 0))) return true; + if (lval_max && rval_max) { + if (is_union(rel->op)) +
MonetDB: properties - Merged with default
Changeset: 085d172eae22 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/085d172eae22 Modified Files: sql/storage/bat/bat_storage.c Branch: properties Log Message: Merged with default diffs (57 lines): diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c --- a/sql/storage/bat/bat_storage.c +++ b/sql/storage/bat/bat_storage.c @@ -2314,7 +2314,7 @@ delta_append_val(sql_trans *tr, sql_delt if (cnt) { if (BATcount(b) < offset) { /* add space */ const void *tv = ATOMnilptr(b->ttype); - lng d = offset - BATcount(b); + BUN d = offset - BATcount(b); if (BUNappendmulti(b, tv, d, true) != GDK_SUCCEED) { bat_destroy(b); if (i != oi) diff --git a/sql/test/dict/Tests/dict04.test b/sql/test/dict/Tests/dict04.test --- a/sql/test/dict/Tests/dict04.test +++ b/sql/test/dict/Tests/dict04.test @@ -322,6 +322,29 @@ statement ok START TRANSACTION statement ok +CREATE TABLE t0 (c0 INT) + +statement ok rowcount 1 +INSERT INTO t0 VALUES (2) + +statement ok +COMMIT + +statement ok +CALL "sys"."dict_compress"('sys','t0','c0', true) + +query I nosort +SELECT * FROM t0 WHERE c0 > 1 + +2 + +statement ok +DROP TABLE t0 + +statement ok +START TRANSACTION + +statement ok DROP ALL PROCEDURE "sys"."dict_compress" statement ok diff --git a/sql/test/mapi/Tests/All b/sql/test/mapi/Tests/All --- a/sql/test/mapi/Tests/All +++ b/sql/test/mapi/Tests/All @@ -4,7 +4,7 @@ sample4 smack00 smack01 python3_dbapi -utf8test +NOT_WIN32?utf8test HAVE_HGE?mal_int128 HAVE_HGE?sql_int128 HAVE_HGE?python3_int128 ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: properties - Fix count for grouping
Changeset: 60d278e13e3e for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/60d278e13e3e Modified Files: sql/server/rel_statistics.c Branch: properties Log Message: Fix count for grouping diffs (21 lines): diff --git a/sql/server/rel_statistics.c b/sql/server/rel_statistics.c --- a/sql/server/rel_statistics.c +++ b/sql/server/rel_statistics.c @@ -820,7 +820,7 @@ rel_get_statistics_(visitor *v, sql_rel case op_groupby: { if (list_empty(rel->r)) { set_count_prop(v->sql->sa, rel, 1); - } else { + } else if (list_length(rel->r) == 1) { sql_exp *e = ((list*)rel->r)->h->data; sql_rel *bt = NULL; if (e->type == e_column && is_unique(e) && name_find_column(rel, e->l, e->r, -1, &bt) && bt && (p = find_prop(bt->p, PROP_COUNT))) { @@ -830,6 +830,8 @@ rel_get_statistics_(visitor *v, sql_rel } else { set_count_prop(v->sql->sa, rel, get_rel_count(l)); } + } else { + set_count_prop(v->sql->sa, rel, get_rel_count(l)); } } break; default: ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - Compilation fix
Changeset: 16ef3ce087fe for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/16ef3ce087fe Modified Files: sql/storage/bat/bat_storage.c Branch: default Log Message: Compilation fix diffs (12 lines): diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c --- a/sql/storage/bat/bat_storage.c +++ b/sql/storage/bat/bat_storage.c @@ -2314,7 +2314,7 @@ delta_append_val(sql_trans *tr, sql_delt if (cnt) { if (BATcount(b) < offset) { /* add space */ const void *tv = ATOMnilptr(b->ttype); - lng d = offset - BATcount(b); + BUN d = offset - BATcount(b); if (BUNappendmulti(b, tv, d, true) != GDK_SUCCEED) { bat_destroy(b); if (i != oi) ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - Next dict thetaselect issue
Changeset: 7c1c0f761999 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/7c1c0f761999 Modified Files: sql/test/dict/Tests/dict04.test Branch: default Log Message: Next dict thetaselect issue diffs (33 lines): diff --git a/sql/test/dict/Tests/dict04.test b/sql/test/dict/Tests/dict04.test --- a/sql/test/dict/Tests/dict04.test +++ b/sql/test/dict/Tests/dict04.test @@ -322,6 +322,29 @@ statement ok START TRANSACTION statement ok +CREATE TABLE t0 (c0 INT) + +statement ok rowcount 1 +INSERT INTO t0 VALUES (2) + +statement ok +COMMIT + +statement ok +CALL "sys"."dict_compress"('sys','t0','c0', true) + +query I nosort +SELECT * FROM t0 WHERE c0 > 1 + +2 + +statement ok +DROP TABLE t0 + +statement ok +START TRANSACTION + +statement ok DROP ALL PROCEDURE "sys"."dict_compress" statement ok ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: properties - This estimation is wrong. Remove it
Changeset: ae4d897b9c50 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/ae4d897b9c50 Modified Files: sql/server/rel_statistics.c Branch: properties Log Message: This estimation is wrong. Remove it diffs (32 lines): diff --git a/sql/server/rel_statistics.c b/sql/server/rel_statistics.c --- a/sql/server/rel_statistics.c +++ b/sql/server/rel_statistics.c @@ -609,7 +609,7 @@ rel_get_statistics_(visitor *v, sql_rel { /* Don't prune updates as pruning will possibly result in removing the joins which therefore cannot be used for constraint checking */ uint8_t has_special_modify = *(uint8_t*) v->data; - prop *p, *p2; + prop *p; bool can_be_pruned = !has_special_modify && v->storage_based_opt; /* Don't look at the same relation twice */ @@ -762,19 +762,6 @@ rel_get_statistics_(visitor *v, sql_rel uniques_estimate = MIN(uniques_estimate, ncount); } } - if ((p = find_prop(el->p, PROP_NUNIQUES)) && (p2 = find_prop(er->p, PROP_NUNIQUES))) { - BUN pv = (BUN) p->value.dval, pv2 = (BUN) p2->value.dval, - mul = (pv == 0 || pv2 == 0) ? 0 : ((pv2 > (BUN_MAX / pv)) ? BUN_MAX : (pv * pv2)); /* check for overflows */ - - if (is_left(rel->op)) - mul = MAX(mul, lv); - else if (is_right(rel->op)) - mul = MAX(mul, rv); - else if (is_full(rel->op)) - mul = MAX(MAX(mul, lv), rv); - - uniques_estimate = MIN(uniques_estimate, mul); - } } } } ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: properties - Throw error if input is invalid
Changeset: 860a5dab6d5a for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/860a5dab6d5a Modified Files: sql/server/rel_dump.c Branch: properties Log Message: Throw error if input is invalid diffs (132 lines): diff --git a/sql/server/rel_dump.c b/sql/server/rel_dump.c --- a/sql/server/rel_dump.c +++ b/sql/server/rel_dump.c @@ -898,7 +898,7 @@ read_exps(mvc *sql, sql_rel *lrel, sql_r return exps; } -static void +static sql_exp* exp_read_min_or_max(mvc *sql, sql_exp *exp, char *r, int *pos, const char *prop_str, rel_prop kind) { atom *a; @@ -913,7 +913,7 @@ exp_read_min_or_max(mvc *sql, sql_exp *e } else { void *ptr = readAtomString(tpe->type->localtype, r, pos); if (!ptr) - return ; + return sql_error(sql, -1, SQLSTATE(42000) "Invalid atom string\n"); a = atom_general_ptr(sql->sa, tpe, ptr); GDKfree(ptr); } @@ -922,9 +922,10 @@ exp_read_min_or_max(mvc *sql, sql_exp *e p->value.pval = a; } skipWS(r, pos); + return exp; } -static void +static sql_exp* exp_read_nuniques(mvc *sql, sql_exp *exp, char *r, int *pos) { void *ptr = NULL; @@ -935,8 +936,10 @@ exp_read_nuniques(mvc *sql, sql_exp *exp (*pos)+= (int) strlen("NUNIQUES"); skipWS(r, pos); - if ((res = ATOMfromstr(tpe->type->localtype, &ptr, &nbytes, r + *pos, true)) < 0) - return; + if ((res = ATOMfromstr(tpe->type->localtype, &ptr, &nbytes, r + *pos, true)) < 0) { + GDKfree(ptr); + return sql_error(sql, -1, SQLSTATE(42000) "Invalid atom string\n"); + } if (!find_prop(exp->p, PROP_NUNIQUES)) { prop *p = exp->p = prop_create(sql->sa, PROP_NUNIQUES, exp->p); @@ -945,6 +948,7 @@ exp_read_nuniques(mvc *sql, sql_exp *exp (*pos) += (int) res; /* it should always fit */ GDKfree(ptr); skipWS(r, pos); + return exp; } static sql_exp* @@ -973,13 +977,16 @@ read_exp_properties(mvc *sql, sql_exp *e skipWS(r,pos); found = true; } else if (strncmp(r+*pos, "MIN", strlen("MIN")) == 0) { - exp_read_min_or_max(sql, exp, r, pos, "MIN", PROP_MIN); + if (!exp_read_min_or_max(sql, exp, r, pos, "MIN", PROP_MIN)) + return NULL; found = true; } else if (strncmp(r+*pos, "MAX", strlen("MAX")) == 0) { - exp_read_min_or_max(sql, exp, r, pos, "MAX", PROP_MAX); + if (!exp_read_min_or_max(sql, exp, r, pos, "MAX", PROP_MAX)) + return NULL; found = true; } else if (strncmp(r+*pos, "NUNIQUES", strlen("NUNIQUES")) == 0) { - exp_read_nuniques(sql, exp, r, pos); + if (!exp_read_nuniques(sql, exp, r, pos)) + return NULL; found = true; } if (!read_prop(sql, exp, r, pos, &found)) @@ -1332,7 +1339,8 @@ exp_read(mvc *sql, sql_rel *lrel, sql_re skipWS(r, pos); exp = exp_convert(sql->sa, exp, exp_subtype(exp), &tpe); } else { - exp = parse_atom(sql, r, pos, &tpe); + if (!(exp = parse_atom(sql, r, pos, &tpe))) + return NULL; skipWS(r, pos); } } @@ -1348,7 +1356,8 @@ exp_read(mvc *sql, sql_rel *lrel, sql_re return sql_error(sql, ERR_NOTFOUND, SQLSTATE(42000) "SQL type %s not found\n", tname); sql_init_subtype(&tpe, t, 0, 0); } - exp = parse_atom(sql, r, pos, &tpe); + if (!(exp = parse_atom(sql, r, pos, &tpe))) + return NULL; skipWS(r, pos); } break; @@ -1638,7 +1647,7 @@ rel_set_types(mvc *sql, sql_rel *rel) return 0; } -static void +static sql_rel* rel_read_count(mvc *sql, sql_rel *rel, char *r, int *pos) { void *ptr = NULL; @@ -1649,13 +1658,16 @@ rel_read_count(mvc *sql, sql_rel *rel, c (*pos)+= (int) strlen("COUNT"); skipWS(r, pos); - if ((res = ATOMfromstr(tpe->type->localtype, &ptr, &nbytes, r + *pos, true)) < 0) - return; + if ((res = ATOMfromstr(tpe->type->localtype, &ptr, &nbytes, r + *pos, true)) < 0) { + GDKfree(ptr); + return sql_error(sql, -1, SQLSTATE(42000) "Invalid atom string\n"); + } set_count_prop(sql->sa, rel, *(BUN*)ptr);
MonetDB: properties - Add right offset
Changeset: e0f43457ce94 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/e0f43457ce94 Modified Files: sql/server/rel_dump.c Branch: properties Log Message: Add right offset diffs (46 lines): diff --git a/sql/server/rel_dump.c b/sql/server/rel_dump.c --- a/sql/server/rel_dump.c +++ b/sql/server/rel_dump.c @@ -929,19 +929,20 @@ exp_read_nuniques(mvc *sql, sql_exp *exp { void *ptr = NULL; size_t nbytes = 0; + ssize_t res = 0; sql_subtype *tpe = sql_bind_localtype("dbl"); (*pos)+= (int) strlen("NUNIQUES"); skipWS(r, pos); - if (ATOMfromstr(tpe->type->localtype, &ptr, &nbytes, r + *pos, true) < 0) + if ((res = ATOMfromstr(tpe->type->localtype, &ptr, &nbytes, r + *pos, true)) < 0) return; if (!find_prop(exp->p, PROP_NUNIQUES)) { prop *p = exp->p = prop_create(sql->sa, PROP_NUNIQUES, exp->p); p->value.dval = *(dbl*)ptr; } - (*pos) += nbytes; + (*pos) += (int) res; /* it should always fit */ GDKfree(ptr); skipWS(r, pos); } @@ -1642,16 +1643,17 @@ rel_read_count(mvc *sql, sql_rel *rel, c { void *ptr = NULL; size_t nbytes = 0; + ssize_t res = 0; sql_subtype *tpe = sql_bind_localtype("oid"); (*pos)+= (int) strlen("COUNT"); skipWS(r, pos); - if (ATOMfromstr(tpe->type->localtype, &ptr, &nbytes, r + *pos, true) < 0) + if ((res = ATOMfromstr(tpe->type->localtype, &ptr, &nbytes, r + *pos, true)) < 0) return; set_count_prop(sql->sa, rel, *(BUN*)ptr); - (*pos) += nbytes; + (*pos) += (int) res; /* it should always fit */ GDKfree(ptr); skipWS(r, pos); } ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: properties - Set count property if sent to the remote s...
Changeset: 71cfb9713288 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/71cfb9713288 Modified Files: sql/server/rel_dump.c Branch: properties Log Message: Set count property if sent to the remote side. Cleanup diffs (65 lines): diff --git a/sql/server/rel_dump.c b/sql/server/rel_dump.c --- a/sql/server/rel_dump.c +++ b/sql/server/rel_dump.c @@ -17,6 +17,7 @@ #include "rel_updates.h" #include "rel_select.h" #include "rel_remote.h" +#include "rel_rewriter.h" #include "rel_optimizer.h" #include "sql_privileges.h" @@ -323,7 +324,7 @@ exp_print(mvc *sql, stream *fout, sql_ex mnstr_printf(fout, " NOT NULL"); if (e->type != e_atom && e->type != e_cmp && is_unique(e)) mnstr_printf(fout, " UNIQUE"); - if (e->p && !exp_is_atom(e)) { + if (e->p && e->type != e_atom && !exp_is_atom(e)) { /* don't show properties on value lists */ for (prop *p = e->p; p; p = p->p) { /* Don't show min/max/unique est on atoms, or when running tests with forcemito */ if ((GDKdebug & FORCEMITOMASK) == 0 || (p->kind != PROP_MIN && p->kind != PROP_MAX && p->kind != PROP_NUNIQUES)) { @@ -954,6 +955,8 @@ read_exp_properties(mvc *sql, sql_exp *e if (strncmp(r+*pos, "COUNT", strlen("COUNT")) == 0) { (*pos)+= (int) strlen("COUNT"); + if (!find_prop(exp->p, PROP_COUNT)) + exp->p = prop_create(sql->sa, PROP_COUNT, exp->p); skipWS(r,pos); found = true; } else if (strncmp(r+*pos, "HASHIDX", strlen("HASHIDX")) == 0) { @@ -1634,6 +1637,25 @@ rel_set_types(mvc *sql, sql_rel *rel) return 0; } +static void +rel_read_count(mvc *sql, sql_rel *rel, char *r, int *pos) +{ + void *ptr = NULL; + size_t nbytes = 0; + sql_subtype *tpe = sql_bind_localtype("oid"); + + (*pos)+= (int) strlen("COUNT"); + skipWS(r, pos); + + if (ATOMfromstr(tpe->type->localtype, &ptr, &nbytes, r + *pos, true) < 0) + return; + + set_count_prop(sql->sa, rel, *(BUN*)ptr); + (*pos) += nbytes; + GDKfree(ptr); + skipWS(r, pos); +} + static sql_rel* read_rel_properties(mvc *sql, sql_rel *rel, char *r, int *pos) { @@ -1642,8 +1664,7 @@ read_rel_properties(mvc *sql, sql_rel *r found = false; if (strncmp(r+*pos, "COUNT", strlen("COUNT")) == 0) { - (*pos)+= (int) strlen("COUNT"); - skipWS(r,pos); + rel_read_count(sql, rel, r, pos); found = true; } else if (strncmp(r+*pos, "REMOTE", strlen("REMOTE")) == 0) { /* Remote tables under remote tables not supported, so remove REMOTE property */ (*pos)+= (int) strlen("REMOTE"); ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: properties - Read nuniques property if sent on remote p...
Changeset: 17e3d03cc29f for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/17e3d03cc29f Modified Files: sql/server/rel_dump.c Branch: properties Log Message: Read nuniques property if sent on remote plans. Be more restrict to dump properties on atom expressions diffs (51 lines): diff --git a/sql/server/rel_dump.c b/sql/server/rel_dump.c --- a/sql/server/rel_dump.c +++ b/sql/server/rel_dump.c @@ -323,7 +323,7 @@ exp_print(mvc *sql, stream *fout, sql_ex mnstr_printf(fout, " NOT NULL"); if (e->type != e_atom && e->type != e_cmp && is_unique(e)) mnstr_printf(fout, " UNIQUE"); - if (e->p && e->type != e_atom) { + if (e->p && !exp_is_atom(e)) { for (prop *p = e->p; p; p = p->p) { /* Don't show min/max/unique est on atoms, or when running tests with forcemito */ if ((GDKdebug & FORCEMITOMASK) == 0 || (p->kind != PROP_MIN && p->kind != PROP_MAX && p->kind != PROP_NUNIQUES)) { @@ -923,6 +923,28 @@ exp_read_min_or_max(mvc *sql, sql_exp *e skipWS(r, pos); } +static void +exp_read_nuniques(mvc *sql, sql_exp *exp, char *r, int *pos) +{ + void *ptr = NULL; + size_t nbytes = 0; + sql_subtype *tpe = sql_bind_localtype("dbl"); + + (*pos)+= (int) strlen("NUNIQUES"); + skipWS(r, pos); + + if (ATOMfromstr(tpe->type->localtype, &ptr, &nbytes, r + *pos, true) < 0) + return; + + if (!find_prop(exp->p, PROP_NUNIQUES)) { + prop *p = exp->p = prop_create(sql->sa, PROP_NUNIQUES, exp->p); + p->value.dval = *(dbl*)ptr; + } + (*pos) += nbytes; + GDKfree(ptr); + skipWS(r, pos); +} + static sql_exp* read_exp_properties(mvc *sql, sql_exp *exp, char *r, int *pos) { @@ -952,6 +974,9 @@ read_exp_properties(mvc *sql, sql_exp *e } else if (strncmp(r+*pos, "MAX", strlen("MAX")) == 0) { exp_read_min_or_max(sql, exp, r, pos, "MAX", PROP_MAX); found = true; + } else if (strncmp(r+*pos, "NUNIQUES", strlen("NUNIQUES")) == 0) { + exp_read_nuniques(sql, exp, r, pos); + found = true; } if (!read_prop(sql, exp, r, pos, &found)) return NULL; ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: properties - Cleanup and add defensive line
Changeset: 192d92d8509b for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/192d92d8509b Modified Files: sql/server/rel_rewriter.c sql/server/rel_statistics.c Branch: properties Log Message: Cleanup and add defensive line diffs (55 lines): diff --git a/sql/server/rel_rewriter.c b/sql/server/rel_rewriter.c --- a/sql/server/rel_rewriter.c +++ b/sql/server/rel_rewriter.c @@ -225,6 +225,7 @@ rewrite_simplify(visitor *v, uint8_t cyc /* make sure the single expression is false, so the generate NULL values won't match */ rel->exps->h->data = exp_atom_bool(v->sql->sa, 0); rel->l = rel_project(v->sql->sa, NULL, nexps); + set_count_prop(v->sql->sa, rel, 0); rel->card = CARD_ATOM; v->changes++; } @@ -510,7 +511,13 @@ void set_count_prop(sql_allocator *sa, sql_rel *rel, BUN val) { if (val != BUN_NONE) { - prop *p = rel->p = prop_create(sa, PROP_COUNT, rel->p); - p->value.lval = val; + prop *found = find_prop(rel->p, PROP_COUNT); + + if (found) { + found->value.lval = val; + } else { + prop *p = rel->p = prop_create(sa, PROP_COUNT, rel->p); + p->value.lval = val; + } } } diff --git a/sql/server/rel_statistics.c b/sql/server/rel_statistics.c --- a/sql/server/rel_statistics.c +++ b/sql/server/rel_statistics.c @@ -732,11 +732,8 @@ rel_get_statistics_(visitor *v, sql_rel if (can_be_pruned && (is_join(rel->op) || is_select(rel->op)) && !list_empty(rel->exps)) { int changes = v->changes; rel->exps = rel_prune_predicates(v, rel); - if (v->changes > changes) { + if (v->changes > changes) rel = rewrite_simplify(v, 0, v->value_based_opt, rel); - if (is_select(rel->op) && get_rel_count(rel->l) == BUN_NONE) /* hack, set generated projection count */ - set_count_prop(v->sql->sa, rel->l, 0); - } } /* propagate row count */ @@ -806,9 +803,9 @@ rel_get_statistics_(visitor *v, sql_rel } } } break; - case op_anti: + case op_anti: { set_count_prop(v->sql->sa, rel, get_rel_count(l)); - break; + } break; case op_semi: case op_select: { /* TODO calculate cardinalities using selectivities */ ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: properties - Do better overflow checks and fix count pr...
Changeset: a0fa73f02941 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/a0fa73f02941 Modified Files: sql/server/rel_statistics.c Branch: properties Log Message: Do better overflow checks and fix count propagation for trivial joins and selections diffs (108 lines): diff --git a/sql/server/rel_statistics.c b/sql/server/rel_statistics.c --- a/sql/server/rel_statistics.c +++ b/sql/server/rel_statistics.c @@ -675,11 +675,7 @@ rel_get_statistics_(visitor *v, sql_rel } else if (can_be_pruned && rv == 0 && !rel_is_ref(rel)) { /* right side empty */ rel = set_setop_side(v, rel, l); } else if (lv != BUN_NONE && rv != BUN_NONE) { - if ((lv + rv) < lv) { - set_count_prop(v->sql->sa, rel, MAX(lv, rv)); - } else { - set_count_prop(v->sql->sa, rel, lv + rv); - } + set_count_prop(v->sql->sa, rel, (rv > (BUN_MAX - lv)) ? BUN_MAX : (lv + rv)); /* overflow check */ } } else if (is_inter(rel->op) || is_except(rel->op)) { BUN lv = get_rel_count(l), rv = get_rel_count(r); @@ -750,7 +746,7 @@ rel_get_statistics_(visitor *v, sql_rel case op_left: case op_right: case op_full: { - BUN lv = get_rel_count(l), rv = get_rel_count(r), uniques_estimate = BUN_NONE, join_idx_estimate = BUN_NONE; + BUN lv = get_rel_count(l), rv = get_rel_count(r), uniques_estimate = BUN_MAX, join_idx_estimate = BUN_MAX; if (!list_empty(rel->exps)) { for (node *n = rel->exps->h ; n ; n = n->next) { @@ -770,8 +766,8 @@ rel_get_statistics_(visitor *v, sql_rel } } if ((p = find_prop(el->p, PROP_NUNIQUES)) && (p2 = find_prop(er->p, PROP_NUNIQUES))) { - BUN pv = (BUN) p->value.dval, pv2 = (BUN) p2->value.dval, mul = pv * pv2; - mul = mul < pv ? MAX(pv, pv2) : mul; /* check for overflows */ + BUN pv = (BUN) p->value.dval, pv2 = (BUN) p2->value.dval, + mul = (pv == 0 || pv2 == 0) ? 0 : ((pv2 > (BUN_MAX / pv)) ? BUN_MAX : (pv * pv2)); /* check for overflows */ if (is_left(rel->op)) mul = MAX(mul, lv); @@ -785,38 +781,42 @@ rel_get_statistics_(visitor *v, sql_rel } } } - if (join_idx_estimate != BUN_NONE) { + if (join_idx_estimate != BUN_MAX) { set_count_prop(v->sql->sa, rel, join_idx_estimate); - } else if (uniques_estimate != BUN_NONE) { + } else if (uniques_estimate != BUN_MAX) { set_count_prop(v->sql->sa, rel, uniques_estimate); } else if (lv != BUN_NONE && rv != BUN_NONE) { - if (list_empty(rel->exps) && is_outerjoin(rel->op)) { /* outer joins without conditions, sum cardinalities instead of multiply */ - if ((lv + rv) < lv) { - set_count_prop(v->sql->sa, rel, MAX(lv, rv)); + if (list_length(rel->exps) == 1 && (exp_is_false(rel->exps->h->data) || exp_is_null(rel->exps->h->data))) { + /* corner cases for outer joins */ + if (is_left(rel->op)) { + set_count_prop(v->sql->sa, rel, lv); + } else if (is_right(rel->op)) { + set_count_prop(v->sql->sa, rel, rv); + } else if (is_full(rel->op)) { + set_count_prop(v->sql->sa, rel, (rv > (BUN_MAX - lv)) ? BUN_MAX : (lv + rv)); /* overflow check */ } else { - set_count_prop(v->sql->sa, rel, lv + rv); + set_count_prop(v->sql->sa, rel, 0); } - } else if ((lv * rv) < lv) { - set_coun
MonetDB: properties - Make count property an unsigned number and...
Changeset: 61c0e7677763 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/61c0e7677763 Modified Files: sql/server/rel_prop.c sql/server/rel_prop.h sql/server/rel_rewriter.c sql/server/rel_rewriter.h sql/server/rel_statistics.c Branch: properties Log Message: Make count property an unsigned number and fix propagation diffs (295 lines): diff --git a/sql/server/rel_prop.c b/sql/server/rel_prop.c --- a/sql/server/rel_prop.c +++ b/sql/server/rel_prop.c @@ -118,7 +118,7 @@ propvalue2string(sql_allocator *sa, prop switch(p->kind) { case PROP_COUNT: { - snprintf(buf, BUFSIZ, LLFMT, p->value.lval); + snprintf(buf, BUFSIZ, BUNFMT, p->value.lval); return sa_strdup(sa, buf); } case PROP_NUNIQUES: { diff --git a/sql/server/rel_prop.h b/sql/server/rel_prop.h --- a/sql/server/rel_prop.h +++ b/sql/server/rel_prop.h @@ -25,7 +25,7 @@ typedef enum rel_prop { typedef struct prop { rel_prop kind; /* kind of property */ union { - lng lval; /* property with simple counts */ + BUN lval; /* property with simple counts */ dbl dval; /* property with estimate */ void *pval; /* property value */ } value; diff --git a/sql/server/rel_rewriter.c b/sql/server/rel_rewriter.c --- a/sql/server/rel_rewriter.c +++ b/sql/server/rel_rewriter.c @@ -499,16 +499,18 @@ exps_unique(mvc *sql, sql_rel *rel, list return 0; } -lng +BUN get_rel_count(sql_rel *rel) { prop *found = find_prop(rel->p, PROP_COUNT); - return found ? found->value.lval : -1; + return found ? found->value.lval : BUN_NONE; } void -set_count_prop(sql_allocator *sa, sql_rel *rel, lng val) +set_count_prop(sql_allocator *sa, sql_rel *rel, BUN val) { - prop *p = rel->p = prop_create(sa, PROP_COUNT, rel->p); - p->value.lval = val; + if (val != BUN_NONE) { + prop *p = rel->p = prop_create(sa, PROP_COUNT, rel->p); + p->value.lval = val; + } } diff --git a/sql/server/rel_rewriter.h b/sql/server/rel_rewriter.h --- a/sql/server/rel_rewriter.h +++ b/sql/server/rel_rewriter.h @@ -47,7 +47,7 @@ extern int exps_unique(mvc *sql, sql_rel extern sql_column *exp_find_column(sql_rel *rel, sql_exp *exp, int pnr); -extern lng get_rel_count(sql_rel *rel); -extern void set_count_prop(sql_allocator *sa, sql_rel *rel, lng val); +extern BUN get_rel_count(sql_rel *rel); +extern void set_count_prop(sql_allocator *sa, sql_rel *rel, BUN val); #endif /*_REL_REWRITER_H_*/ diff --git a/sql/server/rel_statistics.c b/sql/server/rel_statistics.c --- a/sql/server/rel_statistics.c +++ b/sql/server/rel_statistics.c @@ -596,12 +596,12 @@ set_setop_side(visitor *v, sql_rel *rel, return side; } -static lng +static BUN trivial_project_exp_card(sql_exp *e) { if (e->type == e_convert) return trivial_project_exp_card(e->l); - return e->type == e_atom && e->f ? list_length(e->f) : 1; + return e->type == e_atom && e->f ? (BUN) list_length(e->f) : 1; } static sql_rel * @@ -628,7 +628,8 @@ rel_get_statistics_(visitor *v, sql_rel } /* set table row count */ /* TODO look for remote/replica tables */ - set_count_prop(v->sql->sa, rel, isTable(t) ? (lng)store->storage_api.count_col(v->sql->session->tr, ol_first_node(t->columns)->data, 0) : 50); + if (isTable(t)) + set_count_prop(v->sql->sa, rel, (BUN)store->storage_api.count_col(v->sql->session->tr, ol_first_node(t->columns)->data, 0)); } break; case op_union: case op_inter: @@ -662,7 +663,7 @@ rel_get_statistics_(visitor *v, sql_rel r = rel->r; /* propagate row count */ if (is_union(rel->op)) { - lng lv = get_rel_count(l), rv = get_rel_count(r); + BUN lv = get_rel_count(l), rv = get_rel_count(r); if (lv == 0 && rv == 0) { /* both sides empty */ if (can_be_pruned) @@ -673,13 +674,15 @@ rel_get_statistics_(visitor *v, sql_rel rel = set_setop_side(v, rel, r); } else if (can_be_pruned && rv == 0 && !rel_is_ref(rel)) { /* right side empty */ rel = set_setop_side(v, rel, l); - } else if ((lv + rv) < lv) { - set_count_prop(v->sql->sa, rel, MAX(lv, rv)); - } else { - set_count_prop(v->sql->sa, rel, lv + rv); - } + } else if (lv != BUN_NONE && rv != BUN_NONE) { + if ((lv + rv) < lv) { + set_count_prop(v->sql->sa, rel, MAX(lv, rv)); +
MonetDB: properties - Backported properties from future branch
Changeset: 309f95e550b2 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/309f95e550b2 Modified Files: sql/backends/monet5/rel_bin.c sql/backends/monet5/sql_gencode.c sql/server/rel_basetable.c sql/server/rel_distribute.c sql/server/rel_dump.c sql/server/rel_exp.c sql/server/rel_exp.h sql/server/rel_optimize_proj.c sql/server/rel_optimize_sel.c sql/server/rel_optimizer_private.h sql/server/rel_prop.c sql/server/rel_prop.h sql/server/rel_rewriter.c sql/server/rel_rewriter.h sql/server/rel_select.c sql/server/rel_statistics.c sql/server/rel_statistics.h sql/server/rel_statistics_functions.c sql/server/rel_unnest.c sql/storage/bat/bat_storage.c sql/test/BugTracker-2017/Tests/sqlitelogictest-aggregation-having-avg.Bug-6428.test sql/test/BugTracker/Tests/explain.SF-1739353.test sql/test/merge-partitions/Tests/mergepart31.test Branch: properties Log Message: Backported properties from future branch diffs (truncated from 1968 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 @@ -2539,7 +2539,7 @@ rel2bin_join(backend *be, sql_rel *rel, /* handle possible index lookups, expressions are in index order! */ if (!join && (p=find_prop(e->p, PROP_HASHCOL)) != NULL) { - sql_idx *i = p->value; + sql_idx *i = p->value.pval; int oldvtop = be->mb->vtop, oldstop = be->mb->stop, oldvid = be->mb->vid; join = s = rel2bin_hash_lookup(be, rel, left, right, i, en); @@ -3642,7 +3642,7 @@ rel2bin_select(backend *be, sql_rel *rel prop *p; if ((p=find_prop(e->p, PROP_HASHCOL)) != NULL) { - sql_idx *i = p->value; + sql_idx *i = p->value.pval; int oldvtop = be->mb->vtop, oldstop = be->mb->stop, oldvid = be->mb->vid; if (!(sel = rel2bin_hash_lookup(be, rel, sub, NULL, i, en))) { 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 @@ -318,7 +318,7 @@ static int MalBlkPtr curBlk = 0; InstrPtr curInstr = 0, p, o; Symbol backup = NULL; - const char *local_tbl = prp->value; + const char *local_tbl = prp->value.pval; node *n; int i, q, v, res = 0, added_to_cache = 0, *lret, *rret; size_t len = 1024, nr; diff --git a/sql/server/rel_basetable.c b/sql/server/rel_basetable.c --- a/sql/server/rel_basetable.c +++ b/sql/server/rel_basetable.c @@ -156,10 +156,10 @@ bind_col_exp(mvc *sql, char *name, sql_c if (c->t->pkey && ((sql_kc*)c->t->pkey->k.columns->h->data)->c == c) { p = e->p = prop_create(sql->sa, PROP_HASHCOL, e->p); - p->value = c->t->pkey; + p->value.pval = c->t->pkey; } else if (c->unique == 2) { p = e->p = prop_create(sql->sa, PROP_HASHCOL, e->p); - p->value = NULL; + p->value.pval = NULL; } set_basecol(e); return e; @@ -267,11 +267,11 @@ rel_base_projection( mvc *sql, sql_rel * sql_exp *e = exp_column(sql->sa, name, iname, t, CARD_MULTI, has_nils, unique, 1); if (hash_index(i->type)) { p = e->p = prop_create(sql->sa, PROP_HASHIDX, e->p); - p->value = i; + p->value.pval = i; } if (i->type == join_idx) { p = e->p = prop_create(sql->sa, PROP_JOINIDX, e->p); - p->value = i; + p->value.pval = i; } append(exps, e); } @@ -324,10 +324,10 @@ rel_base_add_columns( mvc *sql, sql_rel } if (c->t->pkey && ((sql_kc*)c->t->pkey->k.columns->h->data)->c == c) { p = e->p = prop_create(sql->sa, PROP_HASHCOL, e->p); - p->value = c->t->pkey; + p->value.pval = c->t->pkey; } else if (c->unique == 2) { p = e->p = prop_create(sql->sa, PROP_HASHCOL, e->p); - p->value = NULL; + p->value.pval = NULL; } set_basecol(e); append(r->exps, e); @@ -37
MonetDB: properties - Use right macro for null availability chec...
Changeset: 614fae5d98d4 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/614fae5d98d4 Modified Files: sql/server/rel_statistics.c sql/test/BugTracker/Tests/explain.SF-1739353.test sql/test/BugTracker/Tests/jdbc_no_debug.SF-1739356.test Branch: properties Log Message: Use right macro for null availability check. Fix cmp_notequal case diffs (152 lines): diff --git a/sql/server/rel_statistics.c b/sql/server/rel_statistics.c --- a/sql/server/rel_statistics.c +++ b/sql/server/rel_statistics.c @@ -248,7 +248,7 @@ rel_setop_get_statistics(mvc *sql, sql_r *rval_min = find_prop_and_get(re->p, PROP_MIN), *rval_max = find_prop_and_get(re->p, PROP_MAX); /* for the intersection, if both expresssions don't overlap, it can be pruned */ - if (is_inter(rel->op) && exp_is_not_null(le) && exp_is_not_null(re) && + if (is_inter(rel->op) && !has_nil(le) && !has_nil(re) && ((rval_max && lval_min && atom_cmp(rval_max, lval_min) < 0) || (rval_min && lval_max && atom_cmp(rval_min, lval_max) > 0))) return true; @@ -469,53 +469,55 @@ rel_prune_predicates(visitor *v, sql_rel always_false |= not_int1 || not_int2 || not_int3; /* for anti the middle must be before the left or after the right or the right after the left, for the other the middle must be always between the left and right intervals */ - always_true |= exp_is_not_null(le) && exp_is_not_null(re) && exp_is_not_null(fe) && + always_true |= !has_nil(le) && !has_nil(re) && !has_nil(fe) && lval_min && lval_max && rval_min && rval_max && fval_min && fval_max && (is_anti(e) ? ((lower == cmp_gte ? atom_cmp(rval_min, lval_max) > 0 : atom_cmp(rval_min, lval_max) >= 0) || (higher == cmp_lte ? atom_cmp(lval_min, fval_max) > 0 : atom_cmp(lval_min, fval_max) >= 0) || atom_cmp(rval_min, fval_max) > 0) : ((lower == cmp_gte ? atom_cmp(lval_min, rval_max) >= 0 : atom_cmp(lval_min, rval_max) > 0) && (higher == cmp_lte ? atom_cmp(fval_min, lval_max) >= 0 : atom_cmp(fval_min, lval_max) > 0))); } else if (!fe) { + if (!is_semantics(e)) /* trival not null cmp null case */ + always_false |= !is_anti(e) && ((exp_is_not_null(le) && exp_is_null(re)) || (exp_is_null(le) && exp_is_not_null(re))); switch (e->flag) { case cmp_equal: if (lval_min && lval_max && rval_min && rval_max && (!is_semantics(e) || !has_nil(le) || !has_nil(re))) - always_false |= is_anti(e) ? (atom_cmp(lval_min, rval_min) == 0 && atom_cmp(lval_max, rval_max) <= 0) : (atom_cmp(rval_max, lval_min) < 0 || atom_cmp(rval_min, lval_max) > 0); + always_false |= (is_anti(e) ? (atom_cmp(lval_min, rval_min) == 0 && atom_cmp(lval_max, rval_max) <= 0) : (atom_cmp(rval_max, lval_min) < 0 || atom_cmp(rval_min, lval_max) > 0)); if (is_semantics(e)) { /* prune *= NULL cases */ - always_false |= is_anti(e) ? (exp_is_null(le) && exp_is_null(re)) : ((exp_is_not_null(le) && exp_is_null(re)) || (exp_is_null(le) && exp_is_not_null(re))); - always_true |= is_anti(e) ? ((exp_is_not_null(le) && exp_is_null(re)) || (exp_is_null(le) && exp_is_not_null(re))) : (exp_is_null(le) && exp_is_null(re)); + always_false |= (is_anti(e) ? (exp_is_null(le) && exp_is_null(re)) : ((exp_is_not_null(le) && exp_is_null(re)) || (exp_is_null(le) && exp_is_not_null(re; + always_true |= (is_anti(e) ? ((exp_is_not_null(le) && exp_is_null(re)) || (exp_is_null(le) && exp_is_not_null(re))) : (exp_is_null(le) && exp_is_null(re))); } break; case cmp_notequal: - if (lval_min && lval_max && rval_min && rval_max && (!is_semantics(e) || !has_nil(le) || !has_nil(re))) - always_true |= is_anti(e) ? (atom_cmp(lval_min, rval_min) == 0 && atom_cmp(lval_max, rval_max) <= 0) : (atom_cmp(rval_max, lval_min) < 0 || atom_cmp(rval_min, lval_max) > 0); + if (lval_min && lval_max && rval_min && rval_max) + always_true |= !has_nil(le) && !has_nil(re) && (is_anti(e) ? (atom_cmp(lval_min, rval_min) == 0 && atom_cmp(lval_max, rval_max) <= 0) :
MonetDB: properties - Merged with default
Changeset: 1fcc6b61b775 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/1fcc6b61b775 Modified Files: sql/backends/monet5/sql.c sql/storage/bat/bat_storage.c Branch: properties Log Message: Merged with default diffs (269 lines): diff --git a/clients/odbc/ChangeLog b/clients/odbc/ChangeLog --- a/clients/odbc/ChangeLog +++ b/clients/odbc/ChangeLog @@ -1,3 +1,9 @@ # ChangeLog file for odbc # This file is updated with Maddlog +* Thu Apr 21 2022 Martin van Dinther +- Corrected ODBC API functions SQLPrimaryKeys(), SQLSpecialColumns() and + SQLStatistics() for local temporary tables located in schema tmp. They did + not return any rows when the temp table had a primary or unique key or + index. Now they do return rows as expected. + diff --git a/clients/odbc/driver/SQLPrimaryKeys.c b/clients/odbc/driver/SQLPrimaryKeys.c --- a/clients/odbc/driver/SQLPrimaryKeys.c +++ b/clients/odbc/driver/SQLPrimaryKeys.c @@ -45,6 +45,7 @@ MNDBPrimaryKeys(ODBCStmt *stmt, size_t querylen; size_t pos = 0; char *sch = NULL, *tab = NULL; + char *sysORtmp = "sys"; /* deal with SQL_NTS and SQL_NULL_DATA */ fixODBCstring(CatalogName, NameLength1, SQLSMALLINT, @@ -60,6 +61,12 @@ MNDBPrimaryKeys(ODBCStmt *stmt, addStmtError(stmt, "HY009", NULL, 0); return SQL_ERROR; } + if (NameLength3 == 0) { + /* Invalid string or buffer length */ + addStmtError(stmt, "HY090", NULL, 0); + return SQL_ERROR; + } + #ifdef ODBCDEBUG ODBCLOG("\"%.*s\" \"%.*s\" \"%.*s\"\n", (int) NameLength1, CatalogName ? (char *) CatalogName : "", @@ -106,6 +113,9 @@ MNDBPrimaryKeys(ODBCStmt *stmt, if (query == NULL) goto nomem; + if (SchemaName != NULL && strcmp((const char *) SchemaName, "tmp") == 0) + sysORtmp = "tmp"; + /* SQLPrimaryKeys returns a table with the following columns: VARCHAR table_cat VARCHAR table_schem @@ -121,13 +131,14 @@ MNDBPrimaryKeys(ODBCStmt *stmt, "kc.name as column_name, " "cast(kc.nr + 1 as smallint) as key_seq, " "k.name as pk_name " - "from sys.schemas s, sys.tables t, " - "sys.keys k, sys.objects kc " + "from sys.schemas s, %s._tables t, " + "%s.keys k, %s.objects kc " "where k.id = kc.id and " "k.table_id = t.id and " "t.schema_id = s.id and " "k.type = 0", - stmt->Dbc->dbname); + stmt->Dbc->dbname, + sysORtmp, sysORtmp, sysORtmp); assert(pos < 800); /* Construct the selection condition query part */ diff --git a/clients/odbc/driver/SQLSpecialColumns.c b/clients/odbc/driver/SQLSpecialColumns.c --- a/clients/odbc/driver/SQLSpecialColumns.c +++ b/clients/odbc/driver/SQLSpecialColumns.c @@ -95,6 +95,7 @@ MNDBSpecialColumns(ODBCStmt *stmt, size_t querylen; size_t pos = 0; char *sch = NULL, *tab = NULL; + char *sysORtmp = "sys"; fixODBCstring(CatalogName, NameLength1, SQLSMALLINT, addStmtError, stmt, return SQL_ERROR); fixODBCstring(SchemaName, NameLength2, SQLSMALLINT, addStmtError, stmt, return SQL_ERROR); @@ -204,6 +205,9 @@ MNDBSpecialColumns(ODBCStmt *stmt, if (query == NULL) goto nomem; + if (SchemaName != NULL && strcmp((const char *) SchemaName, "tmp") == 0) + sysORtmp = "tmp"; + /* Note: SCOPE is SQL_SCOPE_TRANSACTION */ /* Note: PSEUDO_COLUMN is SQL_PC_NOT_PSEUDO */ pos += snprintf(query + pos, querylen - pos, @@ -218,10 +222,10 @@ MNDBSpecialColumns(ODBCStmt *stmt, DECIMAL_DIGITS(c) ", " "cast(%d as smallint) as pseudo_column " "from sys.schemas s, " - "sys.tables t, " - "sys.columns c, " - "sys.keys k, " - "sys.objects kc " + "%s._tables t, " + "%s._columns c, " + "%s.keys k, " + "%s.objects kc " "where s.id = t.schema_id and " "t.id = c.table_id and " "t.id = k.table_id and " @@ -246,7 +250,8 @@ MNDBSpecialColumns(ODBCStmt *stmt, DECIMAL_DIGITS_ARGS, #endif /* pseudo_column: */ - SQL_PC_NOT_PSEUDO); + SQL_PC_NOT_PSEUDO, + sysORtmp, sysORtmp, sysORtmp, sysORtmp); assert(pos < 4300); /* TO
MonetDB: properties - Merged with default
Changeset: 27c026ea256c for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/27c026ea256c Modified Files: gdk/gdk.h gdk/gdk_bbp.c sql/server/rel_optimize_proj.c sql/server/rel_rewriter.c sql/test/SQLancer/Tests/sqlancer23.test sql/test/miscellaneous/Tests/simple_plans.test Branch: properties Log Message: Merged with default diffs (truncated from 330 to 300 lines): diff --git a/documentation/source/manual_pages/mserver5.rst.in b/documentation/source/manual_pages/mserver5.rst.in --- a/documentation/source/manual_pages/mserver5.rst.in +++ b/documentation/source/manual_pages/mserver5.rst.in @@ -99,7 +99,7 @@ MSERVER5 OPTIONS **-d**\ [*value*] Set debug level. This is mostly for debugging purposes. The *value* together with the **=** sign is optional. If not specified, it - defaults to **1**. In the short form **-d**, the value, if present, + defaults to **2**. In the short form **-d**, the value, if present, must immediately (i.e. without space) follow the option. The values of multiple instances of this flag are OR-ed together. The value is an integer, which can be (a bit-wise OR of): @@ -108,11 +108,7 @@ MSERVER5 OPTIONS (THRDMASK) thread-specific debug output **2** - (CHECKMASK) property enforcing on new BATs - - **8** - (PROPMASK) property checking on all values: tells about wrongly - set properties + (CHECKMASK) property checking on new BATs **16** (IOMASK) major IO activity @@ -195,7 +191,7 @@ MSERVER5 OPTIONS Equivalent to **--debug=**\ *(DEADBEEFMASK)*. **--properties** - Equivalent to **--debug=**\ *(CHECKMASK \| PROPMASK \| BATMASK)*. + Equivalent to **--debug=**\ *(CHECKMASK)*. **--threads** Equivalent to **--debug=**\ *(THRDMASK \| PARMASK)*. diff --git a/gdk/gdk.h b/gdk/gdk.h --- a/gdk/gdk.h +++ b/gdk/gdk.h @@ -378,8 +378,8 @@ gdk_export _Noreturn void GDKfatal(_In_z #define THRDMASK (1) #define CHECKMASK (1<<1) #define CHECKDEBUG if (GDKdebug & CHECKMASK) -#define PROPMASK (1<<3) -#define PROPDEBUG if (GDKdebug & PROPMASK) +#define PROPMASK (1<<3) /* unused */ +#define PROPDEBUG if (GDKdebug & PROPMASK) /* unused */ #define IOMASK (1<<4) #define BATMASK(1<<5) #define PARMASK(1<<7) diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c --- a/gdk/gdk_bat.c +++ b/gdk/gdk_bat.c @@ -2457,7 +2457,7 @@ BATmode(BAT *b, bool transient) #ifdef NDEBUG /* assertions are disabled, turn failing tests into a message */ #undef assert -#define assert(test) ((void) ((test) || (TRC_CRITICAL_ENDIF(BAT_, "Assertion `%s' failed\n", #test), 0))) +#define assert(test) ((void) ((test) || (TRC_CRITICAL_ENDIF(CHECK, "Assertion `%s' failed\n", #test), 0))) #endif /* Assert that properties are set correctly. @@ -2706,9 +2706,8 @@ BATassertProps(BAT *b) return; } - /* only do a scan if property checking is requested and the bat -* is not a view */ - if (!isview1 && !isview2 && GDKdebug & PROPMASK) { + /* only do a scan if the bat is not a view */ + if (!isview1 && !isview2) { const void *maxval = NULL; const void *minval = NULL; bool seenmax = false, seenmin = false; diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c --- a/gdk/gdk_bbp.c +++ b/gdk/gdk_bbp.c @@ -3062,7 +3062,7 @@ BBPkeepref(BAT *b) BATsettrivprop(b); MT_lock_unset(&b->theaplock); } - if (GDKdebug & (CHECKMASK | PROPMASK)) + if (GDKdebug & CHECKMASK) BATassertProps(b); if (BATsetaccess(b, BAT_READ) == NULL) return; /* already decreffed */ diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c --- a/gdk/gdk_logger.c +++ b/gdk/gdk_logger.c @@ -1116,7 +1116,7 @@ logger_read_transaction(logger *lg) int dbg = GDKdebug; if (!lg->flushing) - GDKdebug &= ~(CHECKMASK|PROPMASK); + GDKdebug &= ~CHECKMASK; while (err == LOG_OK && (ok=log_read_format(lg, &l))) { if (l.flag == 0 && l.id == 0) { @@ -2001,7 +2001,7 @@ logger_load(int debug, const char *fn, c needcommit = true; } dbg = GDKdebug; - GDKdebug &= ~(CHECKMASK|PROPMASK); + GDKdebug &= ~CHECKMASK; if (needcommit && bm_commit(lg) != GDK_SUCCEED) { GDKerror("Logger_new: commit failed"); goto error; @@ -2026,7 +2026,7 @@ logger_load(int debug, const char *fn, c } } dbg = GDKdebug; - GDKdebug &= ~(CHECKMASK|PROPMASK); + GDKdebug &= ~CHECKMASK; if (logger_commit(lg) != GDK_SUCCEED) { goto error; } diff --git a/gdk/gdk_logger_old.c b/gdk/gdk_logger_old.c --- a/gdk/gdk_logger_old.c +++ b/gdk/gdk_logger_old.c @@ -1016,7
MonetDB: default - Make sure the new single expression is false,...
Changeset: b1a78cf6e941 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/b1a78cf6e941 Modified Files: sql/server/rel_rewriter.c sql/test/SQLancer/Tests/sqlancer23.test Branch: default Log Message: Make sure the new single expression is false, so the generated NULL values won't match diffs (26 lines): diff --git a/sql/server/rel_rewriter.c b/sql/server/rel_rewriter.c --- a/sql/server/rel_rewriter.c +++ b/sql/server/rel_rewriter.c @@ -221,6 +221,8 @@ rewrite_simplify(visitor *v, uint8_t cyc rel->r = NULL; rel->op = op_select; } + /* make sure the single expression is false, so the generate NULL values won't match */ + rel->exps->h->data = exp_atom_bool(v->sql->sa, 0); rel->l = rel_project(v->sql->sa, NULL, nexps); rel->card = CARD_ATOM; v->changes++; diff --git a/sql/test/SQLancer/Tests/sqlancer23.test b/sql/test/SQLancer/Tests/sqlancer23.test --- a/sql/test/SQLancer/Tests/sqlancer23.test +++ b/sql/test/SQLancer/Tests/sqlancer23.test @@ -163,6 +163,10 @@ SELECT 1 FROM t0, (SELECT 1 FROM (SELECT WHERE CASE WHEN TRUE THEN 2 = ANY(VALUES (vx.vx)) WHEN FALSE THEN t0.c0 = t0.c0 END +query I nosort +SELECT 1 FROM t0 GROUP BY t0.c0 HAVING max(FALSE) IS NULL + + # Postgres doesn't give an error here, but we are confident it must statement error GDK reported error: mergejoin: more than one match SELECT 1 FROM t0 CROSS JOIN LATERAL (SELECT (VALUES (y.y), (y.y)) FROM (SELECT 1) y(y) WHERE t0.c0 = 2) x(x) ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - Another corner case
Changeset: 1b8624a06de6 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/1b8624a06de6 Modified Files: sql/server/rel_optimize_proj.c Branch: default Log Message: Another corner case diffs (12 lines): diff --git a/sql/server/rel_optimize_proj.c b/sql/server/rel_optimize_proj.c --- a/sql/server/rel_optimize_proj.c +++ b/sql/server/rel_optimize_proj.c @@ -1462,6 +1462,8 @@ rel_simplify_sum(visitor *v, sql_rel *re /* on these scenarios the new column expression will be ordered/(grouped for distinct) or create potential ambiguity (multiple ref), so skip */ continue; } + } else if ((is_simple_project(l->op) && (!list_empty(l->r) || rel_is_ref(l) || need_distinct(l))) || is_groupby(l->op)) { + continue; } /* add count star */ ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - Another corner case. If the underlying projec...
Changeset: 6707bb552537 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/6707bb552537 Modified Files: sql/server/rel_optimize_proj.c sql/test/miscellaneous/Tests/simple_plans.test Branch: default Log Message: Another corner case. If the underlying projection has to be sorted/distinct/multiple refs, then the new optimization cannot be done diffs (93 lines): diff --git a/sql/server/rel_optimize_proj.c b/sql/server/rel_optimize_proj.c --- a/sql/server/rel_optimize_proj.c +++ b/sql/server/rel_optimize_proj.c @@ -1444,7 +1444,25 @@ rel_simplify_sum(visitor *v, sql_rel *re if ((!e1ok && e2ok) || (e1ok && !e2ok)) { sql_exp *ocol = e1ok ? e2 : e1, *constant = e1ok ? e1 : e2, *mul, *colref, *naggr, *newop, *col = ocol, *match; - bool add_col = true; + bool add_col = true, prepend = false; + + /* if 'col' is a projection from the under relation, then use it */ + while (is_numeric_upcast(col)) + col = col->l; + if (col->type == e_column) { + sql_exp *colf = exps_find_exp(l->exps, col); + + /* col is already found in the inner relation. Also look for a new reference for col, eg sql_add(col, 1), 1 as col */ + if (colf && list_position(l->exps, colf) < list_position(l->exps, oexp)) { + add_col = false; + } else if (!colf && is_simple_project(l->op) && list_empty(l->r) && !rel_is_ref(l) && !need_distinct(l)) { + prepend = true; + add_col = false; + } else if (!colf && (is_simple_project(l->op) || is_groupby(l->op))) { + /* on these scenarios the new column expression will be ordered/(grouped for distinct) or create potential ambiguity (multiple ref), so skip */ + continue; + } + } /* add count star */ count_star_exp = rel_groupby_add_count_star(v->sql, groupby, count_star_exp, &count_added); @@ -1457,20 +1475,6 @@ rel_simplify_sum(visitor *v, sql_rel *re if (!has_label(mul)) exp_label(v->sql->sa, mul, ++v->sql->label); - /* if 'col' is a projection from the under relation, then use it */ - while (is_numeric_upcast(col)) - col = col->l; - if (col->type == e_column) { - sql_exp *colf = exps_find_exp(l->exps, col); - - /* col is already found in the inner relation. Also look for a new reference for col, eg sql_add(col, 1), 1 as col */ - if (colf && list_position(l->exps, colf) < list_position(l->exps, oexp)) { - add_col = false; - } else if (!colf && is_simple_project(l->op) && list_empty(l->r) && !rel_is_ref(l) && !need_distinct(l)) { - list_prepend(l->exps, exp_ref(v->sql, col)); - add_col = false; - } - } colref = exp_ref(v->sql, ocol); if (add_col) /* if 'col' will be added, then make sure it has an unique label */ exp_label(v->sql->sa, colref, ++v->sql->label); @@ -1505,6 +1509,10 @@ rel_simplify_sum(visitor *v, sql_rel *re continue; } + /* a column refe
MonetDB: subqueryfun - Uncomment crashing query
Changeset: 21f04e813e7a for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/21f04e813e7a Modified Files: sql/test/SQLancer/Tests/sqlancer24.test Branch: subqueryfun Log Message: Uncomment crashing query diffs (18 lines): diff --git a/sql/test/SQLancer/Tests/sqlancer24.test b/sql/test/SQLancer/Tests/sqlancer24.test --- a/sql/test/SQLancer/Tests/sqlancer24.test +++ b/sql/test/SQLancer/Tests/sqlancer24.test @@ -35,10 +35,10 @@ SELECT 1 FROM (SELECT CAST(NULL AS INT)) 1 -#query I nosort -#SELECT 1 FROM (SELECT 1) x(x) CROSS JOIN LATERAL (SELECT 1 WHERE x.x BETWEEN x.x AND x.x) y(y) -# -#1 +query I nosort +SELECT 1 FROM (SELECT 1) x(x) CROSS JOIN LATERAL (SELECT 1 WHERE x.x BETWEEN x.x AND x.x) y(y) + +1 query I nosort SELECT 1 FROM (SELECT 1) x(x) HAVING min((SELECT x.x)) = 1 ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: subqueryfun - Merged with default
Changeset: bdcaec4e7af6 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/bdcaec4e7af6 Branch: subqueryfun Log Message: Merged with default diffs (truncated from 37544 to 300 lines): diff --git a/.hgtags b/.hgtags --- a/.hgtags +++ b/.hgtags @@ -761,3 +761,5 @@ 8c015afafb5903ea59b0e2cffac1138a0d82e007 cab90a348501b045e19cee5cebcc44f3800bd0a8 Jul2021_21 cab90a348501b045e19cee5cebcc44f3800bd0a8 Jul2021_SP5_release 5872f047d97c98d3a848514438b8f97fa446855d Jan2022_11 +025239a5a6f122042798c0f1132a2c6298514e06 Jan2022_13 +025239a5a6f122042798c0f1132a2c6298514e06 Jan2022_SP2_release diff --git a/MonetDB.spec b/MonetDB.spec --- a/MonetDB.spec +++ b/MonetDB.spec @@ -848,6 +848,24 @@ fi %endif %changelog +* Fri Apr 01 2022 Sjoerd Mullender - 11.43.13-20220401 +- Rebuilt. +- GH#7278: BUG when there is more than one field/filter in the having + clause + +* Fri Apr 1 2022 Sjoerd Mullender - 11.43.13-20220401 +- gdk: Improved speed of BATappend to empty varsized bat: we now just copy + the heaps instead of inserting individual values. + +* Fri Apr 1 2022 Sjoerd Mullender - 11.43.13-20220401 +- monetdb5: Improved parsing speed of blob values, especially on Windows. + On Windows, using the locale-aware functions isdigit and isxdigit is + comparatively very slow, so we avoid them. + +* Tue Mar 29 2022 Sjoerd Mullender - 11.43.13-20220401 +- gdk: Improved speed of projection (BATproject) on varsized bats by sharing + the data heap (vheap). + * Fri Mar 25 2022 Sjoerd Mullender - 11.43.11-20220325 - Rebuilt. - GH#7252: Segmentation fault on second run diff --git a/clients/Tests/MAL-signatures-hge.test b/clients/Tests/MAL-signatures-hge.test --- a/clients/Tests/MAL-signatures-hge.test +++ b/clients/Tests/MAL-signatures-hge.test @@ -58194,11 +58194,6 @@ pattern capi.eval_aggr(X_0:ptr, X_1:bit, CUDFevalAggr; grouped aggregates through CUDF capi -prelude -command capi.prelude():void -CUDFprelude; -(empty) -capi subeval_aggr pattern capi.subeval_aggr(X_0:ptr, X_1:bit, X_2:str, X_3:any...):any... CUDFevalAggr; @@ -59784,11 +59779,6 @@ command geom.mbrRight(X_0:wkb, X_1:wkb): mbrRight_wkb; Returns true if the mbr of geom1 is right of the mbr of geom2 geom -prelude -command geom.prelude():void -geom_prelude; -(empty) -geom setSRID command geom.setSRID(X_0:wkb, X_1:int):wkb wkbSetSRID; @@ -59983,11 +59973,6 @@ identifier command identifier.identifier(X_0:str):identifier IDentifier; Cast a string to an identifer -identifier -prelude -command identifier.prelude():void -IDprelude; -Initialize the module inet != command inet.!=(X_0:inet, X_1:inet):bit @@ -60429,11 +60414,6 @@ command json.number(X_0:json):dbl JSONjson2number; Convert simple JSON values to a double, return nil upon error. json -prelude -command json.prelude():void -JSONprelude; -(empty) -json renderarray pattern json.renderarray(X_0:any...):json JSONrenderarray; @@ -60819,11 +60799,6 @@ command mapi.ping(X_0:int):int SERVERping; Test availability of an Mserver. mapi -prelude -command mapi.prelude():int -SERVERlisten_default; -(empty) -mapi prepare command mapi.prepare(X_0:int, X_1:str):int SERVERprepare; @@ -61319,11 +61294,6 @@ command mmath.pow(X_0:flt, X_1:flt):flt MATHbinary_POWflt; (empty) mmath -prelude -command mmath.prelude():void -MATHprelude; -initilize mmath module -mmath radians command mmath.radians(X_0:dbl):dbl MATHunary_RADIANSdbl; @@ -62039,11 +62009,6 @@ pattern optimizer.postfix(X_0:str, X_1:s OPTwrapper; Postfix the plan,e.g. pushing projections optimizer -prelude -pattern optimizer.prelude():void -optimizer_prelude; -Initialize the optimizer -optimizer profiler pattern optimizer.profiler():str OPTwrapper; @@ -62199,11 +62164,6 @@ command pcre.pcre_quote(X_0:str):str PCREquote; Return a PCRE pattern string that matches the argument exactly. pcre -prelude -command pcre.prelude():void -pcre_init; -Initialize pcre -pcre replace command pcre.replace(X_0:str, X_1:str, X_2:str, X_3:str):str PCREreplace_wrap; @@ -62334,11 +62294,6 @@ unsafe pattern pyapi3.eval_loader(X_0:pt PYAPI3PyAPIevalLoader; loader functions through Python pyapi3 -prelude -command pyapi3.prelude():void -PYAPI3PyAPIprelude; -(empty) -pyapi3 subeval_aggr unsafe pattern pyapi3.subeval_aggr(X_0:ptr, X_1:str, X_2:any...):any... PYAPI3PyAPIevalAggr; @@ -62424,11 +62379,6 @@ pattern rapi.eval_aggr(X_0:ptr, X_1:str, RAPIevalAggr; grouped aggregates through R rapi -prelude -command rapi.prelude():void -RAPIprelude; -(empty) -rapi subeval_aggr pattern rapi.subeval_aggr(X_0:ptr, X_1:str, X_2:any...):any... RAPIevalAggr; @@ -62519,11 +62469,6 @@ command remote.isalive(X_0:str):int RMTisalive; check if conn is still valid and connected remote -prelude -command remote.prelude():void -RMTprelude; -initialise the remote module -remote put pattern remote.put(X_0:str, X_1:any):str RMTput; @@ -64224,11 +64169,6 @@ command str.prefix(X_0:str, X_1:int):str STRprefix; Extract the prefix o
MonetDB: properties - Merged with default
Changeset: ed333780ee94 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/ed333780ee94 Modified Files: sql/server/rel_exp.c sql/test/miscellaneous/Tests/simple_selects.test Branch: properties Log Message: Merged with default diffs (169 lines): diff --git a/gdk/gdk_logger_old.c b/gdk/gdk_logger_old.c --- a/gdk/gdk_logger_old.c +++ b/gdk/gdk_logger_old.c @@ -1715,6 +1715,13 @@ old_logger_destroy(old_logger *lg) BATloop(lg->add, p, q) { b = BATdescriptor(bids[p]); if (b) { + if (b != lg->lg->catalog_bid && + b != lg->lg->catalog_id && + b != lg->lg->dcatalog && + b != lg->lg->seqs_id && + b != lg->lg->seqs_val && + b != lg->lg->dseqs) + b = BATsetaccess(b, BAT_READ); BATmode(b, false); BBPunfix(bids[p]); } diff --git a/monetdb5/modules/atoms/xml.c b/monetdb5/modules/atoms/xml.c --- a/monetdb5/modules/atoms/xml.c +++ b/monetdb5/modules/atoms/xml.c @@ -817,9 +817,11 @@ size_t XMLunquotestring(const char **p, (void) buf; return 0; } -str XMLprelude(void) { +static str +XMLprelude(void) { return MAL_SUCCEED; /* to not break init */ } + str XMLepilogue(void *ret) { (void)ret; return MAL_SUCCEED; 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 @@ -706,7 +706,6 @@ exp_propagate(sql_allocator *sa, sql_exp set_unique(ne); if (is_basecol(oe)) set_basecol(ne); - ne->flag = oe->flag; /* needed if the referenced column is a parameter without type set yet */ ne->p = prop_copy(sa, oe->p); return ne; } diff --git a/sql/server/rel_optimize_others.c b/sql/server/rel_optimize_others.c --- a/sql/server/rel_optimize_others.c +++ b/sql/server/rel_optimize_others.c @@ -95,6 +95,7 @@ exps_push_down_prj(mvc *sql, list *exps, narg = exp_push_down_prj(sql, arg, f, t); if (!narg) return NULL; + narg = exp_propagate(sql->sa, narg, arg); append(nl, narg); } return nl; @@ -103,7 +104,7 @@ exps_push_down_prj(mvc *sql, list *exps, sql_exp * exp_push_down_prj(mvc *sql, sql_exp *e, sql_rel *f, sql_rel *t) { - sql_exp *ne = NULL, *l, *r, *r2; + sql_exp *ne = NULL, *l = NULL, *r = NULL, *r2 = NULL; assert(is_project(f->op)); @@ -152,29 +153,27 @@ exp_push_down_prj(mvc *sql, sql_exp *e, return exp_propagate(sql->sa, e, ne); case e_cmp: if (e->flag == cmp_or || e->flag == cmp_filter) { - list *l = exps_push_down_prj(sql, e->l, f, t); - list *r = exps_push_down_prj(sql, e->r, f, t); - - if (!l || !r) - return NULL; - if (e->flag == cmp_filter) - return exp_filter(sql->sa, l, r, e->f, is_anti(e)); - return exp_or(sql->sa, l, r, is_anti(e)); - } else if (e->flag == cmp_in || e->flag == cmp_notin) { - sql_exp *l = exp_push_down_prj(sql, e->l, f, t); - list *r = exps_push_down_prj(sql, e->r, f, t); + list *l = NULL, *r = NULL; - if (!l || !r) + if (!(l = exps_push_down_prj(sql, e->l, f, t)) || !(r = exps_push_down_prj(sql, e->r, f, t))) return NULL; - return exp_in(sql->sa, l, r, e->flag); + if (e->flag == cmp_filter) { + ne = exp_filter(sql->sa, l, r, e->f, is_anti(e)); + } else { + ne = exp_or(sql->sa, l, r, is_anti(e)); + } + } else if (e->flag == cmp_in || e->flag == cmp_notin) { + list *r = NULL; + + if (!(l = exp_push_down_prj(sql, e->l, f, t)) || !(r = exps_push_down_prj(sql, e->r, f, t))) + return NULL; + ne = exp_in(sql->sa, l, r, e->flag); } else { - l = exp_push_down_prj(sql, e->l, f, t); - r = exp_push_down_prj(sql, e->r, f, t); + if (!(l = exp_push_down_prj(sql, e->l, f, t)) || !(r = exp_push_down_prj(sql, e->r, f, t)) || (e->f && !(r2 = exp_push_down_prj(sql, e->f, f, t + return NULL; if (e->f) { - r2 = exp_push_down_prj(sql, e->f, f, t); - if (l && r && r2) - ne = exp_compare2(sql->s
MonetDB: default - This is no longer needed
Changeset: dd631f3d82d1 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/dd631f3d82d1 Modified Files: sql/server/rel_exp.c Branch: default Log Message: This is no longer needed diffs (11 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 @@ -704,7 +704,6 @@ exp_propagate(sql_allocator *sa, sql_exp set_unique(ne); if (is_basecol(oe)) set_basecol(ne); - ne->flag = oe->flag; /* needed if the referenced column is a parameter without type set yet */ ne->p = prop_copy(sa, oe->p); return ne; } ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - Revert commit 614c76873351 (not correct) Also...
Changeset: d4ef95b98441 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/d4ef95b98441 Modified Files: sql/server/rel_optimize_others.c sql/test/miscellaneous/Tests/simple_selects.test Branch: default Log Message: Revert commit 614c76873351 (not correct) Also added missing expression name proppagations diffs (97 lines): diff --git a/sql/server/rel_optimize_others.c b/sql/server/rel_optimize_others.c --- a/sql/server/rel_optimize_others.c +++ b/sql/server/rel_optimize_others.c @@ -95,6 +95,7 @@ exps_push_down_prj(mvc *sql, list *exps, narg = exp_push_down_prj(sql, arg, f, t); if (!narg) return NULL; + narg = exp_propagate(sql->sa, narg, arg); append(nl, narg); } return nl; @@ -103,7 +104,7 @@ exps_push_down_prj(mvc *sql, list *exps, sql_exp * exp_push_down_prj(mvc *sql, sql_exp *e, sql_rel *f, sql_rel *t) { - sql_exp *ne = NULL, *l, *r, *r2; + sql_exp *ne = NULL, *l = NULL, *r = NULL, *r2 = NULL; assert(is_project(f->op)); @@ -152,29 +153,27 @@ exp_push_down_prj(mvc *sql, sql_exp *e, return exp_propagate(sql->sa, e, ne); case e_cmp: if (e->flag == cmp_or || e->flag == cmp_filter) { - list *l = exps_push_down_prj(sql, e->l, f, t); - list *r = exps_push_down_prj(sql, e->r, f, t); - - if (!l || !r) - return NULL; - if (e->flag == cmp_filter) - return exp_filter(sql->sa, l, r, e->f, is_anti(e)); - return exp_or(sql->sa, l, r, is_anti(e)); - } else if (e->flag == cmp_in || e->flag == cmp_notin) { - sql_exp *l = exp_push_down_prj(sql, e->l, f, t); - list *r = exps_push_down_prj(sql, e->r, f, t); + list *l = NULL, *r = NULL; - if (!l || !r) + if (!(l = exps_push_down_prj(sql, e->l, f, t)) || !(r = exps_push_down_prj(sql, e->r, f, t))) return NULL; - return exp_in(sql->sa, l, r, e->flag); + if (e->flag == cmp_filter) { + ne = exp_filter(sql->sa, l, r, e->f, is_anti(e)); + } else { + ne = exp_or(sql->sa, l, r, is_anti(e)); + } + } else if (e->flag == cmp_in || e->flag == cmp_notin) { + list *r = NULL; + + if (!(l = exp_push_down_prj(sql, e->l, f, t)) || !(r = exps_push_down_prj(sql, e->r, f, t))) + return NULL; + ne = exp_in(sql->sa, l, r, e->flag); } else { - l = exp_push_down_prj(sql, e->l, f, t); - r = exp_push_down_prj(sql, e->r, f, t); + if (!(l = exp_push_down_prj(sql, e->l, f, t)) || !(r = exp_push_down_prj(sql, e->r, f, t)) || (e->f && !(r2 = exp_push_down_prj(sql, e->f, f, t + return NULL; if (e->f) { - r2 = exp_push_down_prj(sql, e->f, f, t); - if (l && r && r2) - ne = exp_compare2(sql->sa, l, r, r2, e->flag, is_symmetric(e)); - } else if (l && r) { + ne = exp_compare2(sql->sa, l, r, r2, e->flag, is_symmetric(e)); + } else { ne = exp_compare(sql->sa, l, r, e->flag); } } @@ -182,10 +181,10 @@ exp_push_down_prj(mvc *sql, sql_exp *e, return NULL; return exp_propagate(sql->sa, ne, e); case e_convert: - l = exp_push_down_prj(sql, e->l, f, t); - if (l) - return exp_convert(sql->sa, l, exp_fromtype(e), exp_totype(e)); - return NULL; + if (!(l = exp_push_down_prj(sql, e->l, f, t))) + return NULL; + ne = exp_convert(sql->sa, l, exp_fromtype(e), exp_totype(e)); + return exp_propagate(sql->sa, ne, e); case e_aggr: case e_func: { list *l = e->l, *nl = NULL; diff --git a/sql/test/miscellaneous/Tests/simple_selects.test b/sql/test/miscellaneous/Tests/simple_selects.test --- a/sql/test/miscellaneous/Tests/simple_selects.test +++ b/sql/test/miscellaneous/Tests/simple_selects.test @@ -974,6 +974,11 @@ SELECT min(1) FROM (SELECT DISTINCT 1) x 1 +query T nosort +SELECT DISTINCT sql_sub(TIME '14:50:49', x.x) FROM (SELECT 1) y(y) CROSS JOIN (SELECT vx.x FROM (SELECT interval '7200' second) vx(x)) x(x) + +12:50:49 + statement ok create global temp table
MonetDB: properties - Look for overflows
Changeset: c513830f2fa8 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/c513830f2fa8 Modified Files: sql/server/rel_statistics_functions.c Branch: properties Log Message: Look for overflows diffs (45 lines): diff --git a/sql/server/rel_statistics_functions.c b/sql/server/rel_statistics_functions.c --- a/sql/server/rel_statistics_functions.c +++ b/sql/server/rel_statistics_functions.c @@ -51,12 +51,15 @@ sql_add_propagate_statistics(mvc *sql, s res2 = atom_general_ptr(sql->sa, &tp, &sub2); } } else if (strcmp(f->func->imp, "time_add_msec_interval") == 0) { - daytime sub1 = time_add_msec_interval((daytime)lmax->data.val.lval, rmax->data.val.lval), - sub2 = time_add_msec_interval((daytime)lmin->data.val.lval, rmin->data.val.lval); + daytime v1 = (daytime)lmax->data.val.lval, v2 = (daytime)lmin->data.val.lval, + sub1 = time_add_msec_interval(v1, rmax->data.val.lval), + sub2 = time_add_msec_interval(v2, rmin->data.val.lval); - sql_find_subtype(&tp, "time", 0, 0); - res1 = atom_general_ptr(sql->sa, &tp, &sub1); - res2 = atom_general_ptr(sql->sa, &tp, &sub2); + if (sub1 >= v1 && sub2 >= v2) { /* look for overflows */ + sql_find_subtype(&tp, "time", 0, 0); + res1 = atom_general_ptr(sql->sa, &tp, &sub1); + res2 = atom_general_ptr(sql->sa, &tp, &sub2); + } } else if (strcmp(f->func->imp, "timestamp_add_msec_interval") == 0) { timestamp sub1, sub2; @@ -144,12 +147,15 @@ sql_sub_propagate_statistics(mvc *sql, s res2 = atom_general_ptr(sql->sa, &tp, &sub2); } } else if (strcmp(f->func->imp, "time_sub_msec_interval") == 0) { - daytime sub1 = time_sub_msec_interval((daytime)lmax->data.val.lval, rmin->data.val.lval), - sub2 = time_sub_msec_interval((daytime)lmin->data.val.lval, rmax->data.val.lval); + daytime v1 = (daytime)lmax->data.val.lval, v2 = (daytime)lmin->data.val.lval, + sub1 = time_sub_msec_interval(v1, rmin->data.val.lval), + sub2 = time_sub_msec_interval(v2, rmax->data.val.lval); - sql_find_subtype(&tp, "time", 0, 0); - res1 = atom_general_ptr(sql->sa, &tp, &sub1); - res2 = atom_general_ptr(sql->sa, &tp, &sub2); + if (sub1 <= v1 && sub2 <= v2) { /* look for overflows */ + sql_find_subtype(&tp, "time", 0, 0); + res1 = atom_general_ptr(sql->sa, &tp, &sub1); + res2 = atom_general_ptr(sql->sa, &tp, &sub2); + } } else if (strcmp(f->func->imp, "timestamp_sub_msec_interval") == 0) { timestamp sub1, sub2; ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: properties - Merged with default
Changeset: bc80d895e75c for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/bc80d895e75c Modified Files: sql/server/rel_optimize_proj.c sql/test/miscellaneous/Tests/simple_selects.test Branch: properties Log Message: Merged with default diffs (80 lines): diff --git a/sql/server/rel_optimize_proj.c b/sql/server/rel_optimize_proj.c --- a/sql/server/rel_optimize_proj.c +++ b/sql/server/rel_optimize_proj.c @@ -1461,13 +1461,12 @@ rel_simplify_sum(visitor *v, sql_rel *re while (is_numeric_upcast(col)) col = col->l; if (col->type == e_column) { - sql_rel *crel = NULL; - sql_exp *colref = rel_find_exp_and_corresponding_rel(l, col, false, &crel, NULL); + sql_exp *colf = exps_find_exp(l->exps, col); /* col is already found in the inner relation. Also look for a new reference for col, eg sql_add(col, 1), 1 as col */ - if (colref && l == crel && list_position(l->exps, colref) < list_position(l->exps, oexp)) { + if (colf && list_position(l->exps, colf) < list_position(l->exps, oexp)) { add_col = false; - } else if (!colref && is_simple_project(l->op) && list_empty(l->r) && !rel_is_ref(l) && !need_distinct(l)) { + } else if (!colf && is_simple_project(l->op) && list_empty(l->r) && !rel_is_ref(l) && !need_distinct(l)) { list_prepend(l->exps, exp_ref(v->sql, col)); add_col = false; } @@ -1601,7 +1600,7 @@ rel_simplify_groupby_columns(visitor *v, if (c->type == e_column) { if (is_simple_project(efrel->op) || is_groupby(efrel->op)) { /* in a simple projection, self-references may occur */ - sql_exp *nc = (c->l ? exps_bind_column2(efrel->exps, c->l, c->r, NULL) : exps_bind_column(efrel->exps, c->r, NULL, NULL, 0)); + sql_exp *nc = exps_find_exp(efrel->exps, c); if (nc && list_position(efrel->exps, nc) < list_position(efrel->exps, exp_col)) { exp_col = c; c = nc; @@ -1639,18 +1638,17 @@ rel_simplify_groupby_columns(visitor *v, list_hash_clear(rel->r); } - sql_exp *f = (col->l ? exps_bind_column2(rel->r, col->l, col->r, NULL) : exps_bind_column(rel->r, col->r, NULL, NULL, 0)); + sql_exp *f = exps_find_exp(rel->r, col); if (f && list_position(rel->r, f) < list_position(rel->r, e)) { /* if already present, remove it */ e->used = 1; } else { /* Use an unique reference to the column found. If there's another grouping column label pointing into it, rel_groupby_cse will hopefully remove it */ - sql_rel *crel = NULL; - sql_exp *colf = rel_find_exp_and_corresponding_rel(l, col, false, &crel, NULL); + sql_exp *colf = exps_find_exp(l->exps, col); /* col is already found in the inner relation. Also look for a new reference for col, eg sql_add(col, 1), 1 as col */ - if (colf && l == crel && list_position(l->exps, colf) < list_position(l->exps, tope)) { + if (colf && list_position(l->exps, colf) < list_position(l->exps, top
MonetDB: default - Use right call to fix crash
Changeset: 82b461a9aabd for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/82b461a9aabd Modified Files: sql/server/rel_optimize_proj.c sql/test/miscellaneous/Tests/simple_selects.test Branch: default Log Message: Use right call to fix crash diffs (80 lines): diff --git a/sql/server/rel_optimize_proj.c b/sql/server/rel_optimize_proj.c --- a/sql/server/rel_optimize_proj.c +++ b/sql/server/rel_optimize_proj.c @@ -1461,13 +1461,12 @@ rel_simplify_sum(visitor *v, sql_rel *re while (is_numeric_upcast(col)) col = col->l; if (col->type == e_column) { - sql_rel *crel = NULL; - sql_exp *colref = rel_find_exp_and_corresponding_rel(l, col, false, &crel, NULL); + sql_exp *colf = exps_find_exp(l->exps, col); /* col is already found in the inner relation. Also look for a new reference for col, eg sql_add(col, 1), 1 as col */ - if (colref && l == crel && list_position(l->exps, colref) < list_position(l->exps, oexp)) { + if (colf && list_position(l->exps, colf) < list_position(l->exps, oexp)) { add_col = false; - } else if (!colref && is_simple_project(l->op) && list_empty(l->r) && !rel_is_ref(l) && !need_distinct(l)) { + } else if (!colf && is_simple_project(l->op) && list_empty(l->r) && !rel_is_ref(l) && !need_distinct(l)) { list_prepend(l->exps, exp_ref(v->sql, col)); add_col = false; } @@ -1601,7 +1600,7 @@ rel_simplify_groupby_columns(visitor *v, if (c->type == e_column) { if (is_simple_project(efrel->op) || is_groupby(efrel->op)) { /* in a simple projection, self-references may occur */ - sql_exp *nc = (c->l ? exps_bind_column2(efrel->exps, c->l, c->r, NULL) : exps_bind_column(efrel->exps, c->r, NULL, NULL, 0)); + sql_exp *nc = exps_find_exp(efrel->exps, c); if (nc && list_position(efrel->exps, nc) < list_position(efrel->exps, exp_col)) { exp_col = c; c = nc; @@ -1639,18 +1638,17 @@ rel_simplify_groupby_columns(visitor *v, list_hash_clear(rel->r); } - sql_exp *f = (col->l ? exps_bind_column2(rel->r, col->l, col->r, NULL) : exps_bind_column(rel->r, col->r, NULL, NULL, 0)); + sql_exp *f = exps_find_exp(rel->r, col); if (f && list_position(rel->r, f) < list_position(rel->r, e)) { /* if already present, remove it */ e->used = 1; } else { /* Use an unique reference to the column found. If there's another grouping column label pointing into it, rel_groupby_cse will hopefully remove it */ - sql_rel *crel = NULL; - sql_exp *colf = rel_find_exp_and_corresponding_rel(l, col, false, &crel, NULL); + sql_exp *colf = exps_find_exp(l->exps, col); /* col is already found in the inner relation. Also look for a new reference for col, eg sql_add(col, 1), 1 as col */ - if (colf && l == crel && list_position(l->exps, colf) < list_position(l->exps, tope)) { + if (colf && list_position(l->exps, colf) < list_position(l->exps
MonetDB: properties - Merged with default
Changeset: c30d19ef72f8 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/c30d19ef72f8 Modified Files: sql/server/rel_optimize_proj.c sql/test/emptydb/Tests/check.stable.out sql/test/emptydb/Tests/check.stable.out.32bit sql/test/miscellaneous/Tests/groupby_expressions.test sql/test/miscellaneous/Tests/simple_selects.test Branch: properties Log Message: Merged with default diffs (truncated from 1346 to 300 lines): diff --git a/clients/Tests/MAL-signatures-hge.test b/clients/Tests/MAL-signatures-hge.test --- a/clients/Tests/MAL-signatures-hge.test +++ b/clients/Tests/MAL-signatures-hge.test @@ -58194,11 +58194,6 @@ pattern capi.eval_aggr(X_0:ptr, X_1:bit, CUDFevalAggr; grouped aggregates through CUDF capi -prelude -command capi.prelude():void -CUDFprelude; -(empty) -capi subeval_aggr pattern capi.subeval_aggr(X_0:ptr, X_1:bit, X_2:str, X_3:any...):any... CUDFevalAggr; @@ -59784,11 +59779,6 @@ command geom.mbrRight(X_0:wkb, X_1:wkb): mbrRight_wkb; Returns true if the mbr of geom1 is right of the mbr of geom2 geom -prelude -command geom.prelude():void -geom_prelude; -(empty) -geom setSRID command geom.setSRID(X_0:wkb, X_1:int):wkb wkbSetSRID; @@ -59983,11 +59973,6 @@ identifier command identifier.identifier(X_0:str):identifier IDentifier; Cast a string to an identifer -identifier -prelude -command identifier.prelude():void -IDprelude; -Initialize the module inet != command inet.!=(X_0:inet, X_1:inet):bit @@ -60429,11 +60414,6 @@ command json.number(X_0:json):dbl JSONjson2number; Convert simple JSON values to a double, return nil upon error. json -prelude -command json.prelude():void -JSONprelude; -(empty) -json renderarray pattern json.renderarray(X_0:any...):json JSONrenderarray; @@ -60819,11 +60799,6 @@ command mapi.ping(X_0:int):int SERVERping; Test availability of an Mserver. mapi -prelude -command mapi.prelude():int -SERVERlisten_default; -(empty) -mapi prepare command mapi.prepare(X_0:int, X_1:str):int SERVERprepare; @@ -61319,11 +61294,6 @@ command mmath.pow(X_0:flt, X_1:flt):flt MATHbinary_POWflt; (empty) mmath -prelude -command mmath.prelude():void -MATHprelude; -initilize mmath module -mmath radians command mmath.radians(X_0:dbl):dbl MATHunary_RADIANSdbl; @@ -62039,11 +62009,6 @@ pattern optimizer.postfix(X_0:str, X_1:s OPTwrapper; Postfix the plan,e.g. pushing projections optimizer -prelude -pattern optimizer.prelude():void -optimizer_prelude; -Initialize the optimizer -optimizer profiler pattern optimizer.profiler():str OPTwrapper; @@ -62199,11 +62164,6 @@ command pcre.pcre_quote(X_0:str):str PCREquote; Return a PCRE pattern string that matches the argument exactly. pcre -prelude -command pcre.prelude():void -pcre_init; -Initialize pcre -pcre replace command pcre.replace(X_0:str, X_1:str, X_2:str, X_3:str):str PCREreplace_wrap; @@ -62334,11 +62294,6 @@ unsafe pattern pyapi3.eval_loader(X_0:pt PYAPI3PyAPIevalLoader; loader functions through Python pyapi3 -prelude -command pyapi3.prelude():void -PYAPI3PyAPIprelude; -(empty) -pyapi3 subeval_aggr unsafe pattern pyapi3.subeval_aggr(X_0:ptr, X_1:str, X_2:any...):any... PYAPI3PyAPIevalAggr; @@ -62424,11 +62379,6 @@ pattern rapi.eval_aggr(X_0:ptr, X_1:str, RAPIevalAggr; grouped aggregates through R rapi -prelude -command rapi.prelude():void -RAPIprelude; -(empty) -rapi subeval_aggr pattern rapi.subeval_aggr(X_0:ptr, X_1:str, X_2:any...):any... RAPIevalAggr; @@ -62519,11 +62469,6 @@ command remote.isalive(X_0:str):int RMTisalive; check if conn is still valid and connected remote -prelude -command remote.prelude():void -RMTprelude; -initialise the remote module -remote put pattern remote.put(X_0:str, X_1:any):str RMTput; @@ -64224,11 +64169,6 @@ command str.prefix(X_0:str, X_1:int):str STRprefix; Extract the prefix of a given length str -prelude -command str.prelude():void -STRprelude; -(empty) -str r_search command str.r_search(X_0:str, X_1:str):int STRReverseStrSearch; @@ -65474,11 +65414,6 @@ command xml.pi(X_0:str, X_1:str):xml XMLpi; Construct a processing instruction xml -prelude -command xml.prelude():void -XMLprelude; -(empty) -xml root command xml.root(X_0:xml, X_1:str, X_2:str):xml XMLroot; diff --git a/clients/Tests/MAL-signatures.test b/clients/Tests/MAL-signatures.test --- a/clients/Tests/MAL-signatures.test +++ b/clients/Tests/MAL-signatures.test @@ -41779,11 +41779,6 @@ pattern capi.eval_aggr(X_0:ptr, X_1:bit, CUDFevalAggr; grouped aggregates through CUDF capi -prelude -command capi.prelude():void -CUDFprelude; -(empty) -capi subeval_aggr pattern capi.subeval_aggr(X_0:ptr, X_1:bit, X_2:str, X_3:any...):any... CUDFevalAggr; @@ -43324,11 +43319,6 @@ command geom.mbrRight(X_0:wkb, X_1:wkb): mbrRight_wkb; Returns true if the mbr of geom1 is right of the mbr of geom2 geom -prelude -command geom.prelude():void -geom_prelude; -(empty) -geom setSRID command geom.setSRID(X_0:wkb, X_1
MonetDB: default - Small fixes for new optimizers
Changeset: 0b6b8d8fb329 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/0b6b8d8fb329 Modified Files: sql/server/rel_optimize_proj.c sql/test/miscellaneous/Tests/groupby_expressions.test sql/test/miscellaneous/Tests/simple_selects.test Branch: default Log Message: Small fixes for new optimizers diffs (107 lines): diff --git a/sql/server/rel_optimize_proj.c b/sql/server/rel_optimize_proj.c --- a/sql/server/rel_optimize_proj.c +++ b/sql/server/rel_optimize_proj.c @@ -1464,9 +1464,10 @@ rel_simplify_sum(visitor *v, sql_rel *re sql_rel *crel = NULL; sql_exp *colref = rel_find_exp_and_corresponding_rel(l, col, false, &crel, NULL); - if (colref && l == crel) { + /* col is already found in the inner relation. Also look for a new reference for col, eg sql_add(col, 1), 1 as col */ + if (colref && l == crel && list_position(l->exps, colref) < list_position(l->exps, oexp)) { add_col = false; - } else if (is_simple_project(l->op) && list_empty(l->r) && !rel_is_ref(l) && !need_distinct(l)) { + } else if (!colref && is_simple_project(l->op) && list_empty(l->r) && !rel_is_ref(l) && !need_distinct(l)) { list_prepend(l->exps, exp_ref(v->sql, col)); add_col = false; } @@ -1539,7 +1540,7 @@ rel_simplify_sum(visitor *v, sql_rel *re /* add column reference with new label, if 'col' was not found */ if (add_col) { - if (!is_simple_project(l->op) || !list_empty(l->r) || rel_is_ref(l) || need_distinct(l) || is_single(l)) + if (!is_simple_project(l->op) || !list_empty(l->r) || rel_is_ref(l) || need_distinct(l)) groupby->l = l = rel_project(v->sql->sa, l, rel_projections(v->sql, l, NULL, 1, 1)); list_append(l->exps, ocol); } @@ -1573,7 +1574,7 @@ rel_simplify_groupby_columns(visitor *v, if (e->type == e_column) { bool searching = true; sql_rel *efrel = NULL; - sql_exp *exp = rel_find_exp_and_corresponding_rel(l, e, false, &efrel, NULL), *col = NULL; + sql_exp *exp = rel_find_exp_and_corresponding_rel(l, e, false, &efrel, NULL), *col = NULL, *tope = exp; while (searching && !col) { sql_exp *exp_col = exp; @@ -1631,7 +1632,7 @@ rel_simplify_groupby_columns(visitor *v, if ((rname && name && (strcmp(rname, e->l) != 0 || strcmp(name, e->r) != 0)) || (!rname && name && strcmp(name, e->r) != 0)) { if (!has_label(e)) /* dangerous to merge, skip it */ continue; - if (!is_simple_project(l->op) || !list_empty(l->r) || rel_is_ref(l) || need_distinct(l) || is_single(l)) + if (!is_simple_project(l->op) || !list_empty(l->r) || rel_is_ref(l) || need_distinct(l)) rel->l = l = rel_project(v->sql->sa, l, rel_projections(v->sql, l, NULL, 1, 1)); list_append(l->exps, e); n->data = e = exp_ref(v->sql, e); @@ -1645,14 +1646,26 @@ rel_simplify_groupby_columns(visitor *v, } else { /* Use an unique reference to the column found. If there's another grouping column label pointing into it, rel_groupby_cse will hopefully remove it */ - sql_exp *ne = exp_ref(v->sql, col); - if (!has_label(ne)) - exp_label(v->sql->sa, ne, ++v->sql->label); - - if (!is_simple_project(l->op) || !list_empty(l
MonetDB: default - Approved output
Changeset: 474819a9bb4a for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/474819a9bb4a Modified Files: sql/test/emptydb/Tests/check.stable.out sql/test/emptydb/Tests/check.stable.out.32bit Branch: default Log Message: Approved output diffs (22 lines): diff --git a/sql/test/emptydb/Tests/check.stable.out b/sql/test/emptydb/Tests/check.stable.out --- a/sql/test/emptydb/Tests/check.stable.out +++ b/sql/test/emptydb/Tests/check.stable.out @@ -4658,7 +4658,6 @@ select 'null in value_partitions.value', [ "sys.keywords", "LOCAL" ] [ "sys.keywords", "LOCALTIME" ] [ "sys.keywords", "LOCALTIMESTAMP"] -[ "sys.keywords", "LOCKED"] [ "sys.keywords", "MATCH" ] [ "sys.keywords", "MATCHED" ] [ "sys.keywords", "MAXVALUE" ] diff --git a/sql/test/emptydb/Tests/check.stable.out.32bit b/sql/test/emptydb/Tests/check.stable.out.32bit --- a/sql/test/emptydb/Tests/check.stable.out.32bit +++ b/sql/test/emptydb/Tests/check.stable.out.32bit @@ -4658,7 +4658,6 @@ select 'null in value_partitions.value', [ "sys.keywords", "LOCAL" ] [ "sys.keywords", "LOCALTIME" ] [ "sys.keywords", "LOCALTIMESTAMP"] -[ "sys.keywords", "LOCKED"] [ "sys.keywords", "MATCH" ] [ "sys.keywords", "MATCHED" ] [ "sys.keywords", "MAXVALUE" ] ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - Missing space
Changeset: d96b8f0c9e3f for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/d96b8f0c9e3f Modified Files: sql/server/rel_optimize_proj.c Branch: default Log Message: Missing space diffs (12 lines): diff --git a/sql/server/rel_optimize_proj.c b/sql/server/rel_optimize_proj.c --- a/sql/server/rel_optimize_proj.c +++ b/sql/server/rel_optimize_proj.c @@ -1367,7 +1367,7 @@ exp_is_const_op(sql_exp *exp, sql_exp *t return exps_are_const_op(exp->l, tope, expr) && exps_are_const_op(exp->r, tope, expr); if (exp->flag == cmp_in || exp->flag == cmp_notin) return exp_is_const_op(exp->l, tope, expr) && exps_are_const_op(exp->r, tope, expr); - return exp_is_const_op(exp->l, tope, expr)&& exp_is_const_op(exp->r, tope, expr) && (!exp->f || exp_is_const_op(exp->f, tope, expr)); + return exp_is_const_op(exp->l, tope, expr) && exp_is_const_op(exp->r, tope, expr) && (!exp->f || exp_is_const_op(exp->f, tope, expr)); case e_column: { if (is_simple_project(expr->op) || is_groupby(expr->op)) { /* in a simple projection, self-references may occur */ ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - Use right call
Changeset: ede1fcb9dda7 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/ede1fcb9dda7 Modified Files: sql/server/rel_optimize_proj.c Branch: default Log Message: Use right call diffs (12 lines): diff --git a/sql/server/rel_optimize_proj.c b/sql/server/rel_optimize_proj.c --- a/sql/server/rel_optimize_proj.c +++ b/sql/server/rel_optimize_proj.c @@ -1367,7 +1367,7 @@ exp_is_const_op(sql_exp *exp, sql_exp *t return exps_are_const_op(exp->l, tope, expr) && exps_are_const_op(exp->r, tope, expr); if (exp->flag == cmp_in || exp->flag == cmp_notin) return exp_is_const_op(exp->l, tope, expr) && exps_are_const_op(exp->r, tope, expr); - return exps_are_const_op(exp->l, tope, expr)&& exps_are_const_op(exp->r, tope, expr) && (!exp->f || exps_are_const_op(exp->f, tope, expr)); + return exp_is_const_op(exp->l, tope, expr)&& exp_is_const_op(exp->r, tope, expr) && (!exp->f || exp_is_const_op(exp->f, tope, expr)); case e_column: { if (is_simple_project(expr->op) || is_groupby(expr->op)) { /* in a simple projection, self-references may occur */ ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - Another prepared statement small issue
Changeset: a6c413edae91 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/a6c413edae91 Modified Files: sql/server/rel_unnest.c sql/test/prepare/Tests/sqlancer_prepare.sql sql/test/prepare/Tests/sqlancer_prepare.stable.err sql/test/prepare/Tests/sqlancer_prepare.stable.err.int128 Branch: default Log Message: Another prepared statement small issue diffs (53 lines): diff --git a/sql/server/rel_unnest.c b/sql/server/rel_unnest.c --- a/sql/server/rel_unnest.c +++ b/sql/server/rel_unnest.c @@ -937,6 +937,9 @@ push_up_project(mvc *sql, sql_rel *rel, rel_bind_var(sql, rel->l, e); if (is_left(rel->op)) { /* add ifthenelse */ /* if id is NULL then NULL else e */ + sql_subtype *tp = exp_subtype(e); + if (!tp) + return sql_error(sql, 10, SQLSTATE(42000) "Query projection must have at least one parameter with known SQL type"); if (!id) { sql_rel *l = r->l; if (is_join(l->op)) @@ -946,7 +949,7 @@ push_up_project(mvc *sql, sql_rel *rel, } sql_exp *ne = rel_unop_(sql, NULL, exp_ref(sql, id), "sys", "isnull", card_value); set_has_no_nil(ne); - ne = rel_nop_(sql, NULL, ne, exp_null(sql->sa, exp_subtype(e)), e, NULL, "sys", "ifthenelse", card_value); + ne = rel_nop_(sql, NULL, ne, exp_null(sql->sa, tp), e, NULL, "sys", "ifthenelse", card_value); exp_prop_alias(sql->sa, ne, e); e = ne; } diff --git a/sql/test/prepare/Tests/sqlancer_prepare.sql b/sql/test/prepare/Tests/sqlancer_prepare.sql --- a/sql/test/prepare/Tests/sqlancer_prepare.sql +++ b/sql/test/prepare/Tests/sqlancer_prepare.sql @@ -94,3 +94,5 @@ ROLLBACK; -- TODO it requires some internal changes to be able to set types on parameters used as freevars PREPARE SELECT 1 FROM (SELECT ?) x(x) CROSS JOIN LATERAL (SELECT 1 FROM ((SELECT 1) INTERSECT (SELECT 2)) vx(vx) JOIN (SELECT 1) z(z) ON x.x) w(w); --error, Could not determine type for argument number 1 + +PREPARE SELECT 2 FROM (SELECT DISTINCT 1) z(z) LEFT OUTER JOIN LATERAL (SELECT z.z, ? WHERE TRUE) a(a,b) ON TRUE; --error, push_up_project requires a type diff --git a/sql/test/prepare/Tests/sqlancer_prepare.stable.err b/sql/test/prepare/Tests/sqlancer_prepare.stable.err --- a/sql/test/prepare/Tests/sqlancer_prepare.stable.err +++ b/sql/test/prepare/Tests/sqlancer_prepare.stable.err @@ -51,3 +51,7 @@ MAPI = (monetdb) /var/tmp/mtest-185783/ QUERY = PREPARE SELECT 1 FROM (SELECT ?) x(x) CROSS JOIN LATERAL (SELECT 1 FROM ((SELECT 1) INTERSECT (SELECT 2)) vx(vx) JOIN (SELECT 1) z(z) ON x.x) w(w); --error, Could not determine type for argument number 1 ERROR = !Could not determine type for argument number 1 CODE = 42000 +MAPI = (monetdb) /var/tmp/mtest-185783/.s.monetdb.32587 +QUERY = PREPARE SELECT 2 FROM (SELECT DISTINCT 1) z(z) LEFT OUTER JOIN LATERAL (SELECT z.z, ? WHERE TRUE) a(a,b) ON TRUE; --error, push_up_project requires a type +ERROR = !Query projection must have at least one parameter with known SQL type +CODE = 42000 diff --git a/sql/test/prepare/Tests/sqlancer_prepare.stable.err.int128 b/sql/test/prepare/Tests/sqlancer_prepare.stable.err.int128 --- a/sql/test/prepare/Tests/sqlancer_prepare.stable.err.int128 +++ b/sql/test/prepare/Tests/sqlancer_prepare.stable.err.int128 @@ -51,3 +51,7 @@ MAPI = (monetdb) /var/tmp/mtest-185783/ QUERY = PREPARE SELECT 1 FROM (SELECT ?) x(x) CROSS JOIN LATERAL (SELECT 1 FROM ((SELECT 1) INTERSECT (SELECT 2)) vx(vx) JOIN (SELECT 1) z(z) ON x.x) w(w); --error, Could not determine type for argument number 1 ERROR = !Could not determine type for argument number 1 CODE = 42000 +MAPI = (monetdb) /var/tmp/mtest-185783/.s.monetdb.32587 +QUERY = PREPARE SELECT 2 FROM (SELECT DISTINCT 1) z(z) LEFT OUTER JOIN LATERAL (SELECT z.z, ? WHERE TRUE) a(a,b) ON TRUE; --error, push_up_project requires a type +ERROR = !Query projection must have at least one parameter with known SQL type +CODE = 42000 ___ chec
MonetDB: histograms - Merged with default
Changeset: d3e9c6c87382 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/d3e9c6c87382 Modified Files: gdk/CMakeLists.txt gdk/gdk.h gdk/gdk_align.c gdk/gdk_bat.c gdk/gdk_batop.c gdk/gdk_bbp.c gdk/gdk_private.h gdk/gdk_storage.c sql/backends/monet5/sql.c Branch: histograms Log Message: Merged with default diffs (truncated from 19747 to 300 lines): diff --git a/.hgtags b/.hgtags --- a/.hgtags +++ b/.hgtags @@ -762,3 +762,4 @@ cab90a348501b045e19cee5cebcc44f3800bd0a8 cab90a348501b045e19cee5cebcc44f3800bd0a8 Jul2021_SP5_release 5872f047d97c98d3a848514438b8f97fa446855d Jan2022_11 025239a5a6f122042798c0f1132a2c6298514e06 Jan2022_13 +025239a5a6f122042798c0f1132a2c6298514e06 Jan2022_SP2_release 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 @@ -775,7 +775,6 @@ void MSresetInstructions(MalBlkPtr mb, i void MSresetStack(Client cntxt, MalBlkPtr mb, MalStkPtr glb); void MSresetVariables(MalBlkPtr mb); void MSscheduleClient(str command, str challenge, bstream *fin, stream *fout, protocol_version protocol, size_t blocksize); -str MSserveClient(Client cntxt); str OIDXcreateImplementation(Client cntxt, int tpe, BAT *b, int pieces); str OIDXdropImplementation(Client cntxt, BAT *b); str QLOGcalls(BAT **r); diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c --- a/clients/mapiclient/dump.c +++ b/clients/mapiclient/dump.c @@ -1267,6 +1267,7 @@ describe_table(Mapi mid, const char *sch type == 4 ? "STREAM " : type == 5 ? "REMOTE " : type == 6 ? "REPLICA " : +type == 7 ? "UNLOGGED " : ""); dquoted_print(toConsole, schema, "."); dquoted_print(toConsole, tname, " "); @@ -1724,6 +1725,10 @@ dump_table_data(Mapi mid, const char *sc /* replica table */ goto doreturn; } + if (strcmp(ttype, "7") == 0) { + /* unlogged table */ + goto doreturn; + } } if (mapi_error(mid)) goto bailout; diff --git a/clients/mapiclient/mhelp.c b/clients/mapiclient/mhelp.c --- a/clients/mapiclient/mhelp.c +++ b/clients/mapiclient/mhelp.c @@ -109,15 +109,15 @@ SQLhelp sqlhelp1[] = { "See also https://www.monetdb.org/documentation/user-guide/sql-manual/transactions/"}, {"COPY BINARY", "Append binary representations into a table", -"COPY [( BIG | LITTLE | NATIVE) ENDIAN] BINARY INTO qname [column_list] FROM string [',' ...] [ON { CLIENT | SERVER }] [NO CONSTRAINT]", +"COPY [( BIG | LITTLE | NATIVE) ENDIAN] BINARY INTO qname [column_list] FROM string [',' ...] [ON { CLIENT | SERVER }]", "qname,column_list", "See also https://www.monetdb.org/documentation/user-guide/sql-manual/data-loading/binary-loading/"}, {"COPY INTO", "Parse a csv file into a table or write a query result to a csv file", "COPY [nrofrecords] INTO qname [column_list] FROM string [',' ...] [headerlist] [ON { CLIENT | SERVER }] [ separators]\n" -" [NULL [AS] string] [LOCKED] [BEST EFFORT] [NO CONSTRAINT] [FWF '(' integer [',' ...] ')'\n" +" [NULL [AS] string] [BEST EFFORT] [FWF '(' integer [',' ...] ')'\n" "COPY [nrofrecords] INTO qname [column_list] FROM STDIN [headerlist] [ separators]\n" -" [NULL [AS] string] [LOCKED] [BEST EFFORT] [NO CONSTRAINT]\n" +" [NULL [AS] string] [BEST EFFORT]\n" "COPY query_expression INTO [STDOUT | string [ON { CLIENT | SERVER }]] [separators] [NULL [AS] string]", "nrofrecords,qname,column_list,headerlist,separators", "See also https://www.monetdb.org/documentation/user-guide/sql-manual/data-loading/copy-from/"}, @@ -187,6 +187,13 @@ SQLhelp sqlhelp1[] = { "CREATE REMOTE TABLE [ IF NOT EXISTS ] qname ON string [WITH [USER 'username'] [[ENCRYPTED] PASSWORD 'password']]", NULL, "remote name should match mapi:monetdb://host:port/database[/schema[/table]]"}, + {"CREATE UNLOGGED TABLE", +"Create a new unlogged table", +"CREATE UNLOGGED TABLE [ IF NOT EXISTS ] qname table_source [STORAGE ident string]\n" +"CREATE UNLOGGED TABLE [ IF NOT EXISTS ] qname FROM LOADER function_ref\n" +"CREATE UNLOGGED TABLE [ IF NOT EXISTS ] qname table_source [on_commit]", +"table_source,on_commit,function_ref", +"See also https://www.monetdb.org/documentation/user-guide/sql-manual/data-definition/table-definition/"}, {"CREATE REPLICA TABLE", "", "CREATE REPLICA TABLE [ IF NOT EXISTS ] qname table_source", diff
MonetDB: properties - Merged with default
Changeset: d0f8984d74e4 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/d0f8984d74e4 Modified Files: gdk/gdk_batop.c gdk/gdk_private.h sql/backends/monet5/rel_bin.c sql/backends/monet5/sql.c sql/backends/monet5/sql_upgrades.c sql/include/sql_relation.h sql/server/rel_optimize_proj.c sql/server/rel_schema.c sql/server/rel_updates.c sql/storage/bat/bat_storage.c sql/storage/store.c 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/miscellaneous/Tests/simple_plans.test sql/test/miscellaneous/Tests/simple_selects.test Branch: properties Log Message: Merged with default diffs (truncated from 19314 to 300 lines): diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c --- a/clients/mapiclient/dump.c +++ b/clients/mapiclient/dump.c @@ -1267,6 +1267,7 @@ describe_table(Mapi mid, const char *sch type == 4 ? "STREAM " : type == 5 ? "REMOTE " : type == 6 ? "REPLICA " : +type == 7 ? "UNLOGGED " : ""); dquoted_print(toConsole, schema, "."); dquoted_print(toConsole, tname, " "); @@ -1724,6 +1725,10 @@ dump_table_data(Mapi mid, const char *sc /* replica table */ goto doreturn; } + if (strcmp(ttype, "7") == 0) { + /* unlogged table */ + goto doreturn; + } } if (mapi_error(mid)) goto bailout; diff --git a/clients/mapiclient/mhelp.c b/clients/mapiclient/mhelp.c --- a/clients/mapiclient/mhelp.c +++ b/clients/mapiclient/mhelp.c @@ -109,15 +109,15 @@ SQLhelp sqlhelp1[] = { "See also https://www.monetdb.org/documentation/user-guide/sql-manual/transactions/"}, {"COPY BINARY", "Append binary representations into a table", -"COPY [( BIG | LITTLE | NATIVE) ENDIAN] BINARY INTO qname [column_list] FROM string [',' ...] [ON { CLIENT | SERVER }] [NO CONSTRAINT]", +"COPY [( BIG | LITTLE | NATIVE) ENDIAN] BINARY INTO qname [column_list] FROM string [',' ...] [ON { CLIENT | SERVER }]", "qname,column_list", "See also https://www.monetdb.org/documentation/user-guide/sql-manual/data-loading/binary-loading/"}, {"COPY INTO", "Parse a csv file into a table or write a query result to a csv file", "COPY [nrofrecords] INTO qname [column_list] FROM string [',' ...] [headerlist] [ON { CLIENT | SERVER }] [ separators]\n" -" [NULL [AS] string] [LOCKED] [BEST EFFORT] [NO CONSTRAINT] [FWF '(' integer [',' ...] ')'\n" +" [NULL [AS] string] [BEST EFFORT] [FWF '(' integer [',' ...] ')'\n" "COPY [nrofrecords] INTO qname [column_list] FROM STDIN [headerlist] [ separators]\n" -" [NULL [AS] string] [LOCKED] [BEST EFFORT] [NO CONSTRAINT]\n" +" [NULL [AS] string] [BEST EFFORT]\n" "COPY query_expression INTO [STDOUT | string [ON { CLIENT | SERVER }]] [separators] [NULL [AS] string]", "nrofrecords,qname,column_list,headerlist,separators", "See also https://www.monetdb.org/documentation/user-guide/sql-manual/data-loading/copy-from/"}, @@ -187,6 +187,13 @@ SQLhelp sqlhelp1[] = { "CREATE REMOTE TABLE [ IF NOT EXISTS ] qname ON string [WITH [USER 'username'] [[ENCRYPTED] PASSWORD 'password']]", NULL, "remote name should match mapi:monetdb://host:port/database[/schema[/table]]"}, + {"CREATE UNLOGGED TABLE", +"Create a new unlogged table", +"CREATE UNLOGGED TABLE [ IF NOT EXISTS ] qname table_source [STORAGE ident string]\n" +"CREATE UNLOGGED TABLE [ IF NOT EXISTS ] qname FROM LOADER function_ref\n" +"CREATE UNLOGGED TABLE [ IF NOT EXISTS ] qname table_source [on_commit]", +"table_source,on_commit,function_ref", +"See also https://www.monetdb.org/documentation/user-guide/sql-manual/data-definition/table-definition/"}, {"CREATE REPLICA TABLE", "", "CREATE REPLICA TABLE [ IF NOT EXISTS ] qname table_source", diff --git a/clients/odbc/driver/SQLGetInfo.c b/clients/odbc/driver/SQLGetInfo.c --- a/clients/odbc/driver/SQLGetInfo.c +++ b/clients/odbc/driver/SQLGetInfo.c @@ -41,13 +41,15 @@ MNDBGetInfo(ODBCDbc *dbc, char buf[64]; const char *sValue = NULL; /* iff non-NULL, return string value */ int len = sizeof(SQLUINTEGER); /* most common size to return */ + MapiHdl hdl = NULL; /* For some info types an active connection is needed */ if (!dbc->Connected && (InfoType == SQL_DATA_SOURCE_NAME || I
MonetDB: default - Use right pointer
Changeset: bc942e85e007 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/bc942e85e007 Modified Files: sql/server/rel_optimize_proj.c sql/test/miscellaneous/Tests/simple_plans.test Branch: default Log Message: Use right pointer diffs (35 lines): diff --git a/sql/server/rel_optimize_proj.c b/sql/server/rel_optimize_proj.c --- a/sql/server/rel_optimize_proj.c +++ b/sql/server/rel_optimize_proj.c @@ -1471,13 +1471,10 @@ rel_simplify_sum(visitor *v, sql_rel *re add_col = false; } } - /* 'col' is not in the under relation, so add it */ - if (add_col) { - ocol = exp_ref(v->sql, ocol); - exp_label(v->sql->sa, ocol, ++v->sql->label); - } - colref = exp_ref(v->sql, ocol); + if (add_col) /* if 'col' will be added, then make sure it has an unique label */ + exp_label(v->sql->sa, colref, ++v->sql->label); + /* 'oexp' contains the type for the input for the 'sum' aggregate */ if (!(colref = exp_check_type(v->sql, exp_subtype(oexp), groupby, colref, type_equal))) { v->sql->session->status = 0; diff --git a/sql/test/miscellaneous/Tests/simple_plans.test b/sql/test/miscellaneous/Tests/simple_plans.test --- a/sql/test/miscellaneous/Tests/simple_plans.test +++ b/sql/test/miscellaneous/Tests/simple_plans.test @@ -693,3 +693,11 @@ project ( | | ) [ ] [ "sys"."sum" no nil ("%11"."%11") as "%14"."%14", "sys"."count"() NOT NULL as "%12"."%12" ] | ) [ "sys"."sql_add"("%14"."%14", "sys"."sql_mul"(smallint(9) "2", "%12"."%12" NOT NULL) NOT NULL) as "%7"."%7" ] ) [ "%7"."%7" ] + +query I nosort +SELECT sum(CASE x.x WHEN 1 THEN 1 END + 2) FROM (select distinct 1) x(x) +UNION ALL +SELECT sum(CASE x.x WHEN 1 THEN 1 END + 2) FROM (select distinct 1) x(x) + +3 +3 ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - Another missing corner case. Look for NULL va...
Changeset: 1296784f3fb0 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/1296784f3fb0 Modified Files: sql/backends/monet5/dict.c sql/test/dict/Tests/dict04.test Branch: default Log Message: Another missing corner case. Look for NULL value input for thetaselect diffs (169 lines): diff --git a/sql/backends/monet5/dict.c b/sql/backends/monet5/dict.c --- a/sql/backends/monet5/dict.c +++ b/sql/backends/monet5/dict.c @@ -717,48 +717,20 @@ DICTthetaselect(Client cntxt, MalBlkPtr BUN p = BUN_NONE; if (ATOMextern(lvi.type)) v = *(ptr*)v; - if (op[0] == '=' || op[0] == '!') { - p = BUNfnd(lv, v); - } else if (op[0] == '<' || op[0] == '>') { - p = SORTfndfirst(lv, v); - if (p != BUN_NONE && op[0] == '<' && op[1] == '=') { - if (ATOMcmp(lvi.type, v, BUNtail(lvi, p)) != 0) - p--; - } - } - if (p != BUN_NONE) { - if (loi.type == TYPE_bte) { - bte val = (bte)p; - bn = BATthetaselect(lo, lc, &val, op); - } else if (loi.type == TYPE_sht) { - sht val = (sht)p; - bn = BATthetaselect(lo, lc, &val, op); - } else - assert(0); - if (bn && (op[0] == '<' || op[0] == '>' || op[0] == '!') && (!lvi.nonil || lvi.nil)) { /* filter the NULL value out */ - p = BUNfnd(lv, ATOMnilptr(lvi.type)); - if (p != BUN_NONE) { - BAT *nbn = NULL; - if (loi.type == TYPE_bte) { - bte val = (bte)p; - nbn = BATthetaselect(lo, bn, &val, "<>"); - } else if (loi.type == TYPE_sht) { - sht val = (sht)p; - nbn = BATthetaselect(lo, bn, &val, "<>"); - } else - assert(0); - BBPreclaim(bn); - bn = nbn; + if (ATOMcmp(lvi.type, v, ATOMnilptr(lvi.type)) == 0) { + /* corner case, if v is NULL skip any calculations */ + bn = BATdense(0, 0, 0); + } else { + if (op[0] == '=' || op[0] == '!') { + p = BUNfnd(lv, v); + } else if (op[0] == '<' || op[0] == '>') { + p = SORTfndfirst(lv, v); + if (p != BUN_NONE && op[0] == '<' && op[1] == '=') { + if (ATOMcmp(lvi.type, v, BUNtail(lvi, p)) != 0) + p--; } } - } else if (op[0] == '!') { - if (!lvi.nonil || lvi.nil) { /* find a possible NULL value */ - p = BUNfnd(lv, ATOMnilptr(lvi.type)); - } else { - p = BUN_NONE; - } - - if (p != BUN_NONE) { /* filter the NULL value out */ + if (p != BUN_NONE) { if (loi.type == TYPE_bte) { bte val = (bte)p; bn = BATthetaselect(lo, lc, &val, op); @@ -767,14 +739,47 @@ DICTthetaselect(Client cntxt, MalBlkPtr bn = BATthetaselect(lo, lc, &val, op); } else assert(0); - } else if (lc) { /* all rows pass, use input candidate list */ - bn = lc; - BBPfix(lc->batCacheid); /* give one extra physical reference to keep the count in the end */ - } else { /* otherwise return all rows */ - bn = BATdense(0, 0, BATcount(lo)); + if (bn && (op[0] == '<' || op[0] == '>' || op[0] == '!') && (!lvi.nonil || lvi.nil)) { /* filter the NULL value out */ + p = BUNfnd(lv, ATOMnilptr(lvi.type)); + if (p != BUN_NONE) { + BAT *nbn = NULL; + if (loi.type == TYPE_bte) { +
MonetDB: default - Memory leak fix
Changeset: 4bc3c6ab255b for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/4bc3c6ab255b Modified Files: sql/backends/monet5/sql_upgrades.c Branch: default Log Message: Memory leak fix diffs (13 lines): 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 @@ -4911,6 +4911,9 @@ sql_update_default(Client c, mvc *sql) err = SQLstatementIntern(c, buf, "update", true, false, NULL); } } + res_table_destroy(output); + output = NULL; + /* if the table type UNLOGGED TABLE is not in the list of table * types, upgrade */ pos = snprintf(buf, bufsize, "select table_type_name from sys.table_types where table_type_name = 'UNLOGGED TABLE';\n"); ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - Also don't forget for the <> case
Changeset: 93584a430d9b for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/93584a430d9b Modified Files: sql/backends/monet5/dict.c sql/test/dict/Tests/dict04.test Branch: default Log Message: Also don't forget for the <> case diffs (29 lines): diff --git a/sql/backends/monet5/dict.c b/sql/backends/monet5/dict.c --- a/sql/backends/monet5/dict.c +++ b/sql/backends/monet5/dict.c @@ -735,7 +735,7 @@ DICTthetaselect(Client cntxt, MalBlkPtr bn = BATthetaselect(lo, lc, &val, op); } else assert(0); - if (bn && (op[0] == '<' || op[0] == '>') && (!lvi.nonil || lvi.nil)) { /* filter the NULL value out */ + if (bn && (op[0] == '<' || op[0] == '>' || op[0] == '!') && (!lvi.nonil || lvi.nil)) { /* filter the NULL value out */ p = BUNfnd(lv, ATOMnilptr(lvi.type)); if (p != BUN_NONE) { BAT *nbn = NULL; diff --git a/sql/test/dict/Tests/dict04.test b/sql/test/dict/Tests/dict04.test --- a/sql/test/dict/Tests/dict04.test +++ b/sql/test/dict/Tests/dict04.test @@ -296,6 +296,13 @@ query I nosort SELECT 1 FROM t0 WHERE t0.c0 <> 1 +statement ok rowcount 1 +INSERT INTO t0 VALUES (1) + +query I nosort +SELECT t0.c0 FROM t0 WHERE t0.c0 <> 1 + + statement ok DROP TABLE t0 ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - For > and < thetaselects on dictionary values...
Changeset: 2a686e131757 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/2a686e131757 Modified Files: sql/backends/monet5/dict.c sql/test/dict/Tests/dict04.test Branch: default Log Message: For > and < thetaselects on dictionary values, don't forget to filter null values out diffs (83 lines): diff --git a/sql/backends/monet5/dict.c b/sql/backends/monet5/dict.c --- a/sql/backends/monet5/dict.c +++ b/sql/backends/monet5/dict.c @@ -735,10 +735,25 @@ DICTthetaselect(Client cntxt, MalBlkPtr bn = BATthetaselect(lo, lc, &val, op); } else assert(0); + if (bn && (op[0] == '<' || op[0] == '>') && (!lvi.nonil || lvi.nil)) { /* filter the NULL value out */ + p = BUNfnd(lv, ATOMnilptr(lvi.type)); + if (p != BUN_NONE) { + BAT *nbn = NULL; + if (loi.type == TYPE_bte) { + bte val = (bte)p; + nbn = BATthetaselect(lo, bn, &val, "<>"); + } else if (loi.type == TYPE_sht) { + sht val = (sht)p; + nbn = BATthetaselect(lo, bn, &val, "<>"); + } else + assert(0); + BBPreclaim(bn); + bn = nbn; + } + } } else if (op[0] == '!') { if (!lvi.nonil || lvi.nil) { /* find a possible NULL value */ - const void *nilp = ATOMnilptr(lvi.type); - p = BUNfnd(lv, nilp); + p = BUNfnd(lv, ATOMnilptr(lvi.type)); } else { p = BUN_NONE; } diff --git a/sql/test/dict/Tests/dict04.test b/sql/test/dict/Tests/dict04.test --- a/sql/test/dict/Tests/dict04.test +++ b/sql/test/dict/Tests/dict04.test @@ -261,6 +261,48 @@ statement ok START TRANSACTION statement ok +CREATE TABLE t0 (c0 INT) + +statement ok rowcount 1 +INSERT INTO t0 VALUES (NULL) + +statement ok +COMMIT + +statement ok +CALL "sys"."dict_compress"('sys','t0','c0', true) + +query I nosort +SELECT 1 FROM t0 WHERE t0.c0 < 1 + + +query I nosort +SELECT 1 FROM t0 WHERE t0.c0 <= 1 + + +query I nosort +SELECT 1 FROM t0 WHERE t0.c0 > -1 + + +query I nosort +SELECT 1 FROM t0 WHERE t0.c0 >= -1 + + +query I nosort +SELECT 1 FROM t0 WHERE t0.c0 = 1 + + +query I nosort +SELECT 1 FROM t0 WHERE t0.c0 <> 1 + + +statement ok +DROP TABLE t0 + +statement ok +START TRANSACTION + +statement ok DROP ALL PROCEDURE "sys"."dict_compress" statement ok ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - Merged with Jan2022
Changeset: c2e3aa57817b for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/c2e3aa57817b Modified Files: sql/server/rel_schema.c sql/test/miscellaneous/Tests/simple_selects.test Branch: default Log Message: Merged with Jan2022 diffs (145 lines): 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 @@ -378,6 +378,10 @@ column_constraint_type(mvc *sql, const c (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT %s: key %s already exists", (kt == pkey) ? "PRIMARY KEY" : "UNIQUE", name); return res; } + if (ol_find_name(t->idxs, name) || mvc_bind_idx(sql, ss, name)) { + (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT %s: an index named '%s' already exists, and it would conflict with the key", kt == pkey ? "PRIMARY KEY" : "UNIQUE", name); + return res; + } switch (mvc_create_ukey(&k, sql, t, name, kt)) { case -1: (void) sql_error(sql, 02, SQLSTATE(HY013) MAL_MALLOC_FAIL); @@ -461,6 +465,10 @@ column_constraint_type(mvc *sql, const c (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT FOREIGN KEY: key '%s' already exists", name); return res; } + if (ol_find_name(t->idxs, name) || mvc_bind_idx(sql, ss, name)) { + (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT FOREIGN KEY: an index named '%s' already exists, and it would conflict with the key", name); + return res; + } /* find unique referenced key */ if (n->next->data.lval) { @@ -719,6 +727,10 @@ table_foreign_key(mvc *sql, const char * (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT FOREIGN KEY: key '%s' already exists", name); return SQL_ERR; } + if (ol_find_name(t->idxs, name) || mvc_bind_idx(sql, ss, name)) { + (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT FOREIGN KEY: an index named '%s' already exists, and it would conflict with the key", name); + return SQL_ERR; + } if (n->next->next->data.lval) { /* find unique referenced key */ dnode *rnms = n->next->next->data.lval->h; list *cols = sa_list(sql->sa); @@ -825,6 +837,10 @@ table_constraint_type(mvc *sql, const ch (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT %s: key '%s' already exists", kt == pkey ? "PRIMARY KEY" : "UNIQUE", name); return SQL_ERR; } + if (ol_find_name(t->idxs, name) || mvc_bind_idx(sql, ss, name)) { + (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT %s: an index named '%s' already exists, and it would conflict with the key", kt == pkey ? "PRIMARY KEY" : "UNIQUE", name); + return SQL_ERR; + } switch (mvc_create_ukey(&k, sql, t, name, kt)) { case -1: @@ -2200,6 +2216,8 @@ rel_create_index(mvc *sql, char *iname, return sql_error(sql, 02, SQLSTATE(42000) "CREATE INDEX: index name cannot contain just digit characters (0 through 9)"); if ((i = mvc_bind_idx(sql, t->s, iname))) return sql_error(sql, 02, SQLSTATE(42S11) "CREATE INDEX: name '%s' already in use", iname); + if (ol_find_name(t->keys, iname) || mvc_bind_key(sql, t->s, iname)) + return sql_error(sql, 02, SQLSTATE(42000) "CREATE INDEX: a key named '%s' already exists, and it would conflict with the index", iname); if (!isTable(t)) return sql_error(sql, 02, SQLSTATE(42S02) "CREATE INDEX: cannot create index on %s '%s'", TABLE_TYPE_DESCRIPTION(t->type, t->properties), tname); nt = dup_sql_table(sql->sa, t); diff --git a/sql/test/miscellaneous/Tests/simple_selects.test b/sql/test/miscellaneous/Tests/simple_selects.test --- a/sql/test/miscellaneous/Tests/simple_selects.test +++ b/sql/test/miscellaneous/Tests/simple_selects.test @@ -1034,6 +1034,42 @@ statement ok START TRANSACTION statement ok +create table x (x int primary key) + +statement ok +create table y (y int) + +statement ok +create index ups on y(y) + +statement error 42000!CONSTRAINT FOREIGN KEY: an index named 'ups' already exists, and it would conflict with the key +alter table y add constraint ups foreign key (y) references x (x) + +statement ok +ROLLBACK + +statement ok +START TRANSACTION + +statement ok +create table x (x int primary key) + +statement ok +create table y (y int) + +statement ok +alter table y add constraint ups2 foreign key (y) references x (x) + +statement error 4
MonetDB: Jan2022 - Added concurrent test
Changeset: 363f588020cc for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/363f588020cc Modified Files: sql/test/transactions/Tests/transaction_isolation5.SQL.py Branch: Jan2022 Log Message: Added concurrent test diffs (43 lines): diff --git a/sql/test/transactions/Tests/transaction_isolation5.SQL.py b/sql/test/transactions/Tests/transaction_isolation5.SQL.py --- a/sql/test/transactions/Tests/transaction_isolation5.SQL.py +++ b/sql/test/transactions/Tests/transaction_isolation5.SQL.py @@ -235,3 +235,39 @@ with SQLTestCase() as mdb1: mdb1.execute('drop procedure ups;').assertSucceeded() mdb1.execute('drop table x;').assertSucceeded() mdb1.execute('commit;').assertSucceeded() + +# Test concurrent index and constraints with the same name on the same table, ugh +with SQLTestCase() as mdb1: +with SQLTestCase() as mdb2: +mdb1.connect(username="monetdb", password="monetdb") +mdb2.connect(username="monetdb", password="monetdb") + +mdb1.execute('start transaction;').assertSucceeded() +mdb1.execute('create table x (x int primary key);').assertSucceeded() +mdb1.execute('create table y (y int);').assertSucceeded() +mdb1.execute('commit;').assertSucceeded() +mdb1.execute('start transaction;').assertSucceeded() +mdb2.execute('start transaction;').assertSucceeded() +mdb1.execute('create index ups on y(y);').assertSucceeded() +mdb2.execute('alter table y add constraint ups foreign key (y) references x (x);').assertFailed(err_code="42000", err_message="ALTER TABLE: sys_y_ups conflicts with another transaction") +mdb1.execute('commit;').assertSucceeded() +mdb2.execute('commit;').assertFailed() +mdb1.execute('start transaction;').assertSucceeded() +mdb1.execute('drop table x;').assertSucceeded() +mdb1.execute('drop table y;').assertSucceeded() +mdb1.execute('commit;').assertSucceeded() + +mdb1.execute('start transaction;').assertSucceeded() +mdb1.execute('create table x (x int primary key);').assertSucceeded() +mdb1.execute('create table y (y int);').assertSucceeded() +mdb1.execute('commit;').assertSucceeded() +mdb1.execute('start transaction;').assertSucceeded() +mdb2.execute('start transaction;').assertSucceeded() +mdb1.execute('alter table y add constraint ups2 foreign key (y) references x (x);').assertSucceeded() +mdb2.execute('create index ups2 on y(y);').assertFailed(err_code="42000", err_message="ALTER TABLE: sys_y_ups2 conflicts with another transaction") +mdb1.execute('commit;').assertSucceeded() +mdb2.execute('commit;').assertFailed() +mdb1.execute('start transaction;').assertSucceeded() +mdb1.execute('drop table y;').assertSucceeded() +mdb1.execute('drop table x;').assertSucceeded() +mdb1.execute('commit;').assertSucceeded() ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: Jan2022 - When creating a key/index check if the counte...
Changeset: bd112e07a0a7 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/bd112e07a0a7 Modified Files: sql/server/rel_schema.c sql/test/miscellaneous/Tests/simple_selects.test Branch: Jan2022 Log Message: When creating a key/index check if the counterpart name exists and throw error, because it will be ambiguous on the backend diffs (99 lines): 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 @@ -376,6 +376,10 @@ column_constraint_type(mvc *sql, const c (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT %s: key %s already exists", (kt == pkey) ? "PRIMARY KEY" : "UNIQUE", name); return res; } + if (ol_find_name(t->idxs, name) || mvc_bind_idx(sql, ss, name)) { + (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT %s: an index named '%s' already exists, and it would conflict with the key", kt == pkey ? "PRIMARY KEY" : "UNIQUE", name); + return res; + } switch (mvc_create_ukey(&k, sql, t, name, kt)) { case -1: (void) sql_error(sql, 02, SQLSTATE(HY013) MAL_MALLOC_FAIL); @@ -455,6 +459,10 @@ column_constraint_type(mvc *sql, const c (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT FOREIGN KEY: key '%s' already exists", name); return res; } + if (ol_find_name(t->idxs, name) || mvc_bind_idx(sql, ss, name)) { + (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT FOREIGN KEY: an index named '%s' already exists, and it would conflict with the key", name); + return res; + } /* find unique referenced key */ if (n->next->data.lval) { @@ -709,6 +717,10 @@ table_foreign_key(mvc *sql, const char * (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT FOREIGN KEY: key '%s' already exists", name); return SQL_ERR; } + if (ol_find_name(t->idxs, name) || mvc_bind_idx(sql, ss, name)) { + (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT FOREIGN KEY: an index named '%s' already exists, and it would conflict with the key", name); + return SQL_ERR; + } if (n->next->next->data.lval) { /* find unique referenced key */ dnode *rnms = n->next->next->data.lval->h; list *cols = sa_list(sql->sa); @@ -815,6 +827,10 @@ table_constraint_type(mvc *sql, const ch (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT %s: key '%s' already exists", kt == pkey ? "PRIMARY KEY" : "UNIQUE", name); return SQL_ERR; } + if (ol_find_name(t->idxs, name) || mvc_bind_idx(sql, ss, name)) { + (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT %s: an index named '%s' already exists, and it would conflict with the key", kt == pkey ? "PRIMARY KEY" : "UNIQUE", name); + return SQL_ERR; + } switch (mvc_create_ukey(&k, sql, t, name, kt)) { case -1: @@ -2185,6 +2201,8 @@ rel_create_index(mvc *sql, char *iname, return sql_error(sql, 02, SQLSTATE(42000) "CREATE INDEX: index name cannot contain just digit characters (0 through 9)"); if ((i = mvc_bind_idx(sql, t->s, iname))) return sql_error(sql, 02, SQLSTATE(42S11) "CREATE INDEX: name '%s' already in use", iname); + if (ol_find_name(t->keys, iname) || mvc_bind_key(sql, t->s, iname)) + return sql_error(sql, 02, SQLSTATE(42000) "CREATE INDEX: a key named '%s' already exists, and it would conflict with the index", iname); if (!isTable(t)) return sql_error(sql, 02, SQLSTATE(42S02) "CREATE INDEX: cannot create index on %s '%s'", TABLE_TYPE_DESCRIPTION(t->type, t->properties), tname); nt = dup_sql_table(sql->sa, t); diff --git a/sql/test/miscellaneous/Tests/simple_selects.test b/sql/test/miscellaneous/Tests/simple_selects.test --- a/sql/test/miscellaneous/Tests/simple_selects.test +++ b/sql/test/miscellaneous/Tests/simple_selects.test @@ -951,3 +951,39 @@ create table bar (i int, FOREIGN KEY (i) statement ok ROLLBACK + +statement ok +START TRANSACTION + +statement ok +create table x (x int primary key) + +statement ok +create table y (y int) + +statement ok +create index ups on y(y) + +statement error 42000!CONSTRAINT FOREIGN KEY: an index named 'ups' already exists, and it would conflict with the key +alter table y add constraint ups foreign key (y) references x (x) + +statement ok +ROLLBACK + +statement ok +START TRANSACTION + +statement ok +create
MonetDB: default - Merged with Jan2022
Changeset: 475f2ed2233c for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/475f2ed2233c Modified Files: sql/storage/store.c sql/test/miscellaneous/Tests/All Branch: default Log Message: Merged with Jan2022 diffs (60 lines): diff --git a/sql/storage/store.c b/sql/storage/store.c --- a/sql/storage/store.c +++ b/sql/storage/store.c @@ -411,9 +411,9 @@ load_key(sql_trans *tr, sql_table *t, re } /* find idx with same name */ - sql_base *i = os_find_name(nk->t->s->idxs, tr, nk->base.name); - if (i) { - nk->idx = (sql_idx*)i; + node *n = ol_find_name(t->idxs, nk->base.name); + if (n) { + nk->idx = (sql_idx*)n->data; nk->idx->key = nk; } return nk; @@ -2885,12 +2885,9 @@ key_dup(sql_trans *tr, sql_key *k, sql_t nk->idx = NULL; if (k->idx) { - sql_base *b = os_find_name(nk->t->s->idxs, tr, nk->base.name); - - if (b) { - nk->idx = (sql_idx *)b; - nk->idx->key = nk; - } + node *n = ol_find_name(t->idxs, nk->base.name); + nk->idx = (sql_idx *)n->data; + nk->idx->key = nk; } if (nk->type != fkey) { diff --git a/sql/test/miscellaneous/Tests/All b/sql/test/miscellaneous/Tests/All --- a/sql/test/miscellaneous/Tests/All +++ b/sql/test/miscellaneous/Tests/All @@ -26,3 +26,4 @@ NOT_ASSERT?sqlfuncnames sequences analyze_test blobs +temp_tables diff --git a/sql/test/miscellaneous/Tests/temp_tables.SQL.py b/sql/test/miscellaneous/Tests/temp_tables.SQL.py new file mode 100644 --- /dev/null +++ b/sql/test/miscellaneous/Tests/temp_tables.SQL.py @@ -0,0 +1,15 @@ +from MonetDBtesting.sqltest import SQLTestCase + +# another temp tables test case +with SQLTestCase() as mdb1: +mdb1.connect(username="monetdb", password="monetdb") +mdb1.execute("CREATE GLOBAL TEMPORARY TABLE t2(c0 INT, c1 TIME UNIQUE) ON COMMIT DELETE ROWS;").assertSucceeded() + +with SQLTestCase() as mdb2: +mdb2.connect(username="monetdb", password="monetdb") +mdb2.execute("INSERT INTO tmp.t2(c1) VALUES(TIME '13:35:22');").assertSucceeded().assertRowCount(1) + +with SQLTestCase() as mdb3: +mdb3.connect(username="monetdb", password="monetdb") +mdb3.execute("INSERT INTO tmp.t2(c1, c0) VALUES(TIME '13:41:34', 66);").assertSucceeded().assertRowCount(1) +mdb3.execute("DROP TABLE tmp.t2;").assertSucceeded() ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: Jan2022 - Merged with Jul2021
Changeset: 4821446e3ccf for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/4821446e3ccf Modified Files: sql/storage/store.c sql/test/miscellaneous/Tests/All Branch: Jan2022 Log Message: Merged with Jul2021 diffs (60 lines): diff --git a/sql/storage/store.c b/sql/storage/store.c --- a/sql/storage/store.c +++ b/sql/storage/store.c @@ -411,9 +411,9 @@ load_key(sql_trans *tr, sql_table *t, re } /* find idx with same name */ - sql_base *i = os_find_name(nk->t->s->idxs, tr, nk->base.name); - if (i) { - nk->idx = (sql_idx*)i; + node *n = ol_find_name(t->idxs, nk->base.name); + if (n) { + nk->idx = (sql_idx*)n->data; nk->idx->key = nk; } return nk; @@ -2909,12 +2909,9 @@ key_dup(sql_trans *tr, sql_key *k, sql_t nk->idx = NULL; if (k->idx) { - sql_base *b = os_find_name(nk->t->s->idxs, tr, nk->base.name); - - if (b) { - nk->idx = (sql_idx *)b; - nk->idx->key = nk; - } + node *n = ol_find_name(t->idxs, nk->base.name); + nk->idx = (sql_idx *)n->data; + nk->idx->key = nk; } if (nk->type != fkey) { diff --git a/sql/test/miscellaneous/Tests/All b/sql/test/miscellaneous/Tests/All --- a/sql/test/miscellaneous/Tests/All +++ b/sql/test/miscellaneous/Tests/All @@ -25,3 +25,4 @@ NOT_ASSERT?sqlfuncnames sequences analyze_test blobs +temp_tables diff --git a/sql/test/miscellaneous/Tests/temp_tables.SQL.py b/sql/test/miscellaneous/Tests/temp_tables.SQL.py new file mode 100644 --- /dev/null +++ b/sql/test/miscellaneous/Tests/temp_tables.SQL.py @@ -0,0 +1,15 @@ +from MonetDBtesting.sqltest import SQLTestCase + +# another temp tables test case +with SQLTestCase() as mdb1: +mdb1.connect(username="monetdb", password="monetdb") +mdb1.execute("CREATE GLOBAL TEMPORARY TABLE t2(c0 INT, c1 TIME UNIQUE) ON COMMIT DELETE ROWS;").assertSucceeded() + +with SQLTestCase() as mdb2: +mdb2.connect(username="monetdb", password="monetdb") +mdb2.execute("INSERT INTO tmp.t2(c1) VALUES(TIME '13:35:22');").assertSucceeded().assertRowCount(1) + +with SQLTestCase() as mdb3: +mdb3.connect(username="monetdb", password="monetdb") +mdb3.execute("INSERT INTO tmp.t2(c1, c0) VALUES(TIME '13:41:34', 66);").assertSucceeded().assertRowCount(1) +mdb3.execute("DROP TABLE tmp.t2;").assertSucceeded() ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: Jul2021 - Be more restrict, the idx must be there while...
Changeset: 3e3ffb101cc1 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/3e3ffb101cc1 Modified Files: sql/storage/store.c Branch: Jul2021 Log Message: Be more restrict, the idx must be there while dupping diffs (17 lines): diff --git a/sql/storage/store.c b/sql/storage/store.c --- a/sql/storage/store.c +++ b/sql/storage/store.c @@ -2896,11 +2896,8 @@ key_dup(sql_trans *tr, sql_key *k, sql_t if (k->idx) { node *n = ol_find_name(t->idxs, nk->base.name); - - if (n) { - nk->idx = (sql_idx *)n->data; - nk->idx->key = nk; - } + nk->idx = (sql_idx *)n->data; + nk->idx->key = nk; } if (nk->type != fkey) { ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: Jul2021 - Retrieve idx from the right set. It fixes the...
Changeset: 85a72763e8d3 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/85a72763e8d3 Modified Files: sql/storage/store.c Branch: Jul2021 Log Message: Retrieve idx from the right set. It fixes the temp tables crash diffs (31 lines): diff --git a/sql/storage/store.c b/sql/storage/store.c --- a/sql/storage/store.c +++ b/sql/storage/store.c @@ -399,9 +399,9 @@ load_key(sql_trans *tr, sql_table *t, re } /* find idx with same name */ - sql_base *i = os_find_name(nk->t->s->idxs, tr, nk->base.name); - if (i) { - nk->idx = (sql_idx*)i; + node *n = ol_find_name(t->idxs, nk->base.name); + if (n) { + nk->idx = (sql_idx*)n->data; nk->idx->key = nk; } return nk; @@ -2895,10 +2895,10 @@ key_dup(sql_trans *tr, sql_key *k, sql_t nk->idx = NULL; if (k->idx) { - sql_base *b = os_find_name(nk->t->s->idxs, tr, nk->base.name); - - if (b) { - nk->idx = (sql_idx *)b; + node *n = ol_find_name(t->idxs, nk->base.name); + + if (n) { + nk->idx = (sql_idx *)n->data; nk->idx->key = nk; } } ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: Jul2021 - Added test
Changeset: a84630c6a456 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/a84630c6a456 Added Files: sql/test/miscellaneous/Tests/temp_tables.SQL.py Branch: Jul2021 Log Message: Added test diffs (20 lines): diff --git a/sql/test/miscellaneous/Tests/temp_tables.SQL.py b/sql/test/miscellaneous/Tests/temp_tables.SQL.py new file mode 100644 --- /dev/null +++ b/sql/test/miscellaneous/Tests/temp_tables.SQL.py @@ -0,0 +1,15 @@ +from MonetDBtesting.sqltest import SQLTestCase + +# another temp tables test case +with SQLTestCase() as mdb1: +mdb1.connect(username="monetdb", password="monetdb") +mdb1.execute("CREATE GLOBAL TEMPORARY TABLE t2(c0 INT, c1 TIME UNIQUE) ON COMMIT DELETE ROWS;").assertSucceeded() + +with SQLTestCase() as mdb2: +mdb2.connect(username="monetdb", password="monetdb") +mdb2.execute("INSERT INTO tmp.t2(c1) VALUES(TIME '13:35:22');").assertSucceeded().assertRowCount(1) + +with SQLTestCase() as mdb3: +mdb3.connect(username="monetdb", password="monetdb") +mdb3.execute("INSERT INTO tmp.t2(c1, c0) VALUES(TIME '13:41:34', 66);").assertSucceeded().assertRowCount(1) +mdb3.execute("DROP TABLE tmp.t2;").assertSucceeded() ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: Jul2021 - Global temp tables heap use after free with idxs
Changeset: cdaaa8a45bfe for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/cdaaa8a45bfe Modified Files: sql/test/miscellaneous/Tests/All Branch: Jul2021 Log Message: Global temp tables heap use after free with idxs diffs (8 lines): diff --git a/sql/test/miscellaneous/Tests/All b/sql/test/miscellaneous/Tests/All --- a/sql/test/miscellaneous/Tests/All +++ b/sql/test/miscellaneous/Tests/All @@ -19,3 +19,4 @@ create_func_temp simple_plans vessels prepare +temp_tables ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - Flag changes
Changeset: dc48875423be for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/dc48875423be Modified Files: sql/server/rel_optimize_proj.c sql/test/miscellaneous/Tests/simple_plans.test Branch: default Log Message: Flag changes diffs (36 lines): diff --git a/sql/server/rel_optimize_proj.c b/sql/server/rel_optimize_proj.c --- a/sql/server/rel_optimize_proj.c +++ b/sql/server/rel_optimize_proj.c @@ -1550,6 +1550,7 @@ rel_simplify_sum(visitor *v, sql_rel *re /* propagate alias and add new expression */ exp_prop_alias(v->sql->sa, newop, e); list_append(upper->exps, newop); + v->changes++; } } } diff --git a/sql/test/miscellaneous/Tests/simple_plans.test b/sql/test/miscellaneous/Tests/simple_plans.test --- a/sql/test/miscellaneous/Tests/simple_plans.test +++ b/sql/test/miscellaneous/Tests/simple_plans.test @@ -640,9 +640,7 @@ PLAN SELECT sum(x), sum(x + 1), sum(x + project ( | project ( | | group by ( -| | | project ( -| | | | [ [ tinyint(3) "1", tinyint(3) "2", tinyint(3) "3", tinyint(3) "4", tinyint(3) "5" ] as "x"."x" ] -| | | ) [ "x"."x" ] +| | | [ [ tinyint(3) "1", tinyint(3) "2", tinyint(3) "3", tinyint(3) "4", tinyint(3) "5" ] as "x"."x" ] | | ) [ ] [ "sys"."sum" no nil ("x"."x") as "%7"."%7", "%7"."%7" as "%20"."%20", "%7"."%7" as "%22"."%22", "%7"."%7" as "%24"."%24", "sys"."count"() NOT NULL as "%16"."%16" ] | ) [ "%7"."%7", "sys"."sql_add"("%20"."%20", "sys"."sql_mul"(tinyint(2) "1", "%16"."%16" NOT NULL) NOT NULL) as "%10"."%10", "sys"."sql_add"("%22"."%22", "sys"."sql_mul"(tinyint(3) "2", "%16"."%16" NOT NULL) NOT NULL) as "%11"."%11", "sys"."sql_add"("%24"."%24", "sys"."sql_mul"(tinyint(3) "3", "%16"."%16" NOT NULL) NOT NULL) as "%12"."%12" ] ) [ "%7"."%7", "%10"."%10", "%11"."%11", "%12"."%12" ] @@ -660,9 +658,7 @@ PLAN SELECT 10*sum(5 - x) as aa, sum(x + project ( | project ( | | group by ( -| | | project ( -| | | | [ [ tinyint(3) "1", tinyint(3) "2", tinyint(3) "3", tinyint(3) "4", tinyint(3) "5" ] as "x"."x" ] -| | | ) [ "x"."x" ] +| | | [ [ tinyint(3) "1", tinyint(3) "2", tinyint(3) "3", tinyint(3) "4", tinyint(3) "5" ] as "x"."x" ] | | ) [ ] [ "sys"."sum" no nil ("x"."x") as "%15"."%15", "%15"."%15" as "%17"."%17", "sys"."count"() NOT NULL as "%11"."%11" ] | ) [ "%11"."%11" NOT NULL, "sys"."sql_sub"("sys"."sql_mul"(tinyint(4) "5", "%11"."%11" NOT NULL) NOT NULL, "%15"."%15") as "%7"."%7", "sys"."sql_add"("%17"."%17", "sys"."sql_mul"(tinyint(5) "12", "%11"."%11" NOT NULL) NOT NULL) as "%10"."%10" ] ) [ "sys"."sql_mul"(tinyint(4) "10", "%7"."%7") as "aa", "sys"."sql_mul"("%10"."%10", tinyint(2) "2") as "bb", "%11"."%11" NOT NULL as "cc" ] ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - Missed plan keyword
Changeset: 715d870c8b35 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/715d870c8b35 Modified Files: sql/test/miscellaneous/Tests/simple_plans.test Branch: default Log Message: Missed plan keyword diffs (12 lines): diff --git a/sql/test/miscellaneous/Tests/simple_plans.test b/sql/test/miscellaneous/Tests/simple_plans.test --- a/sql/test/miscellaneous/Tests/simple_plans.test +++ b/sql/test/miscellaneous/Tests/simple_plans.test @@ -686,7 +686,7 @@ SELECT sum((x + x) + 2) FROM (VALUES (1) 40 query T nosort -SELECT sum((x + x) + 2) FROM (VALUES (1),(2),(3),(4),(5)) x(x) +PLAN SELECT sum((x + x) + 2) FROM (VALUES (1),(2),(3),(4),(5)) x(x) project ( | project ( ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - First iteration of sum(x + 12) into sum(x) + ...
Changeset: bc14799583b5 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/bc14799583b5 Modified Files: sql/server/rel_optimize_proj.c sql/test/miscellaneous/Tests/simple_plans.test Branch: default Log Message: First iteration of sum(x + 12) into sum(x) + 12*count(*) optimization. Tomorrow I will tune it further diffs (truncated from 327 to 300 lines): diff --git a/sql/server/rel_optimize_proj.c b/sql/server/rel_optimize_proj.c --- a/sql/server/rel_optimize_proj.c +++ b/sql/server/rel_optimize_proj.c @@ -1333,6 +1333,231 @@ rel_project_cse(visitor *v, sql_rel *rel return rel; } +static int exp_is_const_op(sql_exp *exp, sql_exp *tope, sql_rel *expr); + +static int +exps_are_const_op(list *exps, sql_exp *tope, sql_rel *expr) +{ + int ok = 1; + + if (list_empty(exps)) + return 1; + for (node *n = exps->h; n && ok; n = n->next) + ok &= exp_is_const_op(n->data, tope, expr); + return ok; +} + +static int +exp_is_const_op(sql_exp *exp, sql_exp *tope, sql_rel *expr) +{ + switch (exp->type) { + case e_atom: + return exp->f ? 0 : 1; + case e_convert: + return exp_is_const_op(exp->l, tope, expr); + case e_func: + case e_aggr: { + sql_subfunc *f = exp->f; + if (f->func->side_effect || IS_ANALYTIC(f->func)) + return 0; + return exps_are_const_op(exp->l, tope, expr); + } + case e_cmp: + if (exp->flag == cmp_or || exp->flag == cmp_filter) + return exps_are_const_op(exp->l, tope, expr) && exps_are_const_op(exp->r, tope, expr); + if (exp->flag == cmp_in || exp->flag == cmp_notin) + return exp_is_const_op(exp->l, tope, expr) && exps_are_const_op(exp->r, tope, expr); + return exps_are_const_op(exp->l, tope, expr)&& exps_are_const_op(exp->r, tope, expr) && (!exp->f || exps_are_const_op(exp->f, tope, expr)); + case e_column: { + if (is_simple_project(expr->op) || is_groupby(expr->op)) { + /* in a simple projection, self-references may occur */ + sql_exp *nexp = (exp->l ? exps_bind_column2(expr->exps, exp->l, exp->r, NULL) : exps_bind_column(expr->exps, exp->r, NULL, NULL, 0)); + if (nexp && list_position(expr->exps, nexp) < list_position(expr->exps, tope)) + return exp_is_const_op(nexp, exp, expr); + } + return 0; + } + default: + return 0; + } +} + +static sql_exp * +rel_groupby_add_count_star(mvc *sql, sql_rel *rel, sql_exp *count_star_exp, bool *count_added) +{ + if (count_star_exp) + return count_star_exp; + if (!list_empty(rel->exps)) { + for (node *n=rel->exps->h; n ; n = n->next) { + sql_exp *e = n->data; + + if (exp_aggr_is_count(e) && !need_distinct(e) && list_length(e->l) == 0) + return e; + } + } + sql_subfunc *cf = sql_bind_func(sql, "sys", "count", sql_bind_localtype("void"), NULL, F_AGGR, true); + *count_added = true; + return rel_groupby_add_aggr(sql, rel, exp_aggr(sql->sa, NULL, cf, 0, 0, rel->card, 0)); +} + +/* optimize sum(x + 12) into sum(x) + 12*count(*) */ +static inline sql_rel * +rel_simplify_sum(visitor *v, sql_rel *rel) +{ + if (is_groupby(rel->op) && !list_empty(rel->exps)) { + sql_rel *upper = NULL, *groupby = rel, *l = groupby->l; + sql_exp *count_star_exp = NULL; + bool count_added = false; + + for (node *n=groupby->exps->h; n ; n = n->next) { + sql_exp *e = n->data; + list *el = e->l; + sql_subfunc *sf = e->f; + + if (e->type == e_aggr && !need_distinct(e) && sf->func->type == F_AGGR && !sf->func->s && !strcmp(sf->func->base.name, "sum")) { + sql_rel *expr = groupby; + sql_exp *exp = (sql_exp*) el->h->data, *oexp = exp; + + while (is_numeric_upcast(exp)) + exp = exp->l; + /* we want to find a +/- call, so expect them to appear only on simple projections */ + while (exp && exp->type == e_column && (is_simple_project(expr->op) || is_groupby(expr->op)) && expr->l) { + sql_rel *nexpr = NULL; + sql_exp *nexp = rel_find_exp_and_corresponding_rel(l, exp, false, &nexpr, NULL); + + /* break when it loops on the same relation */ + if (nexpr == expr && list_position(expr->exps,
MonetDB: default - Merged with Jan2022
Changeset: 08ea6d1ac05e for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/08ea6d1ac05e Modified Files: clients/mapiclient/mhelp.c Branch: default Log Message: Merged with Jan2022 diffs (33 lines): diff --git a/clients/mapiclient/mhelp.c b/clients/mapiclient/mhelp.c --- a/clients/mapiclient/mhelp.c +++ b/clients/mapiclient/mhelp.c @@ -109,15 +109,15 @@ SQLhelp sqlhelp1[] = { "See also https://www.monetdb.org/documentation/user-guide/sql-manual/transactions/"}, {"COPY BINARY", "Append binary representations into a table", -"COPY [( BIG | LITTLE | NATIVE) ENDIAN] BINARY INTO qname [column_list] FROM string [',' ...] [ON { CLIENT | SERVER }] [NO CONSTRAINT]", +"COPY [( BIG | LITTLE | NATIVE) ENDIAN] BINARY INTO qname [column_list] FROM string [',' ...] [ON { CLIENT | SERVER }]", "qname,column_list", "See also https://www.monetdb.org/documentation/user-guide/sql-manual/data-loading/binary-loading/"}, {"COPY INTO", "Parse a csv file into a table or write a query result to a csv file", "COPY [nrofrecords] INTO qname [column_list] FROM string [',' ...] [headerlist] [ON { CLIENT | SERVER }] [ separators]\n" -" [NULL [AS] string] [LOCKED] [BEST EFFORT] [NO CONSTRAINT] [FWF '(' integer [',' ...] ')'\n" +" [NULL [AS] string] [BEST EFFORT] [FWF '(' integer [',' ...] ')'\n" "COPY [nrofrecords] INTO qname [column_list] FROM STDIN [headerlist] [ separators]\n" -" [NULL [AS] string] [LOCKED] [BEST EFFORT] [NO CONSTRAINT]\n" +" [NULL [AS] string] [BEST EFFORT]\n" "COPY query_expression INTO [STDOUT | string [ON { CLIENT | SERVER }]] [separators] [NULL [AS] string]", "nrofrecords,qname,column_list,headerlist,separators", "See also https://www.monetdb.org/documentation/user-guide/sql-manual/data-loading/copy-from/"}, diff --git a/sql/ChangeLog.Jan2022 b/sql/ChangeLog.Jan2022 --- a/sql/ChangeLog.Jan2022 +++ b/sql/ChangeLog.Jan2022 @@ -1,3 +1,7 @@ # ChangeLog file for sql # This file is updated with Maddlog +* Thu Apr 14 2022 Sjoerd Mullender +- The NO CONSTRAINT option of the COPY INTO query has been removed. + It didn't work and it was never a good idea anyway. + ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: Jan2022 - _mul128 is only available on x64 architecture
Changeset: 614b854793b0 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/614b854793b0 Modified Files: gdk/gdk_calc_private.h Branch: Jan2022 Log Message: _mul128 is only available on x64 architecture diffs (12 lines): diff --git a/gdk/gdk_calc_private.h b/gdk/gdk_calc_private.h --- a/gdk/gdk_calc_private.h +++ b/gdk/gdk_calc_private.h @@ -155,7 +155,7 @@ #define LNGMUL_CHECK(lft, rgt, dst, max, on_overflow) \ MULI4_WITH_CHECK(lft, rgt, lng, dst, max, hge, on_overflow) #else -#if defined(_MSC_VER) +#if defined(_MSC_VER) && defined(_M_AMD64) #include #pragma intrinsic(_mul128) #define LNGMUL_CHECK(lft, rgt, dst, max, on_overflow) \ ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - Merged with Jan2022
Changeset: 819bfb3503d5 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/819bfb3503d5 Modified Files: sql/server/rel_schema.c sql/test/miscellaneous/Tests/simple_selects.test Branch: default Log Message: Merged with Jan2022 diffs (55 lines): 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 @@ -434,6 +434,14 @@ column_constraint_type(mvc *sql, const c } if (!rt) return SQL_ERR; + if (!rt->s) { /* disable foreign key on declared table */ + (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT FOREIGN KEY: cannot create foreign key with declared tables"); + return res; + } + if (isTempSchema(t->s) != isTempSchema(rt->s)) { /* disable foreign key between temp and non temp */ + (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT FOREIGN KEY: cannot create foreign key between temporary and non temporary tables"); + return res; + } if (!ns || !*ns) { /* add this to be safe */ (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT FOREIGN KEY: key name name cannot be empty"); return res; @@ -680,6 +688,14 @@ table_foreign_key(mvc *sql, const char * int ref_actions = n->next->next->next->next->data.i_val; assert(n->next->next->next->next->type == type_int); + if (!ft->s) { /* disable foreign key on declared table */ + (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT FOREIGN KEY: cannot create foreign key with declared tables"); + return SQL_ERR; + } + if (isTempSchema(t->s) != isTempSchema(ft->s)) { /* disable foreign key between temp and non temp */ + (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT FOREIGN KEY: cannot create foreign key between temporary and non temporary tables"); + return SQL_ERR; + } if (!ns || !*ns) { /* add this to be safe */ (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT FOREIGN KEY: key name name cannot be empty"); return SQL_ERR; diff --git a/sql/test/miscellaneous/Tests/simple_selects.test b/sql/test/miscellaneous/Tests/simple_selects.test --- a/sql/test/miscellaneous/Tests/simple_selects.test +++ b/sql/test/miscellaneous/Tests/simple_selects.test @@ -1006,6 +1006,18 @@ drop index tmp.ups statement ok drop table x +statement ok +START TRANSACTION + +statement ok +create temp table foo (i int primary key) on commit preserve rows + +statement error 42000!CONSTRAINT FOREIGN KEY: cannot create foreign key between temporary and non temporary tables +create table bar (i int, FOREIGN KEY (i) REFERENCES foo(i)) + +statement ok +ROLLBACK + # some private functions related errors statement error 42000!SELECT: no such binary operator 'scale_up'(decimal,tinyint) select scale_up(12.1, 10) ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: Jan2022 - Disable foreign keys between temp and non tem...
Changeset: 576f8bb3782a for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/576f8bb3782a Modified Files: sql/server/rel_schema.c sql/test/miscellaneous/Tests/simple_selects.test Branch: Jan2022 Log Message: Disable foreign keys between temp and non temp tables. Fixes crash diffs (52 lines): 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 @@ -433,6 +433,14 @@ column_constraint_type(mvc *sql, const c } if (!rt) return SQL_ERR; + if (!rt->s) { /* disable foreign key on declared table */ + (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT FOREIGN KEY: cannot create foreign key with declared tables"); + return res; + } + if (isTempSchema(t->s) != isTempSchema(rt->s)) { /* disable foreign key between temp and non temp */ + (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT FOREIGN KEY: cannot create foreign key between temporary and non temporary tables"); + return res; + } if (!ns || !*ns) { /* add this to be safe */ (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT FOREIGN KEY: key name name cannot be empty"); return res; @@ -679,6 +687,14 @@ table_foreign_key(mvc *sql, const char * int ref_actions = n->next->next->next->next->data.i_val; assert(n->next->next->next->next->type == type_int); + if (!ft->s) { /* disable foreign key on declared table */ + (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT FOREIGN KEY: cannot create foreign key with declared tables"); + return SQL_ERR; + } + if (isTempSchema(t->s) != isTempSchema(ft->s)) { /* disable foreign key between temp and non temp */ + (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT FOREIGN KEY: cannot create foreign key between temporary and non temporary tables"); + return SQL_ERR; + } if (!ns || !*ns) { /* add this to be safe */ (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT FOREIGN KEY: key name name cannot be empty"); return SQL_ERR; diff --git a/sql/test/miscellaneous/Tests/simple_selects.test b/sql/test/miscellaneous/Tests/simple_selects.test --- a/sql/test/miscellaneous/Tests/simple_selects.test +++ b/sql/test/miscellaneous/Tests/simple_selects.test @@ -939,3 +939,15 @@ CREATE INDEX ups ON tmp.x (x) statement ok drop table x + +statement ok +START TRANSACTION + +statement ok +create temp table foo (i int primary key) on commit preserve rows + +statement error 42000!CONSTRAINT FOREIGN KEY: cannot create foreign key between temporary and non temporary tables +create table bar (i int, FOREIGN KEY (i) REFERENCES foo(i)) + +statement ok +ROLLBACK ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: properties - Merged with default
Changeset: de84b81989c2 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/de84b81989c2 Modified Files: gdk/gdk.h gdk/gdk_batop.c gdk/gdk_bbp.c sql/backends/monet5/sql.c sql/backends/monet5/sql_statement.c sql/backends/monet5/sql_upgrades.c sql/server/rel_exp.c sql/server/rel_exp.h sql/server/rel_optimize_proj.c sql/server/rel_rel.c sql/storage/bat/bat_storage.c sql/test/BugTracker-2015/Tests/crash_in_reduce_groupby.Bug-3818.test sql/test/miscellaneous/Tests/groupby_error.test sql/test/miscellaneous/Tests/groupby_expressions.test sql/test/miscellaneous/Tests/simple_selects.test Branch: properties Log Message: Merged with default diffs (truncated from 5865 to 300 lines): diff --git a/.hgtags b/.hgtags --- a/.hgtags +++ b/.hgtags @@ -762,3 +762,4 @@ cab90a348501b045e19cee5cebcc44f3800bd0a8 cab90a348501b045e19cee5cebcc44f3800bd0a8 Jul2021_SP5_release 5872f047d97c98d3a848514438b8f97fa446855d Jan2022_11 025239a5a6f122042798c0f1132a2c6298514e06 Jan2022_13 +025239a5a6f122042798c0f1132a2c6298514e06 Jan2022_SP2_release 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 @@ -775,7 +775,6 @@ void MSresetInstructions(MalBlkPtr mb, i void MSresetStack(Client cntxt, MalBlkPtr mb, MalStkPtr glb); void MSresetVariables(MalBlkPtr mb); void MSscheduleClient(str command, str challenge, bstream *fin, stream *fout, protocol_version protocol, size_t blocksize); -str MSserveClient(Client cntxt); str OIDXcreateImplementation(Client cntxt, int tpe, BAT *b, int pieces); str OIDXdropImplementation(Client cntxt, BAT *b); str QLOGcalls(BAT **r); diff --git a/cmake/monetdb-defines.cmake b/cmake/monetdb-defines.cmake --- a/cmake/monetdb-defines.cmake +++ b/cmake/monetdb-defines.cmake @@ -246,19 +246,33 @@ macro(monetdb_configure_sizes) check_type_size(socklen_t HAVE_SOCKLEN_T LANGUAGE C) cmake_pop_check_state() + cmake_push_check_state() + check_type_size(__int128 SIZEOF___INT128 LANGUAGE C) + check_type_size(__int128_t SIZEOF___INT128_T LANGUAGE C) + check_type_size(__uint128_t SIZEOF___UINT128_T LANGUAGE C) if(INT128) -cmake_push_check_state() -check_type_size(__int128 SIZEOF___INT128 LANGUAGE C) -check_type_size(__int128_t SIZEOF___INT128_T LANGUAGE C) -check_type_size(__uint128_t SIZEOF___UINT128_T LANGUAGE C) -if(HAVE_SIZEOF___INT128 OR HAVE_SIZEOF___INT128_T OR HAVE_SIZEOF___UINT128_T) +if(HAVE_SIZEOF___INT128) set(HAVE_HGE TRUE) message(STATUS "Huge integers are available") else() - message(STATUS "128-bit integers not supported by this compiler") + if(HAVE_SIZEOF___INT128_T AND HAVE_SIZEOF___UINT128_T) +set(HAVE_HGE TRUE) +message(STATUS "Huge integers are available") + else() +message(STATUS "128-bit integers not supported by this compiler") + endif() endif() -cmake_pop_check_state() + endif() + if(HAVE_SIZEOF___INT128) +set(HAVE___INT128 TRUE) endif() + if(HAVE_SIZEOF___INT128_T) +set(HAVE___INT128_T TRUE) + endif() + if(HAVE_SIZEOF___UINT128_T) +set(HAVE___UINT128_T TRUE) + endif() + cmake_pop_check_state() if(ODBC_FOUND) cmake_push_check_state() diff --git a/common/stream/stream.h b/common/stream/stream.h --- a/common/stream/stream.h +++ b/common/stream/stream.h @@ -39,17 +39,6 @@ #else # define stream_export extern #endif -#ifndef HAVE_HGE -# ifdef HAVE___INT128 -# define HAVE_HGE 1 -typedef __int128 hge; -# else -# ifdef HAVE___INT128_T -# define HAVE_HGE 1 -typedef __int128_t hge; -# endif -# endif -#endif /* Defines to help the compiler check printf-style format arguments. * These defines are also in our config.h, but we repeat them here so diff --git a/gdk/gdk.h b/gdk/gdk.h --- a/gdk/gdk.h +++ b/gdk/gdk.h @@ -778,6 +778,7 @@ typedef enum { * tsorted, trevsorted, twidth, tshift, tnonil, tnil, tnokey, tnosorted, * tnorevsorted, tminpos, tmaxpos, and tunique_est; in addition, the * value should be set if the BBP field BBP_logical(bid) is changed. + * This corresponds with any field that gets saved in the BBP.dir file. * * theaplock: this lock should be held when reading or writing any of * the fields mentioned above for batDirtydesc, and also when reading or @@ -797,8 +798,9 @@ typedef struct BAT { bool batTransient:1,/* should the BAT persist on disk? */ batCopiedtodisk:1, /* once written */ -batDirtyflushed:1, /* was dirty before commit started? */ batDirtydesc:1;/* bat descriptor dirty marker */ + /* not part of bitfields since not in BATiter */ + bool batDirtyflushed; /* was dirty before commit started? */ uint16_t selcnt;/* how often used in equi select without hash */ uint16_t unused;/* value=0 for