Changeset: 1c3d6213968b for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1c3d6213968b Modified Files: clients/Tests/exports.stable.out monetdb5/mal/mal_exception.c monetdb5/mal/mal_exception.h monetdb5/optimizer/opt_support.c sql/backends/monet5/Tests/pyapi17.stable.err sql/backends/monet5/Tests/pyloader04.stable.err sql/backends/monet5/UDF/pyapi/connection.c sql/backends/monet5/UDF/pyapi3/Tests/pyapi3_17.stable.err sql/backends/monet5/sql_scenario.c sql/test/BugTracker-2015/Tests/local-remotetable-crash.Bug-3754.stable.err Branch: default Log Message:
Shorten error messages when appropriate. diffs (220 lines): diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out --- a/clients/Tests/exports.stable.out +++ b/clients/Tests/exports.stable.out @@ -2131,6 +2131,7 @@ lng getDiskReads(void); lng getDiskSpace(void); lng getDiskWrites(void); str getExceptionMessage(const char *); +str getExceptionMessageAndState(const char *); str getExceptionPlace(const char *); enum malexception getExceptionType(const char *); int getFltConstant(MalBlkPtr mb, flt val); diff --git a/monetdb5/mal/mal_exception.c b/monetdb5/mal/mal_exception.c --- a/monetdb5/mal/mal_exception.c +++ b/monetdb5/mal/mal_exception.c @@ -329,7 +329,7 @@ getExceptionPlace(const char *exception) * Returns the informational message of the exception given. */ str -getExceptionMessage(const char *exception) +getExceptionMessageAndState(const char *exception) { const char *s, *t; enum malexception i; @@ -349,3 +349,23 @@ getExceptionMessage(const char *exceptio return (str) (exception + 8); return (str) exception; } + +str +getExceptionMessage(const char *exception) +{ + char *msg = getExceptionMessageAndState(exception); + + if (strlen(msg) > 6 && msg[5] == '!' && + ((msg[0] >= '0' && msg[0] <= '9') || + (msg[0] >= 'A' && msg[0] <= 'Z')) && + ((msg[1] >= '0' && msg[1] <= '9') || + (msg[1] >= 'A' && msg[1] <= 'Z')) && + ((msg[2] >= '0' && msg[2] <= '9') || + (msg[2] >= 'A' && msg[2] <= 'Z')) && + ((msg[3] >= '0' && msg[3] <= '9') || + (msg[3] >= 'A' && msg[3] <= 'Z')) && + ((msg[4] >= '0' && msg[4] <= '9') || + (msg[4] >= 'A' && msg[4] <= 'Z'))) + msg += 6; + return msg; +} diff --git a/monetdb5/mal/mal_exception.h b/monetdb5/mal/mal_exception.h --- a/monetdb5/mal/mal_exception.h +++ b/monetdb5/mal/mal_exception.h @@ -55,6 +55,7 @@ mal_export int isExceptionVariable(str n mal_export enum malexception getExceptionType(const char *); mal_export str getExceptionPlace(const char *); +mal_export str getExceptionMessageAndState(const char *); mal_export str getExceptionMessage(const char *); mal_export void dumpExceptionsToStream(stream *out, str msg); mal_export void freeException(str); diff --git a/monetdb5/optimizer/opt_support.c b/monetdb5/optimizer/opt_support.c --- a/monetdb5/optimizer/opt_support.c +++ b/monetdb5/optimizer/opt_support.c @@ -129,7 +129,7 @@ optimizeMALBlock(Client cntxt, MalBlkPtr msg = (str) (*p->fcn) (cntxt, mb, 0, p); if (msg) { str place = getExceptionPlace(msg); - str nmsg = createException(getExceptionType(msg), place, "%s", getExceptionMessage(msg)); + str nmsg = createException(getExceptionType(msg), place, "%s", getExceptionMessageAndState(msg)); if (nmsg && place) { freeException(msg); msg = nmsg; diff --git a/sql/backends/monet5/Tests/pyapi17.stable.err b/sql/backends/monet5/Tests/pyapi17.stable.err --- a/sql/backends/monet5/Tests/pyapi17.stable.err +++ b/sql/backends/monet5/Tests/pyapi17.stable.err @@ -34,12 +34,15 @@ stderr of test 'pyapi17` in directory 's MAPI = (monetdb) /var/tmp/mtest-15243/.s.monetdb.38589 QUERY = SELECT * FROM pyapi17(); ERROR = !Error converting dict return value "a": An array of size 2 was returned, yet we expect a list of 1 columns. The result is invalid.. -MAPI = (monetdb) /var/tmp/mtest-18234/.s.monetdb.33641 +CODE = PY000 +MAPI = (monetdb) /var/tmp/mtest-29559/.s.monetdb.38002 QUERY = SELECT * FROM pyapi17(); ERROR = !Expected a return value with name "c", but this key was not present in the dictionary. -MAPI = (monetdb) /var/tmp/mtest-15243/.s.monetdb.38589 +CODE = PY000 +MAPI = (monetdb) /var/tmp/mtest-29559/.s.monetdb.38002 QUERY = SELECT pyapi17(i) FROM integers; ERROR = !Expected a return value with name "result", but this key was not present in the dictionary. +CODE = PY000 # 18:29:28 > diff --git a/sql/backends/monet5/Tests/pyloader04.stable.err b/sql/backends/monet5/Tests/pyloader04.stable.err --- a/sql/backends/monet5/Tests/pyloader04.stable.err +++ b/sql/backends/monet5/Tests/pyloader04.stable.err @@ -37,7 +37,8 @@ ERROR = !Python exception !> 2. _emit.emit({'a1': 3, 'a2': 4, 'a3': 5}) ! 3. !Unmatched element "a3" in dict -MAPI = (monetdb) /var/tmp/mtest-6147/.s.monetdb.38930 +CODE = PY000 +MAPI = (monetdb) /var/tmp/mtest-29559/.s.monetdb.38002 QUERY = COPY LOADER INTO pyloader04table FROM pyloader04(); ERROR = !Python exception ! @@ -45,7 +46,8 @@ ERROR = !Python exception !> 2. _emit.emit({'a1': 3, 'a2': 4, 3: 5}) ! 3. !Unmatched element "3" in dict -MAPI = (monetdb) /var/tmp/mtest-79373/.s.monetdb.33370 +CODE = PY000 +MAPI = (monetdb) /var/tmp/mtest-29559/.s.monetdb.38002 QUERY = COPY LOADER INTO pyloader04table FROM pyloader04(); ERROR = !Python exception ! @@ -53,7 +55,8 @@ ERROR = !Python exception !> 2. _emit.emit({'a1': [], 'a2': numpy.array([])}) ! 3. !Empty input values supplied -MAPI = (monetdb) /var/tmp/mtest-6147/.s.monetdb.38930 +CODE = PY000 +MAPI = (monetdb) /var/tmp/mtest-29559/.s.monetdb.38002 QUERY = COPY LOADER INTO pyloader04table FROM pyloader04(); ERROR = !Python exception ! @@ -61,7 +64,8 @@ ERROR = !Python exception !> 2. _emit.emit({}) ! 3. !dict must contain at least one element -MAPI = (monetdb) /var/tmp/mtest-6147/.s.monetdb.38930 +CODE = PY000 +MAPI = (monetdb) /var/tmp/mtest-29559/.s.monetdb.38002 QUERY = COPY LOADER INTO pyloader04table FROM pyloader04(); ERROR = !Python exception ! 2. class MyClass: @@ -69,7 +73,8 @@ ERROR = !Python exception !> 4. _emit.emit({'a1': MyClass()}) ! 5. !Unsupported Python Object <type 'instance'> -MAPI = (monetdb) /var/tmp/mtest-6147/.s.monetdb.38930 +CODE = PY000 +MAPI = (monetdb) /var/tmp/mtest-29559/.s.monetdb.38002 QUERY = COPY LOADER INTO pyloader04table FROM pyloader04(); ERROR = !Python exception ! @@ -77,6 +82,7 @@ ERROR = !Python exception !> 2. _emit.emit({'a1': 'hello'}) ! 3. !Failed conversion: Error converting string. +CODE = PY000 # 12:30:44 > # 12:30:44 > "Done." diff --git a/sql/backends/monet5/UDF/pyapi/connection.c b/sql/backends/monet5/UDF/pyapi/connection.c --- a/sql/backends/monet5/UDF/pyapi/connection.c +++ b/sql/backends/monet5/UDF/pyapi/connection.c @@ -60,7 +60,7 @@ Py_END_ALLOW_THREADS; GDKfree(query); if (res != MAL_SUCCEED) { PyErr_Format(PyExc_Exception, "SQL Query Failed: %s", - (res ? res : "<no error>")); + (res ? getExceptionMessage(res) : "<no error>")); return NULL; } @@ -84,7 +84,7 @@ Py_END_ALLOW_THREADS; if (!numpy_array) { _connection_cleanup_result(output); PyErr_Format(PyExc_Exception, "SQL Query Failed: %s", - (res ? res : "<no error>")); + (res ? getExceptionMessage(res) : "<no error>")); return NULL; } PyDict_SetItem(result, diff --git a/sql/backends/monet5/UDF/pyapi3/Tests/pyapi3_17.stable.err b/sql/backends/monet5/UDF/pyapi3/Tests/pyapi3_17.stable.err --- a/sql/backends/monet5/UDF/pyapi3/Tests/pyapi3_17.stable.err +++ b/sql/backends/monet5/UDF/pyapi3/Tests/pyapi3_17.stable.err @@ -33,13 +33,16 @@ stderr of test 'pyapi3_17` in directory MAPI = (monetdb) /var/tmp/mtest-15243/.s.monetdb.38589 QUERY = SELECT * FROM pyapi17(); -ERROR = !Error converting dict return value "a": MALException:pyapi.eval:An array of size 2 was returned, yet we expect a list of 1 columns. The result is invalid.. -MAPI = (monetdb) /var/tmp/mtest-15243/.s.monetdb.38589 +ERROR = !Error converting dict return value "a": An array of size 2 was returned, yet we expect a list of 1 columns. The result is invalid.. +CODE = PY000 +MAPI = (monetdb) /var/tmp/mtest-29559/.s.monetdb.38002 QUERY = SELECT * FROM pyapi17(); ERROR = !Expected a return value with name "c", but this key was not present in the dictionary. -MAPI = (monetdb) /var/tmp/mtest-15243/.s.monetdb.38589 +CODE = PY000 +MAPI = (monetdb) /var/tmp/mtest-29559/.s.monetdb.38002 QUERY = SELECT pyapi17(i) FROM integers; ERROR = !Expected a return value with name "result", but this key was not present in the dictionary. +CODE = PY000 # 18:29:28 > diff --git a/sql/backends/monet5/sql_scenario.c b/sql/backends/monet5/sql_scenario.c --- a/sql/backends/monet5/sql_scenario.c +++ b/sql/backends/monet5/sql_scenario.c @@ -1257,7 +1257,7 @@ SQLcallback(Client c, str msg){ n = strchr(m, '\n'); if (n) *n = 0; - s = getExceptionMessage(m); + s = getExceptionMessageAndState(m); if (n) { *n++ = '\n'; l = n - s; diff --git a/sql/test/BugTracker-2015/Tests/local-remotetable-crash.Bug-3754.stable.err b/sql/test/BugTracker-2015/Tests/local-remotetable-crash.Bug-3754.stable.err --- a/sql/test/BugTracker-2015/Tests/local-remotetable-crash.Bug-3754.stable.err +++ b/sql/test/BugTracker-2015/Tests/local-remotetable-crash.Bug-3754.stable.err @@ -32,7 +32,7 @@ stderr of test 'local-remotetable-crash. MAPI = (monetdb) /var/tmp/mtest-5803/.s.monetdb.31110 QUERY = SELECT * FROM rt; -ERROR = !(mapi:monetdb://monetdb@localhost/mTests_sql_test_BugTracker-2015) 42000!unable to find sys.rt(i) +ERROR = !(mapi:monetdb://monetdb@localhost/mTests_sql_test_BugTracker-2015) unable to find sys.rt(i) # 18:16:20 > _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list