Changeset: cdbf39ef7bdc for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=cdbf39ef7bdc
Modified Files:
        clients/mapiclient/msqldump.c
        clients/python2/monetdb/sql/pythonize.py
        clients/python2/test/capabilities.py
        clients/python3/monetdb/sql/pythonize.py
        clients/python3/test/capabilities.py
        common/stream/stream.c
        gdk/gdk.h
        gdk/gdk_heap.c
        gdk/gdk_logger.c
        gdk/gdk_posix.c
        gdk/gdk_private.h
        gdk/gdk_utils.c
        monetdb5/mal/mal_function.c
        monetdb5/modules/mal/mat.c
        monetdb5/modules/mal/tokenizer.c
        monetdb5/modules/mal/txtsim.c
        monetdb5/optimizer/opt_octopus.c
        monetdb5/optimizer/opt_wrapper.c
        monetdb5/scheduler/run_octopus.c
        sql/backends/monet5/sql.c
        sql/backends/monet5/sql_gencode.c
        sql/test/mapi/Tests/python2_test_monetdb_sql.stable.err
        sql/test/mapi/Tests/python3_test_monetdb_sql.stable.err
Branch: default
Log Message:

Merge with Jan2014 branch.


diffs (truncated from 1818 to 300 lines):

diff --git a/clients/mapiclient/msqldump.c b/clients/mapiclient/msqldump.c
--- a/clients/mapiclient/msqldump.c
+++ b/clients/mapiclient/msqldump.c
@@ -49,6 +49,7 @@
 #include "stream.h"
 #include "msqldump.h"
 #include "mprompt.h"
+#include "dotmonetdb.h"
 
 __declspec(noreturn) static void usage(const char *prog, int xit)
        __attribute__((__noreturn__));
@@ -92,8 +93,6 @@ main(int argc, char **argv)
        Mapi mid;
        int quiet = 0;
        stream *out;
-       struct stat statb;
-       stream *config = NULL;
        char user_set_as_flag = 0;
        char *table = NULL;
        static struct option long_options[] = {
@@ -111,71 +110,14 @@ main(int argc, char **argv)
                {0, 0, 0, 0}
        };
 
