Changeset: 5435cc3f95f8 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5435cc3f95f8
Modified Files:
sql/backends/monet5/sql_fround_impl.h
sql/test/SQLancer/Tests/sqlancer09.stable.err
Branch: Oct2020
Log Message:
Look for overflows in round function
diffs (54 lines):
diff --git a/sql/backends/monet5/sql_fround_impl.h
b/sql/backends/monet5/sql_fround_impl.h
--- a/sql/backends/monet5/sql_fround_impl.h
+++ b/sql/backends/monet5/sql_fround_impl.h
@@ -165,6 +165,8 @@ round_wrap(TYPE *res, const TYPE *v, con
throw(MAL, "round", SQLSTATE(42000) "Digits out of bounds");
*res = round_body(*v, rr);
+ if (isinf(*res))
+ throw(MAL, "round", SQLSTATE(22003) "Overflow in round");
return MAL_SUCCEED;
}
@@ -207,8 +209,14 @@ bat_round_wrap(bat *_res, const bat *_v,
nonil = TRUE;
if (v->tnonil) {
- for (i = 0; i < cnt; i++)
+ for (i = 0; i < cnt; i++) {
dst[i] = round_body_nonil(src[i], rr);
+ if (isinf(dst[i])) {
+ BBPunfix(v->batCacheid);
+ BBPreclaim(res);
+ throw(MAL, "round", SQLSTATE(22003) "Overflow
in round");
+ }
+ }
} else {
for (i = 0; i < cnt; i++) {
if (ISNIL(TYPE)(src[i])) {
@@ -216,6 +224,11 @@ bat_round_wrap(bat *_res, const bat *_v,
dst[i] = NIL(TYPE);
} else {
dst[i] = round_body_nonil(src[i], rr);
+ if (isinf(dst[i])) {
+ BBPunfix(v->batCacheid);
+ BBPreclaim(res);
+ throw(MAL, "round", SQLSTATE(22003)
"Overflow in round");
+ }
}
}
}
diff --git a/sql/test/SQLancer/Tests/sqlancer09.stable.err
b/sql/test/SQLancer/Tests/sqlancer09.stable.err
--- a/sql/test/SQLancer/Tests/sqlancer09.stable.err
+++ b/sql/test/SQLancer/Tests/sqlancer09.stable.err
@@ -39,6 +39,10 @@ MAPI = (monetdb) /var/tmp/mtest-117811/
QUERY = select
(-1.7976931348623157E308)/(0.98067827792867723335490381941781379282474517822265625);
--error, overflow
ERROR = !overflow in calculation -1.7976931348623157e+308/0.98067827792867723.
CODE = 22003
+MAPI = (monetdb) /var/tmp/mtest-164664/.s.monetdb.34087
+QUERY = values (round(-1.4999792343698102e+308, 15)),(1.2); --error, overflow?
+ERROR = !Overflow in round
+CODE = 22003
# 14:35:03 >
# 14:35:03 > "Done."
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list