Changeset: 4bf9094630ca for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4bf9094630ca
Added Files:
        monetdb5/ChangeLog.malparsing
Removed Files:
        monetdb5/mal/mal_readline.c
        monetdb5/mal/mal_readline.h
Modified Files:
        monetdb5/extras/mal_optimizer_template/opt_sql_append.c
        monetdb5/mal/Makefile.ag
        monetdb5/mal/Tests/run
        monetdb5/mal/mal.c
        monetdb5/mal/mal.h
        monetdb5/mal/mal_atom.c
        monetdb5/mal/mal_builder.c
        monetdb5/mal/mal_client.c
        monetdb5/mal/mal_client.h
        monetdb5/mal/mal_dataflow.c
        monetdb5/mal/mal_debugger.c
        monetdb5/mal/mal_errors.h
        monetdb5/mal/mal_exception.c
        monetdb5/mal/mal_exception.h
        monetdb5/mal/mal_factory.c
        monetdb5/mal/mal_function.c
        monetdb5/mal/mal_function.h
        monetdb5/mal/mal_import.c
        monetdb5/mal/mal_import.h
        monetdb5/mal/mal_instruction.c
        monetdb5/mal/mal_interpreter.c
        monetdb5/mal/mal_linker.c
        monetdb5/mal/mal_linker.h
        monetdb5/mal/mal_module.c
        monetdb5/mal/mal_module.h
        monetdb5/mal/mal_namespace.c
        monetdb5/mal/mal_parser.c
        monetdb5/mal/mal_parser.h
        monetdb5/mal/mal_private.h
        monetdb5/mal/mal_profiler.c
        monetdb5/mal/mal_resolve.c
        monetdb5/mal/mal_resolve.h
        monetdb5/mal/mal_scenario.c
        monetdb5/mal/mal_session.c
        monetdb5/mal/mal_session.h
        monetdb5/modules/mal/language.c
        monetdb5/modules/mal/language.h
        monetdb5/modules/mal/language.mal
        monetdb5/modules/mal/mal_init.mal
        monetdb5/modules/mal/tablet.c
        monetdb5/scheduler/run_adder.c
        sql/backends/monet5/sql.c
        sql/backends/monet5/sql_aggr_hge.mal
        sql/backends/monet5/sql_execute.c
        sql/backends/monet5/sql_result.c
        sql/backends/monet5/sql_scenario.c
        sql/backends/monet5/sql_upgrades.c
        sql/backends/monet5/vaults/lidar/lidar.c
        tools/mserver/mserver5.c
Branch: malparsing
Log Message:

Major cleanup of error handling and clients IO

- The client code works strictly through the stream library.
The console readline option is removed.
- Error handling has been stratified. The MAL block
contains a 'errors' field to act as a container for
exceptions that come from deep in the code, e.g. the typechecker.
Most routines that originally used showScripException(), i.e.
sent the message to the client channel directly, has been
turned into use the 'errors' field.
- Several APIs have been changed to return proper exception strings.
- The MALreader and MAL parser have been changed to become more strict.
The MAL reader grabs a single MAL statement from the stream and
passes it as a null terminated string to the parser.
The client record now contains a line and cursor for parsing
- Initialization errors are cast into direct messages to stderr
- The MAL import routines have been simplified.

Mtest does not run due to errors in sql_aggr_*.mal
and the dynamic loading errors identified now require:
-disable-fits --disable-netcdf --disable-lidar --disable-shp
--disable-rintegration --without-samtools


diffs (truncated from 5952 to 300 lines):

