Changeset: bf2953e321fd for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=bf2953e321fd
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:
        sql/backends/monet5/rel_bin.c
        sql/backends/monet5/sql_upgrades.c
        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: Nov2019
Log Message:

Look for table returning fucntions and views while creating relation 
dependencies


diffs (truncated from 980 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
@@ -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) { /* table producing function 
*/
+                       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/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"      ]
 [ "id",        "dependency_tables_on_views",   "DEP_VIEW"      ]
+[ "id",        "dependency_tables_on_views",   "DEP_VIEW"      ]
+[ "id",        "dependency_views_on_functions",        "DEP_VIEW"      ]
 [ "id",        "dependency_views_on_functions",        "DEP_VIEW"      ]
 [ "id",        "dependency_views_on_functions",        "DEP_VIEW"      ]
 [ "id",        "dependency_views_on_procedures",       "DEP_VIEW"      ]
 [ "id",        "dependency_views_on_procedures",       "DEP_VIEW"      ]
+[ "id",        "dependency_views_on_procedures",       "DEP_VIEW"      ]
 [ "id",        "dependency_views_on_views",    "DEP_VIEW"      ]
+[ "id",        "dependency_views_on_views",    "DEP_VIEW"      ]
+[ "id",        "geometry_columns",     "DEP_VIEW"      ]
 [ "id",        "geometry_columns",     "DEP_VIEW"      ]
 [ "id",        "ids",  "DEP_VIEW"      ]
 [ "id",        "ids",  "DEP_VIEW"      ]
@@ -602,36 +638,64 @@ Cleanup
 [ "id",        "roles",        "DEP_VIEW"      ]
 [ "id",        "storage",      "DEP_VIEW"      ]
 [ "id",        "systemfunctions",      "DEP_VIEW"      ]
+[ "imprints",  "schemastorage",        "DEP_VIEW"      ]
+[ "imprints",  "tablestorage", "DEP_VIEW"      ]
 [ "isacolumn", "storagemodel", "DEP_VIEW"      ]
 [ "isacolumn", "tablestoragemodel",    "DEP_VIEW"      ]
+[ "name",      "dependencies_vw",      "DEP_VIEW"      ]
 [ "name",      "dependency_args_on_types",     "DEP_VIEW"      ]
 [ "name",      "dependency_args_on_types",     "DEP_VIEW"      ]
 [ "name",      "dependency_columns_on_functions",      "DEP_VIEW"      ]
+[ "name",      "dependency_columns_on_functions",      "DEP_VIEW"      ]
+[ "name",      "dependency_columns_on_indexes",        "DEP_VIEW"      ]
+[ "name",      "dependency_columns_on_indexes",        "DEP_VIEW"      ]
 [ "name",      "dependency_columns_on_indexes",        "DEP_VIEW"      ]
 [ "name",      "dependency_columns_on_indexes",        "DEP_VIEW"      ]
 [ "name",      "dependency_columns_on_indexes",        "DEP_VIEW"      ]
 [ "name",      "dependency_columns_on_keys",   "DEP_VIEW"      ]
 [ "name",      "dependency_columns_on_keys",   "DEP_VIEW"      ]
+[ "name",      "dependency_columns_on_keys",   "DEP_VIEW"      ]
+[ "name",      "dependency_columns_on_keys",   "DEP_VIEW"      ]
+[ "name",      "dependency_columns_on_procedures",     "DEP_VIEW"      ]
 [ "name",      "dependency_columns_on_procedures",     "DEP_VIEW"      ]
 [ "name",      "dependency_columns_on_triggers",       "DEP_VIEW"      ]
+[ "name",      "dependency_columns_on_triggers",       "DEP_VIEW"      ]
+[ "name",      "dependency_columns_on_triggers",       "DEP_VIEW"      ]
+[ "name",      "dependency_columns_on_types",  "DEP_VIEW"      ]
+[ "name",      "dependency_columns_on_types",  "DEP_VIEW"      ]
+[ "name",      "dependency_columns_on_views",  "DEP_VIEW"      ]
+[ "name",      "dependency_columns_on_views",  "DEP_VIEW"      ]
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to