Changeset: 94542d05b6dc for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/94542d05b6dc
Modified Files:
        clients/mapiclient/mclient.c
        clients/mapilib/mapi.c
        common/stream/mapi_stream.c
        monetdb5/modules/mal/tablet.c
Branch: client_interrupts
Log Message:

Implemented abort in COPY INTO ON CLIENT.


diffs (91 lines):

diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -3135,6 +3135,10 @@ getfile(void *data, const char *filename
                                return (char*) mnstr_peek_error(NULL);
                }
                while (offset > 1) {
+                       if (state == INTERRUPT) {
+                               close_stream(f);
+                               return "interrupted";
+                       }
                        s = mnstr_readline(f, buf, READSIZE);
                        if (s < 0) {
                                close_stream(f);
@@ -3158,6 +3162,11 @@ getfile(void *data, const char *filename
                        return NULL;
                }
        }
+       if (state == INTERRUPT) {
+               close_stream(f);
+               priv->f = NULL;
+               return "interrupted";
+       }
        s = mnstr_read(f, buf, 1, READSIZE);
        if (s <= 0) {
                close_stream(f);
diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -3340,6 +3340,12 @@ read_file(MapiHdl hdl, uint64_t off, cha
                        data = mid->getfilecontent(mid->filecontentprivate, 
NULL, false, 0, &size);
                }
        }
+       if (data != NULL && size == 0) {
+               /* some error occurred */
+               mnstr_clearerr(mid->from);
+               if (mid->oobintr)
+                       mnstr_putoob(mid->to, 1);
+       }
        mnstr_flush(mid->to, MNSTR_FLUSH_DATA);
        line = read_line(mid);
        if (line == NULL)
diff --git a/common/stream/mapi_stream.c b/common/stream/mapi_stream.c
--- a/common/stream/mapi_stream.c
+++ b/common/stream/mapi_stream.c
@@ -150,6 +150,7 @@ setup_transfer(const char *req, const ch
        ssize_t nwritten;
        ssize_t nread;
        bool ok;
+       int oob = 0;
 
        while (!bs->eof)
                bstream_next(bs);
@@ -169,9 +170,19 @@ setup_transfer(const char *req, const ch
 
        char buf[256];
        nread = mnstr_readline(rs, buf, sizeof(buf));
-       ok = (nread == 0 || (nread == 1 && buf[0] == '\n'));
+       ok = (nread == 0 || (nread == 1 && buf[0] == '\n') || !(oob = 
mnstr_getoob(rs)));
        if (!ok) {
-               msg = buf;
+               switch (oob) {
+               case 1:                                 /* client side 
interrupt */
+                       msg = "Query aborted";
+                       break;
+               case 2:
+                       msg = "Read error on client";
+                       break;
+               default:
+                       msg = nread > 0 ? buf : "Unknown error";
+                       break;
+               }
                discard(rs);
                goto end;
        }
diff --git a/monetdb5/modules/mal/tablet.c b/monetdb5/modules/mal/tablet.c
--- a/monetdb5/modules/mal/tablet.c
+++ b/monetdb5/modules/mal/tablet.c
@@ -1249,6 +1249,12 @@ SQLproducer(void *p)
 
                // we may be reading from standard input and may be out of input
                // warn the consumers
+               if (bstream_getoob(task->cntxt->fdin)) {
+                       tablet_error(task, rowno, lineno, int_nil,
+                                                "problem reported by client", 
s);
+                       goto reportlackofinput;
+               }
+
                if (ateof[cur] && partial) {
                        if (unlikely(partial)) {
                                tablet_error(task, rowno, lineno, int_nil,
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to