diff --git a/monetdb5/ChangeLog.malparsing b/monetdb5/ChangeLog.malparsing
new file mode 100644
--- /dev/null
+++ b/monetdb5/ChangeLog.malparsing
@@ -0,0 +1,7 @@
+# ChangeLog file for monetdb5
+# This file is updated with Maddlog
+
+* Sat Mar 25 2017 Martin Kersten <m...@cwi.nl>
+- The MAL block is used as a temporary container for a single exception
+produced deeply in the stack. Mostly it collects syntax/semantic errors.
+
diff --git a/monetdb5/extras/mal_optimizer_template/opt_sql_append.c 
b/monetdb5/extras/mal_optimizer_template/opt_sql_append.c
--- a/monetdb5/extras/mal_optimizer_template/opt_sql_append.c
+++ b/monetdb5/extras/mal_optimizer_template/opt_sql_append.c
@@ -294,11 +294,10 @@ str OPTsql_append(Client cntxt, MalBlkPt
        actions= OPTsql_appendImplementation(cntxt, mb,stk,p);
 
     /* Defense line against incorrect plans */
-       msg = chkTypes(cntxt->nspace, mb, FALSE);
-       if( msg == MAL_SUCCEED)
-               msg = chkFlow(mb);
-       if( msg == MAL_SUCCEED)
-               msg = chkDeclarations(mb);
+       chkTypes(cntxt->nspace, mb, FALSE);
+       chkFlow(mb);
+       chkDeclarations(mb);
+       /* the mb->errors will be set to the first error encountered */
 #ifdef DEBUG_OPT_OPTIMIZERS
        fprintf(stderr,"=FINISHED sql_append %d\n",actions);
        fprintFunction(stderr,mb,0,LIST_MAL_ALL );
diff --git a/monetdb5/mal/Makefile.ag b/monetdb5/mal/Makefile.ag
--- a/monetdb5/mal/Makefile.ag
+++ b/monetdb5/mal/Makefile.ag
@@ -38,7 +38,6 @@ lib_mal = {
                mal_namespace.c mal_namespace.h \
                mal_parser.c mal_parser.h \
                mal_profiler.c mal_profiler.h \
-               mal_readline.c mal_readline.h \
                mal_resolve.c mal_resolve.h \
                mal_sabaoth.c mal_sabaoth.h \
                mal_scenario.c mal_scenario.h \
diff --git a/monetdb5/mal/Tests/run b/monetdb5/mal/Tests/run
--- a/monetdb5/mal/Tests/run
+++ b/monetdb5/mal/Tests/run
@@ -3,7 +3,7 @@
 #DBFARM=$PWD/dbfarm
 DBFARM=/ufs/mk/monet5/Linux/var/MonetDB/dbfarm
 DBNAME=test
-#MSERVER="Mtimeout -timeout 123 mserver --dbpath=$DBFARM/$DBNAME -c All.conf 
--set monet_prompt="
+#MSERVER="mserver --dbpath=$DBFARM/$DBNAME --set monet_prompt="
 MSERVER="valgrind  -v --leak-check=full --show-reachable=yes --num-callers=20 
mserver5 --dbpath=$DBFARM/$DBNAME "
 
 echo "Initialize database"
diff --git a/monetdb5/mal/mal.c b/monetdb5/mal/mal.c
--- a/monetdb5/mal/mal.c
+++ b/monetdb5/mal/mal.c
@@ -90,10 +90,12 @@ int mal_init(void){
        MT_lock_init( &mal_oltpLock, "mal_beatLock");
 #endif
 
+/* Any error encountered here terminates the process
+ * with a message sent to stderr
+ */
        tstAligned();
        MCinit();
-       if (mdbInit()) 
-               return -1;
+       mdbInit();
        monet_memory = MT_npages() * MT_pagesize();
        initNamespace();
        initParser();
@@ -101,9 +103,7 @@ int mal_init(void){
        initHeartbeat();
 #endif
        initResource();
-       if( malBootstrap() == 0)
-               return -1;
-       /* set up the profiler if needed, output sent to console */
+       malBootstrap();
        initProfiler();
        return 0;
 }
diff --git a/monetdb5/mal/mal.h b/monetdb5/mal/mal.h
--- a/monetdb5/mal/mal.h
+++ b/monetdb5/mal/mal.h
@@ -139,7 +139,7 @@ typedef struct SYMDEF {
        struct SYMDEF *peer;            /* where to look next */
        struct SYMDEF *skip;            /* skip to next different symbol */
        str name;
-       int kind;
+       int kind;                                       /* what kind of symbol 
*/
        struct MALBLK *def;                     /* the details of the MAL fcn */
 } *Symbol, SymRecord;
 
@@ -212,7 +212,7 @@ typedef struct MALBLK {
                     unsafeProp:1,              /* unsafe property */
                     sealedProp:1;              /* sealed property (opertions 
for sealed object should be on the full object once) */
 
-       int errors;                             /* left over errors */
+       str errors;                             /* left over errors */
        int typefixed;                  /* no undetermined instruction */
        int flowfixed;                  /* all flow instructions are fixed */
        struct MALBLK *history; /* of optimizer actions */
diff --git a/monetdb5/mal/mal_atom.c b/monetdb5/mal/mal_atom.c
--- a/monetdb5/mal/mal_atom.c
+++ b/monetdb5/mal/mal_atom.c
@@ -32,7 +32,8 @@ static void setAtomName(InstrPtr pci)
        setFunctionId(pci, putName(buf));
 }
 
-int malAtomProperty(MalBlkPtr mb, InstrPtr pci)
+str
+malAtomProperty(MalBlkPtr mb, InstrPtr pci)
 {
        str name;
        int tpe;
@@ -41,14 +42,14 @@ int malAtomProperty(MalBlkPtr mb, InstrP
        name = getFunctionId(pci);
        tpe = getAtomIndex(getModuleId(pci), (int)strlen(getModuleId(pci)), 
TYPE_any);
        if (tpe < 0 || tpe >= GDKatomcnt || tpe >= MAXATOMS)
-               return 0;
+               return MAL_SUCCEED;
        assert(pci->fcn != NULL);
        switch (name[0]) {
        case 'd':
                if (idcmp("del", name) == 0 && pci->argc == 1) {
                        BATatoms[tpe].atomDel = (void (*)(Heap *, var_t 
*))pci->fcn;
                        setAtomName(pci);
-                       return 1;
+                       return MAL_SUCCEED;
                }
                break;
        case 'c':
@@ -56,19 +57,19 @@ int malAtomProperty(MalBlkPtr mb, InstrP
                        BATatoms[tpe].atomCmp = (int (*)(const void *, const 
void *))pci->fcn;
                        BATatoms[tpe].linear = 1;
                        setAtomName(pci);
-                       return 1;
+                       return MAL_SUCCEED;
                }
                break;
        case 'f':
                if (idcmp("fromstr", name) == 0 && pci->argc == 1) {
                        BATatoms[tpe].atomFromStr = (int (*)(const char *, int 
*, ptr *))pci->fcn;
                        setAtomName(pci);
-                       return 1;
+                       return MAL_SUCCEED;
                }
                if (idcmp("fix", name) == 0 && pci->argc == 1) {
                        BATatoms[tpe].atomFix = (int (*)(const void *))pci->fcn;
                        setAtomName(pci);
-                       return 1;
+                       return MAL_SUCCEED;
                }
                break;
        case 'h':
@@ -79,19 +80,19 @@ int malAtomProperty(MalBlkPtr mb, InstrP
                        BATatoms[tpe].align = sizeof(var_t);
                        BATatoms[tpe].atomHeap = (void (*)(Heap *, 
size_t))pci->fcn;
                        setAtomName(pci);
-                       return 1;
+                       return MAL_SUCCEED;
                }
                if (idcmp("hash", name) == 0 && pci->argc == 1) {
                        BATatoms[tpe].atomHash = (BUN (*)(const void 
*))pci->fcn;
                        setAtomName(pci);
-                       return 1;
+                       return MAL_SUCCEED;
                }
                break;
        case 'l':
                if (idcmp("length", name) == 0 && pci->argc == 1) {
                        BATatoms[tpe].atomLen = (int (*)(const void *))pci->fcn;
                        setAtomName(pci);
-                       return 1;
+                       return MAL_SUCCEED;
                }
                break;
        case 'n':
@@ -100,58 +101,58 @@ int malAtomProperty(MalBlkPtr mb, InstrP
 
                        BATatoms[tpe].atomNull = atmnull;
                        setAtomName(pci);
-                       return 1;
+                       return MAL_SUCCEED;
                }
                if (idcmp("nequal", name) == 0 && pci->argc == 1) {
                        BATatoms[tpe].atomCmp = (int (*)(const void *, const 
void *))pci->fcn;
                        setAtomName(pci);
-                       return 1;
+                       return MAL_SUCCEED;
                }
                break;
        case 'p':
                if (idcmp("put", name) == 0 && pci->argc == 1) {
                        BATatoms[tpe].atomPut = (var_t (*)(Heap *, var_t *, 
const void *))pci->fcn;
                        setAtomName(pci);
-                       return 1;
+                       return MAL_SUCCEED;
                }
                break;
        case 's':
                if (idcmp("storage", name) == 0 && pci->argc == 1) {
                        BATatoms[tpe].storage = (*(int (*)(void))pci->fcn)();
                        setAtomName(pci);
-                       return 1;
+                       return MAL_SUCCEED;
                }
                break;
        case 't':
                if (idcmp("tostr", name) == 0 && pci->argc == 1) {
                        BATatoms[tpe].atomToStr = (int (*)(str *, int *, const 
void *))pci->fcn;
                        setAtomName(pci);
-                       return 1;
+                       return MAL_SUCCEED;
                }
                break;
        case 'u':
                if (idcmp("unfix", name) == 0 && pci->argc == 1) {
                        BATatoms[tpe].atomUnfix = (int (*)(const void 
*))pci->fcn;
                        setAtomName(pci);
-                       return 1;
+                       return MAL_SUCCEED;
                }
                break;
        case 'r':
                if (idcmp("read", name) == 0 && pci->argc == 1) {
                        BATatoms[tpe].atomRead = (void *(*)(void *, stream *, 
size_t))pci->fcn;
                        setAtomName(pci);
-                       return 1;
+                       return MAL_SUCCEED;
                }
                break;
        case 'w':
                if (idcmp("write", name) == 0 && pci->argc == 1) {
                        BATatoms[tpe].atomWrite = (gdk_return (*)(const void *, 
stream *, size_t))pci->fcn;
                        setAtomName(pci);
-                       return 1;
+                       return MAL_SUCCEED;
                }
                break;
        }
-       return 0;
+       return MAL_SUCCEED;
 }
 /*
  * Atoms are constructed incrementally in the kernel using the
@@ -161,28 +162,25 @@ int malAtomProperty(MalBlkPtr mb, InstrP
  * acceptable for the kernel.
  */
 
-int
-malAtomDefinition(stream *out, str name, int tpe)
+str
+malAtomDefinition(str name, int tpe)
 {
        int i;
 
        if (strlen(name) >= IDLENGTH) {
-               showException(out, SYNTAX, "atomDefinition", "Atom name '%s' 
too long", name);
-               return -1;
+               throw (SYNTAX, "atomDefinition", "Atom name '%s' too long", 
name);
        }
        if (ATOMindex(name) >= 0) {
 #ifndef HAVE_EMBEDDED /* we can restart embedded MonetDB, making this an 
expected error */
-               showException(out, TYPE, "atomDefinition", "Redefinition of 
atom '%s'", name);
+               throw(TYPE, "atomDefinition", "Redefinition of atom '%s'", 
name);
 #endif
-               return -1;
        }
        if (tpe < 0 || tpe >= GDKatomcnt) {
-               showException(out, TYPE, "atomDefinition", "Undefined atom 
inheritance '%s'", name);
-               return -1;
+               throw(TYPE, "atomDefinition", "Undefined atom inheritance 
'%s'", name);
        }
+       if (strlen(name) >= sizeof(BATatoms[0].name))
+               throw(TYPE, "atomDefinition", "Atom name too long '%s'", name);
 
-       if (strlen(name) >= sizeof(BATatoms[0].name))
-               return -1;
        i = ATOMallocate(name);
        /* overload atom ? */
        if (tpe) {
@@ -194,7 +192,7 @@ malAtomDefinition(stream *out, str name,
                BATatoms[i].storage = i;
                BATatoms[i].linear = 0;
        }
-       return 0;
+       return MAL_SUCCEED;
 }
 /*
  * User defined modules may introduce fixed sized types
diff --git a/monetdb5/mal/mal_builder.c b/monetdb5/mal/mal_builder.c
--- a/monetdb5/mal/mal_builder.c
+++ b/monetdb5/mal/mal_builder.c
@@ -27,7 +27,7 @@ newAssignment(MalBlkPtr mb)
 
        if ( q == NULL)
                return NULL;
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to