Changeset: 6e7f6f8bc84e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6e7f6f8bc84e
Modified Files:
sql/backends/monet5/sql_fround_impl.h
sql/test/SQLancer/Tests/sqlancer02.sql
sql/test/SQLancer/Tests/sqlancer02.stable.err
sql/test/SQLancer/Tests/sqlancer02.stable.out
Branch: Oct2020
Log Message:
I forgot 'isinf' checks in the floating-point round functions
diffs (108 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
@@ -47,6 +47,8 @@ dec_round_wrap(TYPE *res, const TYPE *v,
if (rr <= 0)
throw(MAL, "round", SQLSTATE(42000) "Argument 2 to round
function must be positive");
*res = dec_round_body(*v, rr);
+ if (isinf(*res))
+ throw(MAL, "round", SQLSTATE(22003) "Overflow in round");
return MAL_SUCCEED;
}
@@ -89,8 +91,14 @@ bat_dec_round_wrap(bat *_res, const bat
nonil = TRUE;
if (v->tnonil) {
- for (i = 0; i < cnt; i++)
+ for (i = 0; i < cnt; i++) {
dst[i] = dec_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])) {
@@ -98,6 +106,11 @@ bat_dec_round_wrap(bat *_res, const bat
dst[i] = NIL(TYPE);
} else {
dst[i] = dec_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/sqlancer02.sql
b/sql/test/SQLancer/Tests/sqlancer02.sql
--- a/sql/test/SQLancer/Tests/sqlancer02.sql
+++ b/sql/test/SQLancer/Tests/sqlancer02.sql
@@ -244,3 +244,17 @@ SELECT CASE 1 WHEN 1 THEN 'rr' WHEN ln(-
SELECT CASE 1 WHEN 3 THEN 'rr' WHEN ln(c0) THEN 'a' END FROM (values
(1.2),(2.3)) as t0(c0);
-- NULL
-- NULL
+
+START TRANSACTION;
+CREATE TABLE "sys"."t2" ("c1" DOUBLE NOT NULL,CONSTRAINT "t2_c1_pkey" PRIMARY
KEY ("c1"));
+COPY 6 RECORDS INTO "sys"."t2" FROM stdin USING DELIMITERS E'\t',E'\n','"';
+-3.1207632e+08
+1
+0
+-903197136
+0.3672199296718357
+-1.7976931348623157e+308
+
+update t2 set c1 = (scale_down(t2.c1,
0.39861114390109142480156378951505757868289947509765625))
+where (scale_up(-1155480997, 0.5434124050282382)) is not null;
+ROLLBACK;
diff --git a/sql/test/SQLancer/Tests/sqlancer02.stable.err
b/sql/test/SQLancer/Tests/sqlancer02.stable.err
--- a/sql/test/SQLancer/Tests/sqlancer02.stable.err
+++ b/sql/test/SQLancer/Tests/sqlancer02.stable.err
@@ -26,6 +26,11 @@ MAPI = (monetdb) /var/tmp/mtest-817278/
QUERY = SELECT 1 WHERE scale_up(CAST(0.89767724 AS REAL), 1); --error function
scale_up not available for real,tinyint
ERROR = !types real(24,0) and boolean(1,0) are not equal
CODE = 42000
+MAPI = (monetdb) /var/tmp/mtest-1783405/.s.monetdb.39729
+QUERY = update t2 set c1 = (scale_down(t2.c1,
0.39861114390109142480156378951505757868289947509765625))
+ where (scale_up(-1155480997, 0.5434124050282382)) is not null;
+ERROR = !Overflow in round
+CODE = 22003
# 17:04:12 >
# 17:04:12 > "Done."
diff --git a/sql/test/SQLancer/Tests/sqlancer02.stable.out
b/sql/test/SQLancer/Tests/sqlancer02.stable.out
--- a/sql/test/SQLancer/Tests/sqlancer02.stable.out
+++ b/sql/test/SQLancer/Tests/sqlancer02.stable.out
@@ -296,8 +296,8 @@ stdout of test 'sqlancer02` in directory
[ 5 ]
#create view v0(c0) as (select t0.c2 from t0 where (t0.c2) not between
asymmetric (date '1970-01-23') and (case when r'true' then t0.c2 when case true
when (true) = true then substr(r' x+㶴9rr7긬X0陷?F5{W>gg0N*#Sꖿs', 1) end then
nullif(t0.c2, t0.c2) end));
#SELECT 1 FROM v0 JOIN t0 ON '4321901' LIKE CAST(COALESCE(TIME '21:08:38',
TIME '14:42:56') AS STRING);
-% .%3 # table_name
-% %3 # name
+% .%2 # table_name
+% %2 # name
% tinyint # type
% 1 # length
#SELECT ALL t0.c0, v0.c0 FROM v0 JOIN t0 ON ((upper(COALESCE(r'',
r'4321901')))ILIKE(CAST(COALESCE(sql_max(TIME '05:11:41', TIME '21:08:38'),
COALESCE(TIME '05:10:13', TIME '14:42:56'), sql_min(TIME '16:14:39', TIME
'03:01:13')) AS STRING(586))));
@@ -350,6 +350,17 @@ stdout of test 'sqlancer02` in directory
% 2 # length
[ NULL ]
[ NULL ]
+#START TRANSACTION;
+#CREATE TABLE "sys"."t2" ("c1" DOUBLE NOT NULL,CONSTRAINT "t2_c1_pkey" PRIMARY
KEY ("c1"));
+#COPY 6 RECORDS INTO "sys"."t2" FROM stdin USING DELIMITERS E'\t',E'\n','"';
+#-3.1207632e+08
+#1
+#0
+#-903197136
+#0.3672199296718357
+#-1.7976931348623157e+308
+[ 6 ]
+#ROLLBACK;
# 17:04:12 >
# 17:04:12 > "Done."
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list