Changeset: d9cd33c6f6f8 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d9cd33c6f6f8
Added Files:
        clients/mapilib/ChangeLog
        common/stream/ChangeLog
        sql/backends/monet5/datacell/Tests/datacell99.sql
        sql/backends/monet5/datacell/Tests/datacell99.stable.err
        sql/backends/monet5/datacell/Tests/datacell99.stable.out
        sql/backends/monet5/datacell/Tests/emili.sql
        sql/backends/monet5/datacell/Tests/emili.txt
        
sql/test/BugTracker-2014/Tests/crash_on_groupby_distinct_serial.Bug-3463.sql
        
sql/test/BugTracker-2014/Tests/crash_on_groupby_distinct_serial.Bug-3463.stable.err
        
sql/test/BugTracker-2014/Tests/crash_on_groupby_distinct_serial.Bug-3463.stable.out
        sql/test/BugTracker-2014/Tests/crash_on_or_with_in.Bug-3461.sql
        sql/test/BugTracker-2014/Tests/crash_on_or_with_in.Bug-3461.stable.err
        sql/test/BugTracker-2014/Tests/crash_on_or_with_in.Bug-3461.stable.out
        sql/test/BugTracker-2014/Tests/in_incorrect_multi.Bug-3462.sql
        sql/test/BugTracker-2014/Tests/in_incorrect_multi.Bug-3462.stable.err
        sql/test/BugTracker-2014/Tests/in_incorrect_multi.Bug-3462.stable.out
        sql/test/BugTracker-2014/Tests/select-having.Bug-3458.sql
        sql/test/BugTracker-2014/Tests/select-having.Bug-3458.stable.err
        sql/test/BugTracker-2014/Tests/select-having.Bug-3458.stable.out
        sql/test/BugTracker-2014/Tests/setreadonly_forgets_changes.Bug-3446.sql
        
sql/test/BugTracker-2014/Tests/setreadonly_forgets_changes.Bug-3446.stable.err
        
sql/test/BugTracker-2014/Tests/setreadonly_forgets_changes.Bug-3446.stable.out
Removed Files:
        sql/backends/monet5/datacell/Tests/emili/README
        sql/backends/monet5/datacell/Tests/emili/emili.sql
        sql/backends/monet5/datacell/Tests/emili/sensor.log.gz
        sql/backends/monet5/datacell/Tests/pair00.mal
        sql/backends/monet5/datacell/Tests/pair00.stable.err
        sql/backends/monet5/datacell/Tests/pair00.stable.out
        sql/backends/monet5/datacell/Tests/petrinet00.mal
        sql/backends/monet5/datacell/Tests/petrinet00.stable.err
        sql/backends/monet5/datacell/Tests/petrinet00.stable.out
Modified Files:
        clients/Tests/exports.stable.out
        clients/mapilib/mapi.c
        clients/odbc/driver/SQLConnect.c
        clients/odbc/driver/SQLSetConnectAttr.c
        common/stream/stream.c
        common/stream/stream.h
        gdk/gdk_atoms.c
        gdk/gdk_logger.c
        gdk/gdk_system.h
        gdk/gdk_system_private.h
        gdk/gdk_utils.c
        geom/monetdb5/geom.c
        geom/sql/Tests/All
        geom/sql/Tests/T13.sql
        geom/sql/Tests/T13.stable.out
        geom/sql/Tests/T14.sql
        geom/sql/Tests/T14.stable.out
        monetdb5/mal/mal_client.c
        monetdb5/mal/mal_session.c
        monetdb5/modules/atoms/blob.c
        monetdb5/modules/atoms/streams.c
        monetdb5/modules/mal/Tests/pqueue.mal
        monetdb5/modules/mal/Tests/pqueue.stable.out
        monetdb5/modules/mal/Tests/remote12.mal
        monetdb5/modules/mal/mal_mapi.c
        monetdb5/modules/mal/mal_mapi.h
        monetdb5/modules/mal/remote.c
        monetdb5/optimizer/opt_support.c
        sql/backends/monet5/datacell/50_datacell.sql
        sql/backends/monet5/datacell/Tests/All
        sql/backends/monet5/datacell/Tests/basket00.stable.err
        sql/backends/monet5/datacell/Tests/basket00.stable.out
        sql/backends/monet5/datacell/Tests/datacell00.sql
        sql/backends/monet5/datacell/Tests/datacell00.stable.err
        sql/backends/monet5/datacell/Tests/datacell00.stable.out
        sql/backends/monet5/datacell/Tests/dcload.sql
        sql/backends/monet5/datacell/Tests/dcload.stable.err
        sql/backends/monet5/datacell/Tests/dctemper00.stable.err
        sql/backends/monet5/datacell/Tests/dctemper00.stable.out
        sql/backends/monet5/datacell/Tests/emitter00.stable.err
        sql/backends/monet5/datacell/Tests/emitter00.stable.out
        sql/backends/monet5/datacell/Tests/receptor00.stable.err
        sql/backends/monet5/datacell/Tests/receptor00.stable.out
        sql/backends/monet5/datacell/Tests/scenario01.stable.out
        sql/backends/monet5/datacell/Tests/scenario02.stable.out
        sql/backends/monet5/datacell/Tests/scenario04.stable.out
        sql/backends/monet5/datacell/Tests/scenario05.stable.out
        sql/backends/monet5/datacell/Tests/scenario06.stable.err
        sql/backends/monet5/datacell/Tests/scenario06.stable.out
        sql/backends/monet5/datacell/basket.c
        sql/backends/monet5/datacell/datacell.c
        sql/backends/monet5/datacell/datacell.h
        sql/backends/monet5/datacell/datacell.mal
        sql/backends/monet5/datacell/dcsocket.c
        sql/backends/monet5/datacell/emitter.c
        sql/backends/monet5/datacell/petrinet.c
        sql/backends/monet5/datacell/receptor.c
        sql/backends/monet5/datacell/receptor.mal
        sql/backends/monet5/datacell/sensor.c
        sql/backends/monet5/rel_bin.c
        sql/backends/monet5/sql.c
        sql/backends/monet5/sql_gencode.c
        sql/backends/monet5/sql_gencode.h
        sql/backends/monet5/sql_scenario.c
        sql/benchmarks/tpch/Tests/01-explain.stable.out.32bit
        sql/benchmarks/tpch/Tests/20-explain.stable.out
        sql/benchmarks/tpch/Tests/20-explain.stable.out.32bit
        sql/rel.txt
        sql/server/rel_optimizer.c
        sql/server/rel_select.c
        sql/test/BugTracker-2014/Tests/All
        testing/Mfilter.py.in
