Changeset: 7c273de946b5 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7c273de946b5
Added Files:
        sql/test/BugTracker-2019/Tests/isaUUID.Bug-6784.sql
        sql/test/BugTracker-2019/Tests/isaUUID.Bug-6784.stable.err
        sql/test/BugTracker-2019/Tests/isaUUID.Bug-6784.stable.out
Modified Files:
        clients/Tests/MAL-signatures.stable.out
        clients/Tests/MAL-signatures.stable.out.int128
        common/utils/msabaoth.c
        common/utils/msabaoth.h
        gdk/gdk_utils.c
        monetdb5/mal/mal_session.c
        monetdb5/modules/atoms/uuid.c
        sql/backends/monet5/rel_bin.c
        sql/backends/monet5/sql.c
        sql/backends/monet5/sql.h
        sql/backends/monet5/sql.mal
        sql/server/rel_exp.c
        sql/server/rel_optimizer.c
        sql/server/rel_schema.c
        sql/server/rel_unnest.c
        sql/server/rel_updates.c
        sql/server/rel_updates.h
        sql/test/BugTracker-2015/Tests/crash.Bug-3736.stable.out
        
sql/test/BugTracker-2016/Tests/memory-consumption-query-PLAN-25joins.Bug-3972.stable.out
        sql/test/BugTracker-2017/Tests/complicated_logic.Bug-105.stable.out
        sql/test/BugTracker-2019/Tests/All
        testing/exportutils.py
        tools/merovingian/client/monetdb.c
        tools/merovingian/daemon/client.c
        tools/merovingian/daemon/controlrunner.c
        tools/merovingian/daemon/discoveryrunner.c
        tools/merovingian/daemon/forkmserver.c
        tools/merovingian/daemon/forkmserver.h
        tools/merovingian/utils/database.c
Branch: sq2
Log Message:

merged


diffs (truncated from 1372 to 300 lines):

diff --git a/clients/Tests/MAL-signatures.stable.out 
b/clients/Tests/MAL-signatures.stable.out
--- a/clients/Tests/MAL-signatures.stable.out
+++ b/clients/Tests/MAL-signatures.stable.out
@@ -11772,7 +11772,7 @@ stdout of test 'MAL-signatures` in direc
 [ "sql",       "subdelta",     "command sql.subdelta(col:bat[:oid], 
cand:bat[:oid], uid:bat[:oid], uval:bat[:oid]):bat[:oid] ",        
"DELTAsub2;",   "Return a single bat of selected delta."        ]
 [ "sql",       "subdelta",     "command sql.subdelta(col:bat[:oid], 
cand:bat[:oid], uid:bat[:oid], uval:bat[:oid], ins:bat[:oid]):bat[:oid] ", 
"DELTAsub;",    "Return a single bat of selected delta."        ]
 [ "sql",       "subnull",      "command sql.subnull(l:bat[:any_1], 
gp:bat[:oid], gpe:bat[:oid], no_nil:bit):bat[:bit] ",       "SQLnil_grp;",  "if 
any value in l is nil with in a group return true for that group, else false"   
    ]
-[ "sql",       "subzero_or_one",       "inline function 
sql.subzero_or_one(b:bat[:any_1], gp:bat[:oid], gpe:bat[:oid], 
no_nil:bit):bat[:any_1];",      "",     ""      ]
+[ "sql",       "subzero_or_one",       "command 
sql.subzero_or_one(b:bat[:any_1], gp:bat[:oid], gpe:bat[:oid], 
no_nil:bit):bat[:any_1] ",      "SQLsubzero_or_one;",   ""      ]
 [ "sql",       "sum",  "pattern sql.sum(b:bte, s:lng, e:lng):lng ",    
"SQLsum;",      "return the sum of groups"      ]
 [ "sql",       "sum",  "pattern sql.sum(b:dbl, s:lng, e:lng):dbl ",    
"SQLsum;",      "return the sum of groups"      ]
 [ "sql",       "sum",  "pattern sql.sum(b:flt, s:lng, e:lng):dbl ",    
"SQLsum;",      "return the sum of groups"      ]
diff --git a/clients/Tests/MAL-signatures.stable.out.int128 
b/clients/Tests/MAL-signatures.stable.out.int128
--- a/clients/Tests/MAL-signatures.stable.out.int128
+++ b/clients/Tests/MAL-signatures.stable.out.int128
@@ -16184,7 +16184,7 @@ stdout of test 'MAL-signatures` in direc
 [ "sql",       "subdelta",     "command sql.subdelta(col:bat[:oid], 
cand:bat[:oid], uid:bat[:oid], uval:bat[:oid]):bat[:oid] ",        
"DELTAsub2;",   "Return a single bat of selected delta."        ]
 [ "sql",       "subdelta",     "command sql.subdelta(col:bat[:oid], 
cand:bat[:oid], uid:bat[:oid], uval:bat[:oid], ins:bat[:oid]):bat[:oid] ", 
"DELTAsub;",    "Return a single bat of selected delta."        ]
 [ "sql",       "subnull",      "command sql.subnull(l:bat[:any_1], 
gp:bat[:oid], gpe:bat[:oid], no_nil:bit):bat[:bit] ",       "SQLnil_grp;",  "if 
any value in l is nil with in a group return true for that group, else false"   
    ]
