Changeset: 5633d013012c for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5633d013012c Added Files: sql/test/BugTracker-2017/Tests/sqlitelogictest-select-in.Bug-6433.stable.err sql/test/BugTracker-2017/Tests/sqlitelogictest-select-in.Bug-6433.stable.out sql/test/BugTracker-2017/Tests/sqlitelogictest-select-not-in.Bug-6435.sql sql/test/BugTracker-2017/Tests/sqlitelogictest-select-not-in.Bug-6435.stable.err sql/test/BugTracker-2017/Tests/sqlitelogictest-select-not-in.Bug-6435.stable.out sql/test/BugTracker-2017/Tests/sqlsmith.Bug-6432.sql sql/test/BugTracker-2017/Tests/sqlsmith.Bug-6432.stable.err sql/test/BugTracker-2017/Tests/sqlsmith.Bug-6432.stable.out Modified Files: monetdb5/optimizer/opt_constants.c sql/backends/monet5/sql_cat.c sql/benchmarks/tpch/fileleak/Tests/delete_all.stable.out sql/include/sql_catalog.h sql/server/rel_optimizer.c sql/server/rel_rel.c sql/server/rel_select.c sql/server/rel_updates.c sql/storage/bat/bat_storage.c sql/storage/store.c sql/test/BugTracker-2009/Tests/use_order_column_first.SF-2686008.stable.out sql/test/BugTracker-2017/Tests/All Branch: default Log Message:
Merge with Jul2017 diffs (truncated from 854 to 300 lines): diff --git a/monetdb5/optimizer/opt_constants.c b/monetdb5/optimizer/opt_constants.c --- a/monetdb5/optimizer/opt_constants.c +++ b/monetdb5/optimizer/opt_constants.c @@ -50,7 +50,7 @@ OPTconstantsImplementation(Client cntxt, for (i=0; i< mb->vtop; i++) alias[ i]= i; - for (i=0; i< mb->vtop; i++) + for (i=0; i< mb->vtop && n < 100; i++) if ( isVarConstant(mb,i) && isVarFixed(mb,i) && getVarType(mb,i) != TYPE_ptr){ x= getVar(mb,i); fnd = 0; @@ -81,12 +81,13 @@ OPTconstantsImplementation(Client cntxt, } } - if( actions) + if (actions) for (i = 0; i < mb->stop; i++){ p= getInstrPtr(mb,i); for (k=0; k < p->argc; k++) getArg(p,k) = alias[getArg(p,k)]; } + /* Defense line against incorrect plans */ /* Plan remains unaffected */ //chkTypes(cntxt->usermodule, mb, FALSE); @@ -95,9 +96,9 @@ OPTconstantsImplementation(Client cntxt, /* keep all actions taken as a post block comment */ usec = GDKusec()- usec; - snprintf(buf,256,"%-20s actions=%2d time=" LLFMT " usec","constants",actions,usec); - newComment(mb,buf); - if( actions >= 0) + snprintf(buf,256,"%-20s actions=%2d time=" LLFMT " usec","constants",actions,usec); + newComment(mb,buf); + if (actions >= 0) addtoMalBlkHistory(mb); wrapup: diff --git a/sql/backends/monet5/sql_cat.c b/sql/backends/monet5/sql_cat.c --- a/sql/backends/monet5/sql_cat.c +++ b/sql/backends/monet5/sql_cat.c @@ -871,7 +871,7 @@ SQLdrop_schema(Client cntxt, MalBlkPtr m throw(SQL,"sql.drop_schema",SQLSTATE(42000) "DROP SCHEMA: access denied for %s to schema ;'%s'", stack_get_string(sql, "current_user"), s->base.name); } else if (s == cur_schema(sql)) { throw(SQL,"sql.drop_schema",SQLSTATE(42000) "DROP SCHEMA: cannot drop current schema"); - } else if (strcmp(sname, "sys") == 0 || strcmp(sname, "tmp") == 0) { + } else if (s->system) { throw(SQL,"sql.drop_schema",SQLSTATE(42000) "DROP SCHEMA: access denied for '%s'", sname); } else if (sql_schema_has_user(sql, s)) { throw(SQL,"sql.drop_schema",SQLSTATE(2BM37) "DROP SCHEMA: unable to drop schema '%s' (there are database objects which depend on it", sname); diff --git a/sql/benchmarks/tpch/fileleak/Tests/delete_all.stable.out b/sql/benchmarks/tpch/fileleak/Tests/delete_all.stable.out --- a/sql/benchmarks/tpch/fileleak/Tests/delete_all.stable.out +++ b/sql/benchmarks/tpch/fileleak/Tests/delete_all.stable.out @@ -42,22 +42,22 @@ Ready. (u'l_suppkey', 262144, 60175) (u'l_tax', 524288, 60175) [(u'l_comment', 0), (u'l_commitdate', 0), (u'l_discount', 0), (u'l_extendedprice', 0), (u'l_linenumber', 0), (u'l_linestatus', 0), (u'l_orderkey', 0), (u'l_partkey', 0), (u'l_quantity', 0), (u'l_receiptdate', 0), (u'l_returnflag', 0), (u'l_shipdate', 0), (u'l_shipinstruct', 0), (u'l_shipmode', 0), (u'l_suppkey', 0), (u'l_tax', 0)] -(u'l_comment', 262144, 0) -(u'l_commitdate', 262144, 0) -(u'l_discount', 524288, 0) -(u'l_extendedprice', 524288, 0) -(u'l_linenumber', 262144, 0) -(u'l_linestatus', 65536, 0) -(u'l_orderkey', 262144, 0) -(u'l_partkey', 262144, 0) -(u'l_quantity', 524288, 0) -(u'l_receiptdate', 262144, 0) -(u'l_returnflag', 65536, 0) -(u'l_shipdate', 262144, 0) -(u'l_shipinstruct', 65536, 0) -(u'l_shipmode', 65536, 0) -(u'l_suppkey', 262144, 0) -(u'l_tax', 524288, 0) +(u'l_comment', 65536, 0) +(u'l_commitdate', 65536, 0) +(u'l_discount', 65536, 0) +(u'l_extendedprice', 65536, 0) +(u'l_linenumber', 65536, 0) +(u'l_linestatus', 0, 0) +(u'l_orderkey', 65536, 0) +(u'l_partkey', 65536, 0) +(u'l_quantity', 65536, 0) +(u'l_receiptdate', 65536, 0) +(u'l_returnflag', 0, 0) +(u'l_shipdate', 65536, 0) +(u'l_shipinstruct', 0, 0) +(u'l_shipmode', 0, 0) +(u'l_suppkey', 65536, 0) +(u'l_tax', 65536, 0) # 13:16:20 > # 13:16:20 > "Done." diff --git a/sql/include/sql_catalog.h b/sql/include/sql_catalog.h --- a/sql/include/sql_catalog.h +++ b/sql/include/sql_catalog.h @@ -150,7 +150,7 @@ typedef enum comp_type { #define is_theta_exp(e) ((e) == cmp_gt || (e) == cmp_gte || (e) == cmp_lte ||\ (e) == cmp_lt || (e) == cmp_equal || (e) == cmp_notequal) -#define is_complex_exp(e) ((e) == cmp_or || (e) == cmp_in || (e) == cmp_notin || (e&CMPMASK) == cmp_filter) +#define is_complex_exp(e) ((e&CMPMASK) == cmp_or || (e) == cmp_in || (e) == cmp_notin || (e&CMPMASK) == cmp_filter) typedef enum commit_action_t { CA_COMMIT, /* commit rows, only for persistent tables */ 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 @@ -1306,9 +1306,10 @@ static sql_exp * } if (!ne && !e->l) ne = rel_bind_column(sql, f, e->r, 0); - if (!ne) + if (!ne || ne->type != e_column) return NULL; e = NULL; + /* if (ne->name && ne->rname) e = rel_bind_column2(sql, t, ne->rname, ne->name, 0); if (!e && ne->name && !ne->rname) @@ -1317,6 +1318,11 @@ static sql_exp * e = rel_bind_column2(sql, t, ne->l, ne->r, 0); if (!e && ne->r && !ne->l) e = rel_bind_column(sql, t, ne->r, 0); + */ + if (ne->l && ne->r) + e = rel_bind_column2(sql, t, ne->l, ne->r, 0); + if (!e && ne->r && !ne->l) + e = rel_bind_column(sql, t, ne->r, 0); sql->session->status = 0; sql->errstr[0] = 0; if (e && flag) @@ -1327,10 +1333,13 @@ static sql_exp * return e; case e_cmp: if (get_cmp(e) == cmp_or || get_cmp(e) == cmp_filter) { - list *l = exps_push_down(sql, e->l, f, t); - list *r = exps_push_down(sql, e->r, f, t); - - if (!l || !r) + list *l, *r; + + l = exps_push_down(sql, e->l, f, t); + if (!l) + return NULL; + r = exps_push_down(sql, e->r, f, t); + if (!r) return NULL; if (get_cmp(e) == cmp_filter) return exp_filter(sql->sa, l, r, e->f, is_anti(e)); @@ -1339,13 +1348,19 @@ static sql_exp * list *r; l = _exp_push_down(sql, e->l, f, t); + if (!l) + return NULL; r = exps_push_down(sql, e->r, f, t); - if (!l || !r) + if (!r) return NULL; return exp_in(sql->sa, l, r, e->flag); } else { l = _exp_push_down(sql, e->l, f, t); + if (!l) + return NULL; r = _exp_push_down(sql, e->r, f, t); + if (!r) + return NULL; if (e->f) { r2 = _exp_push_down(sql, e->f, f, t); if (l && r && r2) @@ -8866,7 +8881,7 @@ rewrite_topdown(mvc *sql, sql_rel *rel, } static sql_rel * -_rel_optimizer(mvc *sql, sql_rel *rel, int level) +_rel_optimizer(mvc *sql, sql_rel *rel, int *g_changes, int level) { int changes = 0, e_changes = 0; global_props gp; @@ -9026,20 +9041,16 @@ static sql_rel * rel = rewrite_topdown(sql, rel, &rel_merge_table_rewrite, &changes); if (level <= 0 && mvc_debug_on(sql,8)) rel = rewrite_topdown(sql, rel, &rel_add_dicts, &changes); - - if (changes && level > 10) { - assert(0); - return rel; - } - - if (changes || level == 0) - return _rel_optimizer(sql, rel, ++level); - + *g_changes = changes; return rel; } sql_rel * rel_optimizer(mvc *sql, sql_rel *rel) { - return _rel_optimizer(sql, rel, 0); -} + int level = 0, changes = 1; + + for( ;rel && level < 20 && changes; level++) + rel = _rel_optimizer(sql, rel, &changes, level); + return rel; +} diff --git a/sql/server/rel_rel.c b/sql/server/rel_rel.c --- a/sql/server/rel_rel.c +++ b/sql/server/rel_rel.c @@ -794,6 +794,8 @@ rel_project(sql_allocator *sa, sql_rel * rel->card = l->card; rel->nrcols = l->nrcols; } + if (e && !list_empty(e)) + set_processed(rel); return rel; } 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 @@ -106,7 +106,6 @@ rel_project_exp(sql_allocator *sa, sql_e { sql_rel *rel = rel_project(sa, NULL, append(new_exp_list(sa), e)); - set_processed(rel); return rel; } @@ -172,7 +171,9 @@ rel_project2groupby(mvc *sql, sql_rel *g } } } - return rel_project(sql->sa, g, rel_projections(sql, g, NULL, 1, 1)); + g = rel_project(sql->sa, g, rel_projections(sql, g, NULL, 1, 1)); + reset_processed(g); + return g; } return NULL; } @@ -487,12 +488,13 @@ find_table_function_type(mvc *sql, sql_s for (n = exps->h, m = (*sf)->func->ops->h; n && m; n = n->next, m = m->next) { sql_arg *a = m->data; sql_exp *e = n->data; + sql_subtype anytype = a->type; if (a->type.type->eclass == EC_ANY) { sql_subtype *st = &e->tpe; - sql_init_subtype(&a->type, st->type, st->digits, st->scale); + sql_init_subtype(&anytype, st->type, st->digits, st->scale); } - e = rel_check_type(sql, &a->type, e, type_equal); + e = rel_check_type(sql, &anytype, e, type_equal); if (!e) { nexps = NULL; break; @@ -734,7 +736,6 @@ rel_named_table_operator(mvc *sql, sql_r dnode *n = column_spec->h; sq = rel_project(sql->sa, sq, rel_projections(sql, sq, NULL, 1, 1)); - set_processed(sq); for (en = sq->exps->h; n && en; n = n->next, en = en->next) exp_setname(sql->sa, en->data, tname, n->data.sval ); } @@ -828,7 +829,6 @@ rel_values( mvc *sql, symbol *tableref) vals->f = nexps; } r = rel_project(sql->sa, NULL, exps); - set_processed(r); rel_table_optname(sql, r, optname); return r; } @@ -898,7 +898,6 @@ table_ref(mvc *sql, sql_rel *rel, symbol list *exps = rel_projections(sql, temp_table, NULL, 1, 1); temp_table = rel_project(sql->sa, temp_table, exps); - set_processed(temp_table); for (n = exps->h; n; n = n->next) noninternexp_setname(sql->sa, n->data, tname, NULL); return temp_table; @@ -1823,12 +1822,13 @@ static sql_exp* n = n->next, m = m->next) { sql_arg *a = m->data; sql_exp *e = n->data; + sql_subtype anytype = a->type; if (a->type.type->eclass == EC_ANY) { sql_subtype *st = &e->tpe; - sql_init_subtype(&a->type, st->type, st->digits, st->scale); + sql_init_subtype(&anytype, st->type, st->digits, st->scale); } - e = rel_check_type(sql, &a->type, e, type_equal); + e = rel_check_type(sql, &anytype, e, type_equal); if (!e) { nexps = NULL; break; @@ -2015,7 +2015,6 @@ rel_logical_value_exp(mvc *sql, sql_rel _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list