Changeset: a37ef060983c for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a37ef060983c
Modified Files:
        gdk/gdk_select.c
        gdk/gdk_system.c
        monetdb5/extras/rapi/rapi.c
        monetdb5/mal/mal_builder.c
        monetdb5/mal/mal_dataflow.c
        monetdb5/mal/mal_module.c
        monetdb5/modules/atoms/json.c
        sql/backends/monet5/generator/Tests/crash.Bug-3609.stable.err
        sql/server/rel_select.c
        sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
        sql/test/testdb-upgrade/Tests/dump.stable.out
        sql/test/testdb-upgrade/Tests/upgrade.stable.out
        testing/Mtest.py.in
Branch: default
Log Message:

Merge with Oct2014 branch.


diffs (truncated from 625 to 300 lines):

diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c
--- a/gdk/gdk_select.c
+++ b/gdk/gdk_select.c
@@ -354,8 +354,9 @@ do {                                                        
                \
                }                                                       \
        }                                                               \
        assert((imp_min != nil) && (imp_max != nil));                   \
-       if ((vl > imp_max || vh < imp_min) ||                           \
-           (anti && (vl < imp_min && vh > imp_max))) {                 \
+       if (anti ?                                                      \
+           vl < imp_min && vh > imp_max :                              \
+           vl > imp_max || vh < imp_min) {                             \
                return 0;                                               \
        }                                                               \
 } while (0)
diff --git a/gdk/gdk_system.c b/gdk/gdk_system.c
--- a/gdk/gdk_system.c
+++ b/gdk/gdk_system.c
@@ -530,10 +530,14 @@ static void
 thread_starter(void *arg)
 {
        struct posthread *p = (struct posthread *) arg;
+       pthread_t tid = p->tid;
 
        (*p->func)(p->arg);
        pthread_mutex_lock(&posthread_lock);
-       p->exited = 1;
+       /* *p may have been freed by join_threads, so try to find it
+         * again before using it */
+       if ((p = find_posthread_locked(tid)) != NULL)
+               p->exited = 1;
        pthread_mutex_unlock(&posthread_lock);
 }
 
@@ -551,15 +555,11 @@ join_threads(void)
                        n = p->next;
                        if (p->exited) {
                                tid = p->tid;
+                               rm_posthread_locked(p);
+                               free(p);
                                pthread_mutex_unlock(&posthread_lock);
                                pthread_join(tid, NULL);
                                pthread_mutex_lock(&posthread_lock);
-                               /* find the thread again, mostly to
-                                * keep Coverity happy */
-                               p = find_posthread_locked(tid);
-                               assert(p != NULL);
-                               rm_posthread_locked(p);
-                               free(p);
                                waited = 1;
                                break;
                        }
