Changeset: 2662c6a31089 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2662c6a31089
Modified Files:
        clients/mapilib/mapi.mx
        java/src/nl/cwi/monetdb/jdbc/MonetConnection.java
        sql/backends/monet5/merovingian/daemon/client.c
        sql/backends/monet5/merovingian/daemon/multiplex-funnel.c
Branch: default
Log Message:

mapi:
- treat any language that starts with "sql" as SQL

jdbc:
- treat any language that starts with "sql" as SQL

multiplex-funnel:
- change language multiplex-funnel to sql+mf
- support empty results (SET queries typically do this)
- ignore X commands (JDBC insists on using this)


diffs (144 lines):

diff --git a/clients/mapilib/mapi.mx b/clients/mapilib/mapi.mx
--- a/clients/mapilib/mapi.mx
+++ b/clients/mapilib/mapi.mx
@@ -2163,7 +2163,7 @@
                mid->languageId = LANG_MIL;
        else if (strcmp(lang, "mal") == 0)
                mid->languageId = LANG_MAL;
-       else if (strcmp(lang, "sql") == 0)
+       else if (strstr(lang, "sql") == lang)
                mid->languageId = LANG_SQL;
        else if (strcmp(lang, "xquery") == 0)
                mid->languageId = LANG_XQUERY;
@@ -2255,7 +2255,7 @@
                mid->languageId = LANG_MIL;
        else if (strcmp(lang, "mal") == 0)
                mid->languageId = LANG_MAL;
-       else if (strcmp(lang, "sql") == 0)
+       else if (strstr(lang, "sql") == lang)
                mid->languageId = LANG_SQL;
        else if (strcmp(lang, "xquery") == 0)
                mid->languageId = LANG_XQUERY;
@@ -2340,7 +2340,7 @@
                                        mid->languageId = LANG_MIL;
                                else if (strcmp(val, "mal") == 0)
                                        mid->languageId = LANG_MAL;
-                               else if (strcmp(val, "sql") == 0)
+                               else if (strstr(val, "sql") == val)
                                        mid->languageId = LANG_SQL;
                                else if (strcmp(val, "xquery") == 0)
                                        mid->languageId = LANG_XQUERY;
@@ -5528,7 +5528,7 @@
        if ((result = hdl->result) != 0)
                return result->querytype;
        mapi_setError(hdl->mid, "No query result", "mapi_get_querytype", 
MERROR);
-       return 0;
+       return 0; /* Q_PARSE! */
 }
 
 int
diff --git a/java/src/nl/cwi/monetdb/jdbc/MonetConnection.java 
b/java/src/nl/cwi/monetdb/jdbc/MonetConnection.java
--- a/java/src/nl/cwi/monetdb/jdbc/MonetConnection.java
+++ b/java/src/nl/cwi/monetdb/jdbc/MonetConnection.java
@@ -226,7 +226,7 @@
 
                // we seem to have managed to log in, let's store the
                // language used
-               if ("sql".equals(language)) {
+               if (language.startsWith("sql")) {
                        lang = LANG_SQL;
                } else if ("xquery".equals(language)) {
                        lang = LANG_XQUERY;
diff --git a/sql/backends/monet5/merovingian/daemon/client.c 
b/sql/backends/monet5/merovingian/daemon/client.c
--- a/sql/backends/monet5/merovingian/daemon/client.c
+++ b/sql/backends/monet5/merovingian/daemon/client.c
@@ -228,7 +228,7 @@
                return(newErr("client %s specified no database", host));
        }
 
-       if (strcmp(lang, "multiplex-funnel") == 0) {
+       if (strcmp(lang, "sql+mf") == 0) {
                /* SQL multiplexer with funnelling capabilities */
                /* find/start/attach funnel */
                mplist *w;
diff --git a/sql/backends/monet5/merovingian/daemon/multiplex-funnel.c 
b/sql/backends/monet5/merovingian/daemon/multiplex-funnel.c
--- a/sql/backends/monet5/merovingian/daemon/multiplex-funnel.c
+++ b/sql/backends/monet5/merovingian/daemon/multiplex-funnel.c
@@ -387,6 +387,7 @@
        char *t;
        mapi_int64 rlen;
        int fcnt;
+       char emptyres, isempty;
 
        /* first send the query to all, such that we don't waste time
         * waiting for each server to produce an answer, but wait for all of
@@ -420,7 +421,7 @@
        t = NULL;
        rlen = 0;
        fcnt = -1;
-       /* only support Q_TABLE, because appending is easy */
+       emptyres = 0;
        for (i = 0; i < m->dbcc; i++) {
                if (mapi_read_response(hdl[i]) != MOK) {
                        t = mapi_result_error(hdl[i]);
@@ -437,6 +438,21 @@
                                        m->dbcv[i]->database, t);
                        break;
                }
+               isempty = 0;
+               /* mapi return Q_PARSE for empty results */
+               if (mapi_get_querytype(hdl[i]) == Q_PARSE)
+                       emptyres = isempty = 1;
+               if (emptyres && !isempty) {
+                       t = "err"; /* for cleanup code below */
+                       mnstr_printf(fout, "!node %s returned a result while 
previous "
+                                       "did not\n", m->dbcv[i]->database);
+                       Mfprintf(stderr, "encountered mix of empty and 
non-empty "
+                                       "results\n");
+                       break;
+               }
+               if (isempty)
+                       continue;
+               /* only support Q_TABLE, because appending is easy */
                if (mapi_get_querytype(hdl[i]) != Q_TABLE) {
                        t = "err"; /* for cleanup code below */
                        mnstr_printf(fout, "!node %s returned a non-table 
result\n",
@@ -461,7 +477,7 @@
                        }
                }
        }
-       if (t != NULL) {
+       if (t != NULL || emptyres) {
                mnstr_flush(fout);
                for (i = 0; i < m->dbcc; i++)
                        mapi_close_handle(hdl[i]);
@@ -520,10 +536,28 @@
                                /* don't crash on now stale c */
                                break;
                        }
+                       switch (*buf) {
+                               case 's':
+                               case 'S':
+                                       /* accepted, just SQL queries */
+                                       break;
+                               case 'X':
+                                       /* ignored, some clients just really 
insist on using
+                                        * these */
+                                       mnstr_flush(c->fout);
+                                       continue;
+                               default:
+                                       mnstr_printf(c->fout, "!modifier %c not 
supported by "
+                                                       "multiplex-funnel\n", 
*buf);
+                                       mnstr_flush(c->fout);
+                                       Mfprintf(stderr, "client attempted to 
perform %c "
+                                                       "type query: %s", *buf, 
buf);
+                                       continue;
+                       }
                        /* we assume (and require) the query to fit in one 
block,
                         * that is, we only forward the first block, without 
having
                         * any idea what it is */
-                       multiplexQuery(m, buf, c->fout);
+                       multiplexQuery(m, buf + 1, c->fout);
                }
        }
 }
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to