Changeset: 16bbadccc96e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/16bbadccc96e
Modified Files:
        clients/ChangeLog.Jan2022
        clients/mapiclient/mclient.c
Branch: Jan2022
Log Message:

Use a smaller (than infinite) mapi cache limit for the built-in pager.


diffs (75 lines):

diff --git a/clients/ChangeLog.Jan2022 b/clients/ChangeLog.Jan2022
--- a/clients/ChangeLog.Jan2022
+++ b/clients/ChangeLog.Jan2022
@@ -1,3 +1,10 @@
 # ChangeLog file for clients
 # This file is updated with Maddlog
 
+* Wed Feb 16 2022 Sjoerd Mullender <sjo...@acm.org>
+- Improved the handling of the \r command in mclient.  It now properly
+  counts the header of table, and when a (very) long table is being
+  printed and aborted part way in the built-in pager, not all data is
+  transferred to the client (and then discarded).  Instead at most 1000
+  rows are transferred.
+
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -1320,9 +1320,10 @@ RAWrenderer(MapiHdl hdl)
        }
 }
 
-static void
+static int
 SQLheader(MapiHdl hdl, int *len, int fields, char more)
 {
+       int rows = 1;                           /* start with the separator row 
*/
        SQLseparator(len, fields, '-');
        if (mapi_get_name(hdl, 0)) {
                int i;
@@ -1339,11 +1340,13 @@ SQLheader(MapiHdl hdl, int *len, int fie
                        names[i] = mapi_get_name(hdl, i);
                        numeric[i] = 0;
                }
-               SQLrow(len, numeric, names, fields, 1, more);
+               rows += SQLrow(len, numeric, names, fields, 1, more);
+               rows++;                                 /* add a separator row 
*/
                SQLseparator(len, fields, '=');
                free(names);
                free(numeric);
        }
+       return rows;
 }
 
 static void
@@ -1560,7 +1563,7 @@ SQLrenderer(MapiHdl hdl)
                        break;
        }
 
-       SQLheader(hdl, len, printfields, fields != printfields);
+       rows = SQLheader(hdl, len, printfields, fields != printfields);
 
        while ((rfields = fetch_row(hdl)) != 0) {
                if (mnstr_errnr(toConsole))
@@ -1603,8 +1606,10 @@ SQLrenderer(MapiHdl hdl)
                if (ps > 0 && rows >= ps && fromConsole != NULL) {
                        SQLpagemove(len, printfields, &ps, &silent);
                        rows = 0;
-                       if (silent)
-                               continue;
+                       if (silent) {
+                               mapi_finish(hdl);
+                               break;
+                       }
                }
 
                rows += SQLrow(len, numeric, rest, printfields, 2, 0);
@@ -3502,7 +3507,7 @@ main(int argc, char **argv)
                exit(2);
        }
 
-       mapi_cache_limit(mid, -1);
+       mapi_cache_limit(mid, 1000);
        mapi_setAutocommit(mid, autocommit);
        if (mode == SQL && !settz)
                mapi_set_time_zone(mid, 0);
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to