Changeset: b6f77b0655f6 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b6f77b0655f6
Branch: default
Log Message:
Merge with Oct2020 branch.
diffs (truncated from 2077 to 300 lines):
diff --git a/clients/mapiclient/ReadlineTools.c
b/clients/mapiclient/ReadlineTools.c
--- a/clients/mapiclient/ReadlineTools.c
+++ b/clients/mapiclient/ReadlineTools.c
@@ -291,10 +291,6 @@ continue_completion(rl_completion_func_t
rl_attempted_completion_function = func;
}
-#ifndef BUFSIZ
-#define BUFSIZ 1024
-#endif
-
static void
readline_show_error(const char *msg) {
rl_save_prompt();
@@ -303,13 +299,19 @@ readline_show_error(const char *msg) {
rl_clear_message();
}
+#ifndef BUFFER_SIZE
+#define BUFFER_SIZE 1024
+#endif
+
static int
invoke_editor(int cnt, int key) {
char template[] = "/tmp/mclient_temp_XXXXXX";
- char cmd[BUFSIZ];
- char *editor;
+ char editor_command[BUFFER_SIZE];
+ char *read_buff = NULL;
+ char *editor = NULL;
FILE *fp;
- size_t cmd_len;
+ size_t content_len;
+ size_t read_bytes, idx;
(void) cnt;
(void) key;
@@ -324,35 +326,64 @@ invoke_editor(int cnt, int key) {
fflush(fp);
editor = getenv("VISUAL");
- if (!editor) {
+ if (editor == NULL) {
editor = getenv("EDITOR");
- if (!editor) {
+ if (editor == NULL) {
readline_show_error("invoke_editor: EDITOR/VISUAL env
variable not set\n");
goto bailout;
}
}
- snprintf(cmd, BUFSIZ, "%s %s", editor, template);
- if (system(cmd) != 0) {
+ snprintf(editor_command, BUFFER_SIZE, "%s %s", editor, template);
+ if (system(editor_command) != 0) {
readline_show_error("invoke_editor: Starting editor failed\n");
goto bailout;
}
- fseek(fp, 0, SEEK_SET);
- cmd_len = fread(cmd, sizeof(char), BUFSIZ, fp);
- fclose(fp);
+ fseek(fp, 0L, SEEK_END);
+ content_len = ftell(fp);
+ rewind(fp);
+
+ if (content_len > 0) {
+ read_buff = (char *)malloc(content_len*sizeof(char));
+ 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) {
+ readline_show_error("invoke_editor: Did not read from
file correctly\n");
+ goto bailout;
+ }
- *(cmd + cmd_len) = 0;
+ *(read_buff + read_bytes) = 0;
+
+ /* Remove trailing whitespace */
+ idx = read_bytes - 1;
+ while(isspace(*(read_buff + idx))) {
+ *(read_buff + idx) = 0;
+ idx--;
+ }
- rl_replace_line(cmd, 0);
- rl_point = cmd_len - 1;
+ rl_replace_line(read_buff, 0);
+ rl_point = idx + 1; // place the point one character after the
end of the string
+ free(read_buff);
+ } else {
+ rl_replace_line("", 0);
+ rl_point = 0;
+ }
+
+ fclose(fp);
unlink(template);
return 0;
bailout:
fclose(fp);
+ free(read_buff);
+ unlink(template);
return 1;
}
@@ -375,7 +406,8 @@ init_readline(Mapi mid, const char *lang
rl_attempted_completion_function = mal_completion;
}
- rl_bind_key(024, invoke_editor);
+ rl_add_funmap_entry("invoke-editor", invoke_editor);
+ rl_bind_keyseq("\\M-e", invoke_editor);
if (save_history) {
int len;
diff --git a/common/stream/Tests/All b/common/stream/Tests/All
--- a/common/stream/Tests/All
+++ b/common/stream/Tests/All
@@ -1,13 +1,13 @@
read_uncompressed
HAVE_LIBBZ2?read_bz2
HAVE_LIBZ?read_gz
-HAVE_LIBLZ4?read_lz4
+HAVE_LIBLZ4&HAVE_PYTHON_LZ4?read_lz4
HAVE_LIBLZMA?read_xz
write_uncompressed
HAVE_LIBBZ2?write_bz2
HAVE_LIBZ?write_gz
-HAVE_LIBLZ4?write_lz4
+HAVE_LIBLZ4&HAVE_PYTHON_LZ4?write_lz4
HAVE_LIBLZMA?write_xz
urlstream
diff --git a/common/stream/Tests/testdata.py b/common/stream/Tests/testdata.py
--- a/common/stream/Tests/testdata.py
+++ b/common/stream/Tests/testdata.py
@@ -2,10 +2,7 @@
# Generating test files and verifying them after transmission.
-import bz2
import gzip
-import lz4.frame
-import lzma
import os
import sys
@@ -208,10 +205,13 @@ class TestFile:
elif self.compression == 'gz':
f = gzip.GzipFile(filename, 'wb', fileobj=fileobj,
mtime=131875200, compresslevel=1)
elif self.compression == 'bz2':
+ import bz2
f = bz2.BZ2File(fileobj, 'wb', compresslevel=1)
elif self.compression == 'xz':
+ import lzma
f = lzma.LZMAFile(fileobj, 'wb', preset=1)
elif self.compression == 'lz4': # ok
+ import lz4.frame
f = lz4.frame.LZ4FrameFile(fileobj, 'wb', compression_level=1)
else:
raise Exception("Unknown compression scheme: " + self.compression)
@@ -225,10 +225,13 @@ class TestFile:
elif self.compression == 'gz':
f = gzip.GzipFile(filename, 'rb', mtime=131875200)
elif self.compression == 'bz2':
+ import bz2
f = bz2.BZ2File(filename, 'rb')
elif self.compression == 'xz':
+ import lzma
f = lzma.LZMAFile(filename, 'rb')
elif self.compression == 'lz4':
+ import lz4.frame
f = lz4.frame.LZ4FrameFile(filename, 'rb')
else:
raise Exception("Unknown compression scheme: " + self.compression)
diff --git
a/monetdb5/extras/mal_optimizer_template/Tests/opt_sql_append.stable.out.Windows
b/monetdb5/extras/mal_optimizer_template/Tests/opt_sql_append.stable.out.Windows
---
a/monetdb5/extras/mal_optimizer_template/Tests/opt_sql_append.stable.out.Windows
+++
b/monetdb5/extras/mal_optimizer_template/Tests/opt_sql_append.stable.out.Windows
@@ -72,14 +72,14 @@ stdout of test 'opt_sql_append` in direc
% clob # type
% 235 # length
function user.main():void;
- X_1:void := querylog.define("explain copy into ttt from
E\\'\\\\\\\\tmp/xyz\\';":str, "sequential_pipe":str, 21:int);
+ X_1:void := querylog.define("explain copy into ttt from
E\\'\\\\\\\\tmp/xyz\\';":str, "sequential_pipe":str, 22:int);
X_4:int := sql.mvc();
- (X_26:bat[:int], X_27:bat[:int], X_28:bat[:int]) :=
sql.copy_from(0x3698b20:ptr, "|":str, "\n":str, nil:str, "null":str,
"\\tmp/xyz":str, -1:lng, 0:lng, 0:int, 0:int, nil:str, 0:int);
- X_30:int := sql.append(X_4:int, "sys":str, "ttt":str,
"averylongcolumnnametomakeitlargeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee":str,
X_26:bat[:int]);
- X_35:int := sql.append(X_30:int, "sys":str, "ttt":str, "b":str,
X_27:bat[:int]);
- X_38:int := sql.append(X_35:int, "sys":str, "ttt":str, "c":str,
X_28:bat[:int]);
- X_40:lng := aggr.count(X_28:bat[:int]);
- sql.affectedRows(X_38:int, X_40:lng);
+ (X_28:bat[:int], X_29:bat[:int], X_30:bat[:int]) :=
sql.copy_from(0xXXXXXX:ptr, "|":str, "\n":str, nil:str, "null":str,
"\\tmp/xyz":str, -1:lng, 0:lng, 0:int, 0:int, nil:str, 0:int, 1:int);
+ X_32:int := sql.append(X_4:int, "sys":str, "ttt":str,
"averylongcolumnnametomakeitlargeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee":str,
X_28:bat[:int]);
+ X_37:int := sql.append(X_32:int, "sys":str, "ttt":str, "b":str,
X_29:bat[:int]);
+ X_40:int := sql.append(X_37:int, "sys":str, "ttt":str, "c":str,
X_30:bat[:int]);
+ X_42:lng := aggr.count(X_30:bat[:int]);
+ sql.affectedRows(X_40:int, X_42:lng);
end user.main;
#inline actions= 0 time=0 usec
#remap actions= 0 time=0 usec
@@ -113,14 +113,14 @@ end user.main;
% clob # type
% 235 # length
function user.main():void;
- X_1:void := querylog.define("explain copy into ttt from
E\\'a:\\\\\\\\tmp/xyz\\';":str, "sequential_pipe":str, 21:int);
+ X_1:void := querylog.define("explain copy into ttt from
E\\'a:\\\\\\\\tmp/xyz\\';":str, "sequential_pipe":str, 22:int);
X_4:int := sql.mvc();
- (X_26:bat[:int], X_27:bat[:int], X_28:bat[:int]) :=
sql.copy_from(0x3698b20:ptr, "|":str, "\n":str, nil:str, "null":str,
"a:\\tmp/xyz":str, -1:lng, 0:lng, 0:int, 0:int, nil:str, 0:int);
- X_30:int := sql.append(X_4:int, "sys":str, "ttt":str,
"averylongcolumnnametomakeitlargeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee":str,
X_26:bat[:int]);
- X_35:int := sql.append(X_30:int, "sys":str, "ttt":str, "b":str,
X_27:bat[:int]);
- X_38:int := sql.append(X_35:int, "sys":str, "ttt":str, "c":str,
X_28:bat[:int]);
- X_40:lng := aggr.count(X_28:bat[:int]);
- sql.affectedRows(X_38:int, X_40:lng);
+ (X_28:bat[:int], X_29:bat[:int], X_30:bat[:int]) :=
sql.copy_from(0xXXXXXX:ptr, "|":str, "\n":str, nil:str, "null":str,
"a:\\tmp/xyz":str, -1:lng, 0:lng, 0:int, 0:int, nil:str, 0:int, 1:int);
+ X_32:int := sql.append(X_4:int, "sys":str, "ttt":str,
"averylongcolumnnametomakeitlargeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee":str,
X_28:bat[:int]);
+ X_37:int := sql.append(X_32:int, "sys":str, "ttt":str, "b":str,
X_29:bat[:int]);
+ X_40:int := sql.append(X_37:int, "sys":str, "ttt":str, "c":str,
X_30:bat[:int]);
+ X_42:lng := aggr.count(X_30:bat[:int]);
+ sql.affectedRows(X_40:int, X_42:lng);
end user.main;
#inline actions= 0 time=1 usec
#remap actions= 0 time=2 usec
@@ -171,14 +171,14 @@ end user.main;
% clob # type
% 235 # length
function user.main():void;
- X_1:void := querylog.define("explain copy into ttt from
E\\'\\\\\\\\tmp/xyz\\';":str, "user_0":str, 21:int);
+ X_1:void := querylog.define("explain copy into ttt from
E\\'\\\\\\\\tmp/xyz\\';":str, "user_0":str, 22:int);
X_4:int := sql.mvc();
- (X_26:bat[:int], X_27:bat[:int], X_28:bat[:int]) :=
sql.copy_from(0x3698b20:ptr, "|":str, "\n":str, nil:str, "null":str,
"\\tmp/xyz":str, -1:lng, 0:lng, 0:int, 0:int, nil:str, 0:int);
- X_30:int := sql.append(X_4:int, "sys":str, "ttt":str,
"averylongcolumnnametomakeitlargeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee":str,
X_26:bat[:int]);
- X_35:int := sql.append(X_30:int, "sys":str, "ttt":str, "b":str,
X_27:bat[:int]);
- X_40:lng := aggr.count(X_28:bat[:int]);
- X_38:int := sql.append(X_35:int, "sys":str, "ttt":str, "c":str,
X_28:bat[:int]);
- sql.affectedRows(X_38:int, X_40:lng);
+ (X_28:bat[:int], X_29:bat[:int], X_30:bat[:int]) :=
sql.copy_from(0xXXXXXX:ptr, "|":str, "\n":str, nil:str, "null":str,
"\\tmp/xyz":str, -1:lng, 0:lng, 0:int, 0:int, nil:str, 0:int, 1:int);
+ X_32:int := sql.append(X_4:int, "sys":str, "ttt":str,
"averylongcolumnnametomakeitlargeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee":str,
X_28:bat[:int]);
+ X_37:int := sql.append(X_32:int, "sys":str, "ttt":str, "b":str,
X_29:bat[:int]);
+ X_42:lng := aggr.count(X_30:bat[:int]);
+ X_40:int := sql.append(X_37:int, "sys":str, "ttt":str, "c":str,
X_30:bat[:int]);
+ sql.affectedRows(X_40:int, X_42:lng);
end user.main;
#inline actions= 0 time=0 usec
#remap actions= 0 time=0 usec
@@ -213,14 +213,14 @@ end user.main;
% clob # type
% 235 # length
function user.main():void;
- X_1:void := querylog.define("explain copy into ttt from
\\'Z:/tmp/xyz\\';":str, "user_0":str, 21:int);
+ X_1:void := querylog.define("explain copy into ttt from
\\'Z:/tmp/xyz\\';":str, "user_0":str, 22:int);
X_4:int := sql.mvc();
- (X_26:bat[:int], X_27:bat[:int], X_28:bat[:int]) :=
sql.copy_from(0x2e73790:ptr, "|":str, "\n":str, nil:str, "null":str,
"Z:/tmp/xyz":str, -1:lng, 0:lng, 0:int, 0:int, nil:str, 0:int);
- X_30:int := sql.append(X_4:int, "sys":str, "ttt":str,
"averylongcolumnnametomakeitlargeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee":str,
X_26:bat[:int]);
- X_35:int := sql.append(X_30:int, "sys":str, "ttt":str, "b":str,
X_27:bat[:int]);
- X_40:lng := aggr.count(X_28:bat[:int]);
- X_38:int := sql.append(X_35:int, "sys":str, "ttt":str, "c":str,
X_28:bat[:int]);
- sql.affectedRows(X_38:int, X_40:lng);
+ (X_28:bat[:int], X_29:bat[:int], X_30:bat[:int]) :=
sql.copy_from(0xXXXXXX:ptr, "|":str, "\n":str, nil:str, "null":str,
"Z:/tmp/xyz":str, -1:lng, 0:lng, 0:int, 0:int, nil:str, 0:int, 1:int);
+ X_32:int := sql.append(X_4:int, "sys":str, "ttt":str,
"averylongcolumnnametomakeitlargeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee":str,
X_28:bat[:int]);
+ X_37:int := sql.append(X_32:int, "sys":str, "ttt":str, "b":str,
X_29:bat[:int]);
+ X_42:lng := aggr.count(X_30:bat[:int]);
+ X_40:int := sql.append(X_37:int, "sys":str, "ttt":str, "c":str,
X_30:bat[:int]);
+ sql.affectedRows(X_40:int, X_42:lng);
end user.main;
#inline actions= 0 time=0 usec
#remap actions= 0 time=2 usec
diff --git a/monetdb5/modules/mal/mal_mapi.c b/monetdb5/modules/mal/mal_mapi.c
--- a/monetdb5/modules/mal/mal_mapi.c
+++ b/monetdb5/modules/mal/mal_mapi.c
@@ -272,60 +272,51 @@ static ATOMIC_TYPE threadno = ATOMIC_VAR
static void
SERVERlistenThread(SOCKET *Sock)
{
- char *msg = 0;
+ char *msg = NULL;
int retval;
- SOCKET sock = Sock[0];
- SOCKET usock = Sock[1];
- SOCKET msgsock = INVALID_SOCKET;
+ SOCKET socks[3] = {Sock[0], Sock[1], Sock[2]};
struct challengedata *data;
MT_Id tid;
stream *s;
+ int i;
GDKfree(Sock);
(void) ATOMIC_INC(&nlistener);
do {
+ SOCKET msgsock = INVALID_SOCKET;
#ifdef HAVE_POLL
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list