changeset 65788:b13a687ac3ec Mar2018

mclient: make (more) explicite, which formatter produces timing output and which does not
author Stefan Manegold <Stefan.Manegold@cwi.nl>
date Wed, 14 Feb 2018 03:14:12 +0100
parents 6b7d98a59a98
children 7be7f972a798
files clients/mapiclient/mclient.c
diffstat 1 files changed, 51 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -1843,11 +1843,9 @@ format_result(Mapi mid, MapiHdl hdl, int
 		case Q_UPDATE:
 			SQLqueryEcho(hdl);
 			if (formatter == RAWformatter ||
-			    formatter == TESTformatter)
+			    formatter == TESTformatter) {
 				mnstr_printf(toConsole, "[ %" PRId64 "\t]\n", mapi_rows_affected(hdl));
-			else if (formatter == TRASHformatter) {
-				timerHuman(sqloptimizer, maloptimizer, querytime, singleinstr, 0);
-			} else {
+			} else if (formatter != TRASHformatter) {
 				aff = mapi_rows_affected(hdl);
 				lid = mapi_get_last_id(hdl);
 				mnstr_printf(toConsole,
@@ -1861,16 +1859,46 @@ format_result(Mapi mid, MapiHdl hdl, int
 						     lid);
 				}
 				mnstr_printf(toConsole, "\n");
+			}
+			/* select which formatters show timing info (if requested) */
+			switch (formatter) {
+			/* these formatters never produce timing output */
+			case RAWformatter:
+			case TESTformatter:
+				break;
+			/* these formatters produce timing output when requested */
+			case NOformatter:
+			case CSVformatter:
+			case XMLformatter:
+			case SAMformatter:
+			case TRASHformatter:
+			case TABLEformatter:
+			case EXPANDEDformatter:
 				timerHuman(sqloptimizer, maloptimizer, querytime, singleinstr, 0);
+				break;
 			}
 			continue;
 		case Q_SCHEMA:
 			SQLqueryEcho(hdl);
 			if (formatter == TABLEformatter) {
 				mnstr_printf(toConsole, "operation successful\n");
+			}
+			/* select which formatters show timing info (if requested) */
+			switch (formatter) {
+			/* these formatters never produce timing output */
+			case NOformatter:
+			case RAWformatter:
+			case CSVformatter:
+			case XMLformatter:
+			case SAMformatter:
+			case TESTformatter:
+			case EXPANDEDformatter:
+				break;
+			/* these formatters produce timing output when requested */
+			case TRASHformatter:
+			case TABLEformatter:
 				timerHuman(sqloptimizer, maloptimizer, querytime, singleinstr, 0);
-			} else if (formatter == TRASHformatter) {
-				timerHuman(sqloptimizer, maloptimizer, querytime, singleinstr, 0);
+				break;
 			}
 			continue;
 		case Q_TRANS:
@@ -1957,7 +1985,23 @@ format_result(Mapi mid, MapiHdl hdl, int
 				RAWrenderer(hdl);
 				break;
 			}
-			timerHuman(sqloptimizer, maloptimizer, querytime, singleinstr, 0);
+			/* select which formatters show timing info (if requested) */
+			switch (formatter) {
+			/* these formatters never produce timing output */
+			case NOformatter:
+				break;
+			/* these formatters produce timing output when requested */
+			case RAWformatter:
+			case CSVformatter:
+			case XMLformatter:
+			case SAMformatter:
+			case TESTformatter:
+			case TRASHformatter:
+			case TABLEformatter:
+			case EXPANDEDformatter:
+				timerHuman(sqloptimizer, maloptimizer, querytime, singleinstr, 0);
+				break;
+			}
 		}
 	} while (!mnstr_errnr(toConsole) && (rc = mapi_next_result(hdl)) == 1);
 	/*