Changeset: 77e5b6410033 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=77e5b6410033
Modified Files:
MonetDB/src/gdk/gdk_bbp.mx
MonetDB/src/gdk/gdk_utils.mx
MonetDB5/src/mal/mal_atom.mx
MonetDB5/src/mal/mal_client.mx
MonetDB5/src/mal/mal_import.mx
MonetDB5/src/mal/mal_profiler.mx
MonetDB5/src/mal/mal_resolve.mx
MonetDB5/src/modules/kernel/group.mx
MonetDB5/src/modules/mal/mal_mapi.mx
MonetDB5/src/modules/mal/tablet.mx
sql/src/backends/monet5/sql.mx
sql/src/backends/monet5/sql_scenario.mx
Branch: Oct2010
Log Message:
More coverity errors.
diffs (truncated from 892 to 300 lines):
diff -r 5574493b6a40 -r 77e5b6410033 MonetDB/src/gdk/gdk_bbp.mx
--- a/MonetDB/src/gdk/gdk_bbp.mx Sat Jan 15 15:42:05 2011 +0100
+++ b/MonetDB/src/gdk/gdk_bbp.mx Sat Jan 15 16:55:28 2011 +0100
@@ -3588,7 +3588,7 @@
if (BBPprepare(subcommit)) {
return -1;
}
- if (b->batCopiedtodisk == 0 || nme == NULL || b->batPersistence !=
PERSISTENT) {
+ if (b->batCopiedtodisk == 0 || b->batPersistence != PERSISTENT) {
return 0;
}
/* determine location dir and physical suffix */
diff -r 5574493b6a40 -r 77e5b6410033 MonetDB/src/gdk/gdk_utils.mx
--- a/MonetDB/src/gdk/gdk_utils.mx Sat Jan 15 15:42:05 2011 +0100
+++ b/MonetDB/src/gdk/gdk_utils.mx Sat Jan 15 16:55:28 2011 +0100
@@ -129,6 +129,8 @@
return 0;
}
+ assert(strlen(dbname) < PATHLENGTH);
+ assert(strlen(dbfarm) < PATHLENGTH);
strncpy(GDKdbnameStr, dbname, PATHLENGTH);
strncpy(GDKdbfarmStr, dbfarm, PATHLENGTH);
return 1;
diff -r 5574493b6a40 -r 77e5b6410033 MonetDB5/src/mal/mal_atom.mx
--- a/MonetDB5/src/mal/mal_atom.mx Sat Jan 15 15:42:05 2011 +0100
+++ b/MonetDB5/src/mal/mal_atom.mx Sat Jan 15 16:55:28 2011 +0100
@@ -286,6 +286,8 @@
}
ATOMproperty(name,"", (int (*)()) 0, 0);
+ if( strlen(name) >= sizeof(BATatoms[0].name))
+ return ;
i= ATOMindex(name);
/* overload atom ? */
if (tpe) {
@@ -305,6 +307,8 @@
int i = 0;
ATOMproperty(name,"", (int (*)()) 0, 0);
+ if( strlen(name) >= sizeof(BATatoms[0].name))
+ return -1;
i= ATOMindex(name);
BATatoms[i] = BATatoms[TYPE_chr];
strncpy(BATatoms[i].name, name, sizeof(BATatoms[i].name));
@@ -341,6 +345,8 @@
return -1; /* ERROR! */
}
ATOMproperty(name,"", (int (*)()) 0, 0);
+ if( strlen(name) >= sizeof(BATatoms[0].name))
+ return -1;
i= ATOMindex(name);
BATatoms[i] = BATatoms[tpe];
strncpy(BATatoms[i].name, name, sizeof(BATatoms[i].name));
diff -r 5574493b6a40 -r 77e5b6410033 MonetDB5/src/mal/mal_client.mx
--- a/MonetDB5/src/mal/mal_client.mx Sat Jan 15 15:42:05 2011 +0100
+++ b/MonetDB5/src/mal/mal_client.mx Sat Jan 15 16:55:28 2011 +0100
@@ -461,9 +461,9 @@
#ifdef MAL_CLIENT_DEBUG
printf("# Exit client %d\n", c->idx);
#endif
+ MPresetProfiler(c->fdout);
if (c->father == NULL) { /* normal client */
if( c->fdout && c->fdout != GDKstdout){
- MPresetProfiler(c->fdout);
(void) mnstr_close(c->fdout);
(void) mnstr_destroy(c->fdout);
}
@@ -486,9 +486,9 @@
mal_set_lock(mal_contextLock, "wait");
c->mode = AWAITING;
/* close streams */
+ mal_unset_lock(mal_contextLock, "wait");
MCexitClient(c);
/* wait for work */
- mal_unset_lock(mal_contextLock, "wait");
#ifdef MAL_DEBUG_CLIENT
mnstr_printf(c->fdout,"Put client into pool %d\n",c->idx);
#endif
diff -r 5574493b6a40 -r 77e5b6410033 MonetDB5/src/mal/mal_import.mx
--- a/MonetDB5/src/mal/mal_import.mx Sat Jan 15 15:42:05 2011 +0100
+++ b/MonetDB5/src/mal/mal_import.mx Sat Jan 15 16:55:28 2011 +0100
@@ -213,7 +213,7 @@
c->srcFile = filename;
c->yycur = 0;
c->bak = NULL;
- if ((s = malLoadScript(c, filename, &c->fdin)) == 0)
+ if (malLoadScript(c, filename, &c->fdin) == 0)
parseMAL(c, c->curprg);
filename = p + 1;
}
diff -r 5574493b6a40 -r 77e5b6410033 MonetDB5/src/mal/mal_profiler.mx
--- a/MonetDB5/src/mal/mal_profiler.mx Sat Jan 15 15:42:05 2011 +0100
+++ b/MonetDB5/src/mal/mal_profiler.mx Sat Jan 15 16:55:28 2011 +0100
@@ -276,6 +276,7 @@
mal_export lng getDiskWrites(void);
mal_export lng getUserTime(void);
mal_export lng getSystemTime(void);
+mal_export void _initTrace(void);
#endif
@+ Performance tracing
@@ -765,6 +766,7 @@
should wait for the next instruction the stream
is initiated. This is controlled by a delay-switch
@c
+static int TRACE_init = 0;
str
startProfiling(void)
{
@@ -774,7 +776,8 @@
delayswitch = 1;
} else
cachedProfiling = TRUE;
- initTrace();
+ if (TRACE_init == 0)
+ _initTrace();
malProfileMode = TRUE;
mal_unset_lock(mal_profileLock, "profileLock");
return MAL_SUCCEED;
@@ -976,7 +979,6 @@
All properties identified below are maintained, because this allows
for easy integration with SQL.
@c
-static int TRACE_init = 0;
static int TRACE_event = 0;
static BAT *TRACE_id_event = 0;
static BAT *TRACE_id_time = 0;
diff -r 5574493b6a40 -r 77e5b6410033 MonetDB5/src/mal/mal_resolve.mx
--- a/MonetDB5/src/mal/mal_resolve.mx Sat Jan 15 15:42:05 2011 +0100
+++ b/MonetDB5/src/mal/mal_resolve.mx Sat Jan 15 16:55:28 2011 +0100
@@ -1,4 +1,694 @@
@/
+@/
+The contents of this file are subject to the MonetDB Public License
+Version 1.1 (the "License"); you may not use this file except in
+compliance with the License. You may obtain a copy of the License at
+http://monetdb.cwi.nl/Legal/MonetDBLicense-1.1.html
+
+Software distributed under the License is distributed on an "AS IS"
+basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+License for the specific language governing rights and limitations
+under the License.
+
+The Original Code is the MonetDB Database System.
+
+The Initial Developer of the Original Code is CWI.
+Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
+Copyright August 2008-2011 MonetDB B.V.
+All Rights Reserved.
+@
+
+@f mal_scenario
+@a M. Kersten
+@v 0.0
+@+ Session Scenarios
+In MonetDB multiple languages, optimizers, and execution engines can
+be combined at run time to satisfy a wide user-community.
+Such an assemblage of components is called a @emph{scenario}
+and consists of a @emph{reader}, @emph{parser}, @emph{optimizer},
+@emph{tactic scheduler} and @emph{engine}. These hooks allow
+for both linked-in and external components.
+
+The languages supported are SQL, XQuery,
+and the Monet Assembly Language (MAL).
+The default scenario handles MAL instructions, which is used
+to illustrate the behavior of the scenario steps.
+
+The MAL reader component handles interaction with
+a front-end to obtain a string for subsequent compilation and
+execution. The reader uses the common stream package to read
+data in large chunks, if possible. In interactive mode the lines
+are processed one at a time.
+
+The MAL parser component turns the string into
+an internal representation of the MAL program.
+During this phase semantic checks are performed, such that
+we end up with a type correct program.
+
+The code block is subsequently sent to an MAL optimizer.
+In the default case the program is left untouched. For other languages,
+the optimizer deploys language specific code transformations,
+e.g., foreign-key optimizations in joins and remote query execution.
+All optimization information is statically derived from the
+code blocks and possible catalogues maintained for the query language
+at hand. Optimizers leave advice and their findings in properties
+in the symbol table, see @ref{Property Management}.
+
+Once the program has thus been refined, the
+MAL scheduler prepares for execution using tactical optimizations.
+For example, it may parallelize the code, generate an ad-hoc
+user-defined function, or prepare for efficient replication management.
+In the default case, the program is handed over to the MAL interpreter
+without any further modification.
+
+The final stage is to choose an execution paradigm,
+i.e. interpretative (default), compilation of an ad-hoc user
+defined function, dataflow driven interpretation,
+or vectorized pipe-line execution by a dedicated engine.
+
+A failure encountered in any of the steps terminates the scenario
+cycle. It returns to the user for a new command.
+
+@+ Scenario management
+Scenarios are captured in modules; they can be dynamically loaded
+and remain active until the system is brought to a halt.
+The first time a scenario @sc{xyz} is used, the system looks for a scenario
+initialization routine @sc{xyzinitSystem()} and executes it.
+It is typically used to prepare the server for language specific interactions.
+Thereafter its components are set to those required by
+the scenario and the client initialization takes place.
+
+When the last user interested in a particular scenario leaves the
+scene, we activate its finalization routine calling @sc{xyzexitSystem()}.
+It typically perform cleanup, backup and monitoring functions.
+
+A scenario is interpreted in a strictly linear fashion,
+i.e. performing a symbolic optimization before scheduling decisions
+are taken.
+The routines associated with each state in
+the scenario may patch the code so as to assure that subsequent
+execution can use a different scenario, e.g., to handle dynamic
+code fragments.
+
+@{
+The state of execution is maintained in the scenario record for
+each individual client. Sharing this information between clients
+should be dealt with in the implementation of the scenario managers.
+Upon need, the client can postpone a session scenario by
+pushing a new one(language, optimize, tactic,
+processor). Propagation of the state information is
+encapsulated a scenario2scenario() call. Not all transformations
+may be legal.
+
+@+ Scenario administration
+Administration of scenarios follows the access rules
+defined for code modules in general.
+
+@h
+
+#ifndef _MAL_SCENARIO_H
+#define _MAL_SCENARIO_H
+
+#include "mal_import.h"
+
+#define MAL_SCENARIO_READER 0
+#define MAL_SCENARIO_PARSER 1
+#define MAL_SCENARIO_OPTIMIZE 2
+#define MAL_SCENARIO_SCHEDULER 3
+#define MAL_SCENARIO_ENGINE 4
+#define MAL_SCENARIO_INITCLIENT 5
+#define MAL_SCENARIO_EXITCLIENT 6
+
+/*#define MAL_SCENARIO_DEBUG*/
+@-
+The scenario descriptions contains all information to
+implement the scenario. Each client gets a copy.
+An exception or error detected while parsing is turned
+into an exception and aborts the scenario.
+@h
+#define MAXSCEN 128
+
+typedef struct SCENARIO {
+ str name, language;
+ str initSystem;
+ MALfcn initSystemCmd;
+ str exitSystem;
+ MALfcn exitSystemCmd;
+ str initClient;
+ MALfcn initClientCmd;
+ str exitClient;
+ MALfcn exitClientCmd;
+ str reader;
+ MALfcn readerCmd;
+ void *readerState;
+ str parser;
+ MALfcn parserCmd;
+ void *parserState;
+ str optimizer;
+ MALfcn optimizerCmd;
+ void *optimizerState;
+ str tactics;
+ MALfcn tacticsCmd;
+ void *tacticsState;
+ str engine;
+ MALfcn engineCmd;
+ void *engineState;
+ struct SCENARIO *next;
+} *Scenario;
+
+mal_export str setScenario(Client c, str nme);
+mal_export str runScenario(Client c);
+mal_export str fillScenario(Client c, Scenario scen);
+mal_export void clrScenario(Client c);
+mal_export str getScenarioLanguage(Client c);
+mal_export Scenario getFreeScenario(void);
+
+mal_export str defaultScenario(Client c); /* used in
src/mal/mal_session.c */
+mal_export void exitScenario(Client c); /* used in
src/mal/mal_session.c */
+mal_export str initScenario(Client c, Scenario s);
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list