Changeset: a2dc9ad52144 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a2dc9ad52144
Modified Files:
        clients/mapilib/mapi.c
        clients/mapilib/mapi.h
        sql/backends/monet5/sql_scenario.c
Branch: mapihandshake
Log Message:

Also handshake sizeheader command


diffs (81 lines):

diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -882,6 +882,7 @@ struct MapiStruct {
        int handshake_options;  /* which settings can be sent during 
challenge/response? */
        bool auto_commit;
        bool columnar_protocol;
+       bool sizeheader;
        MapiHdl first;          /* start of doubly-linked list */
        MapiHdl active;         /* set when not all rows have been received */
 
@@ -2782,6 +2783,10 @@ mapi_reconnect(Mapi mid)
        if (mid->handshake_options > MAPI_HANDSHAKE_REPLY_SIZE) {
                CHECK_SNPRINTF(",reply_size=%d", mid->cachelimit);
        }
+       if (mid->handshake_options > MAPI_HANDSHAKE_SIZE_HEADER) {
+               CHECK_SNPRINTF(",size_header=%d", mid->sizeheader); // with 
underscore, despite X command without
+       }
+       }
        if (mid->handshake_options > 0) {
                CHECK_SNPRINTF(":");
        }
@@ -2997,6 +3002,13 @@ mapi_reconnect(Mapi mid)
                if (result != MOK)
                        return mid->error;
        }
+       if (mid->handshake_options <= MAPI_HANDSHAKE_SIZE_HEADER && 
mid->sizeheader != MapiStructDefaults.sizeheader) {
+               char buf[50];
+               sprintf(buf, "%d", !!mid->sizeheader);
+               MapiMsg result = mapi_Xcommand(mid, "sizeheader", buf); // no 
underscore!
+               if (result != MOK)
+                       return mid->error;
+       }
 
        return mid->error;
 }
@@ -3711,6 +3723,9 @@ mapi_set_size_header(Mapi mid, bool valu
                mapi_setError(mid, "size header only supported in SQL", 
__func__, MERROR);
                return MERROR;
        }
+       mid->sizeheader = value;
+       if (!mid->connected)
+               return MOK;
        if (value)
                return mapi_Xcommand(mid, "sizeheader", "1");
        else
diff --git a/clients/mapilib/mapi.h b/clients/mapilib/mapi.h
--- a/clients/mapilib/mapi.h
+++ b/clients/mapilib/mapi.h
@@ -30,6 +30,7 @@ typedef int MapiMsg;
 enum mapi_handshake_options_levels {
        MAPI_HANDSHAKE_AUTOCOMMIT = 1,
        MAPI_HANDSHAKE_REPLY_SIZE,
+       MAPI_HANDSHAKE_SIZE_HEADER,
        // this must always be the last one:
        MAPI_HANDSHAKE_OPTIONS_LEVEL,
 };
diff --git a/sql/backends/monet5/sql_scenario.c 
b/sql/backends/monet5/sql_scenario.c
--- a/sql/backends/monet5/sql_scenario.c
+++ b/sql/backends/monet5/sql_scenario.c
@@ -294,8 +294,10 @@ SQLprepareClient(Client c, int login)
                                        goto bailout;
                                }
                                m->reply_size = value;
+                       } else if (sscanf(tok, "size_header=%d", &value) == 1) {
+                                       be->sizeheader = value != 0;
                        } else {
-                               msg = createException(SQL, "SQLprepareClent", 
SQLSTATE(42000) "unexpected handshake option: %s", tok);
+                               msg = createException(SQL, "SQLprepareClient", 
SQLSTATE(42000) "unexpected handshake option: %s", tok);
                                goto bailout;
                        }
 
@@ -1048,7 +1050,7 @@ SQLparser(Client c)
                        in->pos = in->len;      /* HACK: should use parsed 
length */
                        return MAL_SUCCEED;
                }
-               if (strncmp(in->buf + in->pos, "sizeheader", 10) == 0) {
+               if (strncmp(in->buf + in->pos, "sizeheader", 10) == 0) { // no 
underscore
                        v = (int) strtol(in->buf + in->pos + 10, NULL, 10);
                        be->sizeheader = v != 0;
                        in->pos = in->len;      /* HACK: should use parsed 
length */
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to