Changeset: ab54756698f0 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ab54756698f0
Modified Files:
        clients/Tests/exports.stable.out
        gdk/gdk_logger.c
        sql/backends/monet5/rel_bin.c
        sql/backends/monet5/sql.c
        sql/backends/monet5/sql_upgrades.c
        sql/backends/monet5/vaults/fits/fits.c
        sql/backends/monet5/wlr.c
        sql/server/rel_optimizer.c
        sql/server/rel_unnest.c
        sql/server/rel_updates.c
        sql/storage/bat/bat_logger.c
        sql/storage/store.c
        sql/test/SQLancer/Tests/sqlancer07.test
Branch: nospare
Log Message:

merged


diffs (truncated from 4756 to 300 lines):

diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -69,8 +69,10 @@ monetdb_configure_defines()
 if(HAVE_NETDB_H)
   set(CMAKE_EXTRA_INCLUDE_FILES "netdb.h" "unistd.h")
 endif()
-if(HAVE_WINSOCK_H)
-  set(CMAKE_EXTRA_INCLUDE_FILES "winsock.h")
+if(NOT HAVE_SYS_SOCKET_H)
+  if(HAVE_WINSOCK_H)
+    set(CMAKE_EXTRA_INCLUDE_FILES "winsock.h")
+  endif()
 endif()
 set(CMAKE_REQUIRED_INCLUDES "/usr/include")
 
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
@@ -336,16 +336,25 @@ size_t HEAPmemsize(Heap *h);
 size_t HEAPvmsize(Heap *h);
 void IMPSdestroy(BAT *b);
 lng IMPSimprintsize(BAT *b);
+int MT_access(const char *pathname, int mode);
 int MT_check_nr_cores(void);
 int MT_create_thread(MT_Id *t, void (*function)(void *), void *arg, enum 
MT_thr_detach d, const char *threadname);
 void MT_exiting_thread(void);
+FILE *MT_fopen(const char *filename, const char *mode);
+char *MT_getcwd(char *buffer, size_t size);
 MT_Id MT_getpid(void);
 size_t MT_getrss(void);
 void MT_init(void);
 int MT_join_thread(MT_Id t);
-int MT_lockf(char *filename, int mode);
+int MT_lockf(const char *filename, int mode);
+int MT_mkdir(const char *dirname);
+int MT_open(const char *filename, int flags);
 bool MT_path_absolute(const char *path);
+int MT_remove(const char *filename);
+int MT_rename(const char *old, const char *new);
+int MT_rmdir(const char *dirname);
 void MT_sleep_ms(unsigned int ms);
+int MT_stat(const char *filename, struct stat *stb);
 const char *MT_thread_getalgorithm(void);
 void *MT_thread_getdata(void);
 const char *MT_thread_getname(void);
