Changeset: ba521825f4ac for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ba521825f4ac
Modified Files:
monetdb5/mal/mal_exception.c
sql/ChangeLog.Dec2011
sql/backends/monet5/sql_scenario.c
sql/test/BugDay_2005-10-06_2.9.3/Tests/div_by_zero.SF-987304.stable.err
sql/test/BugDay_2005-11-09_2.9.3/Tests/hang_on_copy_into.SF-1100504.stable.err
sql/test/BugTracker-2010/Tests/connectto.Bug-2548.stable.err
sql/test/Connections/Tests/connections.stable.err
Branch: Dec2011
Log Message:
Strip off exception name and function name from SQL error messages.
diffs (270 lines):
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
@@ -176,13 +176,17 @@ createExceptionInternal(enum malexceptio
printf("exception:%s:%s\n",fcn,format);
#endif
message = GDKmalloc(GDKMAXERRLEN);
- if (!message)
+ if (message == NULL)
return M5OutOfMemory;
- len = snprintf(message, GDKMAXERRLEN - 1, "%s:%s:",
- exceptionNames[type], fcn);
- len += vsnprintf(message + len, GDKMAXERRLEN - 1 - len, format, ap);
- message[len] = '\0';
- return(message);
+ len = snprintf(message, GDKMAXERRLEN, "%s:%s:", exceptionNames[type],
fcn);
+ if (len >= GDKMAXERRLEN) /* shouldn't happen */
+ return message;
+ len += vsnprintf(message + len, GDKMAXERRLEN - len, format, ap);
+ /* realloc to reduce amount of allocated memory (GDKMAXERRLEN is
+ * way more than what is normally needed) */
+ if (len < GDKMAXERRLEN)
+ message = GDKrealloc(message, len + 1);
+ return message;
}
/**
@@ -352,27 +356,34 @@ getExceptionType(str exception)
}
/**
- * Returns the location the exception was raised, if known. It depends
- * on the how the exception was created, what the location looks like.
- * The returned string is mallocced with GDKmalloc, and hence needs to
- * be GDKfreed.
+ * Returns the location the exception was raised, if known. It
+ * depends on how the exception was created, what the location looks
+ * like. The returned string is mallocced with GDKmalloc, and hence
+ * needs to be GDKfreed.
*/
str
getExceptionPlace(str exception)
{
- str ret;
- str s, t;
+ str ret, s, t;
+ enum malexception i;
+ size_t l;
- if ((s = strchr(exception, ':')) != NULL &&
- (t = strchr(s + 1, ':')) != NULL)
- {
- *t = '\0';
- ret = GDKstrdup(s + 1);
- *t = ':';
- return(ret);
- } else {
- return(GDKstrdup("(unknown)"));
+ for (i = MAL; exceptionNames[i] != NULL; i++) {
+ l = strlen(exceptionNames[i]);
+ if (strncmp(exceptionNames[i], exception, l) == 0 &&
+ exception[l] == ':') {
+ s = exception + l + 1;
+ if ((t = strchr(s, ':')) != NULL) {
+ if ((ret = GDKmalloc(t - s + 1)) == NULL)
+ return NULL;
+ strncpy(ret, s, t - s);
+ ret[t - s] = 0;
+ return ret;
+ }
+ break;
+ }
}
+ return GDKstrdup("(unknown)");
}
/**
@@ -382,15 +393,22 @@ str
getExceptionMessage(str exception)
{
str s, t;
+ enum malexception i;
+ size_t l;
- if ((s = strchr(exception, ':')) != NULL) {
- /* skip the place, if there */
- if ((t = strchr(s + 1, ':')) != NULL)
- s = t;
- return(s + 1);
- } else {
- return(exception);
+ for (i = MAL; exceptionNames[i] != NULL; i++) {
+ l = strlen(exceptionNames[i]);
+ if (strncmp(exceptionNames[i], exception, l) == 0 &&
+ exception[l] == ':') {
+ s = exception + l + 1;
+ if ((t = strchr(s, ':')) != NULL)
+ return t + 1;
+ return s;
+ }
}
+ if (strncmp(exception, "!ERROR: ", 8) == 0)
+ return exception + 8;
+ return exception;
}
/**
diff --git a/sql/ChangeLog.Dec2011 b/sql/ChangeLog.Dec2011
--- a/sql/ChangeLog.Dec2011
+++ b/sql/ChangeLog.Dec2011
@@ -1,3 +1,7 @@
# ChangeLog file for sql
# This file is updated with Maddlog
+* Wed Feb 15 2012 Sjoerd Mullender <[email protected]>
+- Stripped off implementation-specific parts from error messages before
+ they get presented to the user.
+
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
@@ -1667,7 +1667,7 @@ cleanup_engine:
be->language = oldlang;
c->glb = oldglb;
return SQLrecompile(c, be);
- } else if (type == SQL) {
+ } else {
/* don't print exception decoration, just the message */
char *n = NULL;
char *o = msg;
@@ -1678,8 +1678,6 @@ cleanup_engine:
}
if (strlen(o) != 0)
mnstr_printf(c->fdout, "!%s\n",
getExceptionMessage(o));
- } else {
- dumpExceptionsToStream(c->fdout, msg);
}
showErrors(c);
m->session->status = -10;
diff --git
a/sql/test/BugDay_2005-10-06_2.9.3/Tests/div_by_zero.SF-987304.stable.err
b/sql/test/BugDay_2005-10-06_2.9.3/Tests/div_by_zero.SF-987304.stable.err
--- a/sql/test/BugDay_2005-10-06_2.9.3/Tests/div_by_zero.SF-987304.stable.err
+++ b/sql/test/BugDay_2005-10-06_2.9.3/Tests/div_by_zero.SF-987304.stable.err
@@ -79,12 +79,12 @@ stderr of test 'div_by_zero.SF-987304` i
# 19:22:52 > mclient -lsql -umonetdb -Pmonetdb --host=alf --port=32644
# 19:22:52 >
-MAPI = monetdb@sofia:39182
+MAPI = monetdb@madrid:31650
QUERY = select 1/0;
-ERROR = !MALException:calc./:Illegal argument Division by zero
-MAPI = monetdb@sofia:39182
+ERROR = !Illegal argument Division by zero
+MAPI = monetdb@madrid:31650
QUERY = select x/y from a;
-ERROR = !ArithmeticException:batcalc./:Division by zero
+ERROR = !Division by zero
# 19:22:52 >
# 19:22:52 > Done.
diff --git
a/sql/test/BugDay_2005-11-09_2.9.3/Tests/hang_on_copy_into.SF-1100504.stable.err
b/sql/test/BugDay_2005-11-09_2.9.3/Tests/hang_on_copy_into.SF-1100504.stable.err
---
a/sql/test/BugDay_2005-11-09_2.9.3/Tests/hang_on_copy_into.SF-1100504.stable.err
+++
b/sql/test/BugDay_2005-11-09_2.9.3/Tests/hang_on_copy_into.SF-1100504.stable.err
@@ -76,7 +76,7 @@ stderr of test 'hang_on_copy_into.SF-110
# 23:26:36 > mclient -lsql -i --host=eir --port=38510
# 23:26:36 >
-MAPI = monetdb@sofia:39182
+MAPI = monetdb@madrid:31246
QUERY = COPY 1 RECORDS INTO "news" FROM stdin USING DELIMITERS '\t', '\n',
'''';
1 'dwerg.net word volwassen, er is eindelijk content
en het voicemail archief begint al aardig vol te lopen.
@@ -90,7 +90,7 @@ QUERY = COPY 1 RECORDS INTO "news" FROM
maar een uurtje of 6 werk om het goed te krijgen. Zoals
je kan zien heb ik bij de voicemails al wat leuke
ERROR = !failed to import table
- ! Incomplete record at end of file.
+ !Incomplete record at end of file.
# 23:26:36 >
# 23:26:36 > Done.
diff --git a/sql/test/BugTracker-2010/Tests/connectto.Bug-2548.stable.err
b/sql/test/BugTracker-2010/Tests/connectto.Bug-2548.stable.err
--- a/sql/test/BugTracker-2010/Tests/connectto.Bug-2548.stable.err
+++ b/sql/test/BugTracker-2010/Tests/connectto.Bug-2548.stable.err
@@ -71,13 +71,13 @@ stderr of test 'connectto.Bug-2548` in d
# 13:12:55 > mclient -lsql -ftest -i -e --host=rig --port=39884
# 13:12:55 >
-MAPI = monetdb@sofia:38256
+MAPI = monetdb@madrid:37072
QUERY = connect to default;
ERROR = !CONNECT TO: DEFAULT is not supported!
-MAPI = monetdb@sofia:38256
+MAPI = monetdb@madrid:37072
QUERY = connect to 'whatever' port 50001 database 'nonexisting' USER 'monetdb'
PASSWORD 'monetdb' LANGUAGE 'mal';
-ERROR = !IOException:mapi.connect:Could not connect: getaddrinfo failed: Name
or service not known
-MAPI = monetdb@sofia:38256
+ERROR = !Could not connect: getaddrinfo failed: Name or service not known
+MAPI = monetdb@madrid:37072
QUERY = disconnect 'whatever';
ERROR = !DISCONNECT CATALOG: no such db_alias 'whatever'
diff --git a/sql/test/Connections/Tests/connections.stable.err
b/sql/test/Connections/Tests/connections.stable.err
--- a/sql/test/Connections/Tests/connections.stable.err
+++ b/sql/test/Connections/Tests/connections.stable.err
@@ -14,43 +14,43 @@ server 12
server 12, client 1
#client1
-MAPI = monetdb@alf:34263
+MAPI = monetdb@madrid:37072
QUERY = connect to 'localhost' port 34 database
'mTests_src_test_Connections_test1' as 'test_db_1' user 'monetdb' password
'monetdb' language 'sql';
-ERROR = !IOException:mapi.connect:Could not connect: could not connect to
localhost:34: Connection refused
-MAPI = monetdb@alf:34263
-QUERY = connect to 'localhost' port 34264 database
'mTests_src_test_Connections_test1' as 'test_db_1' language 'sql';
-ERROR = !syntax error, unexpected LANGUAGE, expecting USER in: "connect to
'localhost' port 34264 database 'mTests_src_test_Connections_test1' as
'test_db_1' language"
-MAPI = monetdb@alf:34263
+ERROR = !Could not connect: could not connect to localhost:34: Connection
refused
+MAPI = monetdb@madrid:37072
+QUERY = connect to 'localhost' port 37073 database
'mTests_src_test_Connections_test1' as 'test_db_1' language 'sql';
+ERROR = !syntax error, unexpected LANGUAGE, expecting USER in: "connect to
'localhost' port 37073 database 'mTests_src_test_Connections_test1' as
'test_db_1' language"
+MAPI = monetdb@madrid:37072
QUERY = connect to 'localhost' database 'mTests_src_test_Connections_test1';
ERROR = !syntax error, unexpected SCOLON, expecting USER in: "connect to
'localhost' database 'mTests_src_test_Connections_test1';"
-MAPI = monetdb@alf:34263
-QUERY = connect 'localhost' port 34264 database
'mTests_src_test_Connections_test1' as 'test_db_1' user 'monetdb' password
'monetdb' language 'sql';
+MAPI = monetdb@madrid:37072
+QUERY = connect 'localhost' port 37073 database
'mTests_src_test_Connections_test1' as 'test_db_1' user 'monetdb' password
'monetdb' language 'sql';
ERROR = !syntax error, unexpected STRING, expecting TO in: "connect
'localhost'"
-MAPI = monetdb@alf:34263
-QUERY = connect to 'localhost' port 34264 as 'test_db_1' user 'monetdb'
password 'monetdb' language 'sql';
-ERROR = !syntax error, unexpected AS, expecting DATABASE in: "connect to
'localhost' port 34264 as"
-MAPI = monetdb@alf:34263
-QUERY = connect to 'localhost' port 34264 database
'mTests_src_test_Connections_test1' as 'test_db' user 'monetdb' language 'sql';
-ERROR = !syntax error, unexpected LANGUAGE, expecting PASSWORD in: "connect to
'localhost' port 34264 database 'mTests_src_test_Connections_test1' as
'test_db' user 'monetdb' language"
-MAPI = monetdb@alf:34263
+MAPI = monetdb@madrid:37072
+QUERY = connect to 'localhost' port 37073 as 'test_db_1' user 'monetdb'
password 'monetdb' language 'sql';
+ERROR = !syntax error, unexpected AS, expecting DATABASE in: "connect to
'localhost' port 37073 as"
+MAPI = monetdb@madrid:37072
+QUERY = connect to 'localhost' port 37073 database
'mTests_src_test_Connections_test1' as 'test_db' user 'monetdb' language 'sql';
+ERROR = !syntax error, unexpected LANGUAGE, expecting PASSWORD in: "connect to
'localhost' port 37073 database 'mTests_src_test_Connections_test1' as
'test_db' user 'monetdb' language"
+MAPI = monetdb@madrid:37072
QUERY = disconnect 'test_db_1';
ERROR = !DISCONNECT CATALOG: no such db_alias 'test_db_1'
server 12, client 2
#client1
-MAPI = monetdb@alf:34263
-QUERY = connect to 'localhost' port 34265 database
'mTests_src_test_Connections_test1' as 'test_db' user 'monetdb' password
'monetdb' language 'sql';
+MAPI = monetdb@madrid:37072
+QUERY = connect to 'localhost' port 37074 database
'mTests_src_test_Connections_test1' as 'test_db' user 'monetdb' password
'monetdb' language 'sql';
ERROR = !CONNECT TO: this connection already exists or the db_alias 'test_db'
was already used!
-MAPI = monetdb@alf:34263
-QUERY = connect to 'localhost' port 34264 database
'mTests_src_test_Connections_test1' as 'test' user 'monetdb' password 'monetdb'
language 'sql';
+MAPI = monetdb@madrid:37072
+QUERY = connect to 'localhost' port 37073 database
'mTests_src_test_Connections_test1' as 'test' user 'monetdb' password 'monetdb'
language 'sql';
ERROR = !CONNECT TO: this connection already exists or the db_alias 'test' was
already used!
-MAPI = monetdb@alf:34263
+MAPI = monetdb@madrid:37072
QUERY = connect to 'localhost' port 4000 database 'dmo' as 'test_db' user
'monetdb' password 'monetdb' language 'sql';
ERROR = !CONNECT TO: this connection already exists or the db_alias 'test_db'
was already used!
-MAPI = monetdb@alf:34263
+MAPI = monetdb@madrid:37072
QUERY = disconnect 'test_db';
ERROR = !DISCONNECT CATALOG: no such db_alias 'test_db'
-MAPI = monetdb@alf:34263
+MAPI = monetdb@madrid:37072
QUERY = disconnect 'test_tb';
ERROR = !DISCONNECT CATALOG: no such db_alias 'test_tb'
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list