-[ "sql",       "subzero_or_one",       "inline function 
sql.subzero_or_one(b:bat[:any_1], gp:bat[:oid], gpe:bat[:oid], 
no_nil:bit):bat[:any_1];",      "",     ""      ]
+[ "sql",       "subzero_or_one",       "command 
sql.subzero_or_one(b:bat[:any_1], gp:bat[:oid], gpe:bat[:oid], 
no_nil:bit):bat[:any_1] ",      "SQLsubzero_or_one;",   ""      ]
 [ "sql",       "sum",  "pattern sql.sum(b:bte, s:lng, e:lng):hge ",    
"SQLsum;",      "return the sum of groups"      ]
 [ "sql",       "sum",  "pattern sql.sum(b:bte, s:lng, e:lng):lng ",    
"SQLsum;",      "return the sum of groups"      ]
 [ "sql",       "sum",  "pattern sql.sum(b:dbl, s:lng, e:lng):dbl ",    
"SQLsum;",      "return the sum of groups"      ]
diff --git a/common/utils/msabaoth.c b/common/utils/msabaoth.c
--- a/common/utils/msabaoth.c
+++ b/common/utils/msabaoth.c
@@ -671,11 +671,7 @@ msab_getSingleStatus(const char *pathbuf
                }
        }
        snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname, 
MAINTENANCEFILE);
-       if (stat(buf, &statbuf) == -1) {
-               sdb->locked = 0;
-       } else {
-               sdb->locked = 1;
-       }
+       sdb->locked = stat(buf, &statbuf) != -1;
 
        /* add scenarios that are supported */
        sdb->scens = NULL;
