Changeset: 91552a305341 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=91552a305341
Modified Files:
        clients/Tests/exports.stable.out
        clients/examples/C/streamcat.c
        clients/mapiclient/mclient.c
        clients/mapiclient/msqldump.c
        clients/mapilib/mapi.c
        common/stream/iconv_stream.c
        common/stream/pump.c
        common/stream/stream.c
        common/stream/stream.h
        gdk/gdk_logger.c
        monetdb5/mal/mal_client.c
        monetdb5/mal/mal_profiler.c
        monetdb5/mal/mal_session.c
        monetdb5/modules/atoms/streams.c
        monetdb5/modules/mal/mal_mapi.c
        monetdb5/modules/mal/remote.c
        monetdb5/modules/mal/tablet.c
        monetdb5/modules/mal/wlc.c
        sql/backends/monet5/sql.c
        sql/backends/monet5/sql_result.c
        sql/backends/monet5/sql_scenario.c
        sql/server/sql_scan.c
        tools/merovingian/daemon/client.c
        tools/merovingian/daemon/controlrunner.c
        tools/merovingian/daemon/multiplex-funnel.c
        tools/merovingian/daemon/proxy.c
        tools/merovingian/utils/control.c
Branch: makelibstreamgreatagain
Log Message:

Add flush_options parameter to mnstr_flush


