Changeset: d1b768b571ab for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d1b768b571ab
Modified Files:
        clients/Tests/MAL-signatures.stable.out
        clients/Tests/MAL-signatures.stable.out.int128
        sql/common/sql_types.c
        sql/server/rel_psm.c
        sql/test/miscellaneous/Tests/simple_selects.stable.err
        tools/monetdbe/monetdbe.c
Branch: scoping2
Log Message:

Merged with default


diffs (truncated from 33641 to 300 lines):

diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -161,16 +161,13 @@ BuildRequires: pkgconfig(libR)
 BuildRequires: texlive-obsolete
 %endif
 %endif
-# if we were to compile with cmocka support (-DWITH_CMOCKA=ON):
-# BuildRequires: pkgconfig(cmocka)
-# if we were to compile with NetCDF support (-DNETCDF=ON):
-# BuildRequires: pkgconfig(netcdf)
-# if we were to compile with proj support (-DWITH_PROJ=ON):
-# BuildRequires: pkgconfig(proj)
-# if we were to compile with snappy support (-DWITH_SNAPPY=ON):
-# BuildRequires: pkgconfig(snappy)
-# if we were to compile with valgrind support (-DWITH_VALGRIND=ON):
-# BuildRequires: pkgconfig(valgrind)
+# optional packages:
+# BuildRequires: pkgconfig(cmocka)     # -DWITH_CMOCKA=ON
+# BuildRequires: pkgconfig(gdal)       # -DSHP=ON
+# BuildRequires: pkgconfig(netcdf)     # -DNETCDF=ON
+# BuildRequires: pkgconfig(proj)       # -DWITH_PROJ=ON
+# BuildRequires: pkgconfig(snappy)     # -DWITH_SNAPPY=ON
+# BuildRequires: pkgconfig(valgrind)   # -DWITH_VALGRIND=ON
 
 %if (0%{?fedora} >= 22)
 Recommends: %{name}-SQL-server5%{?_isa} = %{version}-%{release}
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
@@ -6259,6 +6259,8 @@ stdout of test 'MAL-signatures` in direc
 [ "batmtime",  "timestamp_to_str",     "pattern 
batmtime.timestamp_to_str(X_1:timestamp, X_2:bat[:str], 
X_3:bat[:oid]):bat[:str] ",    "MTIMEtimestamp_to_str_bulk_p1;",       ""      ]
 [ "batmtime",  "timestamp_to_str",     "pattern 
batmtime.timestamp_to_str(X_1:bat[:timestamp], X_2:str):bat[:str] ",   
"MTIMEtimestamp_to_str_bulk_p2;",       ""      ]
 [ "batmtime",  "timestamp_to_str",     "pattern 
batmtime.timestamp_to_str(X_1:bat[:timestamp], X_2:str, 
X_3:bat[:oid]):bat[:str] ",    "MTIMEtimestamp_to_str_bulk_p2;",       ""      ]
+[ "batmtime",  "usweekofyear", "pattern 
batmtime.usweekofyear(X_1:bat[:date]):bat[:int] ",     
"MTIMEdate_extract_usweekofyear_bulk;", ""      ]
+[ "batmtime",  "usweekofyear", "pattern batmtime.usweekofyear(X_1:bat[:date], 
X_2:bat[:oid]):bat[:int] ",      "MTIMEdate_extract_usweekofyear_bulk;", ""     
 ]
 [ "batmtime",  "weekofyear",   "pattern 
batmtime.weekofyear(X_1:bat[:date]):bat[:int] ",       
"MTIMEdate_extract_weekofyear_bulk;",   ""      ]
 [ "batmtime",  "weekofyear",   "pattern batmtime.weekofyear(X_1:bat[:date], 
X_2:bat[:oid]):bat[:int] ",        "MTIMEdate_extract_weekofyear_bulk;",   ""   
   ]
 [ "batmtime",  "year", "pattern batmtime.year(X_1:bat[:date]):bat[:int] ",     
"MTIMEdate_extract_year_bulk;", ""      ]
@@ -9089,6 +9091,7 @@ stdout of test 'MAL-signatures` in direc
 [ "mtime",     "timestamp_sub_month_interval", "command 
mtime.timestamp_sub_month_interval(X_1:timestamp, X_2:int):timestamp ",        
"MTIMEtimestamp_sub_month_interval;",   ""      ]
 [ "mtime",     "timestamp_sub_msec_interval",  "command 
mtime.timestamp_sub_msec_interval(X_1:timestamp, X_2:lng):timestamp ", 
"MTIMEtimestamp_sub_msec_interval;",    ""      ]
 [ "mtime",     "timestamp_to_str",     "command 
mtime.timestamp_to_str(X_1:timestamp, X_2:str):str ",  
"MTIMEtimestamp_to_str;",       ""      ]
+[ "mtime",     "usweekofyear", "command mtime.usweekofyear(X_1:date):int ",    
"MTIMEdate_extract_usweekofyear;",      ""      ]
 [ "mtime",     "weekofyear",   "command mtime.weekofyear(X_1:date):int ",      
"MTIMEdate_extract_weekofyear;",        ""      ]
 [ "mtime",     "year", "command mtime.year(X_1:date):int ",    
"MTIMEdate_extract_year;",      ""      ]
 [ "mtime",     "year", "command mtime.year(X_1:int):int ",     
"MTIMEsql_year;",       ""      ]
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
@@ -8789,6 +8789,8 @@ stdout of test 'MAL-signatures` in direc
 [ "batmtime",  "timestamp_to_str",     "pattern 
batmtime.timestamp_to_str(X_1:timestamp, X_2:bat[:str], 
X_3:bat[:oid]):bat[:str] ",    "MTIMEtimestamp_to_str_bulk_p1;",       ""      ]
 [ "batmtime",  "timestamp_to_str",     "pattern 
batmtime.timestamp_to_str(X_1:bat[:timestamp], X_2:str):bat[:str] ",   
"MTIMEtimestamp_to_str_bulk_p2;",       ""      ]
 [ "batmtime",  "timestamp_to_str",     "pattern 
batmtime.timestamp_to_str(X_1:bat[:timestamp], X_2:str, 
X_3:bat[:oid]):bat[:str] ",    "MTIMEtimestamp_to_str_bulk_p2;",       ""      ]
+[ "batmtime",  "usweekofyear", "pattern 
batmtime.usweekofyear(X_1:bat[:date]):bat[:int] ",     
"MTIMEdate_extract_usweekofyear_bulk;", ""      ]
+[ "batmtime",  "usweekofyear", "pattern batmtime.usweekofyear(X_1:bat[:date], 
X_2:bat[:oid]):bat[:int] ",      "MTIMEdate_extract_usweekofyear_bulk;", ""     
 ]
 [ "batmtime",  "weekofyear",   "pattern 
batmtime.weekofyear(X_1:bat[:date]):bat[:int] ",       
"MTIMEdate_extract_weekofyear_bulk;",   ""      ]
 [ "batmtime",  "weekofyear",   "pattern batmtime.weekofyear(X_1:bat[:date], 
X_2:bat[:oid]):bat[:int] ",        "MTIMEdate_extract_weekofyear_bulk;",   ""   
   ]
 [ "batmtime",  "year", "pattern batmtime.year(X_1:bat[:date]):bat[:int] ",     
"MTIMEdate_extract_year_bulk;", ""      ]
@@ -12391,6 +12393,7 @@ stdout of test 'MAL-signatures` in direc
 [ "mtime",     "timestamp_sub_month_interval", "command 
mtime.timestamp_sub_month_interval(X_1:timestamp, X_2:int):timestamp ",        
"MTIMEtimestamp_sub_month_interval;",   ""      ]
 [ "mtime",     "timestamp_sub_msec_interval",  "command 
mtime.timestamp_sub_msec_interval(X_1:timestamp, X_2:lng):timestamp ", 
"MTIMEtimestamp_sub_msec_interval;",    ""      ]
 [ "mtime",     "timestamp_to_str",     "command 
mtime.timestamp_to_str(X_1:timestamp, X_2:str):str ",  
"MTIMEtimestamp_to_str;",       ""      ]
+[ "mtime",     "usweekofyear", "command mtime.usweekofyear(X_1:date):int ",    
"MTIMEdate_extract_usweekofyear;",      ""      ]
 [ "mtime",     "weekofyear",   "command mtime.weekofyear(X_1:date):int ",      
"MTIMEdate_extract_weekofyear;",        ""      ]
 [ "mtime",     "year", "command mtime.year(X_1:date):int ",    
"MTIMEdate_extract_year;",      ""      ]
 [ "mtime",     "year", "command mtime.year(X_1:int):int ",     
"MTIMEsql_year;",       ""      ]
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
@@ -461,6 +461,7 @@ ssize_t date_fromstr(const char *buf, si
 int date_month(date dt) __attribute__((__const__));
 int date_quarter(date dt) __attribute__((__const__));
 ssize_t date_tostr(str *buf, size_t *len, const date *val, bool external);
+int date_usweekofyear(date dt) __attribute__((__const__));
 int date_weekofyear(date dt) __attribute__((__const__));
 int date_year(date dt) __attribute__((__const__));
 daytime daytime_add_usec(daytime tm, lng usec) __attribute__((__const__));
diff --git a/clients/mapiclient/ReadlineTools.c 
b/clients/mapiclient/ReadlineTools.c
--- a/clients/mapiclient/ReadlineTools.c
+++ b/clients/mapiclient/ReadlineTools.c
@@ -23,6 +23,12 @@
 #include <strings.h>           /* for strncasecmp */
 #endif
 
+#ifndef WIN32
+/* for umask */
+#include <sys/types.h>
+#include <sys/stat.h>
+#endif
+
 static const char *sql_commands[] = {
        "SELECT",
        "INSERT",
@@ -313,37 +319,40 @@ invoke_editor(int cnt, int key) {
        char *read_buff = NULL;
        char *editor = NULL;
        FILE *fp = NULL;
-       size_t content_len;
+       long content_len;
        size_t read_bytes, idx;
-#ifdef WIN32
-       char *mytemp;
-       char template[] = "mclient_temp_XXXXXX";
-#else
-       int mytemp;
-       char template[] = "/tmp/mclient_temp_XXXXXX";
-#endif
 
        (void) cnt;
        (void) key;
 
 #ifdef WIN32
+       char *mytemp;
+       char template[] = "mclient_temp_XXXXXX";
        if ((mytemp = _mktemp(template)) == NULL) {
-#else
-       if ((mytemp = mkstemp(template)) == 0) {
-#endif
                readline_show_error("invoke_editor: Cannot create temp file\n");
                goto bailout;
        }
-
-#ifdef WIN32
        if ((fp = fopen(mytemp, "r+")) == NULL) {
-#else
-       if ((fp = fdopen(mytemp, "r+")) == NULL) {
-#endif
                // Notify the user that we cannot create temp file
                readline_show_error("invoke_editor: Cannot create temp file\n");
                goto bailout;
        }
+#else
+       int mytemp;
+       char template[] = "/tmp/mclient_temp_XXXXXX";
+       mode_t msk = umask(077);
+       mytemp = mkstemp(template);
+       (void) umask(msk);
+       if (mytemp == -1) {
+               readline_show_error("invoke_editor: Cannot create temp file\n");
+               goto bailout;
+       }
+       if ((fp = fdopen(mytemp, "r+")) == NULL) {
+               // Notify the user that we cannot create temp file
+               readline_show_error("invoke_editor: Cannot create temp file\n");
+               goto bailout;
+       }
+#endif
 
        fwrite(rl_line_buffer, sizeof(char), rl_end, fp);
        fflush(fp);
@@ -368,24 +377,24 @@ invoke_editor(int cnt, int key) {
        rewind(fp);
 
        if (content_len > 0) {
-               read_buff = (char *)malloc(content_len*sizeof(char));
+               read_buff = (char *)malloc(content_len + 1);
                if (read_buff == NULL) {
                        readline_show_error("invoke_editor: Cannot allocate 
memory\n");
                        goto bailout;
                }
 
-               read_bytes = fread(read_buff, sizeof(char), content_len, fp);
-               if (read_bytes != content_len) {
+               read_bytes = fread(read_buff, sizeof(char), (size_t) 
content_len, fp);
+               if (read_bytes != (size_t) content_len) {
                        readline_show_error("invoke_editor: Did not read from 
file correctly\n");
                        goto bailout;
                }
 
-               *(read_buff + read_bytes) = 0;
+               read_buff[read_bytes] = 0;
 
                /* Remove trailing whitespace */
                idx = read_bytes - 1;
                while(isspace(*(read_buff + idx))) {
-                       *(read_buff + idx) = 0;
+                       read_buff[idx] = 0;
                        idx--;
                }
 
@@ -404,7 +413,8 @@ invoke_editor(int cnt, int key) {
        return 0;
 
 bailout:
-       fclose(fp);
+       if (fp)
+               fclose(fp);
        free(read_buff);
        unlink(template);
        return 1;
diff --git a/clients/mapiclient/msqldump.c b/clients/mapiclient/msqldump.c
--- a/clients/mapiclient/msqldump.c
+++ b/clients/mapiclient/msqldump.c
@@ -256,7 +256,9 @@ main(int argc, char **argv)
 
        mapi_destroy(mid);
        if (mnstr_errnr(out)) {
-               fprintf(stderr, "%s: %s\n", argv[0], mnstr_error(out));
+               char *err = mnstr_error(out);
+               fprintf(stderr, "%s: %s\n", argv[0], err);
+               free(err);
                return 1;
        }
 
diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -1546,7 +1546,9 @@ close_result(MapiHdl hdl)
                                if (mnstr_printf(mid->to, "%s", msg) < 0 ||
                                    mnstr_flush(mid->to, MNSTR_FLUSH_DATA)) {
                                        close_connection(mid);
-                                       mapi_setError(mid, 
mnstr_error(mid->to), __func__, MTIMEOUT);
+                                       char *err = mnstr_error(mid->to);
+                                       mapi_setError(mid, err, __func__, 
MTIMEOUT);
+                                       free(err);
                                        break;
                                }
                                read_into_cache(hdl, 0);
@@ -1564,7 +1566,9 @@ close_result(MapiHdl hdl)
                                if (mnstr_printf(mid->to, "%s", msg) < 0 ||
                                    mnstr_flush(mid->to, MNSTR_FLUSH_DATA)) {
                                        close_connection(mid);
-                                       mapi_setError(mid, 
mnstr_error(mid->to), __func__, MTIMEOUT);
+                                       char *err = mnstr_error(mid->to);
+                                       mapi_setError(mid, err, __func__, 
MTIMEOUT);
+                                       free(err);
                                } else
                                        read_into_cache(hdl, 0);
                        }
@@ -1788,7 +1792,9 @@ finish_handle(MapiHdl hdl)
                        if (mnstr_printf(mid->to, "%s", msg) < 0 ||
                            mnstr_flush(mid->to, MNSTR_FLUSH_DATA)) {
                                close_connection(mid);
-                               mapi_setError(mid, mnstr_error(mid->to), 
__func__, MTIMEOUT);
+                               char *err = mnstr_error(mid->to);
+                               mapi_setError(mid, err, __func__, MTIMEOUT);
+                               free(err);
                                break;
                        }
                        read_into_cache(hdl, 0);
@@ -2985,22 +2991,24 @@ mapi_resolve(const char *host, int port,
                return NULL;
 
        mid = mapi_mapi(host, port, "mero", "mero", "resolve", pattern);
-       if (mid && mid->error == MOK) {
-               rmax = mid->redirmax;
-               mid->redirmax = 0;
-               mapi_reconnect(mid);    /* real connect, don't follow redirects 
*/
-               mid->redirmax = rmax;
+       if (mid) {
                if (mid->error == MOK) {
-                       close_connection(mid);  /* we didn't expect a 
connection actually */
-               } else {
-                       char **ret = malloc(sizeof(char *) * MAXREDIR);
-                       memcpy(ret, mid->redirects, sizeof(char *) * MAXREDIR);
-                       mid->redirects[0] = NULL;       /* make sure the 
members aren't freed */
-                       mapi_destroy(mid);
-                       return ret;
+                       rmax = mid->redirmax;
+                       mid->redirmax = 0;
+                       mapi_reconnect(mid);    /* real connect, don't follow 
redirects */
+                       mid->redirmax = rmax;
+                       if (mid->error == MOK) {
+                               close_connection(mid);  /* we didn't expect a 
connection actually */
+                       } else {
+                               char **ret = malloc(sizeof(char *) * MAXREDIR);
+                               memcpy(ret, mid->redirects, sizeof(char *) * 
MAXREDIR);
+                               mid->redirects[0] = NULL;       /* make sure 
the members aren't freed */
+                               mapi_destroy(mid);
+                               return ret;
+                       }
                }
+               mapi_destroy(mid);
        }
-       mapi_destroy(mid);
        return NULL;
 }
 
@@ -3306,7 +3314,9 @@ mapi_Xcommand(Mapi mid, const char *cmdn
        if (mnstr_printf(mid->to, "X" "%s %s\n", cmdname, cmdvalue) < 0 ||
            mnstr_flush(mid->to, MNSTR_FLUSH_DATA)) {
                close_connection(mid);
-               mapi_setError(mid, mnstr_error(mid->to), __func__, MTIMEOUT);
+               char *err = mnstr_error(mid->to);
+               mapi_setError(mid, err, __func__, MTIMEOUT);
+               free(err);
                return MERROR;
        }
        if (mid->tracelog) {
@@ -4569,7 +4579,9 @@ mapi_cache_limit(Mapi mid, int limit)
                if (mnstr_printf(mid->to, "X" "reply_size %d\n", limit) < 0 ||
                    mnstr_flush(mid->to, MNSTR_FLUSH_DATA)) {
                        close_connection(mid);
-                       mapi_setError(mid, mnstr_error(mid->to), __func__, 
MTIMEOUT);
+                       char *err = mnstr_error(mid->to);
+                       mapi_setError(mid, err, __func__, MTIMEOUT);
+                       free(err);
                        return MERROR;
                }
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to