Branch: multifarm
Log Message:

Merge with default branch.


diffs (truncated from 4703 to 300 lines):

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
@@ -311,7 +311,6 @@ size_t MT_getrss(void);
 void MT_global_exit(int status) __attribute__((__noreturn__));
 void MT_init(void);
 int MT_join_thread(MT_Id t);
-int MT_kill_thread(MT_Id t);
 int MT_lockf(char *filename, int mode, off_t off, off_t len);
 MT_Id MT_locktrace;
 unsigned long long MT_locktrace_cnt[65536];
@@ -1996,7 +1995,6 @@ str SERVERdisconnectALL(int *ret);
 str SERVERdisconnectWithAlias(int *ret, str *db_alias);
 str SERVERerror(int *ret, int *idx);
 str SERVERexecute(int *ret, int *idx);
-void SERVERexit(void);
 str SERVERexplain(str *ret, int *idx);
 str SERVERfetch_all_rows(lng *ret, int *idx);
 str SERVERfetch_field_bat(int *bid, int *idx);
@@ -2987,7 +2985,7 @@ ssize_t mnstr_read_block(stream *s, void
 ssize_t mnstr_readline(stream *s, void *buf, size_t maxcnt);
 stream *mnstr_rstream(stream *s);
 void mnstr_set_byteorder(stream *s, char bigendian);
-void mnstr_settimeout(stream *s, unsigned int secs);
+void mnstr_settimeout(stream *s, unsigned int ms, int( *func)(void));
 int mnstr_type(stream *s);
 ssize_t mnstr_write(stream *s, const void *buf, size_t elmsize, size_t cnt);
 int mnstr_writeBte(stream *s, signed char val);
diff --git a/clients/mapilib/ChangeLog b/clients/mapilib/ChangeLog
new file mode 100644
--- /dev/null
+++ b/clients/mapilib/ChangeLog
@@ -0,0 +1,6 @@
+# ChangeLog file for mapilib
+# This file is updated with Maddlog
+
+* Fri Mar 28 2014 Sjoerd Mullender <[email protected]>
+- Changed mapi_timeout argument from seconds to milliseconds.
+
diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -2988,8 +2988,8 @@ mapi_timeout(Mapi mid, unsigned int time
        mapi_check(mid, "mapi_timeout");
        if (mid->trace == MAPI_TRACE)
                printf("Set timeout to %u\n", timeout);
-       mnstr_settimeout(mid->to, timeout);
-       mnstr_settimeout(mid->from, timeout);
+       mnstr_settimeout(mid->to, timeout, NULL);
+       mnstr_settimeout(mid->from, timeout, NULL);
        return MOK;
 }
 
diff --git a/clients/odbc/driver/SQLConnect.c b/clients/odbc/driver/SQLConnect.c
--- a/clients/odbc/driver/SQLConnect.c
+++ b/clients/odbc/driver/SQLConnect.c
@@ -267,7 +267,7 @@ SQLConnect_(ODBCDbc *dbc,
                    (dbc->major == 11 && dbc->minor >= 5))
                        mapi_set_size_header(mid, 1);
                /* set timeout after we're connected */
-               mapi_timeout(mid, dbc->sql_attr_connection_timeout);
+               mapi_timeout(mid, dbc->sql_attr_connection_timeout * 1000);
        }
 
        return rc;
