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.
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.)

zyzyis/monetdb,zyzyis/monetdb,zyzyis/monetdb,zyzyis/monetdb,zyzyis/monetdb,zyzyis/monetdb,zyzyis/monetdb,zyzyis/monetdb,zyzyis/monetdb,zyzyis/monetdb