Changeset: 06e1cc9baceb for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=06e1cc9baceb
Modified Files:
        sql/server/rel_optimizer.c
        sql/test/BugTracker-2020/Tests/All
Branch: mtest
Log Message:

Merged with default


diffs (truncated from 1189 to 300 lines):

diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -868,6 +868,15 @@ else
 fi
 %endif
 
+%if %{?rhel:0}%{!?rhel:1} || 0%{?rhel} >= 7
+# fix up some paths (/var/run -> /run)
+# needed because CMAKE_INSTALL_RUNSTATEDIR refers to /var/run
+sed -i 's|/var/run|/run|' \
+    %{buildroot}%{_tmpfilesdir}/monetdbd.conf \
+    %{buildroot}%{_localstatedir}/monetdb5/dbfarm/.merovingian_properties \
+    %{buildroot}%{_unitdir}/monetdbd.service
+%endif
+
 %post -p /sbin/ldconfig
 
 %postun -p /sbin/ldconfig
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -664,6 +664,7 @@ MapiHdl mapi_send(Mapi mid, const char *
 MapiMsg mapi_setAutocommit(Mapi mid, bool autocommit) 
__attribute__((__nonnull__(1)));
 MapiMsg mapi_set_columnar_protocol(Mapi mid, bool columnar_protocol) 
__attribute__((__nonnull__(1)));
 MapiMsg mapi_set_size_header(Mapi mid, bool value) 
__attribute__((__nonnull__(1)));
+MapiMsg mapi_set_timeout(Mapi mid, unsigned int timeout, bool (*callback)(void 
*), void *callback_data) __attribute__((__nonnull__(1)));
 void mapi_setfilecallback(Mapi mid, char *(*getfunc)(void *priv, const char 
*filename, bool binary, uint64_t offset, size_t *size), char *(*putfunc)(void 
*priv, const char *filename, const void *data, size_t size), void *priv) 
__attribute__((__nonnull__(1)));
 int mapi_split_line(MapiHdl hdl) __attribute__((__nonnull__(1)));
 
@@ -1783,7 +1784,7 @@ int mnstr_readStr(stream *restrict s, ch
 ssize_t mnstr_read_block(stream *restrict s, void *restrict buf, size_t 
elmsize, size_t cnt);
 ssize_t mnstr_readline(stream *restrict s, void *restrict buf, size_t maxcnt);
 void mnstr_set_bigendian(stream *s, bool bigendian);
-void mnstr_settimeout(stream *s, unsigned int ms, bool (*func)(void));
+void mnstr_settimeout(stream *s, unsigned int ms, bool (*func)(void *), void 
*data);
 ssize_t mnstr_write(stream *restrict s, const void *restrict buf, size_t 
elmsize, size_t cnt);
 int mnstr_writeBte(stream *s, int8_t val);
 int mnstr_writeBteArray(stream *restrict s, const int8_t *restrict val, size_t 
cnt);
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -3678,8 +3678,9 @@ main(int argc, char **argv)
                                        s = open_rastream(arg);
                        }
                        if (s == NULL) {
-                               fprintf(stderr, "%s: cannot open: %s", arg, 
mnstr_peek_error(NULL));
+                               fprintf(stderr, "%s: cannot open: %s\n", arg, 
mnstr_peek_error(NULL));
                                c |= 1;
+                               optind++;
                                continue;
                        }
                        // doFile closes 's'.
diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -3279,16 +3279,22 @@ prepareQuery(MapiHdl hdl, const char *cm
 
 
 MapiMsg
-mapi_timeout(Mapi mid, unsigned int timeout)
+mapi_set_timeout(Mapi mid, unsigned int timeout, bool (*callback)(void *), 
void *callback_data)
 {
        mapi_check(mid);
        if (mid->trace)
                printf("Set timeout to %u\n", timeout);
-       mnstr_settimeout(mid->to, timeout, NULL);
-       mnstr_settimeout(mid->from, timeout, NULL);
+       mnstr_settimeout(mid->to, timeout, callback, callback_data);
+       mnstr_settimeout(mid->from, timeout, callback, callback_data);
        return MOK;
 }
 
+MapiMsg
+mapi_timeout(Mapi mid, unsigned int timeout)
+{
+       return mapi_set_timeout(mid, timeout, NULL, NULL);
+}
+
 static MapiMsg
 mapi_Xcommand(Mapi mid, const char *cmdname, const char *cmdvalue)
 {
diff --git a/clients/mapilib/mapi.h b/clients/mapilib/mapi.h
--- a/clients/mapilib/mapi.h
+++ b/clients/mapilib/mapi.h
@@ -177,6 +177,8 @@ mapi_export MapiMsg mapi_cache_freeup(Ma
 mapi_export MapiMsg mapi_seek_row(MapiHdl hdl, int64_t rowne, int whence)
        __attribute__((__nonnull__(1)));
 
+mapi_export MapiMsg mapi_set_timeout(Mapi mid, unsigned int timeout, bool 
(*callback)(void *), void *callback_data)
+       __attribute__((__nonnull__(1)));
 mapi_export MapiMsg mapi_timeout(Mapi mid, unsigned int time)
        __attribute__((__nonnull__(1)));
 mapi_export int mapi_fetch_row(MapiHdl hdl)
diff --git a/common/stream/bs2.c b/common/stream/bs2.c
--- a/common/stream/bs2.c
+++ b/common/stream/bs2.c
@@ -594,6 +594,7 @@ bs2_update_timeout(stream *ss)
        if ((s = ss->stream_data.p) != NULL && s->s) {
                s->s->timeout = ss->timeout;
                s->s->timeout_func = ss->timeout_func;
+               s->s->timeout_data = ss->timeout_data;
                if (s->s->update_timeout)
                        s->s->update_timeout(s->s);
        }
diff --git a/common/stream/socket_stream.c b/common/stream/socket_stream.c
--- a/common/stream/socket_stream.c
+++ b/common/stream/socket_stream.c
@@ -53,7 +53,7 @@ socket_write(stream *restrict s, const v
                                   ) && /* it was! */
 #endif
                           s->timeout_func != NULL &&   /* callback function 
exists */
-                          !s->timeout_func())  /* callback says don't stop */
+                          !s->timeout_func(s->timeout_data))   /* callback 
says don't stop */
                       ||(nr < 0 &&
 #ifdef _MSC_VER
                          WSAGetLastError() == WSAEINTR
@@ -153,7 +153,7 @@ socket_read(stream *restrict s, void *re
                        }
 #endif
                        if (ret == 0) {
-                               if (s->timeout_func == NULL || 
s->timeout_func()) {
+                               if (s->timeout_func == NULL || 
s->timeout_func(s->timeout_data)) {
                                        mnstr_set_error(s, MNSTR_TIMEOUT, NULL);
                                        return -1;
                                }
@@ -388,4 +388,3 @@ socket_wstream(SOCKET sock, const char *
        s->binary = true;
        return s;
 }
-
diff --git a/common/stream/stream.c b/common/stream/stream.c
--- a/common/stream/stream.c
+++ b/common/stream/stream.c
@@ -259,11 +259,12 @@ mnstr_readline(stream *restrict s, void 
 
 
 void
-mnstr_settimeout(stream *s, unsigned int ms, bool (*func)(void))
+mnstr_settimeout(stream *s, unsigned int ms, bool (*func)(void *), void *data)
 {
        if (s) {
                s->timeout = ms;
                s->timeout_func = func;
+               s->timeout_data = data;
                if (s->update_timeout)
                        s->update_timeout(s);
        }
@@ -788,6 +789,7 @@ wrapper_update_timeout(stream *s)
 {
        s->inner->timeout = s->timeout;
        s->inner->timeout_func = s->timeout_func;
+       s->inner->timeout_data = s->timeout_data;
        s->inner->update_timeout(s->inner);
 }
 
diff --git a/common/stream/stream.h b/common/stream/stream.h
--- a/common/stream/stream.h
+++ b/common/stream/stream.h
@@ -154,7 +154,7 @@ stream_export char *mnstr_name(const str
 stream_export bool mnstr_isbinary(const stream *s); // unused
 stream_export bool mnstr_get_swapbytes(const stream *s); // sql_result.c/mapi10
 stream_export void mnstr_set_bigendian(stream *s, bool bigendian); // used in 
mapi.c and mal_session.c
-stream_export void mnstr_settimeout(stream *s, unsigned int ms, bool 
(*func)(void)); // used in mapi.c and mal_session.c
+stream_export void mnstr_settimeout(stream *s, unsigned int ms, bool 
(*func)(void *), void *data); // used in mapi.c and mal_session.c
 stream_export int mnstr_isalive(const stream *s); // used once in 
mal_interpreter.c
 
 stream_export stream *open_rstream(const char *filename); // used in 
mclient.c, gdk_logger.c, store.c, snapshot.c
diff --git a/common/stream/stream_internal.h b/common/stream/stream_internal.h
--- a/common/stream/stream_internal.h
+++ b/common/stream/stream_internal.h
@@ -152,7 +152,8 @@ struct stream {
        bool isutf8;            /* known to be UTF-8 due to BOM */
        bool binary;            /* text/binary */
        unsigned int timeout;   /* timeout in ms */
-       bool (*timeout_func)(void); /* callback function: NULL/true -> return */
+       bool (*timeout_func)(void *); /* callback function: NULL/true -> return 
*/
+       void *timeout_data;     /* data for the above */
        union {
                void *p;
                int i;
diff --git a/common/utils/msabaoth.c b/common/utils/msabaoth.c
--- a/common/utils/msabaoth.c
+++ b/common/utils/msabaoth.c
@@ -611,6 +611,7 @@ msab_pickSecret(char **generated_secret)
        if (generated_secret)
        // do not return an error, just continue without a secret
                *generated_secret = NULL;
+       free(secret);
        return NULL;
 #endif
 #endif
@@ -629,6 +630,7 @@ msab_pickSecret(char **generated_secret)
                char err[512];
                snprintf(err, sizeof(err), "unable to open '%s': %s",
                                pathbuf, strerror(errno));
+               free(secret);
                return strdup(err);
        }
        if ((f = fdopen(fd, "w")) == NULL) {
@@ -637,6 +639,7 @@ msab_pickSecret(char **generated_secret)
                                pathbuf, strerror(errno));
                close(fd);
                (void)remove(pathbuf);
+               free(secret);
                return strdup(err);
        }
        if (fwrite(secret, 1, SECRET_LENGTH, f) < SECRET_LENGTH || fclose(f) < 
0) {
@@ -645,11 +648,14 @@ msab_pickSecret(char **generated_secret)
                                strerror(errno));
                fclose(f);
                (void)remove(pathbuf);
+               free(secret);
                return strdup(err);
        }
 
        if (generated_secret)
                *generated_secret = (char*)secret;
+       else
+               free(secret);
        return NULL;
 #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
@@ -26,7 +26,8 @@ newAssignment(MalBlkPtr mb)
        InstrPtr q = newInstruction(mb,NULL,NULL);
        int k;
 
-       assert(q);
+       if (q == NULL)
+               return NULL;
        k = newTmpVariable(mb,TYPE_any);
        if (k < 0) {
                // construct an exception message to be passed to upper layers 
using ->errors
@@ -46,7 +47,8 @@ newStmt(MalBlkPtr mb, const char *module
        str mName = putName(module), nName = putName(name);
 
        q = newInstruction(mb, mName, nName);
-       assert(q);
+       if (q == NULL)
+               return NULL;
        setDestVar(q, newTmpVariable(mb, TYPE_any));
        if (getDestVar(q) < 0 ){
                str msg = createException(MAL, "newStmt", "Can not allocate 
variable");
@@ -64,7 +66,8 @@ newStmtArgs(MalBlkPtr mb, const char *mo
        str mName = putName(module), nName = putName(name);
 
        q = newInstructionArgs(mb, mName, nName, args);
-       assert(q);
+       if (q == NULL)
+               return NULL;
 
        setDestVar(q, newTmpVariable(mb, TYPE_any));
        if (getDestVar(q) < 0 || mb->errors != MAL_SUCCEED) {
@@ -82,7 +85,8 @@ newReturnStmt(MalBlkPtr mb)
        InstrPtr q = newInstruction(mb, NULL, NULL);
        int k;
 
-       assert(q);
+       if (q == NULL)
+               return NULL;
        k = newTmpVariable(mb,TYPE_any);
        if (k < 0 ){
                str msg = createException(MAL, "newReturnStmt", "Can not 
allocate return variable");
@@ -115,7 +119,8 @@ newComment(MalBlkPtr mb, const char *val
        ValRecord cst;
        int k;
 
-       assert(q);
+       if (q == NULL)
+               return NULL;
        q->token = REMsymbol;
        q->barrier = 0;
        cst.vtype= TYPE_str;
@@ -143,7 +148,8 @@ newCatchStmt(MalBlkPtr mb, str nme)
        int i= findVariable(mb,nme);
        int k;
 
-       assert(q);
+       if (q == NULL)
+               return NULL;
        q->barrier = CATCHsymbol;
        if ( i< 0) {
                k = newVariable(mb, nme, strlen(nme),TYPE_str);
@@ -166,7 +172,8 @@ newRaiseStmt(MalBlkPtr mb, str nme)
        int i= findVariable(mb,nme);
        int k;
 
-       assert(q);
+       if (q == NULL)
+               return NULL;
        q->barrier = RAISEsymbol;
        if ( i< 0) {
                k = newVariable(mb, nme, strlen(nme),TYPE_str);
@@ -188,7 +195,8 @@ newExitStmt(MalBlkPtr mb, str nme)
        int i= findVariable(mb,nme);
        int k;
 
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to