Re: [Monetdb-developers] [Monetdb-checkins] clients/src/mapiclient MapiClient.mx, Clients_1-20, 1.88.2.4, 1.88.2.5
Hi Sjoerd, Thanks for fixing some things I was unaware of (empty lines in other languages?)
The timer is again started when the first line of a query is typed. This is the case for *all* languages.
I cannot image cases where it is useful for mclient to keeps stays on someone's typing speed, while I can image cases where one would like to have information about query performance. Do others agree? (I maybe unjustly assumed that timing query performance was the intended behavior) Peter
-----Original Message----- From: monetdb-checkins-bounces@lists.sourceforge.net [mailto:monetdb-checkins-bounces@lists.sourceforge.net] On Behalf Of Sjoerd Mullender Sent: Wednesday, December 19, 2007 3:04 PM To: monetdb-checkins@lists.sourceforge.net Subject: [Monetdb-checkins] clients/src/mapiclient MapiClient.mx,Clients_1-20, 1.88.2.4, 1.88.2.5
Update of /cvsroot/monetdb/clients/src/mapiclient In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv6918
Modified Files: Tag: Clients_1-20 MapiClient.mx Log Message: Did Peter's checkin and Niels' fix correctly: In XQuery mode, when typing <> when there is no query yet will result in just asking for more data, and empty lines in other modes will not end the session. Also fixed \f processing in that the new value is now remembered for a subsequent bare \f. The timer is again started when the first line of a query is typed. This is the case for *all* languages.
Index: MapiClient.mx =================================================================== RCS file: /cvsroot/monetdb/clients/src/mapiclient/MapiClient.mx,v retrieving revision 1.88.2.4 retrieving revision 1.88.2.5 diff -u -d -r1.88.2.4 -r1.88.2.5 --- MapiClient.mx 19 Dec 2007 08:35:21 -0000 1.88.2.4 +++ MapiClient.mx 19 Dec 2007 14:04:09 -0000 1.88.2.5 @@ -152,6 +152,7 @@ XMLformatter }; static enum formatters formatter = NOformatter; +char *output = NULL; /* output format as string */
#define DEFWIDTH 80
@@ -247,8 +248,6 @@ } }
-char *output = NULL; /* output format is a global variable */ - static void SQLsetSpecial(const char *command) { @@ -796,9 +795,14 @@ }
static void -setFormatter(char *s) +setFormatter(Mapi mid, char *s) { - if (strcmp(s, "sql") == 0) + if (mode == XQUERY) { + mapi_output(mid, s); + if (output != NULL) + free(output); + output = strdup(s); + } else if (strcmp(s, "sql") == 0) formatter = TABLEformatter; else if (strcmp(s, "csv") == 0) formatter = CSVformatter; @@ -1123,13 +1127,13 @@ fprintf(toConsole, "\\a - disable auto commit\n"); } if (mode == XQUERY) { - fprintf(toConsole, "\\f - result format: dm or xml[-noheader][-typed|-noroot|-root-FOOBAR] \n"); - } else { + fprintf(toConsole, "\\f - result format: dm or xml[-noheader][-typed|-noroot|-root-FOOBAR]\n"); + } else { fprintf(toConsole, "\\e - echo the query in sql formatting mode\n"); - fprintf(toConsole, "\\f - format using a built-in renderer {csv,tab,raw,sql,xml} \n"); + fprintf(toConsole, "\\f - format using a built-in renderer {csv,tab,raw,sql,xml}\n"); fprintf(toConsole, "\\w# - set maximal page width (-1=raw,0=no limit, >0 max char)\n"); - fprintf(toConsole, "\\r# - set maximum rows per page (-1=raw)\n "); - } + fprintf(toConsole, "\\r# - set maximum rows per page (-1=raw)\n"); + } fprintf(toConsole, "\\L file - save client/server interaction\n"); fprintf(toConsole, "\\X - trace mclient code\n"); fprintf(toConsole, "\\q - terminate session\n"); @@ -1140,9 +1144,10 @@ { char *line = NULL; char *buf = NULL; - ssize_t length; + size_t length; MapiHdl hdl = mapi_get_active(mid); MapiMsg rc = MOK; + int sent = 0; /* whether we sent any data to the server */
#ifdef HAVE_LIBREADLINE if (prompt == NULL) @@ -1185,13 +1190,17 @@ line = fgets(buf, BUFSIZ, fp); } if (line == NULL || (mode == XQUERY && line[0] == '<' && line[1] == '>')) { - length = 0; - if (line) - length = -1; - else if (hdl == NULL) - return 0; /* EOF: nothing more to do */ + /* end of file */ + if (hdl == NULL) { + if (line != NULL) + continue; + /* nothing more to do */ + return 0; + } + /* hdl != NULL, we should finish the current query */ line = NULL; + length = 0; } else length = strlen(line); if (hdl == NULL && length > 0 && line[length - 1] == '\n') { @@ -1217,7 +1226,7 @@ if (mark2) free(mark2); mark2 = strdup(line + 2); - if (mode == XQUERY) + if (mode == XQUERY)
mapi_profile(mid, mark != NULL); continue; case 'X': @@ -1378,31 +1387,31 @@ if (*line == 0) {
fprintf(toConsole, "Current formatter: "); if (mode == XQUERY) - fprintf(toConsole, "%s\n", output); - else switch (formatter) { - case RAWformatter: - fprintf(toConsole, "raw\n"); - break; - case TABLEformatter: - fprintf(toConsole, "sql\n"); - break; - case CSVformatter: - fprintf(toConsole, "csv\n"); - break; - case TABformatter: - fprintf(toConsole, "tab\n"); - break; - case XMLformatter: - fprintf(toConsole, "xml\n"); - break; - default: - fprintf(toConsole, "none\n"); - break; + fprintf(toConsole, "%s\n", output == NULL ? "dm" : output); + else { + switch (formatter) { + case RAWformatter: + fprintf(toConsole, "raw\n"); + break; + case TABLEformatter: + fprintf(toConsole, "sql\n"); + break; + case CSVformatter: + fprintf(toConsole, "csv\n"); + break; + case TABformatter: + fprintf(toConsole, "tab\n"); + break; + case XMLformatter: + fprintf(toConsole, "xml\n"); + break; + default: + fprintf(toConsole, "none\n"); + break; + } } - } else if (mode == XQUERY) - mapi_output(mid, line); - else - setFormatter(line); + } else + setFormatter(mid, line); continue; default: showCommands(); @@ -1412,34 +1421,37 @@ }
if (hdl == NULL) { + timerStart(); hdl = mapi_query_prep(mid); CHECK_RESULT(mid, hdl, buf, continue); } assert(hdl != NULL);
if (length > 0) { + sent = 1; SQLsetSpecial(line); mapi_query_part(hdl, line, length); CHECK_RESULT(mid, hdl, buf, continue); }
- if (mode == XQUERY && line) - continue; /* XQuery always wants more data */ - /* If the server wants more but we're at the end of file (line == NULL), notify the server that we don't have anything more. If the server still wants more (shouldn't happen according to the protocol) we break out of the loop (via the continue). The - assertion at the end will then go off. - */ - timerStart(); - if (mapi_query_done(hdl) == MMORE) { - assert(mode != XQUERY); /* XQuery never sends MMORE */ - if (line != NULL) continue; /* get more data */ - timerStart(); - if (mapi_query_done(hdl) == MMORE) { + assertion at the end will then go off. + + Note that XQuery is weird: we continue + sending more until we reach end-of-file, + and *then* we send the mapi_query_done. To + exit, you need to send an end-of-file + again. */ + if (mode == XQUERY || mapi_query_done(hdl) == MMORE) { + if (line != NULL) { + continue; /* get more data */ + } else if (mapi_query_done(hdl) == MMORE) { + assert(mode != XQUERY); /* XQuery never sends MMORE */ hdl = NULL; continue; /* done */ } @@ -1459,7 +1471,7 @@
/* for XQuery, only exit when end-of-file and we didn't send any data */ - } while (hdl != NULL); + } while (line != NULL || (mode == XQUERY && sent)); /* reached on end of file */ assert(hdl == NULL); return 0; @@ -1603,7 +1615,6 @@ strcmp(optarg, "x") == 0) { language = "xquery"; mode = XQUERY; - if (!output) output = "dm"; } else { fprintf(stderr, "language option needs to be one of sql, mil, mal, or xquery\n"); exit(-1); @@ -1618,7 +1629,7 @@ passwd = optarg; /* can be NULL */ break; case 'f': - output = optarg; /* output format */ + output = strdup(optarg); /* output format */ break; case 'I': input = optarg; @@ -1726,13 +1737,8 @@
mapi_profile(mid, mark != NULL); mapi_trace(mid, trace); - - if (output) { - if (mode == XQUERY) - mapi_output(mid, output); - else - setFormatter(output); - } + if (output) + setFormatter(mid, output);
c = 0;
-------------------------------------------------------------- ----------- SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.n et/marketplace
Monetdb-checkins mailing list Monetdb-checkins@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-checkins
On Fri, Dec 21, 2007 at 11:55:34AM +0100, Peter Boncz wrote:
Hi Sjoerd,
Thanks for fixing some things I was unaware of (empty lines in other languages?)
(As usually) Testing was aware and told us about it ;-) In detail (as far as I can quickly recall): Many MIL and almost all(?) SQL test failed, as they list multiple statements in one script, each terminated by the mandatory ';' but also oftenseparated by empty lines for human readability. The latter is perfectly sound with the respective languages syntaxes. Testing (Mtest.py) runs (most) (server and client) tests by redirecting the given test script to the server's/client's standard input (as opposed to reading from a file --- a feature that was originally introduced to keep the tests going beyond the first error), and with yoru changes, mclient apparently considered an empty line to be the end of a session. Stefan
The timer is again started when the first line of a query is typed. This is the case for *all* languages.
I cannot image cases where it is useful for mclient to keeps stays on someone's typing speed, while I can image cases where one would like to have information about query performance. Do others agree?
(I maybe unjustly assumed that timing query performance was the intended behavior)
Peter
-----Original Message----- From: monetdb-checkins-bounces@lists.sourceforge.net [mailto:monetdb-checkins-bounces@lists.sourceforge.net] On Behalf Of Sjoerd Mullender Sent: Wednesday, December 19, 2007 3:04 PM To: monetdb-checkins@lists.sourceforge.net Subject: [Monetdb-checkins] clients/src/mapiclient MapiClient.mx,Clients_1-20, 1.88.2.4, 1.88.2.5
Update of /cvsroot/monetdb/clients/src/mapiclient In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv6918
Modified Files: Tag: Clients_1-20 MapiClient.mx Log Message: Did Peter's checkin and Niels' fix correctly: In XQuery mode, when typing <> when there is no query yet will result in just asking for more data, and empty lines in other modes will not end the session. Also fixed \f processing in that the new value is now remembered for a subsequent bare \f. The timer is again started when the first line of a query is typed. This is the case for *all* languages. [...]
-- | Dr. Stefan Manegold | mailto:Stefan.Manegold@cwi.nl | | CWI, P.O.Box 94079 | http://www.cwi.nl/~manegold/ | | 1090 GB Amsterdam | Tel.: +31 (20) 592-4212 | | The Netherlands | Fax : +31 (20) 592-4312 |
On Fri, Dec 21, 2007 at 11:55:34AM +0100, Peter Boncz wrote:
Hi Sjoerd,
Thanks for fixing some things I was unaware of (empty lines in other languages?)
The timer is again started when the first line of a query is typed. This is the case for *all* languages.
I cannot image cases where it is useful for mclient to keeps stays on someone's typing speed, while I can image cases where one would like to have information about query performance. Do others agree?
(I maybe unjustly assumed that timing query performance was the intended behavior) The timing was/is meant for overall query performance, ie sending query + query execution + receiving the result (or part of it) in non interactive setups.
Niels
Peter
-----Original Message----- From: monetdb-checkins-bounces@lists.sourceforge.net [mailto:monetdb-checkins-bounces@lists.sourceforge.net] On Behalf Of Sjoerd Mullender Sent: Wednesday, December 19, 2007 3:04 PM To: monetdb-checkins@lists.sourceforge.net Subject: [Monetdb-checkins] clients/src/mapiclient MapiClient.mx,Clients_1-20, 1.88.2.4, 1.88.2.5
Update of /cvsroot/monetdb/clients/src/mapiclient In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv6918
Modified Files: Tag: Clients_1-20 MapiClient.mx Log Message: Did Peter's checkin and Niels' fix correctly: In XQuery mode, when typing <> when there is no query yet will result in just asking for more data, and empty lines in other modes will not end the session. Also fixed \f processing in that the new value is now remembered for a subsequent bare \f. The timer is again started when the first line of a query is typed. This is the case for *all* languages.
Index: MapiClient.mx =================================================================== RCS file: /cvsroot/monetdb/clients/src/mapiclient/MapiClient.mx,v retrieving revision 1.88.2.4 retrieving revision 1.88.2.5 diff -u -d -r1.88.2.4 -r1.88.2.5 --- MapiClient.mx 19 Dec 2007 08:35:21 -0000 1.88.2.4 +++ MapiClient.mx 19 Dec 2007 14:04:09 -0000 1.88.2.5 @@ -152,6 +152,7 @@ XMLformatter }; static enum formatters formatter = NOformatter; +char *output = NULL; /* output format as string */
#define DEFWIDTH 80
@@ -247,8 +248,6 @@ } }
-char *output = NULL; /* output format is a global variable */ - static void SQLsetSpecial(const char *command) { @@ -796,9 +795,14 @@ }
static void -setFormatter(char *s) +setFormatter(Mapi mid, char *s) { - if (strcmp(s, "sql") == 0) + if (mode == XQUERY) { + mapi_output(mid, s); + if (output != NULL) + free(output); + output = strdup(s); + } else if (strcmp(s, "sql") == 0) formatter = TABLEformatter; else if (strcmp(s, "csv") == 0) formatter = CSVformatter; @@ -1123,13 +1127,13 @@ fprintf(toConsole, "\\a - disable auto commit\n"); } if (mode == XQUERY) { - fprintf(toConsole, "\\f - result format: dm or xml[-noheader][-typed|-noroot|-root-FOOBAR] \n"); - } else { + fprintf(toConsole, "\\f - result format: dm or xml[-noheader][-typed|-noroot|-root-FOOBAR]\n"); + } else { fprintf(toConsole, "\\e - echo the query in sql formatting mode\n"); - fprintf(toConsole, "\\f - format using a built-in renderer {csv,tab,raw,sql,xml} \n"); + fprintf(toConsole, "\\f - format using a built-in renderer {csv,tab,raw,sql,xml}\n"); fprintf(toConsole, "\\w# - set maximal page width (-1=raw,0=no limit, >0 max char)\n"); - fprintf(toConsole, "\\r# - set maximum rows per page (-1=raw)\n "); - } + fprintf(toConsole, "\\r# - set maximum rows per page (-1=raw)\n"); + } fprintf(toConsole, "\\L file - save client/server interaction\n"); fprintf(toConsole, "\\X - trace mclient code\n"); fprintf(toConsole, "\\q - terminate session\n"); @@ -1140,9 +1144,10 @@ { char *line = NULL; char *buf = NULL; - ssize_t length; + size_t length; MapiHdl hdl = mapi_get_active(mid); MapiMsg rc = MOK; + int sent = 0; /* whether we sent any data to the server */
#ifdef HAVE_LIBREADLINE if (prompt == NULL) @@ -1185,13 +1190,17 @@ line = fgets(buf, BUFSIZ, fp); } if (line == NULL || (mode == XQUERY && line[0] == '<' && line[1] == '>')) { - length = 0; - if (line) - length = -1; - else if (hdl == NULL) - return 0; /* EOF: nothing more to do */ + /* end of file */ + if (hdl == NULL) { + if (line != NULL) + continue; + /* nothing more to do */ + return 0; + } + /* hdl != NULL, we should finish the current query */ line = NULL; + length = 0; } else length = strlen(line); if (hdl == NULL && length > 0 && line[length - 1] == '\n') { @@ -1217,7 +1226,7 @@ if (mark2) free(mark2); mark2 = strdup(line + 2); - if (mode == XQUERY) + if (mode == XQUERY)
mapi_profile(mid, mark != NULL); continue; case 'X': @@ -1378,31 +1387,31 @@ if (*line == 0) {
fprintf(toConsole, "Current formatter: "); if (mode == XQUERY) - fprintf(toConsole, "%s\n", output); - else switch (formatter) { - case RAWformatter: - fprintf(toConsole, "raw\n"); - break; - case TABLEformatter: - fprintf(toConsole, "sql\n"); - break; - case CSVformatter: - fprintf(toConsole, "csv\n"); - break; - case TABformatter: - fprintf(toConsole, "tab\n"); - break; - case XMLformatter: - fprintf(toConsole, "xml\n"); - break; - default: - fprintf(toConsole, "none\n"); - break; + fprintf(toConsole, "%s\n", output == NULL ? "dm" : output); + else { + switch (formatter) { + case RAWformatter: + fprintf(toConsole, "raw\n"); + break; + case TABLEformatter: + fprintf(toConsole, "sql\n"); + break; + case CSVformatter: + fprintf(toConsole, "csv\n"); + break; + case TABformatter: + fprintf(toConsole, "tab\n"); + break; + case XMLformatter: + fprintf(toConsole, "xml\n"); + break; + default: + fprintf(toConsole, "none\n"); + break; + } } - } else if (mode == XQUERY) - mapi_output(mid, line); - else - setFormatter(line); + } else + setFormatter(mid, line); continue; default: showCommands(); @@ -1412,34 +1421,37 @@ }
if (hdl == NULL) { + timerStart(); hdl = mapi_query_prep(mid); CHECK_RESULT(mid, hdl, buf, continue); } assert(hdl != NULL);
if (length > 0) { + sent = 1; SQLsetSpecial(line); mapi_query_part(hdl, line, length); CHECK_RESULT(mid, hdl, buf, continue); }
- if (mode == XQUERY && line) - continue; /* XQuery always wants more data */ - /* If the server wants more but we're at the end of file (line == NULL), notify the server that we don't have anything more. If the server still wants more (shouldn't happen according to the protocol) we break out of the loop (via the continue). The - assertion at the end will then go off. - */ - timerStart(); - if (mapi_query_done(hdl) == MMORE) { - assert(mode != XQUERY); /* XQuery never sends MMORE */ - if (line != NULL) continue; /* get more data */ - timerStart(); - if (mapi_query_done(hdl) == MMORE) { + assertion at the end will then go off. + + Note that XQuery is weird: we continue + sending more until we reach end-of-file, + and *then* we send the mapi_query_done. To + exit, you need to send an end-of-file + again. */ + if (mode == XQUERY || mapi_query_done(hdl) == MMORE) { + if (line != NULL) { + continue; /* get more data */ + } else if (mapi_query_done(hdl) == MMORE) { + assert(mode != XQUERY); /* XQuery never sends MMORE */ hdl = NULL; continue; /* done */ } @@ -1459,7 +1471,7 @@
/* for XQuery, only exit when end-of-file and we didn't send any data */ - } while (hdl != NULL); + } while (line != NULL || (mode == XQUERY && sent)); /* reached on end of file */ assert(hdl == NULL); return 0; @@ -1603,7 +1615,6 @@ strcmp(optarg, "x") == 0) { language = "xquery"; mode = XQUERY; - if (!output) output = "dm"; } else { fprintf(stderr, "language option needs to be one of sql, mil, mal, or xquery\n"); exit(-1); @@ -1618,7 +1629,7 @@ passwd = optarg; /* can be NULL */ break; case 'f': - output = optarg; /* output format */ + output = strdup(optarg); /* output format */ break; case 'I': input = optarg; @@ -1726,13 +1737,8 @@
mapi_profile(mid, mark != NULL); mapi_trace(mid, trace); - - if (output) { - if (mode == XQUERY) - mapi_output(mid, output); - else - setFormatter(output); - } + if (output) + setFormatter(mid, output);
c = 0;
-------------------------------------------------------------- ----------- SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.n et/marketplace
Monetdb-checkins mailing list Monetdb-checkins@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-checkins
------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Monetdb-developers mailing list Monetdb-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-developers
-- Niels Nes, Centre for Mathematics and Computer Science (CWI) Kruislaan 413, 1098 SJ Amsterdam, The Netherlands room C0.02, phone ++31 20 592-4098, fax ++31 20 592-4312 url: http://www.cwi.nl/~niels e-mail: Niels.Nes@cwi.nl
Hi Niels,
The timing was/is meant for overall query performance, ie sending query + query execution + receiving the result (or part of it) in non interactive setups.
ok, clear. So, would people agree then that in *interactive* mclient mode, timing only the query would be an improvement of the functionality? best, Peter
-----Original Message----- From: Niels Nes [mailto:Niels.Nes@cwi.nl] Sent: Friday, December 21, 2007 12:31 PM To: Peter Boncz Cc: monetdb-developers@lists.sourceforge.net; sjoerd.mullender@cwi.nl Subject: Re: [Monetdb-developers] [Monetdb-checkins] clients/src/mapiclientMapiClient.mx, Clients_1-20, 1.88.2.4, 1.88.2.5
Hi Sjoerd,
Thanks for fixing some things I was unaware of (empty lines in other languages?)
The timer is again started when the first line of a query is typed. This is the case for *all* languages.
I cannot image cases where it is useful for mclient to keeps stays on someone's typing speed, while I can image cases where one would like to have information about query performance. Do others agree?
(I maybe unjustly assumed that timing query performance was
On Fri, Dec 21, 2007 at 11:55:34AM +0100, Peter Boncz wrote: the intended
behavior) The timing was/is meant for overall query performance, ie sending query + query execution + receiving the result (or part of it) in non interactive setups.
Niels
Peter
-----Original Message----- From: monetdb-checkins-bounces@lists.sourceforge.net [mailto:monetdb-checkins-bounces@lists.sourceforge.net] On Behalf Of Sjoerd Mullender Sent: Wednesday, December 19, 2007 3:04 PM To: monetdb-checkins@lists.sourceforge.net Subject: [Monetdb-checkins] clients/src/mapiclient MapiClient.mx,Clients_1-20, 1.88.2.4, 1.88.2.5
Update of /cvsroot/monetdb/clients/src/mapiclient In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv6918
Modified Files: Tag: Clients_1-20 MapiClient.mx Log Message: Did Peter's checkin and Niels' fix correctly: In XQuery mode, when typing <> when there is no query yet will result in just
more data, and empty lines in other modes will not end
asking for the session.
Also fixed \f processing in that the new value is now remembered for a subsequent bare \f. The timer is again started when the first line of a query is typed. This is the case for *all* languages.
Index: MapiClient.mx
===================================================================
RCS file: /cvsroot/monetdb/clients/src/mapiclient/MapiClient.mx,v retrieving revision 1.88.2.4 retrieving revision 1.88.2.5 diff -u -d -r1.88.2.4 -r1.88.2.5 --- MapiClient.mx 19 Dec 2007 08:35:21 -0000 1.88.2.4 +++ MapiClient.mx 19 Dec 2007 14:04:09 -0000 1.88.2.5 @@ -152,6 +152,7 @@ XMLformatter }; static enum formatters formatter = NOformatter; +char *output = NULL; /* output format as string */
#define DEFWIDTH 80
@@ -247,8 +248,6 @@ } }
-char *output = NULL; /* output format is a global variable */ - static void SQLsetSpecial(const char *command) { @@ -796,9 +795,14 @@ }
static void -setFormatter(char *s) +setFormatter(Mapi mid, char *s) { - if (strcmp(s, "sql") == 0) + if (mode == XQUERY) { + mapi_output(mid, s); + if (output != NULL) + free(output); + output = strdup(s); + } else if (strcmp(s, "sql") == 0) formatter = TABLEformatter; else if (strcmp(s, "csv") == 0) formatter = CSVformatter; @@ -1123,13 +1127,13 @@ fprintf(toConsole, "\\a - disable auto commit\n"); } if (mode == XQUERY) { - fprintf(toConsole, "\\f - result format: dm or xml[-noheader][-typed|-noroot|-root-FOOBAR] \n"); - } else { + fprintf(toConsole, "\\f - result format: dm or xml[-noheader][-typed|-noroot|-root-FOOBAR]\n"); + } else { fprintf(toConsole, "\\e - echo the query in sql formatting mode\n"); - fprintf(toConsole, "\\f - format using a built-in renderer {csv,tab,raw,sql,xml} \n"); + fprintf(toConsole, "\\f - format using a built-in renderer {csv,tab,raw,sql,xml}\n"); fprintf(toConsole, "\\w# - set maximal page width (-1=raw,0=no limit, >0 max char)\n"); - fprintf(toConsole, "\\r# - set maximum rows per page (-1=raw)\n "); - } + fprintf(toConsole, "\\r# - set maximum rows per page (-1=raw)\n"); + } fprintf(toConsole, "\\L file - save client/server interaction\n"); fprintf(toConsole, "\\X - trace mclient code\n"); fprintf(toConsole, "\\q - terminate session\n"); @@ -1140,9 +1144,10 @@ { char *line = NULL; char *buf = NULL; - ssize_t length; + size_t length; MapiHdl hdl = mapi_get_active(mid); MapiMsg rc = MOK; + int sent = 0; /* whether we sent any data to the server */
#ifdef HAVE_LIBREADLINE if (prompt == NULL) @@ -1185,13 +1190,17 @@ line = fgets(buf, BUFSIZ, fp); } if (line == NULL || (mode == XQUERY && line[0] == '<' && line[1] == '>')) { - length = 0; - if (line) - length = -1; - else if (hdl == NULL) - return 0; /* EOF: nothing more to do */ + /* end of file */ + if (hdl == NULL) { + if (line != NULL) + continue; + /* nothing more to do */ + return 0; + } + /* hdl != NULL, we should finish the current query */ line = NULL; + length = 0; } else length = strlen(line); if (hdl == NULL && length > 0 && line[length - 1] == '\n') { @@ -1217,7 +1226,7 @@ if (mark2) free(mark2); mark2 = strdup(line + 2); - if (mode == XQUERY) + if (mode == XQUERY)
mapi_profile(mid, mark != NULL); continue; case 'X': @@ -1378,31 +1387,31 @@ if (*line == 0) {
fprintf(toConsole, "Current formatter: "); if (mode == XQUERY) - fprintf(toConsole, "%s\n", output); - else switch (formatter) { - case RAWformatter: - fprintf(toConsole, "raw\n"); - break; - case TABLEformatter: - fprintf(toConsole, "sql\n"); - break; - case CSVformatter: - fprintf(toConsole, "csv\n"); - break; - case TABformatter: - fprintf(toConsole, "tab\n"); - break; - case XMLformatter: - fprintf(toConsole, "xml\n"); - break; - default: - fprintf(toConsole, "none\n"); - break; + fprintf(toConsole, "%s\n", output == NULL ? "dm" : output); + else { + switch (formatter) { + case RAWformatter: + fprintf(toConsole, "raw\n"); + break; + case TABLEformatter: + fprintf(toConsole, "sql\n"); + break; + case CSVformatter: + fprintf(toConsole, "csv\n"); + break; + case TABformatter: + fprintf(toConsole, "tab\n"); + break; + case XMLformatter: + fprintf(toConsole, "xml\n"); + break; + default: + fprintf(toConsole, "none\n"); + break; + } } - } else if (mode == XQUERY) - mapi_output(mid, line); - else - setFormatter(line); + } else + setFormatter(mid, line); continue; default: showCommands(); @@ -1412,34 +1421,37 @@ }
if (hdl == NULL) { + timerStart(); hdl = mapi_query_prep(mid); CHECK_RESULT(mid, hdl, buf, continue); } assert(hdl != NULL);
if (length > 0) { + sent = 1; SQLsetSpecial(line); mapi_query_part(hdl, line, length); CHECK_RESULT(mid, hdl, buf, continue); }
- if (mode == XQUERY && line) - continue; /* XQuery always wants more data */ - /* If the server wants more but we're at the end of file (line == NULL), notify the server that we don't have anything more. If the server still wants more (shouldn't happen according to the protocol) we break out of the loop (via the continue). The - assertion at the end will then go off. - */ - timerStart(); - if (mapi_query_done(hdl) == MMORE) { - assert(mode != XQUERY); /* XQuery never sends MMORE */ - if (line != NULL) continue; /* get more data */ - timerStart(); - if (mapi_query_done(hdl) == MMORE) { + assertion at the end will then go off. + + Note that XQuery is weird: we continue + sending more until we reach end-of-file, + and *then* we send the mapi_query_done. To + exit, you need to send an end-of-file + again. */ + if (mode == XQUERY || mapi_query_done(hdl) == MMORE) { + if (line != NULL) { + continue; /* get more data */ + } else if (mapi_query_done(hdl) == MMORE) { + assert(mode != XQUERY); /* XQuery never sends MMORE */ hdl = NULL; continue; /* done */ } @@ -1459,7 +1471,7 @@
/* for XQuery, only exit when end-of-file and we didn't send any data */ - } while (hdl != NULL); + } while (line != NULL || (mode == XQUERY && sent)); /* reached on end of file */ assert(hdl == NULL); return 0; @@ -1603,7 +1615,6 @@ strcmp(optarg, "x") == 0) { language = "xquery"; mode = XQUERY; - if (!output) output = "dm"; } else { fprintf(stderr, "language option needs to be one of sql, mil, mal, or xquery\n"); exit(-1); @@ -1618,7 +1629,7 @@ passwd = optarg; /* can be NULL */ break; case 'f': - output = optarg; /* output format */ + output = strdup(optarg); /* output format */ break; case 'I': input = optarg; @@ -1726,13 +1737,8 @@
mapi_profile(mid, mark != NULL); mapi_trace(mid, trace); - - if (output) { - if (mode == XQUERY) - mapi_output(mid, output); - else - setFormatter(output); - } + if (output) + setFormatter(mid, output);
c = 0;
-------------------------------------------------------------- ----------- SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.n et/marketplace
Monetdb-checkins mailing list Monetdb-checkins@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-checkins
-------------------------------------------------------------- -----------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Monetdb-developers mailing list Monetdb-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-developers
--
Niels Nes, Centre for Mathematics and Computer Science (CWI) Kruislaan 413, 1098 SJ Amsterdam, The Netherlands room C0.02, phone ++31 20 592-4098, fax ++31 20 592-4312 url: http://www.cwi.nl/~niels e-mail: Niels.Nes@cwi.nl
Peter Boncz wrote:
Hi Niels,
The timing was/is meant for overall query performance, ie sending query + query execution + receiving the result (or part of it) in non interactive setups.
ok, clear.
So, would people agree then that in *interactive* mclient mode, timing only the query would be an improvement of the functionality?
Timing the time it takes to execute the query is indeed what would be done in an ideal world, but the world is not ideal. The problem is mostly with the non XQuery languages where you can have multiple statements on a single line and single statements on multiple lines. The timer should be started when the first part of a query is sent, since that first part may already contain a full query which you want to include in the time. If the server then wants more input because on that same first line there was the start of a second query, you necessarily include the time it takes for the user to type that second line. There isn't really much you can do about that. XQuery is different since there are no multiple queries on a line, and mclient knows where the query boundaries are. So mclient could do the timing properly. However, that means that the code has to differentiate between XQuery and the other languages. There are already too many of those places for my liking. So timing works best when you present mclient with a file instead of attempting to do it interactively. -- Sjoerd Mullender
Peter Boncz wrote:
Hi Niels,
The timing was/is meant for overall query performance, ie sending query + query execution + receiving the result (or part of it) in non interactive setups.
ok, clear.
So, would people agree then that in *interactive* mclient mode, timing only the query would be an improvement of the functionality?
best,
Peter The actual query timing should be captured and returned by the back-end itself.
Empty lines are empty requests to the server and mclient does not perform any analysis. Skipping empty lines is not easy, unless you bring in language semantics. I.e. just ignoring lines with blancs may not be appropriate. And the timing illustrates that indeed an empty request was handled. So keep mclient simple.
Hi Martin, et al
The actual query timing should be captured and returned by the back-end itself.
That is done already, indeed, in XQuery. It provides even a breakup in Trans+Shred+Query+Update/Print. But it is also interesting to see the communication time between mclient and Mserver. That you get by doing Timer-SUM(servertime). By including client think time in interactive mode, this insight is missing now. I recall that in previous versions of MapiClient, this was not an issue; so when I noticed it, I thought it was a bug.
Empty lines are empty requests to the server and mclient does not perform any analysis. Skipping empty lines is not easy, unless you bring in language semantics. I.e. just ignoring lines with blancs may not be appropriate.
In case of XQuery, the mclient does not send the empty lines to the server; it always parses through intil a CTRL-D or <> is encountered. This is the existing state of affairs, and I do not propose to change that.
And the timing illustrates that indeed an empty request was handled.
I do not understand the above. The question I posed is whether in interactive mode, for XQuery (because it may not be useful for other languages), we could make the timing more accurate by resetting the time counter just before the query is sent. For XQuery that would give the perfect insight in communication time. Knowing about the communication time is informative, and recall that this cannot be done server-side. Another option is to exclude the in my eyes now confusing Timer functionality for all languages in interactive mode. Peter
-----Original Message----- From: Martin Kersten [mailto:Martin.Kersten@cwi.nl] Sent: Friday, December 21, 2007 1:15 PM To: P.Boncz@cwi.nl; monetdb-developers@lists.sourceforge.net Subject: Re: [Monetdb-developers] [Monetdb-checkins] clients/src/mapiclientMapiClient.mx, Clients_1-20, 1.88.2.4, 1.88.2.5
Peter Boncz wrote:
Hi Niels,
The timing was/is meant for overall query performance, ie sending query + query execution + receiving the result (or part of it) in non interactive setups.
ok, clear.
So, would people agree then that in *interactive* mclient mode, timing only the query would be an improvement of the functionality?
best,
Peter The actual query timing should be captured and returned by the back-end itself.
Empty lines are empty requests to the server and mclient does not perform any analysis. Skipping empty lines is not easy, unless you bring in language semantics. I.e. just ignoring lines with blancs may not be appropriate.
And the timing illustrates that indeed an empty request was handled. So keep mclient simple.
participants (5)
-
Martin Kersten
-
Niels Nes
-
Peter Boncz
-
Sjoerd Mullender
-
Stefan Manegold