Changeset: e2404ca61055 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e2404ca61055
Modified Files:
sql/backends/monet5/sql_fround_impl.h
sql/backends/monet5/sql_round_impl.h
sql/test/SQLancer/Tests/sqlancer02.sql
sql/test/SQLancer/Tests/sqlancer02.stable.out
Branch: clean-candidates
Log Message:
Missed argument checks
diffs (132 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
@@ -130,7 +130,7 @@ bat_dec_round_wrap_cst(Client cntxt, Mal
goto bailout;
}
if (b->ttype != TPE(TYPE)) {
- msg = createException(MAL, "round", SQLSTATE(42000) "Argument 1
must have a " STRING(TYPE) " tail");
+ msg = createException(MAL, "round", SQLSTATE(42000) "Argument 2
must have a " STRING(TYPE) " tail");
goto bailout;
}
if (sid1 && !is_bat_nil(*sid1) && !(bs = BATdescriptor(*sid1))) {
@@ -205,8 +205,8 @@ bat_dec_round_wrap_nocst(Client cntxt, M
msg = createException(MAL, "round", SQLSTATE(HY005)
RUNTIME_OBJECT_MISSING);
goto bailout;
}
- if (left->ttype != TPE(TYPE)) {
- msg = createException(MAL, "round", SQLSTATE(42000) "Argument 1
must have a " STRING(TYPE) " tail");
+ if (left->ttype != TPE(TYPE) || right->ttype != TPE(TYPE)) {
+ msg = createException(MAL, "round", SQLSTATE(42000) "Arguments
must have a " STRING(TYPE) " tail");
goto bailout;
}
if ((sid1 && !is_bat_nil(*sid1) && !(lefts = BATdescriptor(*sid1))) ||
(sid2 && !is_bat_nil(*sid2) && !(rights = BATdescriptor(*sid2)))) {
@@ -395,8 +395,8 @@ bat_round_wrap_cst(Client cntxt, MalBlkP
msg = createException(MAL, "round", SQLSTATE(HY005)
RUNTIME_OBJECT_MISSING);
goto bailout;
}
- if (b->ttype != TPE(TYPE)) {
- msg = createException(MAL, "round", SQLSTATE(42000) "Argument 1
must have a " STRING(TYPE) " tail");
+ if (b->ttype != TYPE_bte) {
+ msg = createException(MAL, "round", SQLSTATE(42000) "Argument 2
must have a bte tail");
goto bailout;
}
if (sid1 && !is_bat_nil(*sid1) && !(bs = BATdescriptor(*sid1))) {
@@ -476,6 +476,10 @@ bat_round_wrap_nocst(Client cntxt, MalBl
msg = createException(MAL, "round", SQLSTATE(42000) "Argument 1
must have a " STRING(TYPE) " tail");
goto bailout;
}
+ if (right->ttype != TYPE_bte) {
+ msg = createException(MAL, "round", SQLSTATE(42000) "Argument 2
must have a bte tail");
+ goto bailout;
+ }
if ((sid1 && !is_bat_nil(*sid1) && !(lefts = BATdescriptor(*sid1))) ||
(sid2 && !is_bat_nil(*sid2) && !(rights = BATdescriptor(*sid2)))) {
msg = createException(MAL, "round", SQLSTATE(HY005)
RUNTIME_OBJECT_MISSING);
goto bailout;
diff --git a/sql/backends/monet5/sql_round_impl.h
b/sql/backends/monet5/sql_round_impl.h
--- a/sql/backends/monet5/sql_round_impl.h
+++ b/sql/backends/monet5/sql_round_impl.h
@@ -216,8 +216,8 @@ bat_dec_round_wrap_nocst(Client cntxt, M
msg = createException(MAL, "round", SQLSTATE(HY005)
RUNTIME_OBJECT_MISSING);
goto bailout;
}
- if (left->ttype != TPE(TYPE)) {
- msg = createException(MAL, "round", SQLSTATE(42000) "Argument 1
must have a " STRING(TYPE) " tail");
+ if (left->ttype != TPE(TYPE) || right->ttype != TPE(TYPE)) {
+ msg = createException(MAL, "round", SQLSTATE(42000) "Arguments
must have a " STRING(TYPE) " tail");
goto bailout;
}
if ((sid1 && !is_bat_nil(*sid1) && !(lefts = BATdescriptor(*sid1))) ||
(sid2 && !is_bat_nil(*sid2) && !(rights = BATdescriptor(*sid2)))) {
@@ -404,7 +404,7 @@ bat_round_wrap_cst(Client cntxt, MalBlkP
bool nils = false;
struct canditer ci1 = {0};
oid off1;
- bat *res = getArgReference_bat(stk, pci, 0), *bid =
getArgReference_bat(stk, pci, 1),
+ bat *res = getArgReference_bat(stk, pci, 0), *bid =
getArgReference_bat(stk, pci, 2),
*sid1 = pci->argc == 6 ? getArgReference_bat(stk, pci, 3) :
NULL;
(void) cntxt;
@@ -413,8 +413,8 @@ bat_round_wrap_cst(Client cntxt, MalBlkP
msg = createException(MAL, "round", SQLSTATE(HY005)
RUNTIME_OBJECT_MISSING);
goto bailout;
}
- if (b->ttype != TPE(TYPE)) {
- msg = createException(MAL, "round", SQLSTATE(42000) "Argument 1
must have a " STRING(TYPE) " tail");
+ if (b->ttype != TYPE_bte) {
+ msg = createException(MAL, "round", SQLSTATE(42000) "Argument 2
must have a bte tail");
goto bailout;
}
if (sid1 && !is_bat_nil(*sid1) && !(bs = BATdescriptor(*sid1))) {
@@ -489,6 +489,10 @@ bat_round_wrap_nocst(Client cntxt, MalBl
msg = createException(MAL, "round", SQLSTATE(42000) "Argument 1
must have a " STRING(TYPE) " tail");
goto bailout;
}
+ if (right->ttype != TYPE_bte) {
+ msg = createException(MAL, "round", SQLSTATE(42000) "Argument 2
must have a bte tail");
+ goto bailout;
+ }
if ((sid1 && !is_bat_nil(*sid1) && !(lefts = BATdescriptor(*sid1))) ||
(sid2 && !is_bat_nil(*sid2) && !(rights = BATdescriptor(*sid2)))) {
msg = createException(MAL, "round", SQLSTATE(HY005)
RUNTIME_OBJECT_MISSING);
goto bailout;
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
@@ -260,3 +260,10 @@ true
SELECT substr(ltrim('1Yc',''), CAST(t2.tc2 AS INT), "second"(CAST(t0.tc0 AS
TIMESTAMP))) FROM t2, t0;
ROLLBACK;
+
+START TRANSACTION;
+CREATE TABLE "sys"."t2" ("c0" INTEGER NOT NULL);
+INSERT INTO "t2" VALUES (59), (-3), (5), (0), (1), (-6);
+
+UPDATE t2 SET c0 = 5 WHERE least(((3)=(round(0.55, t2.c0))), true);
+ROLLBACK;
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))));
@@ -377,6 +377,13 @@ stdout of test 'sqlancer02` in directory
[ "1Yc" ]
[ "1Yc" ]
#ROLLBACK;
+#START TRANSACTION;
+#CREATE TABLE "sys"."t2" ("c0" INTEGER NOT NULL);
+#INSERT INTO "t2" VALUES (59), (-3), (5), (0), (1), (-6);
+[ 6 ]
+#UPDATE t2 SET c0 = 5 WHERE least(((3)=(round(0.55, t2.c0))), true);
+[ 0 ]
+#ROLLBACK;
# 17:04:12 >
# 17:04:12 > "Done."
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list