Changeset: 484f26cbb84e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=484f26cbb84e
Modified Files:
        sql/backends/monet5/sql_gencode.c
Branch: Nov2019
Log Message:

If errors are generated in the MAL block return error in the current call


diffs (108 lines):

diff --git a/sql/backends/monet5/sql_gencode.c 
b/sql/backends/monet5/sql_gencode.c
--- a/sql/backends/monet5/sql_gencode.c
+++ b/sql/backends/monet5/sql_gencode.c
@@ -64,7 +64,7 @@ constantAtom(backend *sql, MalBlkPtr mb,
 
        (void) sql;
        cst.vtype = 0;
-       if(VALcopy(&cst, vr) == NULL)
+       if (VALcopy(&cst, vr) == NULL)
                return -1;
        idx = defConstant(mb, vr->vtype, &cst);
        return idx;
@@ -280,7 +280,7 @@ static int
        Symbol backup = NULL;
        const char *local_tbl = prp->value;
        node *n;
-       int i, q, v;
+       int i, q, v, res = 0;
        int *lret, *rret;
        char *lname;
        sql_rel *r = rel;
@@ -558,9 +558,9 @@ static int
 
        /* catch exceptions */
        p = newCatchStmt(curBlk,"MALexception");
-        p = newExitStmt(curBlk,"MALexception");
-        p = newCatchStmt(curBlk,"SQLexception");
-        p = newExitStmt(curBlk,"SQLexception");
+       p = newExitStmt(curBlk,"MALexception");
+       p = newCatchStmt(curBlk,"SQLexception");
+       p = newExitStmt(curBlk,"SQLexception");
        /* remote.disconnect(q); */
        p = newStmt(curBlk, remoteRef, disconnectRef);
        p = pushArgument(curBlk, p, q);
@@ -573,12 +573,14 @@ static int
 
        SQLaddQueryToCache(c);
        //chkProgram(c->usermodule, c->curprg->def);
-       if(!c->curprg->def->errors)
+       if (!c->curprg->def->errors)
                c->curprg->def->errors = SQLoptimizeFunction(c, c->curprg->def);
+       if (c->curprg->def->errors)
+               res = -1;
        if (backup)
                c->curprg = backup;
        GDKfree(lname);         /* make sure stub is called */
-       return 0;
+       return res;
 }
 
 int
@@ -792,12 +794,14 @@ backend_dumpproc(backend *be, Client c, 
        if (backend_dumpstmt(be, mb, r, 1, 1, be->q?be->q->codestring:NULL) < 
0) 
                goto cleanup;
 
-       if (cq){
+       if (cq) {
                SQLaddQueryToCache(c);
                // optimize this code the 'old' way
-               if ( (m->emode == m_prepare || 
!qc_isaquerytemplate(getFunctionId(getInstrPtr(c->curprg->def,0)))) && 
!c->curprg->def->errors )
+               if ((m->emode == m_prepare || 
!qc_isaquerytemplate(getFunctionId(getInstrPtr(c->curprg->def,0)))) && 
!c->curprg->def->errors)
                        c->curprg->def->errors = 
SQLoptimizeFunction(c,c->curprg->def);
        }
+       if (c->curprg->def->errors)
+               goto cleanup;
 
        // restore the context for the wrapper code
        curPrg = c->curprg;
@@ -1152,6 +1156,7 @@ backend_create_sql_func(backend *be, sql
        Symbol backup = NULL, curPrg = NULL;
        int i, retseen = 0, sideeffects = 0, vararg = (f->varres || f->vararg), 
no_inline = 0;
        sql_rel *r;
+       str msg = MAL_SUCCEED;
 
        /* nothing to do for internal and ready (not recompiling) functions, 
besides finding respective MAL implementation */
        if (!f->sql && (f->lang == FUNC_LANG_INT || f->lang == FUNC_LANG_MAL)) {
@@ -1267,13 +1272,21 @@ backend_create_sql_func(backend *be, sql
                curBlk->unsafeProp = 1;
        /* optimize the code */
        SQLaddQueryToCache(c);
-       if( curBlk->inlineProp == 0 && !c->curprg->def->errors) {
-               c->curprg->def->errors = SQLoptimizeFunction(c, c->curprg->def);
-       } else if(curBlk->inlineProp != 0){
+       if (curBlk->inlineProp == 0 && !c->curprg->def->errors) {
+               msg = SQLoptimizeFunction(c, c->curprg->def);
+       } else if (curBlk->inlineProp != 0) {
                chkProgram(c->usermodule, c->curprg->def);
-               if(!c->curprg->def->errors)
-                       c->curprg->def->errors = 
SQLoptimizeFunction(c,c->curprg->def);
+               if (!c->curprg->def->errors)
+                       msg = SQLoptimizeFunction(c,c->curprg->def);
        }
+       if (msg) {
+               if (c->curprg->def->errors)
+                       GDKfree(msg);
+               else
+                       c->curprg->def->errors = msg;
+       }
+       if (c->curprg->def->errors)
+               goto cleanup;
        if (backup)
                c->curprg = backup;
        return 0;
@@ -1396,4 +1409,3 @@ rel_print(mvc *sql, sql_rel *rel, int de
        close_stream(s);
        buffer_destroy(b);
 }
-
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to