-       if (getenv("DOTMONETDBFILE") == NULL) {
-               if (stat(".monetdb", &statb) == 0) {
-                       config = open_rastream(".monetdb");
-               } else if (getenv("HOME") != NULL) {
-                       char buf[1024];
-                       snprintf(buf, sizeof(buf), "%s/.monetdb", 
getenv("HOME"));
-                       if (stat(buf, &statb) == 0) {
-                               config = open_rastream(buf);
-                       }
-               }
-       } else {
-               char *cfile = getenv("DOTMONETDBFILE");
-               if (strcmp(cfile, "") != 0) {
-                       if (stat(cfile, &statb) == 0) {
-                               config = open_rastream(cfile);
-                       } else {
-                               fprintf(stderr, "failed to open file '%s': 
%s\n",
-                                               cfile, strerror(errno));
-                       }
-               }
-       }
-
-       if (config != NULL) {
-               char buf[1024];
-               char *q;
-               ssize_t len;
-               int line = 0;
-               while ((len = mnstr_readline(config, buf, sizeof(buf) - 1)) > 
0) {
-                       line++;
-                       buf[len - 1] = '\0'; /* drop newline */
-                       if (buf[0] == '#' || buf[0] == '\0')
-                               continue;
-                       if ((q = strchr(buf, '=')) == NULL) {
-                               fprintf(stderr, "%s:%d: syntax error: %s\n",
-                                               mnstr_name(config), line, buf);
-                               continue;
-                       }
-                       *q++ = '\0';
-                       /* this basically sucks big time, as I can't easily set
-                        * a default, hence I only do things I think are useful
-                        * for now, needs a better solution */
-                       if (strcmp(buf, "user") == 0) {
-                               user = strdup(q); /* leak */
-                               q = NULL;
-                       } else if (strcmp(buf, "password") == 0 ||
-                                       strcmp(buf, "passwd") == 0)
-                       {
-                               passwd = strdup(q); /* leak */
-                               q = NULL;
-                       } else if (strcmp(buf, "language") == 0) {
-                               /* make sure we don't barf about this as unknown
-                                * property, it's supported by mclient */
-                               q = NULL;
-                       }
-                       if (q != NULL)
-                               fprintf(stderr, "%s:%d: unknown property: %s\n",
-                                               mnstr_name(config), line, buf);
-               }
-               mnstr_destroy(config);
-       }
+       parse_dotmonetdb(&user, &passwd, NULL, NULL, NULL, NULL);
 
        while ((c = getopt_long(argc, argv, "h:p:d:Dft:NXu:q?", long_options, 
NULL)) != -1) {
                switch (c) {
                case 'u':
-                       user = optarg;
+                       if (user)
+                               free(user);
+                       user = strdup(optarg);
                        user_set_as_flag = 1;
                        break;
                case 'h':
@@ -235,6 +177,10 @@ main(int argc, char **argv)
                passwd = simple_prompt("password", BUFSIZ, 0, NULL);
 
        mid = mapi_connect(host, port, user, passwd, "sql", dbname);
+       if (user)
+               free(user);
+       if (passwd)
+               free(passwd);
        if (mid == NULL) {
                fprintf(stderr, "failed to allocate Mapi structure\n");
                exit(2);
diff --git a/clients/python2/monetdb/sql/pythonize.py 
b/clients/python2/monetdb/sql/pythonize.py
--- a/clients/python2/monetdb/sql/pythonize.py
+++ b/clients/python2/monetdb/sql/pythonize.py
@@ -59,7 +59,7 @@ def py_timetz(data):
     """ returns a python Time where data contains a tz code
     """
     t, timezone_delta = _extract_timezone(data)
-    return (datetime.datetime.strptime(t, '%H:%M:%S') + timezone_delta).time()
+    return (datetime.datetime.strptime(t, '%H:%M:%S.%f') + 
timezone_delta).time()
 
 
 def py_date(data):
diff --git a/clients/python2/test/capabilities.py 
b/clients/python2/test/capabilities.py
--- a/clients/python2/test/capabilities.py
+++ b/clients/python2/test/capabilities.py
@@ -241,7 +241,7 @@ class DatabaseTest(unittest.TestCase):
                  ('col1 TIME',),
                  generator)
 
-    def test_TIME(self):
+    def test_TIMETZ(self):
         ticks = time()
         def generator(row,col):
             return self.db_module.TimeFromTicks(ticks+row*86400-col*1313)
diff --git a/clients/python3/monetdb/sql/pythonize.py 
b/clients/python3/monetdb/sql/pythonize.py
--- a/clients/python3/monetdb/sql/pythonize.py
+++ b/clients/python3/monetdb/sql/pythonize.py
@@ -63,7 +63,7 @@ def py_timetz(data):
     """ returns a python Time where data contains a tz code
     """
     t, timezone_delta = _extract_timezone(data)
-    return (datetime.datetime.strptime(t, '%H:%M:%S') + timezone_delta).time()
+    return (datetime.datetime.strptime(t, '%H:%M:%S.%f') + 
timezone_delta).time()
 
 
 def py_date(data):
diff --git a/clients/python3/test/capabilities.py 
b/clients/python3/test/capabilities.py
--- a/clients/python3/test/capabilities.py
+++ b/clients/python3/test/capabilities.py
@@ -241,7 +241,7 @@ class DatabaseTest(unittest.TestCase):
                  ('col1 TIME',),
                  generator)
 
-    def test_TIME(self):
+    def test_TIMETZ(self):
         ticks = time()
         def generator(row,col):
             return self.db_module.TimeFromTicks(ticks+row*86400-col*1313)
diff --git a/common/stream/stream.c b/common/stream/stream.c
--- a/common/stream/stream.c
+++ b/common/stream/stream.c
@@ -190,6 +190,8 @@ mnstr_init(void)
 ssize_t
 mnstr_read(stream *s, void *buf, size_t elmsize, size_t cnt)
 {
+       if (s == NULL)
+               return -1;
 #ifdef STREAM_DEBUG
        printf("read %s " SZFMT " " SZFMT "\n", s->name ? s->name : 
"<unnamed>", elmsize, cnt);
 #endif
@@ -207,6 +209,8 @@ mnstr_readline(stream *s, void *buf, siz
 {
        char *b = buf, *start = buf;
 
+       if (s == NULL)
+               return -1;
 #ifdef STREAM_DEBUG
        printf("readline %s " SZFMT "\n", s->name ? s->name : "<unnamed>", 
maxcnt);
 #endif
@@ -262,6 +266,8 @@ mnstr_readline(stream *s, void *buf, siz
 ssize_t
 mnstr_write(stream *s, const void *buf, size_t elmsize, size_t cnt)
 {
+       if (s == NULL || buf == NULL)
+               return -1;
 #ifdef STREAM_DEBUG
        printf("write %s " SZFMT " " SZFMT "\n", s->name ? s->name : 
"<unnamed>", elmsize, cnt);
 #endif
@@ -274,10 +280,12 @@ mnstr_write(stream *s, const void *buf, 
 void
 mnstr_settimeout(stream *s, unsigned int ms, int (*func)(void))
 {
-       s->timeout = ms;
-       s->timeout_func = func;
-       if (s->update_timeout)
-               (*s->update_timeout)(s);
+       if (s) {
+               s->timeout = ms;
+               s->timeout_func = func;
+               if (s->update_timeout)
+                       (*s->update_timeout)(s);
+       }
 }
 
 void
@@ -305,7 +313,7 @@ mnstr_destroy(stream *s)
 char *
 mnstr_error(stream *s)
 {
-       if (s == 0)
+       if (s == NULL)
                return "Connection terminated";
        return (*s->error) (s);
 }
@@ -314,7 +322,7 @@ mnstr_error(stream *s)
 int
 mnstr_flush(stream *s)
 {
-       if (!s)
+       if (s == NULL)
                return -1;
 #ifdef STREAM_DEBUG
        printf("flush %s\n", s->name ? s->name : "<unnamed>");
@@ -331,7 +339,7 @@ mnstr_flush(stream *s)
 int
 mnstr_fsync(stream *s)
 {
-       if (!s)
+       if (s == NULL)
                return -1;
 #ifdef STREAM_DEBUG
        printf("fsync %s (%d)\n", s->name ? s->name : "<unnamed>", s->errnr);
@@ -347,7 +355,7 @@ mnstr_fsync(stream *s)
 int
 mnstr_fgetpos(stream *s, lng *p)
 {
-       if (!s)
+       if (s == NULL)
                return -1;
 #ifdef STREAM_DEBUG
        printf("fgetpos %s\n", s->name ? s->name : "<unnamed>");
@@ -362,7 +370,7 @@ mnstr_fgetpos(stream *s, lng *p)
 int
 mnstr_fsetpos(stream *s, lng p)
 {
-       if (!s)
+       if (s == NULL)
                return -1;
 #ifdef STREAM_DEBUG
        printf("fsetpos %s\n", s->name ? s->name : "<unnamed>");
@@ -378,7 +386,7 @@ mnstr_fsetpos(stream *s, lng p)
 char *
 mnstr_name(stream *s)
 {
-       if (s == 0)
+       if (s == NULL)
                return "connection terminated";
        return s->name;
 }
@@ -386,7 +394,7 @@ mnstr_name(stream *s)
 int
 mnstr_errnr(stream *s)
 {
-       if (s == 0)
+       if (s == NULL)
                return MNSTR_READ_ERROR;
        return s->errnr;
 }
@@ -404,7 +412,7 @@ mnstr_clearerr(stream *s)
 int
 mnstr_type(stream *s)
 {
-       if (s == 0)
+       if (s == NULL)
                return 0;
        return s->type;
 }
@@ -412,7 +420,7 @@ mnstr_type(stream *s)
 int
 mnstr_byteorder(stream *s)
 {
-       if (s == 0)
+       if (s == NULL)
                return 0;
        return s->byteorder;
 }
@@ -420,6 +428,8 @@ mnstr_byteorder(stream *s)
 void
 mnstr_set_byteorder(stream *s, char bigendian)
 {
+       if (s == NULL)
+               return;
 #ifdef STREAM_DEBUG
        printf("mnstr_set_byteorder %s\n", s->name ? s->name : "<unnamed>");
 #endif
@@ -436,13 +446,17 @@ mnstr_set_byteorder(stream *s, char bige
 void
 close_stream(stream *s)
 {
-       s->close(s);
-       s->destroy(s);
+       if (s) {
+               s->close(s);
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to