diff --git a/clients/odbc/driver/SQLSetConnectAttr.c 
b/clients/odbc/driver/SQLSetConnectAttr.c
--- a/clients/odbc/driver/SQLSetConnectAttr.c
+++ b/clients/odbc/driver/SQLSetConnectAttr.c
@@ -99,7 +99,7 @@ SQLSetConnectAttr_(ODBCDbc *dbc,
        case SQL_ATTR_CONNECTION_TIMEOUT:
                dbc->sql_attr_connection_timeout = (SQLUINTEGER) (size_t) 
ValuePtr;
                if (dbc->mid)
-                       mapi_timeout(dbc->mid, 
dbc->sql_attr_connection_timeout);
+                       mapi_timeout(dbc->mid, dbc->sql_attr_connection_timeout 
* 1000);
                break;
        case SQL_ATTR_TXN_ISOLATION:
                /* nothing to change, we only do the highest level */
diff --git a/common/stream/ChangeLog b/common/stream/ChangeLog
new file mode 100644
--- /dev/null
+++ b/common/stream/ChangeLog
@@ -0,0 +1,10 @@
+# ChangeLog file for stream
+# This file is updated with Maddlog
+
+* Fri Mar 28 2014 Sjoerd Mullender <[email protected]>
+- Changed mnstr_settimeout function so that the specified timeout is now
+  in milliseconds (used to be seconds), and that it also needs an extra
+  argument specifying a callback function (no arguments, int result)
+  that should return TRUE if the timeout should cause the function to
+  abort or continue what it was doing.
+
diff --git a/common/stream/stream.c b/common/stream/stream.c
--- a/common/stream/stream.c
+++ b/common/stream/stream.c
@@ -141,7 +141,8 @@ struct stream {
        char isutf8;            /* known to be UTF-8 due to BOM */
        short type;             /* ascii/binary */
        char *name;
-       unsigned int timeout;
+       unsigned int timeout;      /* timeout in ms */
+       int (*timeout_func)(void); /* callback function: NULL/true -> return */
        union {
                void *p;
                int i;
@@ -149,9 +150,9 @@ struct stream {
        } stream_data;
        int errnr;
        ssize_t (*read) (stream *s, void *buf, size_t elmsize, size_t cnt);
-       ssize_t (*readline) (stream *s, void *buf, size_t maxcnt);
        ssize_t (*write) (stream *s, const void *buf, size_t elmsize, size_t 
cnt);
        void (*close) (stream *s);
+       void (*clrerr) (stream *s);
        char *(*error) (stream *s);
        void (*destroy) (stream *s);
        int (*flush) (stream *s);
@@ -198,30 +199,61 @@ mnstr_read(stream *s, void *buf, size_t 
        return (*s->read) (s, buf, elmsize, cnt);
 }
 
-/* Read one line (seperated by \n) of atmost maxcnt characters from
+/* Read one line (seperated by \n) of at most maxcnt-1 characters from
  * the stream.  Returns the number of characters actually read,
- * includes the trailing \n */
+ * includes the trailing \n; terminated by a NULL byte. */
 ssize_t
 mnstr_readline(stream *s, void *buf, size_t maxcnt)
 {
+       char *b = buf, *start = buf;
+
 #ifdef STREAM_DEBUG
        printf("readline %s " SZFMT "\n", s->name ? s->name : "<unnamed>", 
maxcnt);
 #endif
        assert(s->access == ST_READ);
        if (s->errnr)
                return -1;
-       if (!s->readline) {
-               size_t len = 0;
-               char *b = buf, *start = buf;
-               while ((*s->read) (s, start, 1, 1) > 0 && len < maxcnt) {
-                       if (*start++ == '\n')
-                               break;
+       if (maxcnt == 0)
+               return 0;
+       if (maxcnt == 1) {
+               *start = 0;
+               return 0;
+       }
+       for (;;) {
+               switch ((*s->read)(s, start, 1, 1)) {
+               case 1:
+                       /* successfully read a character,
+                        * check whether it is the line
+                        * separator and whether we have space
+                        * left for more */
+                       if (*start++ == '\n' || --maxcnt == 1) {
+                               *start = 0;
+#if 0
+                               if (s->type == ST_ASCII &&
+                                   start[-1] == '\n' &&
+                                   start > b + 1 &&
+                                   start[-2] == '\r') {
+                                       /* convert CR-LF to just LF */
+                                       start[-2] = start[-1];
+                                       start--;
+                               }
+#endif
+                               return (ssize_t) (start - b);
+                       }
+                       break;
+               case -1:
+                       /* error: if we didn't read anything yet,
+                        * return the error, otherwise return what we
+                        * have */
+                       if (start == b)
+                               return -1;
+                       /* fall through */
+               case 0:
+                       /* end of file: return what we have */
+                       *start = 0;
+                       return (ssize_t) (start - b);
                }
-               if (s->errnr)
-                       return -1;
-               return (ssize_t) (start - b);
-       } else
-               return (*s->readline) (s, buf, maxcnt);
+       }
 }
 
 /* Write cnt elements of size elmsize to the stream.  Returns the
@@ -240,9 +272,10 @@ mnstr_write(stream *s, const void *buf, 
 }
 
 void
-mnstr_settimeout(stream *s, unsigned int secs)
+mnstr_settimeout(stream *s, unsigned int ms, int (*func)(void))
 {
-       s->timeout = secs;
+       s->timeout = ms;
+       s->timeout_func = func;
        if (s->update_timeout)
                (*s->update_timeout)(s);
 }
@@ -361,8 +394,11 @@ mnstr_errnr(stream *s)
 void
 mnstr_clearerr(stream *s)
 {
-       if (s != NULL)
+       if (s != NULL) {
                s->errnr = MNSTR_NO__ERROR;
+               if (s->clrerr)
+                       (*s->clrerr) (s);
+       }
 }
 
 int
@@ -461,6 +497,9 @@ error(stream *s)
        case MNSTR_WRITE_ERROR:
                snprintf(buf, BUFSIZ, "error writing file %s\n", s->name);
                return strdup(buf);
+       case MNSTR_TIMEOUT:
+               snprintf(buf, BUFSIZ, "timeout on %s\n", s->name);
+               return strdup(buf);
        }
        return strdup("Unknown error");
 }
@@ -481,9 +520,9 @@ create_stream(const char *name)
        s->errnr = MNSTR_NO__ERROR;
        s->stream_data.p = NULL;
        s->read = NULL;
-       s->readline = NULL;
        s->write = NULL;
        s->close = NULL;
+       s->clrerr = NULL;
        s->error = error;
        s->destroy = destroy;
        s->flush = NULL;
@@ -491,6 +530,7 @@ create_stream(const char *name)
        s->fgetpos = NULL;
        s->fsetpos = NULL;
        s->timeout = 0;
+       s->timeout_func = NULL;
        s->update_timeout = NULL;
 #ifdef STREAM_DEBUG
        printf("create_stream %s -> " PTRFMT "\n", name ? name : "<unnamed>", 
PTRFMTCAST s);
@@ -508,8 +548,9 @@ file_read(stream *s, void *buf, size_t e
        size_t rc = 0;
 
        if (!feof(fp)) {
-               rc = fread(buf, elmsize, cnt, fp);
-               if (ferror(fp)) {
+               if (ferror(fp) ||
+                   ((rc = fread(buf, elmsize, cnt, fp)) == 0 &&
+                    ferror(fp))) {
                        s->errnr = MNSTR_READ_ERROR;
                        return -1;
                }
@@ -549,6 +590,14 @@ file_close(stream *s)
        s->stream_data.p = NULL;
 }
 
+static void
+file_clrerr(stream *s)
+{
+       FILE *fp = (FILE *) s->stream_data.p;
+
+       clearerr(fp);
+}
+
 static int
 file_flush(stream *s)
 {
@@ -645,9 +694,9 @@ open_stream(const char *filename, const 
        if ((fp = fopen(filename, flags)) == NULL)
                s->errnr = MNSTR_OPEN_ERROR;
        s->read = file_read;
-       s->readline = NULL;
        s->write = file_write;
        s->close = file_close;
+       s->clrerr = file_clrerr;
        s->flush = file_flush;
        s->fsync = file_fsync;
        s->fgetpos = file_fgetpos;
@@ -1455,73 +1504,84 @@ socket_write(stream *s, const void *buf,
                ((nr = write(s->stream_data.s, ((const char *) buf + res),
                             size - res)) > 0)
 #endif
-               || (s->timeout == 0
-                   && (errno == EAGAIN || errno == EWOULDBLOCK))
-               || errno == EINTR)
+               || (nr < 0 &&   /* syscall failed */
+                   s->timeout > 0 && /* potentially timeout */
+                   (errno == EAGAIN || errno == EWOULDBLOCK) && /* it was! */
+                   s->timeout_func != NULL && /* callback function exists */
+                   !(*s->timeout_func)())     /* callback says don't stop */
+               || (nr < 0 && errno == EINTR)) /* interrupted */
                ) {
                errno = 0;
                if (nr > 0)
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to