Changeset: f98c0609fa56 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f98c0609fa56 Added Files: sql/test/Dependencies/Tests/view_table_udf.sql sql/test/Dependencies/Tests/view_table_udf.stable.err sql/test/Dependencies/Tests/view_table_udf.stable.out Modified Files: clients/mapiclient/eventparser.c sql/backends/monet5/rel_bin.c sql/backends/monet5/sql_upgrades.c sql/server/rel_optimizer.c sql/server/rel_optimizer.h sql/storage/sql_storage.h sql/storage/store.c sql/test/Dependencies/Tests/All sql/test/Dependencies/Tests/Dependencies.stable.out sql/test/Dependencies/Tests/Dependencies.stable.out.int128 sql/test/Dependencies/Tests/dependency_loop.stable.out sql/test/Dependencies/Tests/dependency_loop.stable.out.int128 sql/test/merge-partitions/Tests/mergepart21.stable.err Branch: default Log Message:
Merge with Nov2019 diffs (truncated from 1025 to 300 lines): diff --git a/clients/mapiclient/eventparser.c b/clients/mapiclient/eventparser.c --- a/clients/mapiclient/eventparser.c +++ b/clients/mapiclient/eventparser.c @@ -229,7 +229,7 @@ keyvalueparser(char *txt, EventRecord *e curr_time = *localtime(&sec); #endif ev->time = malloc(DATETIME_CHAR_LENGTH*sizeof(char)); - snprintf(ev->time, DATETIME_CHAR_LENGTH, "%d/%02d/%02d %02d:%02d:%02d.%lu", + snprintf(ev->time, DATETIME_CHAR_LENGTH, "%d/%02d/%02d %02d:%02d:%02d.%"PRIu64, curr_time.tm_year + 1900, curr_time.tm_mon, curr_time.tm_mday, curr_time.tm_hour, curr_time.tm_min, curr_time.tm_sec, microsec); ev->clkticks = sec * 1000000; 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 @@ -5746,7 +5746,7 @@ id_cmp(int *id1, int *id2) static list * cond_append(list *l, int *id) { - if (*id >= 2000 && !list_find(l, id, (fcmp) &id_cmp)) + if (*id >= FUNC_OIDS && !list_find(l, id, (fcmp) &id_cmp)) list_append(l, id); return l; } @@ -5856,37 +5856,32 @@ rel_deps(mvc *sql, sql_rel *r, list *ref if (!t && c) t = c->t; + cond_append(l, &t->base.id); - if (isTable(t)) { - /* find all used columns */ - node *en; - for( en = r->exps->h; en; en = en->next ) { - sql_exp *exp = en->data; - const char *oname = exp->r; - - if (is_func(exp->type)) { - list *exps = exp->l; - sql_exp *cexp = exps->h->data; - const char *cname = cexp->r; - - c = find_sql_column(t, cname); - cond_append(l, &c->base.id); - } else if (oname[0] == '%' && strcmp(oname, TID) == 0) { - continue; - } else if (oname[0] == '%') { - sql_idx *i = find_sql_idx(t, oname+1); - - cond_append(l, &i->base.id); - } else { - sql_column *c = find_sql_column(t, oname); - cond_append(l, &c->base.id); - } + /* find all used columns */ + for (node *en = r->exps->h; en; en = en->next) { + sql_exp *exp = en->data; + const char *oname = exp->r; + + assert(!is_func(exp->type)); + if (oname[0] == '%' && strcmp(oname, TID) == 0) { + continue; + } else if (oname[0] == '%') { + sql_idx *i = find_sql_idx(t, oname+1); + cond_append(l, &i->base.id); + } else { + sql_column *c = find_sql_column(t, oname); + cond_append(l, &c->base.id); } } - } break; - case op_table: - /* */ - break; + } break; + case op_table: { + if ((r->flag == 0 || r->flag == 1) && r->r) { /* table producing function, excluding rel_relational_func cases */ + sql_exp *op = r->r; + sql_subfunc *f = op->f; + cond_append(l, &f->func->base.id); + } + } break; case op_join: case op_left: case op_right: @@ -5933,7 +5928,7 @@ rel_deps(mvc *sql, sql_rel *r, list *ref } break; } - if (r->exps) { + if (!is_base(r->op) && r->exps) { if (exps_deps(sql, r->exps, refs, l) != 0) return -1; } 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 @@ -46,7 +46,7 @@ sql_fix_system_tables(Client c, mvc *sql for (n = types->h; n; n = n->next) { sql_type *t = n->data; - if (t->base.id >= 2000) + if (t->base.id >= FUNC_OIDS) continue; pos += snprintf(buf + pos, bufsize - pos, @@ -68,7 +68,7 @@ sql_fix_system_tables(Client c, mvc *sql sql_arg *arg; node *m; - if (func->base.id >= 2000) + if (func->base.id >= FUNC_OIDS) continue; pos += snprintf(buf + pos, bufsize - pos, @@ -136,7 +136,7 @@ sql_fix_system_tables(Client c, mvc *sql sql_func *aggr = n->data; sql_arg *arg; - if (aggr->base.id >= 2000) + if (aggr->base.id >= FUNC_OIDS) continue; pos += snprintf(buf + pos, bufsize - pos, @@ -283,7 +283,7 @@ sql_update_geom(Client c, mvc *sql, int for (n = types->h; n; n = n->next) { sql_type *t = n->data; - if (t->base.id < 2000 && + if (t->base.id < FUNC_OIDS && (strcmp(t->base.name, "mbr") == 0 || strcmp(t->base.name, "wkb") == 0 || strcmp(t->base.name, "wkba") == 0)) 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 @@ -9137,7 +9137,8 @@ optimize_rel(mvc *sql, sql_rel *rel, int changes = 0; } - rel = rewrite_topdown(sql, rel, &rel_merge_table_rewrite, &changes); + if (value_based_opt) + 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); *g_changes = changes; diff --git a/sql/server/rel_optimizer.h b/sql/server/rel_optimizer.h --- a/sql/server/rel_optimizer.h +++ b/sql/server/rel_optimizer.h @@ -12,13 +12,13 @@ #include "sql_relation.h" #include "sql_mvc.h" -extern sql_rel * rel_optimizer(mvc *sql, sql_rel *rel, int value_based_opt); +extern sql_rel *rel_optimizer(mvc *sql, sql_rel *rel, int value_based_opt); extern int exp_joins_rels(sql_exp *e, list *rels); -extern void *name_find_column( sql_rel *rel, const char *rname, const char *name, int pnr, sql_rel **bt ); +extern void *name_find_column(sql_rel *rel, const char *rname, const char *name, int pnr, sql_rel **bt); extern int exps_unique(mvc *sql, sql_rel *rel, list *exps); -extern sql_rel * rel_dce(mvc *sql, sql_rel *rel); +extern sql_rel *rel_dce(mvc *sql, sql_rel *rel); #endif /*_REL_OPTIMIZER_H_*/ diff --git a/sql/storage/sql_storage.h b/sql/storage/sql_storage.h --- a/sql/storage/sql_storage.h +++ b/sql/storage/sql_storage.h @@ -36,6 +36,9 @@ typedef enum store_type { #define STORE_READONLY (store_readonly) +/* builtin functions have ids less than this */ +#define FUNC_OIDS 2000 + extern sql_trans *gtrans; extern list *active_sessions; extern ATOMIC_TYPE store_nr_active; diff --git a/sql/storage/store.c b/sql/storage/store.c --- a/sql/storage/store.c +++ b/sql/storage/store.c @@ -51,9 +51,6 @@ static int logger_debug = 0; static sql_trans *spare_trans[MAX_SPARES]; static int spares = 0; -/* builtin functions have ids less than this */ -#define FUNC_OIDS 2000 - static int key_cmp(sql_key *k, sqlid *id) { diff --git a/sql/test/Dependencies/Tests/All b/sql/test/Dependencies/Tests/All --- a/sql/test/Dependencies/Tests/All +++ b/sql/test/Dependencies/Tests/All @@ -1,2 +1,3 @@ HAVE_GEOM&HAVE_SAMTOOLS?Dependencies HAVE_GEOM?dependency_loop +view_table_udf diff --git a/sql/test/Dependencies/Tests/Dependencies.stable.out b/sql/test/Dependencies/Tests/Dependencies.stable.out --- a/sql/test/Dependencies/Tests/Dependencies.stable.out +++ b/sql/test/Dependencies/Tests/Dependencies.stable.out @@ -140,7 +140,9 @@ Dependencies between database objects % varchar, varchar, char # type % 4, 2, 8 # length [ "age", "v1", "DEP_VIEW" ] +[ "age", "v2", "DEP_VIEW" ] [ "id", "v1", "DEP_VIEW" ] +[ "id", "v2", "DEP_VIEW" ] [ "name", "v1", "DEP_VIEW" ] #SELECT c.name, k.name, 'DEP_KEY' from columns as c, objects as kc, keys as k where kc."name" = c.name AND kc.id = k.id AND k.table_id = c.table_id AND k.rkey = -1 order by c.name, k.name; % .c, .k, .L11 # table_name @@ -184,9 +186,11 @@ Dependencies between database objects % varchar, varchar, char # type % 9, 8, 8 # length [ "age", "f2", "DEP_FUNC" ] +[ "age", "f2", "DEP_FUNC" ] [ "auth_name", "getproj4", "DEP_FUNC" ] [ "auth_srid", "getproj4", "DEP_FUNC" ] [ "id", "f2", "DEP_FUNC" ] +[ "id", "f2", "DEP_FUNC" ] [ "name", "f2", "DEP_FUNC" ] [ "proj4text", "getproj4", "DEP_FUNC" ] [ "srid", "getproj4", "DEP_FUNC" ] @@ -487,8 +491,12 @@ Cleanup [ "atomwidth", "storagemodel", "DEP_VIEW" ] [ "atomwidth", "tablestoragemodel", "DEP_VIEW" ] [ "column", "storagemodel", "DEP_VIEW" ] +[ "columnsize", "schemastorage", "DEP_VIEW" ] +[ "columnsize", "tablestorage", "DEP_VIEW" ] [ "count", "storagemodel", "DEP_VIEW" ] +[ "count", "tablestorage", "DEP_VIEW" ] [ "count", "tablestoragemodel", "DEP_VIEW" ] +[ "default_schema", "dependency_schemas_on_users", "DEP_VIEW" ] [ "depend_id", "dependencies_vw", "DEP_VIEW" ] [ "depend_id", "dependency_args_on_types", "DEP_VIEW" ] [ "depend_id", "dependency_columns_on_functions", "DEP_VIEW" ] @@ -534,6 +542,11 @@ Cleanup [ "func_id", "dependency_args_on_types", "DEP_VIEW" ] [ "func_id", "ids", "DEP_VIEW" ] [ "grantor", "roles", "DEP_VIEW" ] +[ "hashes", "schemastorage", "DEP_VIEW" ] +[ "hashes", "tablestorage", "DEP_VIEW" ] +[ "heapsize", "schemastorage", "DEP_VIEW" ] +[ "heapsize", "tablestorage", "DEP_VIEW" ] +[ "id", "dependencies_vw", "DEP_VIEW" ] [ "id", "dependencies_vw", "DEP_VIEW" ] [ "id", "dependency_args_on_types", "DEP_VIEW" ] [ "id", "dependency_args_on_types", "DEP_VIEW" ] @@ -541,16 +554,28 @@ Cleanup [ "id", "dependency_args_on_types", "DEP_VIEW" ] [ "id", "dependency_columns_on_functions", "DEP_VIEW" ] [ "id", "dependency_columns_on_functions", "DEP_VIEW" ] +[ "id", "dependency_columns_on_functions", "DEP_VIEW" ] +[ "id", "dependency_columns_on_indexes", "DEP_VIEW" ] +[ "id", "dependency_columns_on_indexes", "DEP_VIEW" ] [ "id", "dependency_columns_on_indexes", "DEP_VIEW" ] [ "id", "dependency_columns_on_indexes", "DEP_VIEW" ] [ "id", "dependency_columns_on_keys", "DEP_VIEW" ] [ "id", "dependency_columns_on_keys", "DEP_VIEW" ] +[ "id", "dependency_columns_on_keys", "DEP_VIEW" ] +[ "id", "dependency_columns_on_keys", "DEP_VIEW" ] +[ "id", "dependency_columns_on_procedures", "DEP_VIEW" ] [ "id", "dependency_columns_on_procedures", "DEP_VIEW" ] [ "id", "dependency_columns_on_procedures", "DEP_VIEW" ] [ "id", "dependency_columns_on_triggers", "DEP_VIEW" ] [ "id", "dependency_columns_on_triggers", "DEP_VIEW" ] +[ "id", "dependency_columns_on_triggers", "DEP_VIEW" ] +[ "id", "dependency_columns_on_triggers", "DEP_VIEW" ] [ "id", "dependency_columns_on_types", "DEP_VIEW" ] [ "id", "dependency_columns_on_types", "DEP_VIEW" ] +[ "id", "dependency_columns_on_types", "DEP_VIEW" ] +[ "id", "dependency_columns_on_types", "DEP_VIEW" ] +[ "id", "dependency_columns_on_views", "DEP_VIEW" ] +[ "id", "dependency_columns_on_views", "DEP_VIEW" ] [ "id", "dependency_columns_on_views", "DEP_VIEW" ] [ "id", "dependency_functions_on_functions", "DEP_VIEW" ] [ "id", "dependency_functions_on_functions", "DEP_VIEW" ] @@ -564,24 +589,35 @@ Cleanup [ "id", "dependency_functions_on_types", "DEP_VIEW" ] [ "id", "dependency_functions_on_views", "DEP_VIEW" ] [ "id", "dependency_functions_on_views", "DEP_VIEW" ] +[ "id", "dependency_functions_on_views", "DEP_VIEW" ] [ "id", "dependency_keys_on_foreignkeys", "DEP_VIEW" ] [ "id", "dependency_owners_on_schemas", "DEP_VIEW" ] [ "id", "dependency_owners_on_schemas", "DEP_VIEW" ] [ "id", "dependency_schemas_on_users", "DEP_VIEW" ] [ "id", "dependency_tables_on_foreignkeys", "DEP_VIEW" ] +[ "id", "dependency_tables_on_foreignkeys", "DEP_VIEW" ] +[ "id", "dependency_tables_on_functions", "DEP_VIEW" ] [ "id", "dependency_tables_on_functions", "DEP_VIEW" ] [ "id", "dependency_tables_on_functions", "DEP_VIEW" ] [ "id", "dependency_tables_on_indexes", "DEP_VIEW" ] +[ "id", "dependency_tables_on_indexes", "DEP_VIEW" ] +[ "id", "dependency_tables_on_procedures", "DEP_VIEW" ] [ "id", "dependency_tables_on_procedures", "DEP_VIEW" ] [ "id", "dependency_tables_on_procedures", "DEP_VIEW" ] [ "id", "dependency_tables_on_triggers", "DEP_VIEW" ] [ "id", "dependency_tables_on_triggers", "DEP_VIEW" ] +[ "id", "dependency_tables_on_triggers", "DEP_VIEW" ] _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list