Changeset: 645df759eac8 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/645df759eac8
Modified Files:
        sql/backends/monet5/rel_bin.c
        sql/backends/monet5/sql_cat.c
        sql/backends/monet5/sql_statement.c
        sql/backends/monet5/sql_upgrades.c
        sql/common/sql_types.c
        sql/server/rel_dump.c
        sql/server/rel_exp.c
        sql/server/rel_optimizer.c
        sql/server/rel_propagate.c
        sql/server/rel_psm.c
        sql/server/rel_rel.c
        sql/server/rel_select.c
        sql/server/rel_sequence.c
        sql/server/rel_unnest.c
        sql/server/rel_updates.c
        sql/server/sql_privileges.c
        sql/server/sql_semantic.c
        sql/server/sql_semantic.h
Branch: privfuncs
Log Message:

Disable binding private functions from user queries. Some tests need approval


diffs (truncated from 2353 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
@@ -66,11 +66,11 @@ sql_unop_(backend *be, const char *fname
        sql_subfunc *f = NULL;
 
        rt = tail_type(rs);
-       f = sql_bind_func(sql, "sys", fname, rt, NULL, F_FUNC);
+       f = sql_bind_func(sql, "sys", fname, rt, NULL, F_FUNC, true);
        /* try to find the function without a type, and convert
         * the value to the type needed by this function!
         */
-       if (!f && (f = sql_find_func(sql, "sys", fname, 1, F_FUNC, NULL)) != 
NULL) {
+       if (!f && (f = sql_find_func(sql, "sys", fname, 1, F_FUNC, true, NULL)) 
!= NULL) {
                sql_arg *a = f->func->ops->h->data;
 
                sql->session->status = 0;
@@ -439,10 +439,10 @@ handle_in_exps(backend *be, sql_exp *ce,
        if (c->nrcols == 0 || depth || !reduce) {
                sql_subtype *bt = sql_bind_localtype("bit");
                sql_subfunc *cmp = (in)
-                       ?sql_bind_func(sql, "sys", "=", tail_type(c), 
tail_type(c), F_FUNC)
-                       :sql_bind_func(sql, "sys", "<>", tail_type(c), 
tail_type(c), F_FUNC);
-               sql_subfunc *a = (in)?sql_bind_func(sql, "sys", "or", bt, bt, 
F_FUNC)
-                                    :sql_bind_func(sql, "sys", "and", bt, bt, 
F_FUNC);
+                       ?sql_bind_func(sql, "sys", "=", tail_type(c), 
tail_type(c), F_FUNC, true)
+                       :sql_bind_func(sql, "sys", "<>", tail_type(c), 
tail_type(c), F_FUNC, true);
+               sql_subfunc *a = (in)?sql_bind_func(sql, "sys", "or", bt, bt, 
F_FUNC, true)
+                                    :sql_bind_func(sql, "sys", "and", bt, bt, 
F_FUNC, true);
 
                for( n = nl->h; n; n = n->next) {
                        sql_exp *e = n->data;
@@ -610,7 +610,7 @@ exp_bin_or(backend *be, sql_exp *e, stmt
                        return s;
 
                if (!sin && sel1 && sel1->nrcols == 0 && s->nrcols == 0) {
-                       sql_subfunc *f = sql_bind_func(be->mvc, "sys", 
anti?"or":"and", bt, bt, F_FUNC);
+                       sql_subfunc *f = sql_bind_func(be->mvc, "sys", 
anti?"or":"and", bt, bt, F_FUNC, true);
                        assert(f);
                        s = stmt_binop(be, sel1, s, sin, f);
                } else if (sel1 && (sel1->nrcols == 0 || s->nrcols == 0)) {
@@ -637,7 +637,7 @@ exp_bin_or(backend *be, sql_exp *e, stmt
                        return s;
 
                if (!sin && sel2 && sel2->nrcols == 0 && s->nrcols == 0) {
-                       sql_subfunc *f = sql_bind_func(be->mvc, "sys", 
anti?"or":"and", bt, bt, F_FUNC);
+                       sql_subfunc *f = sql_bind_func(be->mvc, "sys", 
anti?"or":"and", bt, bt, F_FUNC, true);
                        assert(f);
                        s = stmt_binop(be, sel2, s, sin, f);
                } else if (sel2 && (sel2->nrcols == 0 || s->nrcols == 0)) {
@@ -652,7 +652,7 @@ exp_bin_or(backend *be, sql_exp *e, stmt
                sel2 = s;
        }
        if (sel1->nrcols == 0 && sel2->nrcols == 0) {
-               sql_subfunc *f = sql_bind_func(be->mvc, "sys", anti?"and":"or", 
bt, bt, F_FUNC);
+               sql_subfunc *f = sql_bind_func(be->mvc, "sys", anti?"and":"or", 
bt, bt, F_FUNC, true);
                assert(f);
                return stmt_binop(be, sel1, sel2, NULL, f);
        }
@@ -680,9 +680,9 @@ exp2bin_case(backend *be, sql_exp *fe, s
        int next_cond = 1, single_value = (fe->card <= CARD_ATOM && (!left || 
!left->nrcols));
        char name[16], *nme = NULL;
        sql_subtype *bt = sql_bind_localtype("bit");
-       sql_subfunc *not = sql_bind_func(be->mvc, "sys", "not", bt, NULL, 
F_FUNC);
-       sql_subfunc *or = sql_bind_func(be->mvc, "sys", "or", bt, bt, F_FUNC);
-       sql_subfunc *and = sql_bind_func(be->mvc, "sys", "and", bt, bt, F_FUNC);
+       sql_subfunc *not = sql_bind_func(be->mvc, "sys", "not", bt, NULL, 
F_FUNC, true);
+       sql_subfunc *or = sql_bind_func(be->mvc, "sys", "or", bt, bt, F_FUNC, 
true);
+       sql_subfunc *and = sql_bind_func(be->mvc, "sys", "and", bt, bt, F_FUNC, 
true);
 
        if (single_value) {
                /* var_x = nil; */
@@ -787,7 +787,7 @@ exp2bin_case(backend *be, sql_exp *fe, s
                                if (en->next) {
                                        cond = stmt_unop(be, cond, nsel, not);
 
-                                       sql_subfunc *isnull = 
sql_bind_func(be->mvc, "sys", "isnull", bt, NULL, F_FUNC);
+                                       sql_subfunc *isnull = 
sql_bind_func(be->mvc, "sys", "isnull", bt, NULL, F_FUNC, true);
                                        cond = stmt_binop(be, cond, 
stmt_unop(be, cond, nsel, isnull), nsel, or);
                                        if (ocond)
                                                cond = stmt_binop(be, ocond, 
cond, nsel, and);
@@ -815,9 +815,9 @@ exp2bin_casewhen(backend *be, sql_exp *f
        int next_cond = 1, single_value = (fe->card <= CARD_ATOM && (!left || 
!left->nrcols));
        char name[16], *nme = NULL;
        sql_subtype *bt = sql_bind_localtype("bit");
-       sql_subfunc *not = sql_bind_func(be->mvc, "sys", "not", bt, NULL, 
F_FUNC);
-       sql_subfunc *or = sql_bind_func(be->mvc, "sys", "or", bt, bt, F_FUNC);
-       sql_subfunc *and = sql_bind_func(be->mvc, "sys", "and", bt, bt, F_FUNC);
+       sql_subfunc *not = sql_bind_func(be->mvc, "sys", "not", bt, NULL, 
F_FUNC, true);
+       sql_subfunc *or = sql_bind_func(be->mvc, "sys", "or", bt, bt, F_FUNC, 
true);
+       sql_subfunc *and = sql_bind_func(be->mvc, "sys", "and", bt, bt, F_FUNC, 
true);
        sql_subfunc *cmp;
 
        if (single_value) {
@@ -834,7 +834,7 @@ exp2bin_casewhen(backend *be, sql_exp *f
        stmt *case_when = exp_bin(be, e, left, right, NULL, NULL, NULL, nsel, 
depth+1, 0, 1);
        if (!case_when)
                return NULL;
-       cmp = sql_bind_func(be->mvc, "sys", "=", exp_subtype(e), 
exp_subtype(e), F_FUNC);
+       cmp = sql_bind_func(be->mvc, "sys", "=", exp_subtype(e), 
exp_subtype(e), F_FUNC, true);
        if (!cmp)
                return NULL;
        if (!single_value && !case_when->nrcols) {
@@ -968,7 +968,7 @@ exp2bin_casewhen(backend *be, sql_exp *f
                                if (en->next) {
                                        cond = stmt_unop(be, cond, nsel, not);
 
-                                       sql_subfunc *isnull = 
sql_bind_func(be->mvc, "sys", "isnull", bt, NULL, F_FUNC);
+                                       sql_subfunc *isnull = 
sql_bind_func(be->mvc, "sys", "isnull", bt, NULL, F_FUNC, true);
                                        cond = stmt_binop(be, cond, 
stmt_unop(be, cond, nsel, isnull), nsel, or);
                                        if (ocond)
                                                cond = stmt_binop(be, ocond, 
cond, nsel, and);
@@ -996,8 +996,8 @@ exp2bin_coalesce(backend *be, sql_exp *f
        int single_value = (fe->card <= CARD_ATOM && (!left || !left->nrcols));
        char name[16], *nme = NULL;
        sql_subtype *bt = sql_bind_localtype("bit");
-       sql_subfunc *and = sql_bind_func(be->mvc, "sys", "and", bt, bt, F_FUNC);
-       sql_subfunc *not = sql_bind_func(be->mvc, "sys", "not", bt, NULL, 
F_FUNC);
+       sql_subfunc *and = sql_bind_func(be->mvc, "sys", "and", bt, bt, F_FUNC, 
true);
+       sql_subfunc *not = sql_bind_func(be->mvc, "sys", "not", bt, NULL, 
F_FUNC, true);
 
        if (single_value) {
                /* var_x = nil; */
@@ -1036,7 +1036,7 @@ exp2bin_coalesce(backend *be, sql_exp *f
                                stmt *pos = rsel;
 
                                if (en->next) {
-                                       sql_subfunc *a = sql_bind_func(be->mvc, 
"sys", "isnotnull", tail_type(es), NULL, F_FUNC);
+                                       sql_subfunc *a = sql_bind_func(be->mvc, 
"sys", "isnotnull", tail_type(es), NULL, F_FUNC, true);
                                        ncond = stmt_unop(be, es, NULL, a);
                                        if (ncond->nrcols == 0) {
                                                stmt *l = 
bin_find_smallest_column(be, left);
@@ -1076,7 +1076,7 @@ exp2bin_coalesce(backend *be, sql_exp *f
                } else {
                        stmt *cond = ocond;
                        if (en->next) {
-                               sql_subfunc *a = sql_bind_func(be->mvc, "sys", 
"isnotnull", tail_type(es), NULL, F_FUNC);
+                               sql_subfunc *a = sql_bind_func(be->mvc, "sys", 
"isnotnull", tail_type(es), NULL, F_FUNC, true);
                                ncond = stmt_unop(be, es, nsel, a);
 
                                if (ocond)
@@ -1516,7 +1516,7 @@ exp_bin(backend *be, sql_exp *e, stmt *l
                                        int in_flag = e->flag==mark_in?1:0;
                                        if (is_anti(e))
                                                in_flag = !in_flag;
-                                       sql_subfunc *f = sql_bind_func(sql, 
"sys", in_flag?"=":"<>", tail_type(l), tail_type(l), F_FUNC);
+                                       sql_subfunc *f = sql_bind_func(sql, 
"sys", in_flag?"=":"<>", tail_type(l), tail_type(l), F_FUNC, true);
                                        assert(f);
                                        s = stmt_binop(be, l, r, sel, f);
                                        if (l->cand)
@@ -1525,7 +1525,7 @@ exp_bin(backend *be, sql_exp *e, stmt *l
                                                s->cand = r->cand;
                                } else if (!reduce || (l->nrcols == 0 && 
r->nrcols == 0)) {
                                        sql_subfunc *f = sql_bind_func(sql, 
"sys", compare_func((comp_type)e->flag, is_anti(e)),
-                                                                               
                   tail_type(l), tail_type(l), F_FUNC);
+                                                                               
                   tail_type(l), tail_type(l), F_FUNC, true);
                                        assert(f);
                                        if (is_semantics(e)) {
                                                if (exp_is_null(e->l) && 
exp_is_null(e->r)) {
@@ -1676,7 +1676,7 @@ sql_Nop_(backend *be, const char *fname,
                list_append(tl, tail_type(a4));
        }
 
-       if ((f = sql_bind_func_(sql, "sys", fname, tl, F_FUNC)))
+       if ((f = sql_bind_func_(sql, "sys", fname, tl, F_FUNC, true)))
                return stmt_Nop(be, stmt_list(be, sl), NULL, f, NULL);
        return sql_error(sql, ERR_NOTFOUND, SQLSTATE(42000) "SELECT: no such 
operator '%s'", fname);
 }
@@ -2274,13 +2274,13 @@ rel2bin_hash_lookup(backend *be, sql_rel
                if (!s)
                        return NULL;
                if (h) {
-                       sql_subfunc *xor = sql_bind_func_result(sql, "sys", 
"rotate_xor_hash", F_FUNC, lng, 3, lng, it, tail_type(s));
+                       sql_subfunc *xor = sql_bind_func_result(sql, "sys", 
"rotate_xor_hash", F_FUNC, true, lng, 3, lng, it, tail_type(s));
 
                        h = stmt_Nop(be, stmt_list(be, list_append( list_append(
                                list_append(sa_list(sql->sa), h), bits), s)), 
NULL, xor, NULL);
                        semantics = 1;
                } else {
-                       sql_subfunc *hf = sql_bind_func_result(sql, "sys", 
"hash", F_FUNC, lng, 1, tail_type(s));
+                       sql_subfunc *hf = sql_bind_func_result(sql, "sys", 
"hash", F_FUNC, true, lng, 1, tail_type(s));
 
                        h = stmt_unop(be, s, NULL, hf);
                }
@@ -2311,11 +2311,11 @@ join_hash_key( backend *be, list *l )
                stmt *s = m->data;
 
                if (h) {
-                       sql_subfunc *xor = sql_bind_func_result(sql, "sys", 
"rotate_xor_hash", F_FUNC, lng, 3, lng, it, tail_type(s));
+                       sql_subfunc *xor = sql_bind_func_result(sql, "sys", 
"rotate_xor_hash", F_FUNC, true, lng, 3, lng, it, tail_type(s));
 
                        h = stmt_Nop(be, stmt_list(be, list_append( 
list_append( list_append(sa_list(sql->sa), h), bits), s )), NULL, xor, NULL);
                } else {
-                       sql_subfunc *hf = sql_bind_func_result(sql, "sys", 
"hash", F_FUNC, lng, 1, tail_type(s));
+                       sql_subfunc *hf = sql_bind_func_result(sql, "sys", 
"hash", F_FUNC, true, lng, 1, tail_type(s));
                        h = stmt_unop(be, s, NULL, hf);
                }
        }
@@ -2708,12 +2708,12 @@ rel2bin_join(backend *be, sql_rel *rel, 
                stmt *last = l->t->data;
                sql_subtype *tp = tail_type(last);
 
-               sql_subfunc *isnil = sql_bind_func(sql, "sys", "isnull", tp, 
NULL, F_FUNC);
+               sql_subfunc *isnil = sql_bind_func(sql, "sys", "isnull", tp, 
NULL, F_FUNC, true);
 
                stmt *s = stmt_unop(be, last, NULL, isnil);
 
                sql_subtype *bt = sql_bind_localtype("bit");
-               sql_subfunc *not = sql_bind_func(be->mvc, "sys", "not", bt, 
NULL, F_FUNC);
+               sql_subfunc *not = sql_bind_func(be->mvc, "sys", "not", bt, 
NULL, F_FUNC, true);
 
                s = stmt_unop(be, s, NULL, not);
                s = stmt_alias(be, s, rnme, nme);
@@ -3100,7 +3100,7 @@ rel2bin_single(backend *be, stmt *s)
                stmt *t = n->data;
                const char *rnme = table_name(sql->sa, t);
                const char *nme = column_name(sql->sa, t);
-               sql_subfunc *zero_or_one = sql_bind_func(sql, "sys", 
"zero_or_one", tail_type(t), NULL, F_AGGR);
+               sql_subfunc *zero_or_one = sql_bind_func(sql, "sys", 
"zero_or_one", tail_type(t), NULL, F_AGGR, true);
 
                t = stmt_aggr(be, t, NULL, NULL, zero_or_one, 1, 0, 1);
                t = stmt_alias(be, t, rnme, nme);
@@ -3265,7 +3265,7 @@ rel2bin_except(backend *be, sql_rel *rel
        lcnt = stmt_append(be, lcnt, ncnt);
        rcnt = stmt_append(be, rcnt, zero);
 
-       min = sql_bind_func(sql, "sys", "sql_sub", lng, lng, F_FUNC);
+       min = sql_bind_func(sql, "sys", "sql_sub", lng, lng, F_FUNC, true);
        s = stmt_binop(be, lcnt, rcnt, NULL, min); /* use count */
 
        /* now we have gid,cnt, blowup to full groupsizes */
@@ -3363,7 +3363,7 @@ rel2bin_inter(backend *be, sql_rel *rel,
        lcnt = stmt_project(be, lm, lcnt);
        rcnt = stmt_project(be, rm, rcnt);
 
-       min = sql_bind_func(sql, "sys", "sql_min", lng, lng, F_FUNC);
+       min = sql_bind_func(sql, "sys", "sql_min", lng, lng, F_FUNC, true);
        s = stmt_binop(be, lcnt, rcnt, NULL, min);
 
        /* now we have gid,cnt, blowup to full groupsizes */
@@ -3449,7 +3449,7 @@ rel2bin_project(backend *be, sql_rel *re
                                return NULL;
                        if (oe) {
                                sql_subtype *lng = sql_bind_localtype("lng");
-                               sql_subfunc *add = sql_bind_func_result(sql, 
"sys", "sql_add", F_FUNC, lng, 2, lng, lng);
+                               sql_subfunc *add = sql_bind_func_result(sql, 
"sys", "sql_add", F_FUNC, true, lng, 2, lng, lng);
                                stmt *o = exp_bin(be, oe, NULL, NULL, NULL, 
NULL, NULL, NULL, 0, 0, 0);
                                if(!o)
                                        return NULL;
@@ -3922,10 +3922,10 @@ insert_check_ukey(backend *be, list *ins
        stmt *res;
 
        sql_subtype *lng = sql_bind_localtype("lng");
-       sql_subfunc *cnt = sql_bind_func(sql, "sys", "count", 
sql_bind_localtype("void"), NULL, F_AGGR);
+       sql_subfunc *cnt = sql_bind_func(sql, "sys", "count", 
sql_bind_localtype("void"), NULL, F_AGGR, true);
        sql_subtype *bt = sql_bind_localtype("bit");
        stmt *dels = stmt_tid(be, k->t, 0);
-       sql_subfunc *ne = sql_bind_func_result(sql, "sys", "<>", F_FUNC, bt, 2, 
lng, lng);
+       sql_subfunc *ne = sql_bind_func_result(sql, "sys", "<>", F_FUNC, true, 
bt, 2, lng, lng);
 
        if (list_length(k->columns) > 1) {
                node *m;
@@ -3980,7 +3980,7 @@ insert_check_ukey(backend *be, list *ins
 
                /* 2nd stage: find out if inserted are unique */
                if ((!idx_inserts && ins->nrcols) || (idx_inserts && 
idx_inserts->nrcols)) {    /* insert columns not atoms */
-                       sql_subfunc *or = sql_bind_func_result(sql, "sys", 
"or", F_FUNC, bt, 2, bt, bt);
+                       sql_subfunc *or = sql_bind_func_result(sql, "sys", 
"or", F_FUNC, true, bt, 2, bt, bt);
                        stmt *orderby_ids = NULL, *orderby_grp = NULL;
                        stmt *sel = NULL;
 
@@ -4013,7 +4013,7 @@ insert_check_ukey(backend *be, list *ins
                        if (!orderby_grp || !orderby_ids)
                                return NULL;
 
-                       sum = sql_bind_func(sql, "sys", "not_unique", 
tail_type(orderby_grp), NULL, F_AGGR);
+                       sum = sql_bind_func(sql, "sys", "not_unique", 
tail_type(orderby_grp), NULL, F_AGGR, true);
                        ssum = stmt_aggr(be, orderby_grp, NULL, NULL, sum, 1, 
0, 1);
                        /* combine results */
                        s = stmt_binop(be, s, ssum, NULL, or);
@@ -4054,7 +4054,7 @@ insert_check_ukey(backend *be, list *ins
                if (h->nrcols) {        /* insert multiple atoms */
                        sql_subfunc *sum;
                        stmt *count_sum = NULL;
-                       sql_subfunc *or = sql_bind_func_result(sql, "sys", 
"or", F_FUNC, bt, 2, bt, bt);
+                       sql_subfunc *or = sql_bind_func_result(sql, "sys", 
"or", F_FUNC, true, bt, 2, bt, bt);
                        stmt *ssum, *ss;
 
                        stmt *g = list_fetch(inserts, c->c->colnr), *ins = g;
@@ -4068,7 +4068,7 @@ insert_check_ukey(backend *be, list *ins
                        g = stmt_group(be, ins, NULL, NULL, NULL, 1);
                        ss = stmt_result(be, g, 2); /* use count */
                        /* (count(ss) <> sum(ss)) */
-                       sum = sql_bind_func(sql, "sys", "sum", lng, NULL, 
F_AGGR);
+                       sum = sql_bind_func(sql, "sys", "sum", lng, NULL, 
F_AGGR, true);
                        ssum = stmt_aggr(be, ss, NULL, NULL, sum, 1, 0, 1);
                        ssum = sql_Nop_(be, "ifthenelse", sql_unop_(be, 
"isnull", ssum), stmt_atom_lng(be, 0), ssum, NULL);
                        count_sum = stmt_binop(be, check_types(be, 
tail_type(ssum), stmt_aggr(be, ss, NULL, NULL, cnt, 1, 0, 1), type_equal), 
ssum, NULL, ne);
@@ -4093,9 +4093,9 @@ insert_check_fkey(backend *be, list *ins
        char *msg = NULL;
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to