Changeset: f0394c6adf9e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f0394c6adf9e
Modified Files:
clients/mapiclient/mclient.c
Branch: Jun2020
Log Message:
Cleanup code.
diffs (122 lines):
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -1987,13 +1987,12 @@ doRequest(Mapi mid, const char *buf)
return errseen;
}
-#define CHECK_RESULT(mid, hdl, break_or_continue, buf, fp) \
+#define CHECK_RESULT(mid, hdl, buf, fp) \
switch (mapi_error(mid)) { \
- case MOK: \
- /* everything A OK */ \
+ case MOK: /* everything A OK */ \
break; \
- case MERROR: \
- /* some error, but try to continue */ \
+ case MERROR: /* some error, but try to continue */ \
+ case MTIMEOUT: /* lost contact with the server */ \
if (formatter == TABLEformatter) { \
mapi_noexplain(mid, ""); \
} else { \
@@ -2006,21 +2005,8 @@ doRequest(Mapi mid, const char *buf)
} else \
mapi_explain(mid, stderr); \
errseen = true; \
- break_or_continue; \
- case MTIMEOUT: \
- /* lost contact with the server */ \
- if (formatter == TABLEformatter) { \
- mapi_noexplain(mid, ""); \
- } else { \
- mapi_noexplain(mid, NULL); \
- } \
- if (hdl) { \
- mapi_explain_query(hdl, stderr); \
- mapi_close_handle(hdl); \
- hdl = NULL; \
- } else \
- mapi_explain(mid, stderr); \
- errseen = true; \
+ if (mapi_error(mid) == MERROR) \
+ continue; /* why not in do-while */ \
timerEnd(); \
if (buf) \
free(buf); \
@@ -2072,12 +2058,12 @@ doFileBulk(Mapi mid, stream *fp)
timerResume();
if (hdl == NULL) {
hdl = mapi_query_prep(mid);
- CHECK_RESULT(mid, hdl, continue, buf, fp);
+ CHECK_RESULT(mid, hdl, buf, fp);
}
assert(hdl != NULL);
mapi_query_part(hdl, buf, (size_t) length);
- CHECK_RESULT(mid, hdl, continue, buf, fp);
+ CHECK_RESULT(mid, hdl, buf, fp);
/* if not at EOF, make sure there is a newline in the
* buffer */
@@ -2096,14 +2082,14 @@ doFileBulk(Mapi mid, stream *fp)
(length > 0 || mapi_query_done(hdl) == MMORE))
continue; /* get more data */
- CHECK_RESULT(mid, hdl, continue, buf, fp);
+ CHECK_RESULT(mid, hdl, buf, fp);
rc = format_result(mid, hdl, false);
if (rc == MMORE && (length > 0 || mapi_query_done(hdl) != MOK))
continue; /* get more data */
- CHECK_RESULT(mid, hdl, continue, buf, fp);
+ CHECK_RESULT(mid, hdl, buf, fp);
mapi_close_handle(hdl);
hdl = NULL;
@@ -2610,7 +2596,7 @@ doFile(Mapi mid, stream *fp, bool useins
hdl = mapi_query(mid, query);
free(query);
- CHECK_RESULT(mid, hdl,
continue, buf, fp);
+ CHECK_RESULT(mid, hdl, buf, fp);
while (fetch_row(hdl) == 3) {
char *type =
mapi_fetch_field(hdl, 0);
char *name =
mapi_fetch_field(hdl, 1);
@@ -2859,7 +2845,7 @@ doFile(Mapi mid, stream *fp, bool useins
if (hdl == NULL) {
timerStart();
hdl = mapi_query_prep(mid);
- CHECK_RESULT(mid, hdl, continue, buf, fp);
+ CHECK_RESULT(mid, hdl, buf, fp);
} else
timerResume();
@@ -2868,7 +2854,7 @@ doFile(Mapi mid, stream *fp, bool useins
if (length > 0) {
SQLsetSpecial(line);
mapi_query_part(hdl, line, length);
- CHECK_RESULT(mid, hdl, continue, buf, fp);
+ CHECK_RESULT(mid, hdl, buf, fp);
}
/* If the server wants more but we're at the
@@ -2886,7 +2872,7 @@ doFile(Mapi mid, stream *fp, bool useins
continue; /* done */
}
}
- CHECK_RESULT(mid, hdl, continue, buf, fp);
+ CHECK_RESULT(mid, hdl, buf, fp);
if (mapi_get_querytype(hdl) == Q_PREPARE) {
prepno = mapi_get_tableid(hdl);
@@ -2898,7 +2884,7 @@ doFile(Mapi mid, stream *fp, bool useins
if (rc == MMORE && (line != NULL || mapi_query_done(hdl) !=
MOK))
continue; /* get more data */
- CHECK_RESULT(mid, hdl, continue, buf, fp);
+ CHECK_RESULT(mid, hdl, buf, fp);
timerEnd();
mapi_close_handle(hdl);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list