diff --git a/common/utils/msabaoth.h b/common/utils/msabaoth.h
--- a/common/utils/msabaoth.h
+++ b/common/utils/msabaoth.h
@@ -27,7 +27,7 @@ typedef enum {
 typedef struct Ssabdb {
        char *dbname;            /* database name */
        char *path;              /* path to this database */
-       int locked;              /* whether this database is under maintenance 
*/
+       bool locked;             /* whether this database is under maintenance 
*/
        SABdbState state;        /* current database state */
        sablist* scens;          /* scenarios available for this database */
        sablist* conns;          /* connections available for this database */
diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -408,51 +408,107 @@ MT_init(void)
        fc = fopen("/proc/self/cgroup", "r");
        if (fc != NULL) {
                char buf[1024];
+               /* each line is of the form:
+                * hierarchy-ID:controller-list:cgroup-path
+                *
+                * For cgroup v1, the hierarchy-ID refers to the
+                * second column in /proc/cgroups (which we ignore)
+                * and the controller-list is a comma-separated list
+                * of the controllers bound to the hierarchy.  We look
+                * for the "memory" controller and use its
+                * cgroup-path.  We ignore the other lines.
+                *
+                * For cgroup v2, the hierarchy-ID is 0 and the
+                * controller-list is empty.  We just use the
+                * cgroup-path.
+                *
+                * We use the first line that we can match (either v1
+                * or v2) and for which we can open any of the files
+                * that we are looking for.
+                */
                while (fgets(buf, (int) sizeof(buf), fc) != NULL) {
+                       char pth[1024];
                        char *p, *q;
-                       p = strchr(buf, ':');
-                       if (p == NULL)
-                               break;
-                       q = p + 1;
-                       p = strchr(q, ':');
+                       bool success = false; /* true if we can open any file */
+                       FILE *f;
+                       uint64_t mem;
+
+                       p = strchr(buf, '\n');
                        if (p == NULL)
                                break;
-                       *p++ = 0;
-                       if (strstr(q, "memory") != NULL) {
-                               char pth[1024];
-                               FILE *f;
-                               q = strchr(p, '\n');
-                               if (q == NULL)
+                       *p = 0;
+                       if (strncmp(buf, "0::", 3) == 0) {
+                               /* cgroup v2 entry */
+                               q = stpconcat(pth, "/sys/fs/cgroup",
+                                             buf + 3, "/", NULL);
+                               /* hard limit */
+                               strcpy(q, "memory.max");
+                               f = fopen(pth, "r");
+                               if (f != NULL) {
+                                       if (fscanf(f, "%" SCNu64, &mem) == 1 && 
mem < (uint64_t) _MT_pagesize * _MT_npages) {
+                                               _MT_npages = (size_t) (mem / 
_MT_pagesize);
+                                       }
+                                       success = true;
+                                       /* assume "max" if not a number */
+                                       fclose(f);
+                               }
+                               /* soft limit */
+                               strcpy(q, "memory.high");
+                               f = fopen(pth, "r");
+                               if (f != NULL) {
+                                       if (fscanf(f, "%" SCNu64, &mem) == 1 && 
mem < (uint64_t) _MT_pagesize * _MT_npages) {
+                                               _MT_npages = (size_t) (mem / 
_MT_pagesize);
+                                       }
+                                       success = true;
+                                       /* assume "max" if not a number */
+                                       fclose(f);
+                               }
+                               /* limit of memory+swap usage
+                                * we use this as maximum virtual memory size */
+                               strcpy(q, "memory.swap.max");
+                               f = fopen(pth, "r");
+                               if (f != NULL) {
+                                       if (fscanf(f, "%" SCNu64, &mem) == 1
+                                           && mem < (uint64_t) GDK_vm_maxsize) 
{
+                                               GDK_vm_maxsize = (size_t) mem;
+                                       }
+                                       success = true;
+                                       fclose(f);
+                               }
+                       } else {
+                               /* cgroup v1 entry */
+                               p = strchr(buf, ':');
+                               if (p == NULL)
                                        break;
-                               *q = 0;
-                               q = stpconcat(pth, "/sys/fs/cgroup/memory",
-                                             p, NULL);
-                               /* sometimes the path in
-                                * /proc/self/cgroup ends in "/" (or
-                                * actually, is "/"); in all other
-                                * cases add one */
-                               if (q[-1] != '/')
-                                       *q++ = '/';
+                               q = p + 1;
+                               p = strchr(q, ':');
+                               if (p == NULL)
+                                       break;
+                               *p++ = 0;
+                               if (strstr(q, "memory") == NULL)
+                                       continue;
+                               q = stpconcat(pth, "/sys/fs/cgroup/", q,
+                                             p, "/", NULL);
                                /* limit of memory usage */
                                strcpy(q, "memory.limit_in_bytes");
                                f = fopen(pth, "r");
                                if (f != NULL) {
-                                       uint64_t mem;
                                        if (fscanf(f, "%" SCNu64, &mem) == 1
                                            && mem < (uint64_t) _MT_pagesize * 
_MT_npages) {
                                                _MT_npages = (size_t) (mem / 
_MT_pagesize);
                                        }
+                                       success = true;
                                        fclose(f);
                                }
                                /* soft limit of memory usage */
                                strcpy(q, "memory.soft_limit_in_bytes");
                                f = fopen(pth, "r");
                                if (f != NULL) {
-                                       uint64_t mem;
                                        if (fscanf(f, "%" SCNu64, &mem) == 1
                                            && mem < (uint64_t) _MT_pagesize * 
_MT_npages) {
                                                _MT_npages = (size_t) (mem / 
_MT_pagesize);
                                        }
+                                       success = true;
                                        fclose(f);
                                }
                                /* limit of memory+swap usage
@@ -460,16 +516,16 @@ MT_init(void)
                                strcpy(q, "memory.memsw.limit_in_bytes");
                                f = fopen(pth, "r");
                                if (f != NULL) {
-                                       uint64_t mem;
                                        if (fscanf(f, "%" SCNu64, &mem) == 1
                                            && mem < (uint64_t) GDK_vm_maxsize) 
{
                                                GDK_vm_maxsize = (size_t) mem;
                                        }
+                                       success = true;
                                        fclose(f);
                                }
+                       }
+                       if (success)
                                break;
-
-                       }
                }
                fclose(fc);
        }
diff --git a/monetdb5/mal/mal_session.c b/monetdb5/mal/mal_session.c
--- a/monetdb5/mal/mal_session.c
+++ b/monetdb5/mal/mal_session.c
@@ -295,7 +295,7 @@ MSscheduleClient(str command, str challe
                                GDKfree(command);
                                return;
                        }
-                       if (stats->locked == 1) {
+                       if (stats->locked) {
                                if (uid == 0) {
                                        mnstr_printf(fout, "#server is running 
in "
                                                                 "maintenance 
mode\n");
diff --git a/monetdb5/modules/atoms/uuid.c b/monetdb5/modules/atoms/uuid.c
--- a/monetdb5/modules/atoms/uuid.c
+++ b/monetdb5/modules/atoms/uuid.c
@@ -163,7 +163,7 @@ UUIDfromString(const char *svalue, size_
        return (ssize_t) (s - svalue);
 
   bailout:
-       GDKerror("Syntax error in UUID.\n");
+       **retval = uuid_nil;
        return -1;
 }
 
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
@@ -332,6 +332,27 @@ handle_in_exps(backend *be, sql_exp *ce,
                        s = stmt_uselect(be, 
                                stmt_const(be, bin_first_column(be, left), s), 
                                stmt_bool(be, 1), cmp_equal, sel, 0); 
+       } else if (list_length(nl) < 16) {
+               comp_type cmp = (in)?cmp_equal:cmp_notequal;
+
+               if (!in)
+                       s = sel;
+               for( n = nl->h; n; n = n->next) {
+                       sql_exp *e = n->data;
+                       stmt *i = exp_bin(be, use_r?e->r:e, left, right, grp, 
ext, cnt, NULL);
+                       if(!i)
+                               return NULL;
+
+                       if (in) { 
+                               i = stmt_uselect(be, c, i, cmp, sel, 0); 
+                               if (s)
+                                       s = stmt_tunion(be, s, i); 
+                               else
+                                       s = i;
+                       } else {
+                               s = stmt_uselect(be, c, i, cmp, s, 0); 
+                       }
+               }
        } else {
                // TODO: handle_in_exps should contain all necessary logic for 
in-expressions to be SQL compliant.
                // For non-SQL-standard compliant behavior, e.g. PostgreSQL 
backwards compatibility, we should
@@ -381,7 +402,6 @@ handle_in_exps(backend *be, sql_exp *ce,
                        s = stmt_result(be, s, 0);
                }
        }
-
        return s;
 }
 
@@ -1954,7 +1974,7 @@ rel2bin_join(backend *be, sql_rel *rel, 
                        stmt *s = NULL;
                        prop *p;
 
-                       /* only handle simple joins here */             
+                       /* only handle simple joins here */
                        if ((exp_has_func(e) && get_cmp(e) != cmp_filter) ||
                            get_cmp(e) == cmp_or || e->f) {
                                if (!join && !list_length(lje)) {
@@ -2155,7 +2175,6 @@ rel2bin_antijoin(backend *be, sql_rel *r
        right = row2cols(be, right);
 
        if (rel->exps) {
-
                jexps = sa_list(sql->sa);
                mexps = sa_list(sql->sa);
 
@@ -2232,7 +2251,7 @@ rel2bin_semijoin(backend *be, sql_rel *r
         *      first cheap join(s) (equality or idx) 
         *      second selects/filters 
         */
-       
+
 #if 0
        if (rel->exps && rel->op == op_anti && need_no_nil(rel)) {
                sql_subtype *lng = sql_bind_localtype("lng");
@@ -2293,21 +2312,43 @@ rel2bin_semijoin(backend *be, sql_rel *r
 #endif
        if (rel->exps) {
                int idx = 0;
+               list *jexps = sa_list(sql->sa);
                list *lje = sa_list(sql->sa);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to