Changeset: 4749a5ad3b7f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4749a5ad3b7f
Modified Files:
clients/mapiclient/mclient.c
clients/mapiclient/msqldump.c
clients/mapiclient/stethoscope.c
clients/mapilib/mapi.c
common/stream/fwf.c
gdk/gdk_logger.c
monetdb5/mal/mal_import.c
monetdb5/modules/atoms/streams.c
monetdb5/modules/mal/mal_io.c
monetdb5/modules/mal/mal_mapi.c
monetdb5/modules/mal/tokenizer.c
monetdb5/modules/mal/wlc.c
sql/backends/monet5/sql.c
sql/backends/monet5/sql_scenario.c
sql/backends/monet5/wlr.c
sql/storage/bat/bat_logger.c
sql/storage/store.c
tools/merovingian/daemon/client.c
tools/merovingian/daemon/proxy.c
tools/merovingian/daemon/snapshot.c
tools/merovingian/utils/control.c
Branch: makelibstreamgreatagain
Log Message:
Propagate the new libstream open- errors
diffs (truncated from 507 to 300 lines):
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -2672,7 +2672,7 @@ doFile(Mapi mid, stream *fp, bool useins
mnstr_errnr(s)) {
if (s)
close_stream(s);
- fprintf(stderr, "%s: cannot
open\n", line);
+ fprintf(stderr, "Cannot open
%s: %s\n", line, mnstr_peek_error(NULL));
} else
doFile(mid, s, 0, 0, 0);
continue;
@@ -2694,11 +2694,11 @@ 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));
if (toConsole != NULL) {
close_stream(toConsole);
}
toConsole = stdout_stream;
- fprintf(stderr, "Cannot open
%s\n", line);
}
continue;
case 'L':
@@ -3030,7 +3030,7 @@ getfile(void *data, const char *filename
#endif
}
if (f == NULL)
- return "cannot open file";
+ return (char*) mnstr_peek_error(NULL);
while (offset > 1) {
s = mnstr_readline(f, buf, READSIZE);
if (s < 0) {
@@ -3073,14 +3073,14 @@ putfile(void *data, const char *filename
if (filename != NULL) {
if ((priv->f = open_wastream(filename)) == NULL)
- return "cannot open file";
+ return (char*)mnstr_peek_error(NULL);
#ifdef HAVE_ICONV
if (encoding) {
stream *f = priv->f;
priv->f = iconv_wstream(f, encoding, mnstr_name(f));
if (priv->f == NULL) {
close_stream(f);
- return "cannot open file";
+ return (char*)mnstr_peek_error(NULL);
}
}
#endif
diff --git a/clients/mapiclient/msqldump.c b/clients/mapiclient/msqldump.c
--- a/clients/mapiclient/msqldump.c
+++ b/clients/mapiclient/msqldump.c
@@ -200,7 +200,7 @@ main(int argc, char **argv)
out = file_wastream(stdout, "stdout");
if (out == NULL) {
- fprintf(stderr, "failed to allocate stream\n");
+ fprintf(stderr, "failed to allocate stream: %s\n",
mnstr_peek_error(NULL));
exit(2);
}
if (!quiet) {
diff --git a/clients/mapiclient/stethoscope.c b/clients/mapiclient/stethoscope.c
--- a/clients/mapiclient/stethoscope.c
+++ b/clients/mapiclient/stethoscope.c
@@ -277,7 +277,7 @@ main(int argc, char **argv)
trace = fopen(filename,"w");
if(trace == NULL) {
- fprintf(stderr,"Could not create file '%s', printing to
stdout instead...\n", filename);
+ fprintf(stderr,"Could not create file '%s' (%s),
printing to stdout instead...\n", filename, strerror(errno));
filename = NULL;
}
}
diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -1003,7 +1003,8 @@ static ATOMIC_FLAG mapi_initialized = AT
#define check_stream(mid, s, msg, e) \
do { \
if ((s) == NULL || mnstr_errnr(s)) { \
- mapi_log_record(mid, msg); \
+ if (msg != NULL) mapi_log_record(mid, msg); \
+ mapi_log_record(mid, mnstr_peek_error(s)); \
mapi_log_record(mid, __func__); \
close_connection(mid); \
mapi_setError((mid), (msg), __func__, MTIMEOUT); \
@@ -2560,10 +2561,10 @@ mapi_reconnect(Mapi mid)
if (!isa_block_stream(mid->to)) {
mid->to = block_stream(mid->to);
- check_stream(mid, mid->to, mnstr_error(mid->to), mid->error);
+ check_stream(mid, mid->to, NULL, mid->error);
mid->from = block_stream(mid->from);
- check_stream(mid, mid->from, mnstr_error(mid->from),
mid->error);
+ check_stream(mid, mid->from, NULL, mid->error);
}
try_again_after_redirect:
@@ -4721,7 +4722,7 @@ mapi_fetch_line(MapiHdl hdl)
result->tableid,
result->cache.first +
result->cache.tuplecount) < 0 ||
mnstr_flush(hdl->mid->to))
- check_stream(hdl->mid, hdl->mid->to,
mnstr_error(hdl->mid->to), NULL);
+ check_stream(hdl->mid, hdl->mid->to, NULL, NULL);
reply = mapi_fetch_line_internal(hdl);
}
return reply;
@@ -5246,7 +5247,7 @@ mapi_fetch_all_rows(MapiHdl hdl)
if (mnstr_printf(mid->to, "X" "export %d %" PRId64 "\n",
result->tableid, result->cache.first
+ result->cache.tuplecount) < 0 ||
mnstr_flush(mid->to))
- check_stream(mid, mid->to,
mnstr_error(mid->to), 0);
+ check_stream(mid, mid->to, NULL, 0);
}
if (mid->active)
read_into_cache(mid->active, 0);
diff --git a/common/stream/fwf.c b/common/stream/fwf.c
--- a/common/stream/fwf.c
+++ b/common/stream/fwf.c
@@ -166,7 +166,6 @@ stream_fwf_create(stream *restrict s, si
free(fsd->in_buf);
free(fsd->out_buf);
free(fsd);
- mnstr_set_open_error(STREAM_FWF_NAME, errno, NULL);
return NULL;
}
ns->read = stream_fwf_read;
diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -1093,7 +1093,7 @@ logger_open(logger *lg)
lg->end = 0;
if (lg->log == NULL || mnstr_errnr(lg->log)) {
- TRC_CRITICAL(GDK, "creating %s failed\n", filename);
+ TRC_CRITICAL(GDK, "creating %s failed: %s\n", filename,
mnstr_peek_error(NULL));
GDKfree(filename);
return GDK_FAIL;
}
diff --git a/monetdb5/mal/mal_import.c b/monetdb5/mal/mal_import.c
--- a/monetdb5/mal/mal_import.c
+++ b/monetdb5/mal/mal_import.c
@@ -91,7 +91,7 @@ malLoadScript(str name, bstream **fdin)
fd = malOpenSource(name);
if (fd == NULL || mnstr_errnr(fd) == MNSTR_OPEN_ERROR) {
close_stream(fd);
- throw(MAL, "malInclude", "could not open file: %s", name);
+ throw(MAL, "malInclude", "could not open file: %s: %s", name,
mnstr_peek_error(NULL));
}
sz = getFileSize(fd);
if (sz > (size_t) 1 << 29) {
diff --git a/monetdb5/modules/atoms/streams.c b/monetdb5/modules/atoms/streams.c
--- a/monetdb5/modules/atoms/streams.c
+++ b/monetdb5/modules/atoms/streams.c
@@ -24,11 +24,10 @@ str mnstr_open_rstreamwrap(Stream *S, st
stream *s;
if ((s = open_rstream(*filename)) == NULL || mnstr_errnr(s)) {
- int errnr = errno;
if (s)
close_stream(s);
throw(IO, "streams.open", "could not open file '%s': %s",
- *filename, GDKstrerror(errnr, (char[128]){0},
128));
+ *filename, mnstr_peek_error(NULL));
} else {
*(stream**)S = s;
}
@@ -40,11 +39,10 @@ str mnstr_open_wstreamwrap(Stream *S, st
stream *s;
if ((s = open_wstream(*filename)) == NULL || mnstr_errnr(s)) {
- int errnr = errno;
if (s)
close_stream(s);
throw(IO, "streams.open", "could not open file '%s': %s",
- *filename, GDKstrerror(errnr, (char[128]){0},
128));
+ *filename, mnstr_peek_error(NULL));
} else {
*(stream**)S = s;
}
@@ -57,11 +55,10 @@ str mnstr_open_rastreamwrap(Stream *S, s
stream *s;
if ((s = open_rastream(*filename)) == NULL || mnstr_errnr(s)) {
- int errnr = errno;
if (s)
close_stream(s);
throw(IO, "streams.open", "could not open file '%s': %s",
- *filename, GDKstrerror(errnr, (char[128]){0},
128));
+ *filename, mnstr_peek_error(NULL));
} else {
*(stream**)S = s;
}
@@ -74,11 +71,10 @@ str mnstr_open_wastreamwrap(Stream *S, s
stream *s;
if ((s = open_wastream(*filename)) == NULL || mnstr_errnr(s)) {
- int errnr = errno;
if (s)
close_stream(s);
throw(IO, "streams.open", "could not open file '%s': %s",
- *filename, GDKstrerror(errnr, (char[128]){0},
128));
+ *filename, mnstr_peek_error(NULL));
} else {
*(stream**)S = s;
}
diff --git a/monetdb5/modules/mal/mal_io.c b/monetdb5/modules/mal/mal_io.c
--- a/monetdb5/modules/mal/mal_io.c
+++ b/monetdb5/modules/mal/mal_io.c
@@ -611,12 +611,12 @@ IOexport(void *ret, bat *bid, str *fnme)
s = open_wastream(*fnme);
if (s == NULL ){
BBPunfix(b->batCacheid);
- throw(MAL, "io.export", RUNTIME_FILE_NOT_FOUND ":%s", *fnme);
+ throw(MAL, "io.export", "%s", mnstr_peek_error(NULL));
}
if (mnstr_errnr(s)) {
mnstr_close(s);
BBPunfix(b->batCacheid);
- throw(MAL, "io.export", RUNTIME_FILE_NOT_FOUND ":%s", *fnme);
+ throw(MAL, "io.export", "%s", mnstr_peek_error(NULL));
}
BATprintcolumns(s, 1, &b);
close_stream(s);
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
@@ -471,16 +471,19 @@ SERVERlistenThread(SOCKET *Sock)
continue;
}
data->in = socket_rstream(msgsock, "Server read");
- data->out = socket_wstream(msgsock, "Server write");
- if (data->in == NULL || data->out == NULL) {
+ if (data->in == NULL) {
stream_alloc_fail:
mnstr_destroy(data->in);
mnstr_destroy(data->out);
GDKfree(data);
closesocket(msgsock);
- TRC_ERROR(MAL_SERVER, "Cannot allocate stream\n");
+ TRC_ERROR(MAL_SERVER, "Cannot allocate stream: %s\n",
mnstr_peek_error(NULL));
continue;
}
+ data->out = socket_wstream(msgsock, "Server write");
+ if (data->out == NULL) {
+ goto stream_alloc_fail;
+ }
s = block_stream(data->in);
if (s == NULL) {
goto stream_alloc_fail;
diff --git a/monetdb5/modules/mal/tokenizer.c b/monetdb5/modules/mal/tokenizer.c
--- a/monetdb5/modules/mal/tokenizer.c
+++ b/monetdb5/modules/mal/tokenizer.c
@@ -388,10 +388,10 @@ TKNZRdepositFile(void *r, str *fnme)
/* later, handle directory separator */
fs = open_rastream(buf);
if (fs == NULL)
- throw(MAL, "tokenizer.depositFile", RUNTIME_FILE_NOT_FOUND
"%s", buf);
+ throw(MAL, "tokenizer.depositFile", "%s",
mnstr_peek_error(NULL));
if (mnstr_errnr(fs)) {
close_stream(fs);
- throw(MAL, "tokenizer.depositFile", RUNTIME_FILE_NOT_FOUND
"%s", buf);
+ throw(MAL, "tokenizer.depositFile", "%s",
mnstr_peek_error(NULL));
}
bs = bstream_create(fs, SIZE);
if (bs == NULL)
diff --git a/monetdb5/modules/mal/wlc.c b/monetdb5/modules/mal/wlc.c
--- a/monetdb5/modules/mal/wlc.c
+++ b/monetdb5/modules/mal/wlc.c
@@ -261,7 +261,7 @@ str WLCsetConfig(void){
fd = open_wastream(path);
GDKfree(path);
if( fd == NULL)
- throw(MAL,"wlc.setConfig","Could not access wlc.config\n");
+ throw(MAL,"wlc.setConfig","Could not access wlc.config: %s\n",
mnstr_peek_error(NULL));
if( wlc_snapshot[0] )
mnstr_printf(fd,"snapshot=%s\n", wlc_snapshot);
mnstr_printf(fd,"logs=%s\n", wlc_dir);
diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -759,7 +759,7 @@ mvc_logfile(Client cntxt, MalBlkPtr mb,
if (!strNil(filename)) {
if((m->scanner.log = open_wastream(filename)) == NULL)
- throw(SQL, "sql.logfile", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
+ throw(SQL, "sql.logfile", SQLSTATE(HY013) "%s",
mnstr_peek_error(NULL));
}
return MAL_SUCCEED;
}
@@ -2581,8 +2581,7 @@ mvc_export_table_wrap( Client cntxt, Mal
s = cntxt->fdout;
} else if (!onclient) {
if ((s = open_wastream(filename)) == NULL || mnstr_errnr(s)) {
- msg= createException(IO, "streams.open",
SQLSTATE(42000) "could not open file '%s': %s",
- filename?filename:"stdout",
GDKstrerror(errno, (char[128]){0}, 128));
+ msg= createException(IO, "streams.open",
SQLSTATE(42000) "%s", mnstr_peek_error(NULL));
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list