Changeset: 048a5e75c5cd for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=048a5e75c5cd
Modified Files:
sql/backends/monet5/sql_fround_impl.h
sql/server/rel_select.c
sql/test/SQLancer/Tests/sqlancer02.sql
sql/test/SQLancer/Tests/sqlancer02.stable.out
Branch: default
Log Message:
Merged with Oct2020
diffs (247 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
@@ -38,6 +38,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 = ISNIL(TYPE)(*v) ? NIL(TYPE) : dec_round_body(*v, rr);
+ if (isinf(*res))
+ throw(MAL, "round", SQLSTATE(22003) "Overflow in round");
return MAL_SUCCEED;
}
@@ -95,6 +97,10 @@ bat_dec_round_wrap(Client cntxt, MalBlkP
nils = true;
} else {
dst[i] = dec_round_body(x, r);
+ if (isinf(dst[i])) {
+ msg = createException(MAL, "round",
SQLSTATE(22003) "Overflow in round");
+ goto bailout;
+ }
}
}
} else {
@@ -107,6 +113,10 @@ bat_dec_round_wrap(Client cntxt, MalBlkP
nils = true;
} else {
dst[i] = dec_round_body(x, r);
+ if (isinf(dst[i])) {
+ msg = createException(MAL, "round",
SQLSTATE(22003) "Overflow in round");
+ goto bailout;
+ }
}
}
}
@@ -168,6 +178,10 @@ bat_dec_round_wrap_cst(Client cntxt, Mal
nils = true;
} else {
dst[i] = dec_round_body(x, r);
+ if (isinf(dst[i])) {
+ msg = createException(MAL, "round",
SQLSTATE(22003) "Overflow in round");
+ goto bailout;
+ }
}
}
} else {
@@ -186,6 +200,10 @@ bat_dec_round_wrap_cst(Client cntxt, Mal
nils = true;
} else {
dst[i] = dec_round_body(x, r);
+ if (isinf(dst[i])) {
+ msg = createException(MAL, "round",
SQLSTATE(22003) "Overflow in round");
+ goto bailout;
+ }
}
}
}
@@ -257,6 +275,10 @@ bat_dec_round_wrap_nocst(Client cntxt, M
nils = true;
} else {
dst[i] = dec_round_body(x, rr);
+ if (isinf(dst[i])) {
+ msg = createException(MAL, "round",
SQLSTATE(22003) "Overflow in round");
+ goto bailout;
+ }
}
}
} else {
@@ -276,6 +298,10 @@ bat_dec_round_wrap_nocst(Client cntxt, M
nils = true;
} else {
dst[i] = dec_round_body(x, rr);
+ if (isinf(dst[i])) {
+ msg = createException(MAL, "round",
SQLSTATE(22003) "Overflow in round");
+ goto bailout;
+ }
}
}
}
diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c
--- a/sql/server/rel_select.c
+++ b/sql/server/rel_select.c
@@ -5293,21 +5293,18 @@ static sql_rel*
rel_having_limits_nodes(sql_query *query, sql_rel *rel, SelectNode *sn,
exp_kind ek, int group_totals)
{
mvc *sql = query->sql;
+ sql_rel *inner = NULL;
+ int single_value = 1;
+
+ if (is_project(rel->op) && rel->l) {
+ inner = rel->l;
+ single_value = 0;
+ }
if (sn->having) {
- sql_rel *inner = NULL;
- int single_value = 1;
-
- if (is_project(rel->op) && rel->l) {
- inner = rel->l;
- single_value = 0;
- }
-
if (inner && is_groupby(inner->op))
set_processed(inner);
- inner = rel_logical_exp(query, inner, sn->having, sql_having |
group_totals);
-
- if (!inner)
+ if (!(inner = rel_logical_exp(query, inner, sn->having,
sql_having | group_totals)))
return NULL;
if (inner->exps && exps_card(inner->exps) > CARD_AGGR)
return sql_error(sql, 02, SQLSTATE(42000) "SELECT:
cannot compare sets with values, probably an aggregate function missing");
@@ -5390,6 +5387,9 @@ rel_having_limits_nodes(sql_query *query
rel = rel_sample(sql->sa, rel, exps);
}
+ /* after parsing the current query, set the group by relation as
processed */
+ if (!sn->having && inner && is_groupby(inner->op))
+ set_processed(inner);
if (rel)
set_processed(rel);
return rel;
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
@@ -267,3 +267,17 @@ INSERT INTO "t2" VALUES (59), (-3), (5),
UPDATE t2 SET c0 = 5 WHERE least(((3)=(round(0.55, t2.c0))), true);
ROLLBACK;
+
+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
@@ -384,6 +384,17 @@ stdout of test 'sqlancer02` in directory
#UPDATE t2 SET c0 = 5 WHERE least(((3)=(round(0.55, t2.c0))), true);
[ 0 ]
#ROLLBACK;
+#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."
diff --git a/sql/test/SQLancer/Tests/sqlancer09.sql
b/sql/test/SQLancer/Tests/sqlancer09.sql
--- a/sql/test/SQLancer/Tests/sqlancer09.sql
+++ b/sql/test/SQLancer/Tests/sqlancer09.sql
@@ -401,3 +401,23 @@ ROLLBACK;
SELECT 1 HAVING group_concat('') NOT LIKE '3' IS NULL;
-- empty
+
+START TRANSACTION;
+create or replace view v0(vc0, vc1, vc2) as (values (3, true, 0.3));
+create or replace view v1(vc0, vc1) as (select 0.80, 'a');
+
+select 1 from v0, v1
+inner join (values (88), (3), (59)) as sub0 on true natural join
+(select distinct v0.vc0 from v1, v0 group by v0.vc1) as sub1
+where v0.vc0 = 0.06683239;
+
+create or replace view v0(vc0, vc1, vc2) as (values (nullif(cast(220424338 as
smallint), case 0.04487378302689426501359548637992702424526214599609375 when
126710153 then 0.6929207132873739 when 26968 then 26968.0 when 1679982115 then
29 else 0.8204445662571608 end), cast(sql_min(r'', r'#Ts9.H') as boolean),
0.45182237213592768565462165497592650353908538818359375));
+create or replace view v1(vc0, vc1) as (select
round(0.80863825841427316998277774473535828292369842529296875,
0.6571010204254646), r'䝀i8jPo' where not (false));
+
+select all v0.vc2, greatest(min(all least(-266013300, 864326131)),
-1183805674), greatest(-544857133, + (v0.vc2)) from v0, v1
+inner join (values (+ (88)), (greatest(0.8732546822607857,
greatest(1933292715, -525885982))), (case when (-1466474216) in
+(-1504372996, 417052418, 94) then least(28288, 1447812316) when cast(r'' as
boolean) then "second"(time '14:18:59') else
+((-730700220)-(929722313)) end)) as sub0 on true natural join (select distinct
v0.vc0 from v1, v0 where ((((v0.vc1)and(v0.vc1)))
+or(v0.vc1)) group by v0.vc1) as sub1 where (v0.vc0) in (0.06683239) group by
least(-1913343924, 10622),
+((v1.vc1)not ilike(least(v1.vc1, v1.vc1)));
+ROLLBACK;
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
@@ -48,6 +48,14 @@ QUERY = update t2 set c1 = 0.01242740338
(coalesce(-1053775800, 991217471)) and
(((0.6974006550632457)+(1832026960)));
ERROR = !division by zero.
CODE = 22012
+MAPI = (monetdb) /var/tmp/mtest-125379/.s.monetdb.32501
+QUERY = select all v0.vc2, greatest(min(all least(-266013300, 864326131)),
-1183805674), greatest(-544857133, + (v0.vc2)) from v0, v1
+ inner join (values (+ (88)), (greatest(0.8732546822607857,
greatest(1933292715, -525885982))), (case when (-1466474216) in
+ (-1504372996, 417052418, 94) then least(28288, 1447812316) when
cast(r'' as boolean) then "second"(time '14:18:59') else
+ ((-730700220)-(929722313)) end)) as sub0 on true natural join (select
distinct v0.vc0 from v1, v0 where ((((v0.vc1)and(v0.vc1)))
+ or(v0.vc1)) group by v0.vc1) as sub1 where (v0.vc0) in (0.06683239)
group by least(-1913343924, 10622),
+ERROR = !overflow in conversion of 220424338 to sht.
+CODE = 22003
# 14:35:03 >
# 14:35:03 > "Done."
diff --git a/sql/test/SQLancer/Tests/sqlancer09.stable.out
b/sql/test/SQLancer/Tests/sqlancer09.stable.out
--- a/sql/test/SQLancer/Tests/sqlancer09.stable.out
+++ b/sql/test/SQLancer/Tests/sqlancer09.stable.out
@@ -391,6 +391,20 @@ stdout of test 'sqlancer09` in directory
% %3 # name
% tinyint # type
% 1 # length
+#START TRANSACTION;
+#create or replace view v0(vc0, vc1, vc2) as (values (3, true, 0.3));
+#create or replace view v1(vc0, vc1) as (select 0.80, 'a');
+#select 1 from v0, v1
+#inner join (values (88), (3), (59)) as sub0 on true natural join
+#(select distinct v0.vc0 from v1, v0 group by v0.vc1) as sub1
+#where v0.vc0 = 0.06683239;
+% .%23 # table_name
+% %23 # name
+% tinyint # type
+% 1 # length
+#create or replace view v0(vc0, vc1, vc2) as (values (nullif(cast(220424338 as
smallint), case 0.04487378302689426501359548637992702424526214599609375 when
126710153 then 0.6929207132873739 when 26968 then 26968.0 when 1679982115 then
29 else 0.8204445662571608 end), cast(sql_min(r'', r'#Ts9.H') as boolean),
0.45182237213592768565462165497592650353908538818359375));
+#create or replace view v1(vc0, vc1) as (select
round(0.80863825841427316998277774473535828292369842529296875,
0.6571010204254646), r'䝀i8jPo' where not (false));
+#ROLLBACK;
# 14:35:03 >
# 14:35:03 > "Done."
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list