Changeset: be65b6152ecd for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=be65b6152ecd
Modified Files:
monetdb5/mal/mal_exception.c
monetdb5/modules/kernel/algebra.c
sql/backends/monet5/sql_scenario.c
Branch: Apr2019
Log Message:
Don't overwrite MAL error: it could be the static value M5OutOfMemory.
diffs (94 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
@@ -350,7 +350,7 @@ getExceptionMessageAndState(const char *
if (strncmp(exceptionNames[i], exception, l) == 0 &&
exception[l] == ':') {
s = exception + l + 1;
- if ((t = strchr(s, ':')) != NULL)
+ if ((t = strpbrk(s, ":\n")) != NULL && *t == ':')
return (str) (t + 1);
return (str) s;
}
diff --git a/monetdb5/modules/kernel/algebra.c
b/monetdb5/modules/kernel/algebra.c
--- a/monetdb5/modules/kernel/algebra.c
+++ b/monetdb5/modules/kernel/algebra.c
@@ -367,7 +367,7 @@ do_join(bat *r1, bat *r2, const bat *lid
else
est = (BUN) *estimate;
- err = GDK_EXCEPTION; /* most likely error now */
+ err = NULL; /* most likely error now is GDK_EXCEPTION */
if (thetafunc) {
assert(joinfunc == NULL);
@@ -428,6 +428,8 @@ do_join(bat *r1, bat *r2, const bat *lid
BBPunfix(candleft->batCacheid);
if (candright)
BBPunfix(candright->batCacheid);
+ if (err == NULL)
+ throw(MAL, funcname, GDK_EXCEPTION);
throw(MAL, funcname, "%s", err);
}
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
@@ -1341,18 +1341,19 @@ SQLCacheRemove(Client c, str nme)
str
SQLcallback(Client c, str msg){
- if(msg && (strstr(msg, "MALexception") || strstr(msg,"GDKexception")))
{
+ char newerr[1024];
+
+ if (msg && (strstr(msg, "MALexception") || strstr(msg,"GDKexception")))
{
// massage the error to comply with SQL
char *s;
- s= strchr(msg,(int)':');
- if (s )
- s= strchr(msg,(int)':');
- if( s){
- char newerr[1024];
+ s = strchr(msg, ':');
+ if (s) {
s++;
+ if (s - msg >= (ptrdiff_t) sizeof(newerr))
+ s = msg + sizeof(newerr) - 1;
strncpy(newerr, msg, s - msg);
newerr[s-msg] = 0;
- snprintf(newerr + (s-msg), 1024 -(s-msg),
SQLSTATE(HY020) "%s",s);
+ snprintf(newerr + (s-msg), sizeof(newerr) -(s-msg),
SQLSTATE(HY020) "%s",s);
freeException(msg);
msg = GDKstrdup(newerr);
}
@@ -1362,23 +1363,25 @@ SQLcallback(Client c, str msg){
char *m, *n, *p, *s;
size_t l;
- m = p = msg;
+ m = msg;
+ p = newerr;
while (m && *m) {
n = strchr(m, '\n');
- if (n)
- *n = 0;
s = getExceptionMessageAndState(m);
if (n) {
- *n++ = '\n';
+ n++; /* include newline */
l = n - s;
} else {
l = strlen(s);
}
- memmove(p, s, l);
+ if (p + l >= newerr + sizeof(newerr))
+ l = newerr + sizeof(newerr) - p - 1;
+ memcpy(p, s, l);
p += l;
m = n;
}
*p = 0;
+ msg = GDKstrdup(newerr);
}
return MALcallback(c,msg);
}
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list