Changeset: 2d8726cee0f8 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2d8726cee0f8
Modified Files:
        sql/backends/monet5/sql_scenario.c
Branch: Aug2011
Log Message:

Fixed a bug where SQL thought a function should exist and MAL thought not.
When a SQL client connects, the server allocated a MAL-level client
record which may reuse part of a client record that an earlier client
had used.  In particular, the client record contains MAL functions
that the SQL engine had created so that SQL can reuse those
functions.  (That is in particular, c->nspace->subscope.)
In addition, a SQL-level client record is allocated which may also
reuse part of a client record from an earlier client.  This data
contains the information used by the SQL engine to determine whether
it has to recreate MAL functions.  This is the data in m->session->tr.
Unfortunately, the two client records are not in any way linked,
although the idea behind the reuse was that they were.
This means that if you fire lots of clients off at the server which
all do a very simple query (such as call a SQL function) and then
disconnect, it may happen that a new client inherits the SQL client
record (which thinks the MAL function implementating the SQL function
still exists) but get a fresh MAL client record (where the MAL
function does not exist).  If this happens, the execution of the query
will result in an error about the MAL function not being found.

What this fix does is recognize the situation and set the inherited
flag that indicates that the MAL implementation of the SQL function
exists in the SQL client record to indicate that the MAL implentation
does not exist if it does, in fact, not exist.

Note that the reverse situation where the MAL implementation does
exist but SQL thinks it doesn't can also occur, but that doesn't do
any harm since the MAL function will just be overwritten.

(The inheriting in SQL happens in sql_trans_create when spares > 0.)


diffs (29 lines):

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
@@ -411,6 +411,25 @@ SQLinitClient(Client c)
                mvc_reset(m, c->fdin, c->fdout, SQLdebug, NR_GLOBAL_VARS);
                backend_reset(be);
        }
+       if (m->session->tr) {
+               node *n = ((sql_schema *) 
m->session->tr->schemas.set->h->data)->funcs.set->h;
+               sql_func *f;
+               Symbol s;
+               while (n) {
+                       f = (sql_func *) n->data;
+                       if (f->sql > 1) {
+                               s = c->nspace->subscope[((unsigned char *) 
f->base.name)[0]];
+                               while (s) {
+                                       if (strcmp(s->name, f->base.name) == 0)
+                                               break;
+                                       s = s->skip;
+                               }
+                               if (s == 0)
+                                       f->sql = 1;
+                       }
+                       n = n->next;
+               }
+       }
        /* pass through credentials of the user if not console */
        schema = monet5_user_get_def_schema(m, c->user);
        if (!schema) {
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to