diffs (truncated from 1197 to 300 lines):

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
@@ -1929,7 +1929,7 @@ mnstr_error_kind mnstr_errnr(const strea
 char *mnstr_error(const stream *s);
 const char *mnstr_error_kind_name(mnstr_error_kind k);
 int mnstr_fgetpos(stream *restrict s, fpos_t *restrict p);
-int mnstr_flush(stream *s);
+int mnstr_flush(stream *s, mnstr_flush_level flush_level);
 int mnstr_fsetpos(stream *restrict s, fpos_t *restrict p);
 int mnstr_fsync(stream *s);
 buffer *mnstr_get_buffer(stream *s);
diff --git a/clients/examples/C/streamcat.c b/clients/examples/C/streamcat.c
--- a/clients/examples/C/streamcat.c
+++ b/clients/examples/C/streamcat.c
@@ -534,7 +534,7 @@ int cmd_bstream(char *argv[])
                                croak(2, "could not open '%s': %s", filename, 
strerror(errno));
                        copy_file_to_stream(f, bs, 42);
                        fclose(f);
-                       mnstr_flush(bs);
+                       mnstr_flush(bs, MNSTR_FLUSH_DATA);
                }
                mnstr_destroy(bs);
                if (additional) {
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -243,7 +243,7 @@ timerResume(void)
 static void
 timerEnd(void)
 {
-       mnstr_flush(toConsole);
+       mnstr_flush(toConsole, MNSTR_FLUSH_DATA);
        t1 = gettime();
        assert(t1 >= t0);
 }
@@ -280,7 +280,7 @@ timerHuman(int64_t sqloptimizer, int64_t
        if (timermode == T_CLOCK && (singleinstr != total)) {
                /* print wall-clock in "human-friendly" format */
                fflush(stderr);
-               mnstr_flush(toConsole);
+               mnstr_flush(toConsole, MNSTR_FLUSH_DATA);
                if (t / 1000 < 1000) {
                        fprintf(stderr, "clk: %" PRId64 ".%03d ms\n", t / 1000, 
(int) (t % 1000));
                        fflush(stderr);
@@ -306,7 +306,7 @@ timerHuman(int64_t sqloptimizer, int64_t
        if (timermode == T_PERF && (!total || singleinstr != total)) {
                /* for performance measures we use milliseconds as the base */
                fflush(stderr);
-               mnstr_flush(toConsole);
+               mnstr_flush(toConsole, MNSTR_FLUSH_DATA);
                if (!total)
                        fprintf(stderr, "sql:%" PRId64 ".%03d opt:%" PRId64 
".%03d run:%" PRId64 ".%03d ",
                                 sqloptimizer / 1000, (int) (sqloptimizer % 
1000),
@@ -827,7 +827,7 @@ XMLrenderer(MapiHdl hdl)
        char *name;
 
        /* we must use toConsole since the XML file is encoded in UTF-8 */
-       mnstr_flush(toConsole);
+       mnstr_flush(toConsole, MNSTR_FLUSH_DATA);
        mnstr_printf(toConsole, "<?xml version='1.0' encoding='UTF-8'?>\n");
        mnstr_printf(toConsole,
                     "<!DOCTYPE table [\n"
@@ -864,7 +864,7 @@ XMLrenderer(MapiHdl hdl)
                mnstr_printf(toConsole, "</row>\n");
        }
        mnstr_printf(toConsole, "</table>\n");
-       mnstr_flush(toConsole);
+       mnstr_flush(toConsole, MNSTR_FLUSH_DATA);
 }
 
 static void
@@ -919,7 +919,7 @@ EXPANDEDrenderer(MapiHdl hdl)
                        } while (*edata);
                }
        }
-       mnstr_flush(toConsole);
+       mnstr_flush(toConsole, MNSTR_FLUSH_DATA);
 }
 
 static void
@@ -1377,7 +1377,7 @@ SQLpagemove(int *len, int fields, int *p
 
        SQLseparator(len, fields, '-');
        mnstr_printf(toConsole, "next page? (continue,quit,next)");
-       mnstr_flush(toConsole);
+       mnstr_flush(toConsole, MNSTR_FLUSH_DATA);
        sz = mnstr_readline(fromConsole, buf, sizeof(buf));
        if (sz > 0) {
                if (buf[0] == 'c')
@@ -1789,7 +1789,7 @@ format_result(Mapi mid, MapiHdl hdl, boo
                timerHumanStop();
                /* handle errors first */
                if (mapi_result_error(hdl) != NULL) {
-                       mnstr_flush(toConsole);
+                       mnstr_flush(toConsole, MNSTR_FLUSH_DATA);
                        if (formatter == TABLEformatter) {
                                mapi_noexplain(mid, "");
                        } else {
@@ -2097,7 +2097,7 @@ doFileBulk(Mapi mid, stream *fp)
        timerEnd();
 
        free(buf);
-       mnstr_flush(toConsole);
+       mnstr_flush(toConsole, MNSTR_FLUSH_DATA);
        if (fp)
                close_stream(fp);
        return errseen;
@@ -2277,7 +2277,7 @@ doFile(Mapi mid, stream *fp, bool useins
                        mnstr_write(toConsole, p, 1, strlen(p));
 #endif
                }
-               mnstr_flush(toConsole);
+               mnstr_flush(toConsole, MNSTR_FLUSH_DATA);
                timerPause();
                /* read a line */
                length = 0;
@@ -3084,7 +3084,7 @@ putfile(void *data, const char *filename
                        return NULL; /* successfully opened file */
        } else if (buf == NULL) {
                /* done writing */
-               int flush = mnstr_flush(priv->f);
+               int flush = mnstr_flush(priv->f, MNSTR_FLUSH_DATA);
                close_stream(priv->f);
                priv->f = NULL;
                return flush < 0 ? "error writing output" : NULL;
diff --git a/clients/mapiclient/msqldump.c b/clients/mapiclient/msqldump.c
--- a/clients/mapiclient/msqldump.c
+++ b/clients/mapiclient/msqldump.c
@@ -246,7 +246,7 @@ main(int argc, char **argv)
                mnstr_printf(out, "COMMIT;\n");
        } else
                c = dump_database(mid, out, describe, useinserts);
-       mnstr_flush(out);
+       mnstr_flush(out, MNSTR_FLUSH_DATA);
 
        mapi_destroy(mid);
        if (mnstr_errnr(out)) {
diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -1393,7 +1393,7 @@ mapi_log_header(Mapi mid, char *mark)
        now = (usec() - firstcall) / 1000;
        mnstr_printf(mid->tracelog, ":%" PRId64 "[%" PRIu32 "]:%s\n",
                     now, mid->index, mark);
-       mnstr_flush(mid->tracelog);
+       mnstr_flush(mid->tracelog, MNSTR_FLUSH_DATA);
 }
 
 static void
@@ -1403,7 +1403,7 @@ mapi_log_record(Mapi mid, const char *ms
                return;
        mapi_log_header(mid, "W");
        mnstr_printf(mid->tracelog, "%s", msg);
-       mnstr_flush(mid->tracelog);
+       mnstr_flush(mid->tracelog, MNSTR_FLUSH_DATA);
 }
 
 MapiMsg
@@ -1528,7 +1528,7 @@ close_result(MapiHdl hdl)
                                mapi_log_record(mid, msg);
                                mid->active = hdl;
                                if (mnstr_printf(mid->to, "%s", msg) < 0 ||
-                                   mnstr_flush(mid->to)) {
+                                   mnstr_flush(mid->to, MNSTR_FLUSH_DATA)) {
                                        close_connection(mid);
                                        mapi_setError(mid, 
mnstr_error(mid->to), __func__, MTIMEOUT);
                                        break;
@@ -1546,7 +1546,7 @@ close_result(MapiHdl hdl)
                                mapi_log_record(mid, msg);
                                mid->active = hdl;
                                if (mnstr_printf(mid->to, "%s", msg) < 0 ||
-                                   mnstr_flush(mid->to)) {
+                                   mnstr_flush(mid->to, MNSTR_FLUSH_DATA)) {
                                        close_connection(mid);
                                        mapi_setError(mid, 
mnstr_error(mid->to), __func__, MTIMEOUT);
                                } else
@@ -1759,7 +1759,7 @@ finish_handle(MapiHdl hdl)
                        assert(mid->active == NULL || mid->active == hdl);
                        hdl->needmore = false;
                        mid->active = hdl;
-                       mnstr_flush(mid->to);
+                       mnstr_flush(mid->to, MNSTR_FLUSH_DATA);
                        check_stream(mid, mid->to, "write error on stream", 
mid->error);
                        read_into_cache(hdl, 0);
                }
@@ -1770,7 +1770,7 @@ finish_handle(MapiHdl hdl)
                        mapi_log_record(mid, msg);
                        mid->active = hdl;
                        if (mnstr_printf(mid->to, "%s", msg) < 0 ||
-                           mnstr_flush(mid->to)) {
+                           mnstr_flush(mid->to, MNSTR_FLUSH_DATA)) {
                                close_connection(mid);
                                mapi_setError(mid, mnstr_error(mid->to), 
__func__, MTIMEOUT);
                                break;
@@ -1789,7 +1789,7 @@ finish_handle(MapiHdl hdl)
                        assert(mid->active == NULL || mid->active == hdl);
                        hdl->needmore = false;
                        mid->active = hdl;
-                       mnstr_flush(mid->to);
+                       mnstr_flush(mid->to, MNSTR_FLUSH_DATA);
                        check_stream(mid, mid->to, "write error on stream", 
mid->error);
                        read_into_cache(hdl, 0);
                }
@@ -2805,7 +2805,7 @@ mapi_reconnect(Mapi mid)
        mnstr_write(mid->to, buf, 1, len);
        mapi_log_record(mid, buf);
        check_stream(mid, mid->to, "Could not send initial byte sequence", 
mid->error);
-       mnstr_flush(mid->to);
+       mnstr_flush(mid->to, MNSTR_FLUSH_DATA);
        check_stream(mid, mid->to, "Could not send initial byte sequence", 
mid->error);
 
        /* consume the welcome message from the server */
@@ -3329,7 +3329,7 @@ mapi_Xcommand(Mapi mid, const char *cmdn
        if (mid->active && read_into_cache(mid->active, 0) != MOK)
                return MERROR;
        if (mnstr_printf(mid->to, "X" "%s %s\n", cmdname, cmdvalue) < 0 ||
-           mnstr_flush(mid->to)) {
+           mnstr_flush(mid->to, MNSTR_FLUSH_DATA)) {
                close_connection(mid);
                mapi_setError(mid, mnstr_error(mid->to), __func__, MTIMEOUT);
                return MERROR;
@@ -3337,7 +3337,7 @@ mapi_Xcommand(Mapi mid, const char *cmdn
        if (mid->tracelog) {
                mapi_log_header(mid, "W");
                mnstr_printf(mid->tracelog, "X" "%s %s\n", cmdname, cmdvalue);
-               mnstr_flush(mid->tracelog);
+               mnstr_flush(mid->tracelog, MNSTR_FLUSH_DATA);
        }
        hdl = prepareQuery(mapi_new_handle(mid), "Xcommand");
        if (hdl == NULL)
@@ -3616,7 +3616,7 @@ read_line(Mapi mid)
                if (mid->tracelog) {
                        mapi_log_header(mid, "R");
                        mnstr_write(mid->tracelog, mid->blk.buf + mid->blk.end, 
1, len);
-                       mnstr_flush(mid->tracelog);
+                       mnstr_flush(mid->tracelog, MNSTR_FLUSH_DATA);
                }
                mid->blk.buf[mid->blk.end + len] = 0;
                if (mid->trace) {
@@ -4077,13 +4077,13 @@ write_file(MapiHdl hdl, char *filename)
        if (filename == NULL) {
                /* malloc failure */
                mnstr_printf(mid->to, "!HY001!allocation failure\n");
-               mnstr_flush(mid->to);
+               mnstr_flush(mid->to, MNSTR_FLUSH_DATA);
                return;
        }
        if (mid->putfilecontent == NULL) {
                free(filename);
                mnstr_printf(mid->to, "!HY000!cannot send files\n");
-               mnstr_flush(mid->to);
+               mnstr_flush(mid->to, MNSTR_FLUSH_DATA);
                return;
        }
        line = mid->putfilecontent(mid->filecontentprivate, filename, NULL, 0);
@@ -4092,10 +4092,10 @@ write_file(MapiHdl hdl, char *filename)
                if (strchr(line, '\n'))
                        line = "incorrect response from application";
                mnstr_printf(mid->to, "!HY000!%.64s\n", line);
-               mnstr_flush(mid->to);
+               mnstr_flush(mid->to, MNSTR_FLUSH_DATA);
                return;
        }
-       mnstr_flush(mid->to);
+       mnstr_flush(mid->to, MNSTR_FLUSH_DATA);
        while ((len = mnstr_read(mid->from, data, 1, sizeof(data))) > 0) {
                if (line == NULL)
                        line = mid->putfilecontent(mid->filecontentprivate,
@@ -4107,7 +4107,7 @@ write_file(MapiHdl hdl, char *filename)
        if (line && strchr(line, '\n'))
                line = "incorrect response from application";
        mnstr_printf(mid->to, "%s\n", line ? line : "");
-       mnstr_flush(mid->to);
+       mnstr_flush(mid->to, MNSTR_FLUSH_DATA);
 }
 
 #define MiB    (1 << 20)       /* a megabyte */
@@ -4123,13 +4123,13 @@ read_file(MapiHdl hdl, uint64_t off, cha
        if (filename == NULL) {
                /* malloc failure */
                mnstr_printf(mid->to, "!HY001!allocation failure\n");
-               mnstr_flush(mid->to);
+               mnstr_flush(mid->to, MNSTR_FLUSH_DATA);
                return;
        }
        if (mid->getfilecontent == NULL) {
                free(filename);
                mnstr_printf(mid->to, "!HY000!cannot retrieve files\n");
-               mnstr_flush(mid->to);
+               mnstr_flush(mid->to, MNSTR_FLUSH_DATA);
                return;
        }
        data = mid->getfilecontent(mid->filecontentprivate, filename, binary,
@@ -4139,7 +4139,7 @@ read_file(MapiHdl hdl, uint64_t off, cha
                if (strchr(data, '\n'))
                        data = "incorrect response from application";
                mnstr_printf(mid->to, "!HY000!%.64s\n", data);
-               mnstr_flush(mid->to);
+               mnstr_flush(mid->to, MNSTR_FLUSH_DATA);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to