Changeset: f43f978d24f8 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/f43f978d24f8
Modified Files:
        clients/Tests/MAL-signatures.stable.out
        clients/Tests/MAL-signatures.stable.out.int128
        monetdb5/mal/mal_interpreter.c
        monetdb5/modules/mal/remote.c
        sql/backends/monet5/sql_gencode.c
        sql/test/BugTracker-2015/Tests/local-remotetable-crash.Bug-3754.SQL.py
        sql/test/BugTracker-2015/Tests/schemadiff.Bug-3778.SQL.py
        
sql/test/BugTracker-2019/Tests/remote-table-non-existent-column.Bug-6750.py
        sql/test/BugTracker-2020/Tests/table-udf-on-remote.Bug-6971.py
        sql/test/SQLancer/Tests/sqlancer20.SQL.py
        sql/test/remote/Tests/invalid_creds.SQL.py
Branch: Jan2022
Log Message:

Cleaned exception handling on remote plans.

Don't add 'exception not caught' extra message for MAL sequences besides main 
function calls.
There's an extra catch block need for when the remote connection cannot be made 
at all (eg. bad credentials).
Reapproved tests.


diffs (222 lines):

diff --git a/clients/Tests/MAL-signatures.stable.out 
b/clients/Tests/MAL-signatures.stable.out
--- a/clients/Tests/MAL-signatures.stable.out
+++ b/clients/Tests/MAL-signatures.stable.out
@@ -9219,7 +9219,6 @@
 [ "rapi",      "eval_aggr",    "pattern rapi.eval_aggr(X_0:ptr, X_1:str, 
X_2:any...):any... ", "RAPIevalAggr;",        "grouped aggregates through R"  ]
 [ "rapi",      "prelude",      "command rapi.prelude():void ", "RAPIprelude;", 
""      ]
 [ "rapi",      "subeval_aggr", "pattern rapi.subeval_aggr(X_0:ptr, X_1:str, 
X_2:any...):any... ",      "RAPIevalAggr;",        "grouped aggregates through 
R"  ]
-[ "remote",    "assert",       "pattern remote.assert(X_0:bit, X_1:str):void 
",        "RMTassert;",   "Generate an exception when b==true"    ]
 [ "remote",    "batbincopy",   "pattern remote.batbincopy():bat[:any] ",       
"RMTbincopyfrom;",      "store the binary BAT data in the BBP and return as 
BAT"        ]
 [ "remote",    "batbincopy",   "pattern remote.batbincopy(X_0:bat[:any]):void 
",       "RMTbincopyto;",        "dump BAT b in binary form to the stream"      
 ]
 [ "remote",    "batload",      "pattern remote.batload(X_0:any_1, 
X_1:int):bat[:any_1] ",      "RMTbatload;",  "create a BAT of the given type 
and size, and load values from the input stream"        ]
diff --git a/clients/Tests/MAL-signatures.stable.out.int128 
b/clients/Tests/MAL-signatures.stable.out.int128
--- a/clients/Tests/MAL-signatures.stable.out.int128
+++ b/clients/Tests/MAL-signatures.stable.out.int128
@@ -12519,7 +12519,6 @@
 [ "rapi",      "eval_aggr",    "pattern rapi.eval_aggr(X_0:ptr, X_1:str, 
X_2:any...):any... ", "RAPIevalAggr;",        "grouped aggregates through R"  ]
 [ "rapi",      "prelude",      "command rapi.prelude():void ", "RAPIprelude;", 
""      ]
 [ "rapi",      "subeval_aggr", "pattern rapi.subeval_aggr(X_0:ptr, X_1:str, 
X_2:any...):any... ",      "RAPIevalAggr;",        "grouped aggregates through 
R"  ]
-[ "remote",    "assert",       "pattern remote.assert(X_0:bit, X_1:str):void 
",        "RMTassert;",   "Generate an exception when b==true"    ]
 [ "remote",    "batbincopy",   "pattern remote.batbincopy():bat[:any] ",       
"RMTbincopyfrom;",      "store the binary BAT data in the BBP and return as 
BAT"        ]
 [ "remote",    "batbincopy",   "pattern remote.batbincopy(X_0:bat[:any]):void 
",       "RMTbincopyto;",        "dump BAT b in binary form to the stream"      
 ]
 [ "remote",    "batload",      "pattern remote.batload(X_0:any_1, 
X_1:int):bat[:any_1] ",      "RMTbatload;",  "create a BAT of the given type 
and size, and load values from the input stream"        ]
diff --git a/monetdb5/mal/mal_interpreter.c b/monetdb5/mal/mal_interpreter.c
--- a/monetdb5/mal/mal_interpreter.c
+++ b/monetdb5/mal/mal_interpreter.c
@@ -1185,9 +1185,6 @@ str runMALsequence(Client cntxt, MalBlkP
                                runtimeProfileExit(cntxt, mb, stk, 
getInstrPtr(mb,0), &runtimeProfileFunction);
                                break;
                        }
-                       if (stkpc == mb->stop)
-                               ret = mb->errors = createMalException(mb, 
stkpc, TYPE,
-                                       "Exception raised\n");
                        break;
                case YIELDsymbol:     /* to be defined */
                        if( startedProfileQueue)
@@ -1238,7 +1235,8 @@ str runMALsequence(Client cntxt, MalBlkP
        MT_thread_set_qry_ctx(qry_ctx_save);
 
        /* if we could not find the exception variable, cascade a new one */
-       if (exceptionVar >= 0) {
+       /* don't add 'exception not caught' extra message for MAL sequences 
besides main function calls */
+       if (exceptionVar >= 0 && (ret == MAL_SUCCEED || !pcicaller)) {
                char nme[256];
                snprintf(nme,256,"%s.%s[%d]", getModuleId(getInstrPtr(mb,0)), 
getFunctionId(getInstrPtr(mb,0)), stkpc);
                if (ret != MAL_SUCCEED) {
diff --git a/monetdb5/modules/mal/remote.c b/monetdb5/modules/mal/remote.c
--- a/monetdb5/modules/mal/remote.c
+++ b/monetdb5/modules/mal/remote.c
@@ -1681,39 +1681,10 @@ RMTregisterSupervisor(int *ret, str *sup
        return MAL_SUCCEED;
 }
 
-/* this is needed in remote plans */
-static str
-RMTassert(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
-{
-       bool flg = (bool) *getArgReference_bit(stk, pci, 1);
-       str msg = *getArgReference_str(stk, pci, 2);
-
-       (void) cntxt;
-       (void) mb;
-       if (flg) {
-               if (strlen(msg) > 6 &&
-                   msg[5] == '!' &&
-                   (isdigit((unsigned char) msg[0]) ||
-                    isupper((unsigned char) msg[0])) &&
-                   (isdigit((unsigned char) msg[1]) ||
-                    isupper((unsigned char) msg[1])) &&
-                   (isdigit((unsigned char) msg[2]) ||
-                    isupper((unsigned char) msg[2])) &&
-                   (isdigit((unsigned char) msg[3]) ||
-                    isupper((unsigned char) msg[3])) &&
-                   (isdigit((unsigned char) msg[4]) ||
-                    isupper((unsigned char) msg[4])))
-                       throw(REMOTE, "assert", "%s", msg); /* includes state */
-               throw(REMOTE, "assert", SQLSTATE(M0M29) "%s", msg);
-       }
-       return MAL_SUCCEED;
-}
-
 #include "mel.h"
 mel_func remote_init_funcs[] = {
  command("remote", "prelude", RMTprelude, false, "initialise the remote 
module", args(1,1, arg("",void))),
  command("remote", "epilogue", RMTepilogue, false, "release the resources held 
by the remote module", args(1,1, arg("",void))),
- pattern("remote", "assert", RMTassert, false, "Generate an exception when 
b==true", args(1,3, arg("",void),arg("b",bit),arg("msg",str))),
  command("remote", "resolve", RMTresolve, false, "resolve a pattern against 
Merovingian and return the URIs", args(1,2, batarg("",str),arg("pattern",str))),
  pattern("remote", "connect", RMTconnect, false, "returns a newly created 
connection for uri, using user name and password", args(1,5, 
arg("",str),arg("uri",str),arg("user",str),arg("passwd",str),arg("scen",str))),
  command("remote", "connect", RMTconnectScen, false, "returns a newly created 
connection for uri, using user name, password and scenario", args(1,6, 
arg("",str),arg("uri",str),arg("user",str),arg("passwd",str),arg("scen",str),arg("columnar",bit))),
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
@@ -668,10 +668,8 @@ static int
        pushInstruction(curBlk, p);
 
        /* catch exceptions */
-       p = newCatchStmt(curBlk,"MALException");
-       p = newExitStmt(curBlk,"MALException");
-       p = newCatchStmt(curBlk,"SQLException");
-       p = newExitStmt(curBlk,"SQLException");
+       p = newCatchStmt(curBlk, "ANYexception");
+       p = newExitStmt(curBlk, "ANYexception");
 
        /* end remote transaction */
        p = newInstruction(curBlk, remoteRef, execRef);
@@ -690,9 +688,13 @@ static int
        p = newStmt(curBlk, remoteRef, disconnectRef);
        p = pushArgument(curBlk, p, q);
 
+       /* the connection may not start (eg bad credentials),
+               so calling 'disconnect' on the catch block may throw another 
exception, add another catch */
+       p = newCatchStmt(curBlk, "ANYexception");
+       p = newExitStmt(curBlk, "ANYexception");
+
        /* throw the exception back */
-       p = newStmt(curBlk, remoteRef, assertRef);
-       p = pushBit(curBlk, p, TRUE);
+       p = newRaiseStmt(curBlk, "RemoteException");
        p = pushStr(curBlk, p, "Exception occurred in the remote server, please 
check the log there");
 
        pushEndInstruction(curBlk);
diff --git 
a/sql/test/BugTracker-2015/Tests/local-remotetable-crash.Bug-3754.SQL.py 
b/sql/test/BugTracker-2015/Tests/local-remotetable-crash.Bug-3754.SQL.py
--- a/sql/test/BugTracker-2015/Tests/local-remotetable-crash.Bug-3754.SQL.py
+++ b/sql/test/BugTracker-2015/Tests/local-remotetable-crash.Bug-3754.SQL.py
@@ -13,7 +13,7 @@ CREATE REMOTE TABLE rt (LIKE t1) ON 'map
 try:
     cur1.execute('SELECT * from rt;')
     print('Exception expected')
-except pymonetdb.IntegrityError as e:
+except pymonetdb.DatabaseError as e:
     if 'Exception occurred in the remote server, please check the log there' 
not in str(e):
         print(str(e))
 
diff --git a/sql/test/BugTracker-2015/Tests/schemadiff.Bug-3778.SQL.py 
b/sql/test/BugTracker-2015/Tests/schemadiff.Bug-3778.SQL.py
--- a/sql/test/BugTracker-2015/Tests/schemadiff.Bug-3778.SQL.py
+++ b/sql/test/BugTracker-2015/Tests/schemadiff.Bug-3778.SQL.py
@@ -101,7 +101,7 @@ with tempfile.TemporaryDirectory() as tm
             try:
                 c.execute("select * from " + shardtable + workers[0]['tpf'] )
                 sys.stderr.write('Exception expected')
-            except pymonetdb.IntegrityError as e:
+            except pymonetdb.DatabaseError as e:
                 if 'Exception occurred in the remote server, please check the 
log there' not in str(e):
                    print(str(e))
             else:
diff --git 
a/sql/test/BugTracker-2019/Tests/remote-table-non-existent-column.Bug-6750.py 
b/sql/test/BugTracker-2019/Tests/remote-table-non-existent-column.Bug-6750.py
--- 
a/sql/test/BugTracker-2019/Tests/remote-table-non-existent-column.Bug-6750.py
+++ 
b/sql/test/BugTracker-2019/Tests/remote-table-non-existent-column.Bug-6750.py
@@ -41,13 +41,13 @@ with tempfile.TemporaryDirectory() as fa
             try:
                 cur2.execute("select col2 from tab1;")  # col2 doesn't exist
                 sys.stderr.write('Exception expected')
-            except pymonetdb.IntegrityError as e:
+            except pymonetdb.DatabaseError as e:
                 if 'Exception occurred in the remote server, please check the 
log there' not in str(e):
                     sys.stderr.write(str(e))
             try:
                 cur2.execute("select col1 from tab2;")  # col1 is not a 
floating point column
                 sys.stderr.write('Exception expected')
-            except pymonetdb.IntegrityError as e:
+            except pymonetdb.DatabaseError as e:
                 if 'Exception occurred in the remote server, please check the 
log there' not in str(e):
                     sys.stderr.write(str(e))
             cur2.execute("drop table tab1;")
@@ -63,7 +63,7 @@ with tempfile.TemporaryDirectory() as fa
             try:
                 cur2.execute("select * from m2;")  # Infinite loop while 
resolving the children of m2
                 sys.stderr.write('Exception expected')
-            except pymonetdb.IntegrityError as e:
+            except pymonetdb.DatabaseError as e:
                 if 'Exception occurred in the remote server, please check the 
log there' not in str(e):
                     sys.stderr.write(str(e))
 
diff --git a/sql/test/BugTracker-2020/Tests/table-udf-on-remote.Bug-6971.py 
b/sql/test/BugTracker-2020/Tests/table-udf-on-remote.Bug-6971.py
--- a/sql/test/BugTracker-2020/Tests/table-udf-on-remote.Bug-6971.py
+++ b/sql/test/BugTracker-2020/Tests/table-udf-on-remote.Bug-6971.py
@@ -62,7 +62,7 @@ with tempfile.TemporaryDirectory() as fa
             try:
                 node2_cur.execute("select * from mudf((select 
sx,sxx,sxy,sy,syy,'\"' from fofo))")
                 sys.stderr.write('Exception expected')
-            except pymonetdb.IntegrityError as e:
+            except pymonetdb.DatabaseError as e:
                 if 'Exception occurred in the remote server, please check the 
log there' not in str(e):
                     sys.stderr.write(str(e))
             node2_cur.execute("select * from mudf((select sx,sxx,sxy,sy,syy,1 
as \"a\"\"a\" from fofo))")
diff --git a/sql/test/SQLancer/Tests/sqlancer20.SQL.py 
b/sql/test/SQLancer/Tests/sqlancer20.SQL.py
--- a/sql/test/SQLancer/Tests/sqlancer20.SQL.py
+++ b/sql/test/SQLancer/Tests/sqlancer20.SQL.py
@@ -54,7 +54,7 @@ with SQLTestCase() as cli:
     COMMIT;""" % (port, db)).assertSucceeded()
 
     cli.execute('SELECT "setmasklen"(INET \'9.49.240.200/13\', 48061431) FROM 
rrt0;') \
-        .assertFailed(err_message="(mapi:monetdb://monetdb@localhost/%s) 
Illegal netmask length value: 48061431" % (db,))
+        .assertFailed(err_message="Exception occurred in the remote server, 
please check the log there")
     cli.execute('INSERT INTO rt0(c0) VALUES(1);') \
         .assertSucceeded().assertRowCount(1)
     cli.execute('ALTER TABLE rt0 ADD CONSTRAINT con3 UNIQUE(c0);') \
diff --git a/sql/test/remote/Tests/invalid_creds.SQL.py 
b/sql/test/remote/Tests/invalid_creds.SQL.py
--- a/sql/test/remote/Tests/invalid_creds.SQL.py
+++ b/sql/test/remote/Tests/invalid_creds.SQL.py
@@ -121,16 +121,15 @@ with tempfile.TemporaryDirectory() as TM
             try:
                 c.execute("SELECT COUNT(*) FROM ratings0")
                 sys.stderr.write("Exception expected")
-            except pymonetdb.OperationalError as e1:
-                if "invalid credentials for user 'invaliduser'" not in str(e1):
-                    sys.stderr.write("Exception: invalid credentials for user 
'invaliduser' expected")
-
+            except pymonetdb.DatabaseError as e:
+                if 'Exception occurred in the remote server, please check the 
log there' not in str(e):
+                   print(str(e))
             try:
                 c.execute("SELECT COUNT(*) FROM ratings")
                 sys.stderr.write("Exception expected")
-            except pymonetdb.OperationalError as e2:
-                if "invalid credentials for user 'invaliduser'" not in str(e2):
-                    sys.stderr.write("Exception: invalid credentials for user 
'invaliduser' expected")
+            except pymonetdb.DatabaseError as e:
+                if 'Exception occurred in the remote server, please check the 
log there' not in str(e):
+                   print(str(e))
             for wrec in workers:
                 wrec['proc'].communicate()
             supervisorproc.communicate()
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to