diff --git a/monetdb5/extras/rapi/rapi.c b/monetdb5/extras/rapi/rapi.c
--- a/monetdb5/extras/rapi/rapi.c
+++ b/monetdb5/extras/rapi/rapi.c
@@ -352,7 +352,7 @@ int RAPIinstalladdons(void) {
        SEXP librisexp;
 
        // r library folder, create if not exists
-       snprintf(rlibs, BUFSIZ, "%s%c%s", GDKgetenv("gdk_dbpath"), DIR_SEP,
+       snprintf(rlibs, sizeof(rlibs), "%s%c%s", GDKgetenv("gdk_dbpath"), 
DIR_SEP,
                         "rapi_packages");
 
        if (mkdir(rlibs, S_IRWXU) != 0 && errno != EEXIST) {
@@ -368,7 +368,7 @@ int RAPIinstalladdons(void) {
        UNPROTECT(1);
 
        // run rapi.R environment setup script
-       snprintf(rapiinclude, BUFSIZ, "source(\"%s\")",
+       snprintf(rapiinclude, sizeof(rapiinclude), "source(\"%s\")",
                         locate_file("rapi", ".R", 0));
        R_tryEvalSilent(
                VECTOR_ELT(
@@ -402,7 +402,9 @@ str RAPIeval(Client cntxt, MalBlkPtr mb,
        int i, j = 1;
        char argbuf[64];
        char argnames[1000] = "";
+       size_t pos;
        char* rcall;
+       size_t rcalllen;
        size_t ret_rows = 0;
        int ret_cols = 0; /* int because pci->retc is int, too*/
        str *args;
@@ -422,7 +424,8 @@ str RAPIeval(Client cntxt, MalBlkPtr mb,
                          rapi_enableflag);
        }
 
-       rcall = malloc(strlen(exprStr) + sizeof(argnames) + 100);
+       rcalllen = strlen(exprStr) + sizeof(argnames) + 100;
+       rcall = malloc(rcalllen);
        if (rcall == NULL) {
                throw(MAL, "rapi.eval", MAL_MALLOC_FAIL);
        }
@@ -459,7 +462,7 @@ str RAPIeval(Client cntxt, MalBlkPtr mb,
                                args[i] = GDKstrdup("aggr_group");
                                seengrp = TRUE;
                        } else {
-                               sprintf(argbuf, "arg%i", i - pci->retc - 1);
+                               snprintf(argbuf, sizeof(argbuf), "arg%i", i - 
pci->retc - 1);
                                args[i] = GDKstrdup(argbuf);
                        }
                }
@@ -559,15 +562,21 @@ str RAPIeval(Client cntxt, MalBlkPtr mb,
         * a clear path for return values, namely using the builtin return() 
function
         * this is also compatible with PL/R
         */
-       for (i = pci->retc + 2; i < pci->argc; i++) {
-               strcat(argnames, args[i]);
-               if (i < pci->argc - 1) {
-                       strcat(argnames, ", ");
-               }
+       pos = 0;
+       for (i = pci->retc + 2; i < pci->argc && pos < sizeof(argnames); i++) {
+               pos += snprintf(argnames + pos, sizeof(argnames) - pos, "%s%s",
+                                               args[i], i < pci->argc - 1 ? ", 
" : "");
        }
-       sprintf(rcall,
-                       "ret <- as.data.frame((function(%s){%s})(%s), nm=NA, 
stringsAsFactors=F)\n",
-                       argnames, exprStr, argnames);
+       if (pos >= sizeof(argnames)) {
+               msg = createException(MAL, "rapi.eval", "Command too large");
+               goto wrapup;
+       }
+       if (snprintf(rcall, rcalllen,
+                                "ret <- as.data.frame((function(%s){%s})(%s), 
nm=NA, stringsAsFactors=F)\n",
+                                argnames, exprStr, argnames) >= (int) 
rcalllen) {
+               msg = createException(MAL, "rapi.eval", "Command too large");
+               goto wrapup;
+       }
 #ifdef _RAPI_DEBUG_
        printf("# R call %s\n",rcall);
 #endif
diff --git a/monetdb5/mal/mal_builder.c b/monetdb5/mal/mal_builder.c
--- a/monetdb5/mal/mal_builder.c
+++ b/monetdb5/mal/mal_builder.c
@@ -327,6 +327,7 @@ pushSht(MalBlkPtr mb, InstrPtr q, sht va
 
        cst.vtype= TYPE_sht;
        cst.val.shval= val;
+       cst.len = 0;
        _t = defConstant(mb,TYPE_sht,&cst);
        return pushArgument(mb, q, _t);
 }
diff --git a/monetdb5/mal/mal_dataflow.c b/monetdb5/mal/mal_dataflow.c
--- a/monetdb5/mal/mal_dataflow.c
+++ b/monetdb5/mal/mal_dataflow.c
@@ -763,7 +763,6 @@ runMALdataflow(Client cntxt, MalBlkPtr m
                        *ret = TRUE;
                        return MAL_SUCCEED;
                }
-               i = THREADS;                    /* we didn't create an extra 
thread */
        }
        assert(todo);
        /* in addition, create one more worker that will only execute
@@ -886,13 +885,12 @@ runMALdataflow(Client cntxt, MalBlkPtr m
        MT_lock_destroy(&flow->flowlock);
        GDKfree(flow);
 
-       if (i != THREADS) {
-               /* we created one worker, now tell one worker to exit again */
-               MT_lock_set(&todo->l, "runMALdataflow");
-               todo->exitcount++;
-               MT_lock_unset(&todo->l, "runMALdataflow");
-               MT_sema_up(&todo->s, "runMALdataflow");
-       }
+       /* we created one worker, now tell one worker to exit again */
+       MT_lock_set(&todo->l, "runMALdataflow");
+       todo->exitcount++;
+       MT_lock_unset(&todo->l, "runMALdataflow");
+       MT_sema_up(&todo->s, "runMALdataflow");
+
        return msg;
 }
 
diff --git a/monetdb5/mal/mal_module.c b/monetdb5/mal/mal_module.c
--- a/monetdb5/mal/mal_module.c
+++ b/monetdb5/mal/mal_module.c
@@ -474,7 +474,6 @@ char **getHelp(Module m, str inputpat, i
                GDKfree(pat);
                return msg;
        }
-       if( m1 ) m = m1;
 
 #ifdef MAL_SCOPE_DEBUG
        printf("showHelp: %s %s [" SZFMT "] %s %s\n",
@@ -496,7 +495,6 @@ char **getHelp(Module m, str inputpat, i
                                        snprintf(buf,sizeof(buf)," %s.%s",
                                                ((*modnme=='*' || *modnme==0)? 
m->name:modnme),s->name);
                                        if( tstDuplicate(msg,buf+1) ) {
-                                               fnd=1;
                                                continue;
                                        }
                                } else
diff --git a/monetdb5/modules/atoms/json.c b/monetdb5/modules/atoms/json.c
--- a/monetdb5/modules/atoms/json.c
+++ b/monetdb5/modules/atoms/json.c
@@ -2114,9 +2114,9 @@ JSONjsonaggr(BAT **bnp, BAT *b, BAT *g, 
       out:
        if (t2)
                BBPunfix(t2->batCacheid);
-       if (freeb && b)
+       if (freeb)
                BBPunfix(b->batCacheid);
-       if (freeg && g)
+       if (freeg)
                BBPunfix(g->batCacheid);
        if (buf)
                GDKfree(buf);
diff --git a/sql/backends/monet5/generator/Tests/crash.Bug-3609.stable.err 
b/sql/backends/monet5/generator/Tests/crash.Bug-3609.stable.err
--- a/sql/backends/monet5/generator/Tests/crash.Bug-3609.stable.err
+++ b/sql/backends/monet5/generator/Tests/crash.Bug-3609.stable.err
@@ -30,8 +30,9 @@ stderr of test 'crash.Bug-3609` in direc
 # 22:37:46 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-5645" "--port=33733"
 # 22:37:46 >  
 
-MAPI  = (monetdb) /var/tmp/mtest-2737/.s.monetdb.36093
+MAPI  = (monetdb) /var/tmp/mtest-30092/.s.monetdb.31340
 QUERY = select generate_series(0,2,1);
+ERROR = !SELECT: no such operator 'generate_series'
 
 
 
diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c
--- a/sql/server/rel_select.c
+++ b/sql/server/rel_select.c
@@ -4184,8 +4184,6 @@ rel_case(mvc *sql, sql_rel **rel, int to
                if (!tpe) 
                        return sql_error(sql, 02, "result type missing");
                supertype(&rtype, restype, tpe);
-               if (!tpe) 
-                       return sql_error(sql, 02, "result types %s,%s of case 
are not compatible", restype->type->sqlname, tpe->type->sqlname);
                restype = &rtype;
        }
        if (opt_else || else_exp) {
diff --git a/sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out 
b/sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
--- a/sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
+++ b/sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
@@ -19,170 +19,10 @@ stdout of test 'upgrade` in directory 's
 # MonetDB/SQL module loaded
 
 Ready.
-Running database upgrade commands:
-set schema "sys";
-delete from _columns where table_id not in (select id from _tables);
-insert into _columns values( (select max(id)+1 from _columns), 'system', 
'boolean', 1, 0, (select _tables.id from _tables join schemas on 
_tables.schema_id=schemas.id where schemas.name='sys' and 
_tables.name='schemas'), NULL, true, 4, NULL);
-insert into _columns values( (select max(id)+1 from _columns), 'varres', 
'boolean', 1, 0, (select _tables.id from _tables join schemas on 
_tables.schema_id=schemas.id where schemas.name='sys' and 
_tables.name='functions'), NULL, true, 7, NULL);
-insert into _columns values( (select max(id)+1 from _columns), 'vararg', 
'boolean', 1, 0, (select _tables.id from _tables join schemas on 
_tables.schema_id=schemas.id where schemas.name='sys' and 
_tables.name='functions'), NULL, true, 8, NULL);
-insert into _columns values( (select max(id)+1 from _columns), 'inout', 
'tinyint', 8, 0, (select _tables.id from _tables join schemas on 
_tables.schema_id=schemas.id where schemas.name='sys' and _tables.name='args'), 
NULL, true, 6, NULL);
-insert into _columns values( (select max(id)+1 from _columns), 'language', 
'int', 32, 0, (select _tables.id from _tables join schemas on 
_tables.schema_id=schemas.id where schemas.name='sys' and 
_tables.name='functions'), NULL, true, 9, NULL);
-delete from _columns where table_id in (select _tables.id from _tables join 
schemas on _tables.schema_id=schemas.id where schemas.name='sys' and 
_tables.name='functions') and name='sql';
-update _columns set number='9' where name = 'schema_id' and table_id in 
(select _tables.id from _tables join schemas on _tables.schema_id=schemas.id 
where schemas.name='sys' and _tables.name='functions');
-update _columns set number='7' where name = 'number' and table_id in (select 
_tables.id from _tables join schemas on _tables.schema_id=schemas.id where 
schemas.name='sys' and _tables.name='args');
-update _columns set number='4' where name = 'language' and table_id in (select 
_tables.id from _tables join schemas on _tables.schema_id=schemas.id where 
schemas.name='sys' and _tables.name='functions');
-delete from _columns where table_id in (select id from _tables where name like 
'#%');
-delete from _tables where name like '#%';
-create table upgradeOct2014 as (select * from functions where type = 5 and 
language <> 0) with data;
-create table upgradeOct2014_changes (c bigint);
-create function drop_func_upgrade_oct2014( id integer ) returns int external 
name sql.drop_func_upgrade_oct2014;
-insert into upgradeOct2014_changes select drop_func_upgrade_oct2014(id) from 
upgradeOct2014;
-drop function drop_func_upgrade_oct2014;
-create function create_func_upgrade_oct2014( f string ) returns int external 
name sql.create_func_upgrade_oct2014;
-insert into upgradeOct2014_changes select create_func_upgrade_oct2014(func) 
from upgradeOct2014;
-drop function create_func_upgrade_oct2014;
-drop table upgradeOct2014_changes;
-drop table upgradeOct2014;
-drop function sys.bbp;
-create function sys.bbp() returns table (id int, name string, htype string, 
ttype string, count BIGINT, refcnt int, lrefcnt int, location string, heat int, 
dirty string, status string, kind string) external name bbp.get;
-create schema json;
 
-create type json external name json;
-
-create function json.filter(js json, pathexpr string)
-returns json external name json.filter;
-
-create function json.filter(js json, name tinyint)
-returns json external name json.filter;
-
-create function json.filter(js json, name integer)
-returns json external name json.filter;
-
-create function json.filter(js json, name bigint)
-returns json external name json.filter;
-
-create function json.text(js json, e string)
-returns string external name json.text;
-
-create function json.number(js json)
-returns float external name json.number;
-
-create function json."integer"(js json)
-returns bigint external name json."integer";
-
-create function json.isvalid(js string)
-returns bool external name json.isvalid;
-
-create function json.isobject(js string)
-returns bool external name json.isobject;
-
-create function json.isarray(js string)
-returns bool external name json.isarray;
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to