Changeset: 18471e6cd453 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=18471e6cd453
Added Files:
        clients/mapiclient/mapisplit-dummy.c
        clients/mapiclient/profiler-dummy.c
Modified Files:
        clients/mapiclient/Makefile.ag
        clients/mapiclient/mclient.c
Branch: default
Log Message:

mclient progress meter part one, mal statement progress


diffs (148 lines):

diff --git a/clients/mapiclient/Makefile.ag b/clients/mapiclient/Makefile.ag
--- a/clients/mapiclient/Makefile.ag
+++ b/clients/mapiclient/Makefile.ag
@@ -16,7 +16,7 @@
 # All Rights Reserved.
 
 MTSAFE
-INCLUDES = ../mapilib ../../common/options ../../common/stream $(READLINE_INCS)
+INCLUDES = ../mapilib ../../common/options ../../common/stream 
../R/MonetDB.R/src/ $(READLINE_INCS)
 
 lib_mcutil = {
        NOINST
@@ -24,7 +24,7 @@ lib_mcutil = {
 }
 
 bin_mclient = {
-       SOURCES = mclient.c ReadlineTools.c ReadlineTools.h
+       SOURCES = mclient.c ReadlineTools.c ReadlineTools.h mapisplit-dummy.c 
profiler-dummy.c
        LIBS = libmcutil ../mapilib/libmapi \
                ../../common/stream/libstream \
                $(READLINE_LIBS) \
diff --git a/clients/mapiclient/mapisplit-dummy.c 
b/clients/mapiclient/mapisplit-dummy.c
new file mode 100644
--- /dev/null
+++ b/clients/mapiclient/mapisplit-dummy.c
@@ -0,0 +1,5 @@
+/*
+This refers to ../R/MonetDB.R/src/mapisplit.c . We cannot have this file here, 
+as the R connector needs to be able to compile stand-alone. 
+*/
+#include "mapisplit.c"
\ No newline at end of file
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -78,6 +78,8 @@
 #define S_ISREG(m)     (((m) & S_IFMT) == S_IFREG)
 #endif
 
+#include "profiler.h"
+
 enum modes {
        MAL,
        SQL,
@@ -1934,14 +1936,13 @@ doFileBulk(Mapi mid, FILE *fp)
                        }
                }
                timerResume();
-
                if (hdl == NULL) {
                        hdl = mapi_query_prep(mid);
                        CHECK_RESULT(mid, hdl, buf, continue, buf);
                }
 
                assert(hdl != NULL);
-
+               profiler_arm();
                mapi_query_part(hdl, buf, length);
                CHECK_RESULT(mid, hdl, buf, continue, buf);
 
@@ -2722,6 +2723,8 @@ doFile(Mapi mid, const char *file, int u
 
                if (hdl == NULL) {
                        timerStart();
+                       profiler_arm();
+
                        hdl = mapi_query_prep(mid);
                        CHECK_RESULT(mid, hdl, buf, continue, buf);
                } else
@@ -2861,6 +2864,7 @@ usage(const char *prog, int xit)
        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, " -P          | --progress         show progress 
bar\n");
        fprintf(stderr, "The file argument can be - for stdin\n");
        exit(xit);
 }
@@ -2887,6 +2891,7 @@ main(int argc, char **argv)
        int interactive = 0;
        int has_fileargs = 0;
        int option_index = 0;
+       int progress = 0;
        int settz = 1;
        int autocommit = 1;     /* autocommit mode default on */
        struct stat statb;
@@ -2912,6 +2917,7 @@ main(int argc, char **argv)
                {"pager", 1, 0, '|'},
 #endif
                {"port", 1, 0, 'p'},
+               {"progress", 0, 0, 'P'},
                {"rows", 1, 0, 'r'},
                {"statement", 1, 0, 's'},
 #if 0
@@ -2970,7 +2976,7 @@ main(int argc, char **argv)
 #if 0
                                "t"
 #endif
-                               "w:r:p:s:Xu:vzH?",
+                               "w:r:p:s:Xu:vzHP?",
                                long_options, &option_index)) != -1) {
                switch (c) {
                case 0:
@@ -3114,6 +3120,9 @@ main(int argc, char **argv)
                case 'z':
                        settz = 0;
                        break;
+               case 'P':
+                       progress = 1;
+                       break;
                case '?':
                        /* a bit of a hack: look at the option that the
                         * current `c' is based on and see if we recognize
@@ -3226,6 +3235,16 @@ main(int argc, char **argv)
                }
        }
 
+       // switch on progress bars
+       if (mode == SQL && progress) {
+               char* buf = malloc(100);
+               int port = profiler_start();
+               sprintf(buf, "CALL profiler_openstream('127.0.0.1', %d)", port);
+               mapi_query(mid, buf);
+               sprintf(buf, "CALL profiler_stethoscope(0)");
+               mapi_query(mid, buf);
+       }
+
        /* give the user a welcome message with some general info */
        if (!has_fileargs && command == NULL && isatty(fileno(stdin))) {
                char *lang;
@@ -3296,6 +3315,7 @@ main(int argc, char **argv)
                /* execute from command-line, need interactive to know whether
                 * to keep the mapi handle open */
                timerStart();
+               profiler_arm();
                c = doRequest(mid, command);
                timerEnd();
        }
diff --git a/clients/mapiclient/profiler-dummy.c 
b/clients/mapiclient/profiler-dummy.c
new file mode 100644
--- /dev/null
+++ b/clients/mapiclient/profiler-dummy.c
@@ -0,0 +1,5 @@
+/*
+This refers to ../R/MonetDB.R/src/profiler.c . We cannot have this file here, 
+as the R connector needs to be able to compile stand-alone. 
+*/
+#include "profiler.c"
\ No newline at end of file
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to