@@ -562,12 +571,9 @@ ssize_t timestamp_precision_tostr(str *b
 ssize_t timestamp_tostr(str *buf, size_t *len, const timestamp *val, bool 
external);
 ssize_t timestamp_tz_fromstr(const char *buf, size_t *len, timestamp **ret, 
bool external);
 const timestamp unixepoch;
+wchar_t *utf8towchar(const char *src);
 gdk_return void_inplace(BAT *b, oid id, const void *val, bool force) 
__attribute__((__warn_unused_result__));
-int win_mkdir(const char *, const int mode);
-int win_rename(const char *, const char *);
-int win_rmdir(const char *);
-int win_stat(const char *, struct stat *);
-int win_unlink(const char *);
+char *wchartoutf8(const wchar_t *src);
 int winerror(int);
 
 # mapi
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -1939,7 +1939,7 @@ format_result(Mapi mid, MapiHdl hdl, boo
        if (timerHumanCalled)
                timerHuman(sqloptimizer, maloptimizer, querytime, singleinstr, 
true);
        if (mnstr_errnr(toConsole)) {
-               fprintf(stderr, "write error: %s\n", 
mnstr_peek_error(toConsole));
+               mnstr_printf(stderr_stream, "write error: %s\n", 
mnstr_peek_error(toConsole));
                mnstr_clearerr(toConsole);
                errseen = true;
        }
@@ -2020,7 +2020,7 @@ doFileBulk(Mapi mid, stream *fp)
        bufsize = 10240;
        buf = malloc(bufsize + 1);
        if (!buf) {
-               fprintf(stderr, "cannot allocate memory for send buffer\n");
+               mnstr_printf(stderr_stream, "cannot allocate memory for send 
buffer\n");
                if (fp)
                        close_stream(fp);
                return true;
@@ -2043,7 +2043,7 @@ doFileBulk(Mapi mid, stream *fp)
                } else {
                        buf[length] = 0;
                        if (strlen(buf) < (size_t) length) {
-                               fprintf(stderr, "NULL byte in input\n");
+                               mnstr_printf(stderr_stream, "NULL byte in 
input\n");
                                errseen = true;
                                break;
                        }
@@ -2235,7 +2235,7 @@ doFile(Mapi mid, stream *fp, bool useins
                rl.s = fp;
                rl.buf = NULL;
                if ((fp = callback_stream(&rl, myread, NULL, NULL, mydestroy, 
mnstr_name(fp))) == NULL) {
-                       fprintf(stderr,"Malloc for doFile failed");
+                       mnstr_printf(stderr_stream,"Malloc for doFile failed");
                        exit(2);
                }
 #endif
@@ -2243,7 +2243,7 @@ doFile(Mapi mid, stream *fp, bool useins
 #ifdef HAVE_ICONV
        if (encoding) {
                if ((fp = iconv_rstream(fp, encoding, mnstr_name(fp))) == NULL) 
{
-                       fprintf(stderr,"Malloc failure");
+                       mnstr_printf(stderr_stream,"Malloc failure");
                        exit(2);
                }
        }
@@ -2257,7 +2257,7 @@ doFile(Mapi mid, stream *fp, bool useins
        bufsiz = READBLOCK;
        buf = malloc(bufsiz);
        if (buf == NULL) {
-               fprintf(stderr,"Malloc for doFile failed");
+               mnstr_printf(stderr_stream,"Malloc for doFile failed");
                exit(2);
        }
 
@@ -2285,7 +2285,7 @@ doFile(Mapi mid, stream *fp, bool useins
                        if (l <= 0)
                                break;
                        if (!seen_null_byte && strlen(buf + length) < (size_t) 
l) {
-                               fprintf(stderr, "NULL byte in input on line %d 
of input\n", lineno);
+                               mnstr_printf(stderr_stream, "NULL byte in input 
on line %d of input\n", lineno);
                                seen_null_byte = true;
                                errseen = true;
                                if (hdl) {
@@ -2300,7 +2300,7 @@ doFile(Mapi mid, stream *fp, bool useins
                        if (newbuf) {
                                buf = newbuf;
                        } else {
-                               fprintf(stderr,"Malloc failure");
+                               mnstr_printf(stderr_stream,"Malloc failure");
                                length = 0;
                                errseen = true;
                                if (hdl) {
@@ -2432,7 +2432,7 @@ doFile(Mapi mid, stream *fp, bool useins
                                                        wantsSystem = true;
                                                        break;
                                                default:
-                                                       fprintf(stderr, 
"unknown sub-command for \\d: %c\n", *line);
+                                                       
mnstr_printf(stderr_stream, "unknown sub-command for \\d: %c\n", *line);
                                                        length = 0;
                                                        line[1] = '\0';
                                                        break;
@@ -2478,7 +2478,7 @@ doFile(Mapi mid, stream *fp, bool useins
                                        }
                                        *q = '\0';
                                        if (escaped) {
-                                               fprintf(stderr, "unexpected end 
of string while "
+                                               mnstr_printf(stderr_stream, 
"unexpected end of string while "
                                                        "looking for matching 
\"\n");
                                                continue;
                                        }
@@ -2558,7 +2558,7 @@ doFile(Mapi mid, stream *fp, bool useins
                                                char *q = query, *endq = query 
+ len;
 
                                                if (query == NULL) {
-                                                       fprintf(stderr, "memory 
allocation failure\n");
+                                                       
mnstr_printf(stderr_stream, "memory allocation failure\n");
                                                        continue;
                                                }
 
@@ -2630,7 +2630,7 @@ doFile(Mapi mid, stream *fp, bool useins
                                        while (my_isspace(line[length - 1]))
                                                line[--length] = 0;
                                        if (line[2] && !my_isspace(line[2])) {
-                                               fprintf(stderr, "space required 
after \\D\n");
+                                               mnstr_printf(stderr_stream, 
"space required after \\D\n");
                                                continue;
                                        }
                                        for (line += 2; *line && 
my_isspace(*line); line++)
@@ -2663,7 +2663,7 @@ doFile(Mapi mid, stream *fp, bool useins
                                            mnstr_errnr(s)) {
                                                if (s)
                                                        close_stream(s);
-                                               fprintf(stderr, "Cannot open 
%s: %s\n", line, mnstr_peek_error(NULL));
+                                               mnstr_printf(stderr_stream, 
"Cannot open %s: %s\n", line, mnstr_peek_error(NULL));
                                        } else
                                                doFile(mid, s, 0, 0, 0);
                                        continue;
@@ -2685,7 +2685,7 @@ doFile(Mapi mid, stream *fp, bool useins
                                                toConsole = stderr_stream;
                                        else if ((toConsole = 
open_wastream(line)) == NULL ||
                                                 mnstr_errnr(toConsole)) {
-                                               fprintf(stderr, "Cannot open 
%s: %s\n", line, mnstr_peek_error(toConsole));
+                                               mnstr_printf(stderr_stream, 
"Cannot open %s: %s\n", line, mnstr_peek_error(toConsole));
                                                if (toConsole != NULL) {
                                                        close_stream(toConsole);
                                                }
@@ -2822,7 +2822,7 @@ doFile(Mapi mid, stream *fp, bool useins
                                        } else if (strncmp(line,"perf",4) == 0 
|| strcmp(line,"performance") == 0) {
                                                timermode = T_PERF;
                                        } else if (*line != '\0') {
-                                               fprintf(stderr, "warning: 
invalid argument to -t: %s\n",
+                                               mnstr_printf(stderr_stream, 
"warning: invalid argument to -t: %s\n",
                                                        line);
                                        }
                                        continue;
@@ -3097,45 +3097,45 @@ static _Noreturn void usage(const char *
 static void
 usage(const char *prog, int xit)
 {
-       fprintf(stderr, "Usage: %s [ options ] [ file or database [ file ... ] 
]\n", prog);
-       fprintf(stderr, "\nOptions are:\n");
+       mnstr_printf(stderr_stream, "Usage: %s [ options ] [ file or database [ 
file ... ] ]\n", prog);
+       mnstr_printf(stderr_stream, "\nOptions are:\n");
 #ifdef HAVE_SYS_UN_H
-       fprintf(stderr, " -h hostname | --host=hostname    host or UNIX domain 
socket to connect to\n");
+       mnstr_printf(stderr_stream, " -h hostname | --host=hostname    host or 
UNIX domain socket to connect to\n");
 #else
-       fprintf(stderr, " -h hostname | --host=hostname    host to connect 
to\n");
+       mnstr_printf(stderr_stream, " -h hostname | --host=hostname    host to 
connect to\n");
 #endif
-       fprintf(stderr, " -p portnr   | --port=portnr      port to connect 
to\n");
-       fprintf(stderr, " -u user     | --user=user        user id\n");
-       fprintf(stderr, " -d database | --database=database  database to 
connect to (may be URI)\n");
+       mnstr_printf(stderr_stream, " -p portnr   | --port=portnr      port to 
connect to\n");
+       mnstr_printf(stderr_stream, " -u user     | --user=user        user 
id\n");
+       mnstr_printf(stderr_stream, " -d database | --database=database  
database to connect to (may be URI)\n");
 
-       fprintf(stderr, " -e          | --echo             echo the query\n");
+       mnstr_printf(stderr_stream, " -e          | --echo             echo the 
query\n");
 #ifdef HAVE_ICONV
-       fprintf(stderr, " -E charset  | --encoding=charset specify encoding 
(character set) of the terminal\n");
+       mnstr_printf(stderr_stream, " -E charset  | --encoding=charset specify 
encoding (character set) of the terminal\n");
 #endif
-       fprintf(stderr, " -f kind     | --format=kind      specify output 
format {csv,tab,raw,sql,xml,trash,rowcount}\n");
-       fprintf(stderr, " -H          | --history          load/save cmdline 
history (default off)\n");
-       fprintf(stderr, " -i          | --interactive      interpret `\\' 
commands on stdin\n");
-       fprintf(stderr, " -t          | --timer=format     use time formatting 
{none,clock,performance} (none is default)\n");
-       fprintf(stderr, " -l language | --language=lang    {sql,mal}\n");
-       fprintf(stderr, " -L logfile  | --log=logfile      save client/server 
interaction\n");
-       fprintf(stderr, " -s stmt     | --statement=stmt   run single 
statement\n");
-       fprintf(stderr, " -X          | --Xdebug           trace mapi network 
interaction\n");
-       fprintf(stderr, " -z          | --timezone         do not tell server 
our timezone\n");
+       mnstr_printf(stderr_stream, " -f kind     | --format=kind      specify 
output format {csv,tab,raw,sql,xml,trash,rowcount}\n");
+       mnstr_printf(stderr_stream, " -H          | --history          
load/save cmdline history (default off)\n");
+       mnstr_printf(stderr_stream, " -i          | --interactive      
interpret `\\' commands on stdin\n");
+       mnstr_printf(stderr_stream, " -t          | --timer=format     use time 
formatting {none,clock,performance} (none is default)\n");
+       mnstr_printf(stderr_stream, " -l language | --language=lang    
{sql,mal}\n");
+       mnstr_printf(stderr_stream, " -L logfile  | --log=logfile      save 
client/server interaction\n");
+       mnstr_printf(stderr_stream, " -s stmt     | --statement=stmt   run 
single statement\n");
+       mnstr_printf(stderr_stream, " -X          | --Xdebug           trace 
mapi network interaction\n");
+       mnstr_printf(stderr_stream, " -z          | --timezone         do not 
tell server our timezone\n");
 #ifdef HAVE_POPEN
-       fprintf(stderr, " -| cmd      | --pager=cmd        for pagination\n");
+       mnstr_printf(stderr_stream, " -| cmd      | --pager=cmd        for 
pagination\n");
 #endif
-       fprintf(stderr, " -v          | --version          show version 
information and exit\n");
-       fprintf(stderr, " -?          | --help             show this usage 
message\n");
+       mnstr_printf(stderr_stream, " -v          | --version          show 
version information and exit\n");
+       mnstr_printf(stderr_stream, " -?          | --help             show 
this usage message\n");
 
-       fprintf(stderr, "\nSQL specific opions \n");
-       fprintf(stderr, " -n nullstr  | --null=nullstr     change NULL 
representation for sql, csv and tab output modes\n");
-       fprintf(stderr, " -a          | --autocommit       turn off autocommit 
mode\n");
-       fprintf(stderr, " -R          | --allow-remote     allow remote 
content\n");
-       fprintf(stderr, " -r nr       | --rows=nr          for pagination\n");
-       fprintf(stderr, " -w nr       | --width=nr         for pagination\n");
-       fprintf(stderr, " -D          | --dump             create an SQL 
dump\n");
-       fprintf(stderr, " -N          | --inserts          use INSERT INTO 
statements when dumping\n");
-       fprintf(stderr, "The file argument can be - for stdin\n");
+       mnstr_printf(stderr_stream, "\nSQL specific opions \n");
+       mnstr_printf(stderr_stream, " -n nullstr  | --null=nullstr     change 
NULL representation for sql, csv and tab output modes\n");
+       mnstr_printf(stderr_stream, " -a          | --autocommit       turn off 
autocommit mode\n");
+       mnstr_printf(stderr_stream, " -R          | --allow-remote     allow 
remote content\n");
+       mnstr_printf(stderr_stream, " -r nr       | --rows=nr          for 
pagination\n");
+       mnstr_printf(stderr_stream, " -w nr       | --width=nr         for 
pagination\n");
+       mnstr_printf(stderr_stream, " -D          | --dump             create 
an SQL dump\n");
+       mnstr_printf(stderr_stream, " -N          | --inserts          use 
INSERT INTO statements when dumping\n");
+       mnstr_printf(stderr_stream, "The file argument can be - for stdin\n");
        exit(xit);
 }
 
@@ -3152,7 +3152,11 @@ isfile(FILE *fp)
 }
 
 int
+#ifdef _MSC_VER
+wmain(int argc, wchar_t **wargv)
+#else
 main(int argc, char **argv)
+#endif
 {
        int port = 0;
        char *user = NULL;
@@ -3209,6 +3213,20 @@ main(int argc, char **argv)
                {0, 0, 0, 0}
        };
 
+#ifdef _MSC_VER
+       char **argv = malloc((argc + 1) * sizeof(char *));
+       if (argv == NULL) {
+               fprintf(stderr, "cannot allocate memory for argument 
conversion\n");
+               exit(1);
+       }
+       for (int i = 0; i < argc; i++) {
+               if ((argv[i] = wchartoutf8(wargv[i])) == NULL) {
+                       fprintf(stderr, "cannot convert argument to UTF-8\n");
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to