Changeset: 3a9d50962c23 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/3a9d50962c23
Modified Files:
        monetdb5/mal/mal_instruction.c
        monetdb5/optimizer/opt_mitosis.c
        sql/server/rel_psm.c
Branch: default
Log Message:

Merge with Dec2025 branch.


diffs (143 lines):

diff --git a/monetdb5/mal/mal_instruction.c b/monetdb5/mal/mal_instruction.c
--- a/monetdb5/mal/mal_instruction.c
+++ b/monetdb5/mal/mal_instruction.c
@@ -912,9 +912,9 @@ pushArgument(MalBlkPtr mb, InstrPtr p, i
                if (mb->errors)
                        return p;
        }                                                       /* protect 
against the case that the instruction is malloced in isolation */
-       if (mb->maxarg < p->maxarg)
-               mb->maxarg = p->maxarg;
        p->argv[p->argc++] = varid;
+       if (mb->maxarg < p->argc)
+               mb->maxarg = p->argc;
        return p;
 }
 
diff --git a/monetdb5/optimizer/opt_mitosis.c b/monetdb5/optimizer/opt_mitosis.c
--- a/monetdb5/optimizer/opt_mitosis.c
+++ b/monetdb5/optimizer/opt_mitosis.c
@@ -13,6 +13,7 @@
 #include "opt_mitosis.h"
 #include "mal_interpreter.h"
 
+#define MAXSLICES 128                  /* to be refined */
 #define MIN_PART_SIZE 100000   /* minimal record count per partition */
 #define MAX_PARTS2THREADS_RATIO 4      /* There should be at most this 
multiple more of partitions than threads */
 
