Changeset: 38152883cf31 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=38152883cf31
Modified Files:
        sql/storage/store.c
Branch: mmt
Log Message:

merged with Oct2020


diffs (truncated from 2236 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/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
@@ -1538,7 +1538,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);
@@ -1556,7 +1558,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);
                        }
@@ -1780,7 +1784,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);
@@ -2977,22 +2983,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;
 }
 
@@ -3292,7 +3300,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) {
@@ -4543,7 +4553,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;
                }
                hdl = prepareQuery(mapi_new_handle(mid), "reply_size");
diff --git a/clients/odbc/winsetup/install.c b/clients/odbc/winsetup/install.c
--- a/clients/odbc/winsetup/install.c
+++ b/clients/odbc/winsetup/install.c
@@ -18,10 +18,10 @@
 #define DLL ".dll"
 #endif
 
-static char *DriverName = "MonetDB ODBC Driver";
-static char *DataSourceName = "MonetDB";
-static char *DriverDLL = "MonetODBC" DLL;
-static char *DriverDLLs = "MonetODBCs" DLL;
+static const char *DriverName = "MonetDB ODBC Driver";
+static const char *DataSourceName = "MonetDB";
+static const char *DriverDLL = "MonetODBC" DLL;
+static const char *DriverDLLs = "MonetODBCs" DLL;
 
 /* General error handler for installer functions */
 
@@ -38,10 +38,10 @@ ProcessSQLErrorMessages(const char *func
        do {
                errmsg[0] = '\0';
                rc = SQLInstallerError(errnr, &errcode,
-                                      errmsg, sizeof(errmsg), &errmsglen);
+                                                          errmsg, 
sizeof(errmsg), &errmsglen);
                if (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO) {
                        MessageBox(NULL, errmsg, func,
-                                  MB_ICONSTOP | MB_OK | MB_TASKMODAL | 
MB_SETFOREGROUND);
+                                          MB_ICONSTOP | MB_OK | MB_TASKMODAL | 
MB_SETFOREGROUND);
                        func_rc = TRUE;
                }
                errnr++;
@@ -55,8 +55,8 @@ ProcessSysErrorMessage(DWORD err, const 
        char *lpMsgBuf;
 
        FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | 
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
-                     NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
-                     (LPTSTR) & lpMsgBuf, 0, NULL);
+                                 NULL, err, MAKELANGID(LANG_NEUTRAL, 
SUBLANG_DEFAULT),
+                                 (LPTSTR) & lpMsgBuf, 0, NULL);
        MessageBox(NULL, (LPCTSTR) lpMsgBuf, func, MB_OK | MB_ICONINFORMATION);
        LocalFree(lpMsgBuf);
 }
@@ -71,9 +71,8 @@ CheckIfFileExists(const char *filepath, 
 }
 
 static BOOL
-InstallMyDriver(const char *driverpath)
+InstallMyDriver(const char *driverpath, const char *drivername)
 {
-       char driver[300];
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to