@@ -21,15 +22,19 @@ str
 OPTmitosisImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
                                                 InstrPtr pci)
 {
-       int i, j, limit, slimit, pieces = 1, mito_parts = 0,
-               mito_size = 0, row_size = 0, mt = -1, nr_cols = 0, nr_aggrs = 0,
-               nr_maps = 0;
-       str schema = 0, table = 0;
-       BUN r = 0, rowcnt = 0;          /* table should be sizeable to consider 
parallel execution */
+       int i, j, limit, slimit, pieces = 1, mito_parts = 0;
+       int mito_size = 0, row_size = 0, mt = -1, nr_cols = 0, nr_aggrs = 0;
+       int nr_maps = 0;
+       const char *schema = NULL;
+       const char *table = NULL;
+       BUN r = 0;
+       BUN rowcnt = 0;         /* table should be sizeable to consider 
parallel execution */
        InstrPtr p, q, *old, target = 0;
-       size_t argsize = 6 * sizeof(lng), m = 0;
+       size_t argsize = 6 * sizeof(lng);
+       size_t m = 0;
        /*       estimate size per operator estimate:   4 args + 2 res */
-       int threads = GDKnr_threads ? GDKnr_threads : 1, maxparts = MAXSLICES;
+       int threads = GDKnr_threads ? GDKnr_threads : 1;
+       int maxparts = MAXSLICES;
        str msg = MAL_SUCCEED;
 
        /* if the user has associated limitation on the number of threads, 
respect it in the
@@ -58,7 +63,7 @@ OPTmitosisImplementation(Client cntxt, M
 
                /* mitosis/mergetable bailout conditions */
                /* Crude protection against self join explosion */
-               if (p->retc == 2 && isMatJoinOp(p))
+               if (p->retc == 2 && isMatJoinOp(p) && threads < maxparts)
                        maxparts = threads;
 
                nr_aggrs += (p->argc > 2 && getModuleId(p) == aggrRef);
@@ -180,7 +185,7 @@ OPTmitosisImplementation(Client cntxt, M
                 * |threads| partitions at a time fit in memory,
                 * i.e., (threads*(rowcnt/pieces) <= m),
                 * i.e., (rowcnt/pieces <= m/threads),
-                * i.e., (pieces => rowcnt/(m/threads))
+                * i.e., (pieces >= rowcnt/(m/threads))
                 * (assuming that (m > threads*MIN_PART_SIZE)) */
                /* the number of pieces affects SF-100, going beyond 8x 
increases
                 * the optimizer costs beyond the execution time
diff --git a/monetdb5/optimizer/opt_mitosis.h b/monetdb5/optimizer/opt_mitosis.h
--- a/monetdb5/optimizer/opt_mitosis.h
+++ b/monetdb5/optimizer/opt_mitosis.h
@@ -12,8 +12,6 @@
 #define _OPT_MITOSIS_
 #include "opt_support.h"
 
-#define MAXSLICES 1024                 /* to be refined */
-
 extern str OPTmitosisImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
                                                                        
InstrPtr p);
 
diff --git a/monetdb5/optimizer/opt_reorder.c b/monetdb5/optimizer/opt_reorder.c
--- a/monetdb5/optimizer/opt_reorder.c
+++ b/monetdb5/optimizer/opt_reorder.c
@@ -53,8 +53,6 @@ OPTreorderImplementation(Client ctx, Mal
        int top[MAXSLICES] = { 0 };
        int barriers[MAXSLICES] = { 0 }, btop = 0, off = 0;
 
-       for (i = 0; i < MAXSLICES; i++)
-               top[i] = 0;
        if (MB_LARGE(mb)) {
                goto wrapup;
        }
diff --git a/sql/server/rel_psm.c b/sql/server/rel_psm.c
--- a/sql/server/rel_psm.c
+++ b/sql/server/rel_psm.c
@@ -880,6 +880,7 @@ has_generic_decimal_result(list *types)
        return false;
 }
 
+#define admin_privs(g) ((g) == USER_MONETDB || (g) == ROLE_SYSADMIN)
 
 static sql_rel *
 rel_create_func(sql_query *query, dlist *qname, dlist *params, symbol *res, 
dlist *ext_name, dlist *body, sql_ftype type, sql_flang lang, int replace, int 
order_spec)
@@ -929,6 +930,8 @@ rel_create_func(sql_query *query, dlist 
                return sql_error(sql, 02, SQLSTATE(42000) "CREATE %s: %s 
functions creation via SQL not supported", F, fn);
        else if (LANG_EXT(lang) && !(type == F_FUNC || type == F_AGGR || type 
== F_UNION || type == F_LOADER))
                return sql_error(sql, 02, SQLSTATE(42000) "CREATE %s: %ss 
creation via external programming languages not supported", F, fn);
+       else if (lang != FUNC_LANG_SQL && !admin_privs(sql->user_id) && 
!admin_privs(sql->role_id))
+               return sql_error(sql, 02, SQLSTATE(42000) "CREATE %s: 
insufficient privileges for user '%s'", F, get_string_global_var(sql, 
"current_user"));
 
        if (sname && !(s = mvc_bind_schema(sql, sname)))
                return sql_error(sql, ERR_NOTFOUND, SQLSTATE(3F000) "CREATE %s: 
no such schema '%s'", F, sname);
diff --git a/sql/test/Users/Tests/All b/sql/test/Users/Tests/All
--- a/sql/test/Users/Tests/All
+++ b/sql/test/Users/Tests/All
@@ -18,4 +18,5 @@ userCallFunction
 withGrantOption
 user_default_role
 user_default_schema
+user_create_external_func
 create_user_options
diff --git a/sql/test/Users/Tests/user_create_external_func.reqtests 
b/sql/test/Users/Tests/user_create_external_func.reqtests
new file mode 100644
--- /dev/null
+++ b/sql/test/Users/Tests/user_create_external_func.reqtests
@@ -0,0 +1,1 @@
+user_default_schema
diff --git a/sql/test/Users/Tests/user_create_external_func.test 
b/sql/test/Users/Tests/user_create_external_func.test
new file mode 100644
--- /dev/null
+++ b/sql/test/Users/Tests/user_create_external_func.test
@@ -0,0 +1,8 @@
+@connection(id=bar, username=bar, password=bar)
+statement error
+CREATE PROCEDURE foo.snap(tarfile string) EXTERNAL NAME sql.hot_snapshot
+
+@connection(id=bar)
+statement error
+CALL foo.snap('/var/lib/monetdb/whatever.tar')
+
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to