Changeset: 41088c8ac745 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=41088c8ac745
Modified Files:
sql/test/subquery/Tests/subquery3.sql
sql/test/subquery/Tests/subquery3.stable.err
sql/test/subquery/Tests/subquery3.stable.out
Branch: default
Log Message:
If the table returning function returns more than one row for each input row,
then a cardinality violation will be expected
diffs (84 lines):
diff --git a/sql/test/subquery/Tests/subquery3.sql
b/sql/test/subquery/Tests/subquery3.sql
--- a/sql/test/subquery/Tests/subquery3.sql
+++ b/sql/test/subquery/Tests/subquery3.sql
@@ -452,6 +452,28 @@ FROM another_T;
-- 1
-- 1
+CREATE OR REPLACE FUNCTION evilfunction(input INT) RETURNS TABLE (outt INT)
BEGIN RETURN TABLE(VALUES (input), (input)); END;
+
+SELECT * FROM evilfunction(1);
+ -- 1
+ -- 1
+
+SELECT
+ (SELECT outt FROM evilfunction((SELECT MIN(col1))))
+FROM another_T; --error, more than one row returned by a subquery used as an
expression
+
+SELECT
+ (SELECT outt FROM evilfunction((SELECT MAX(ColID) FROM
tbl_ProductSales)))
+FROM another_T; --error, more than one row returned by a subquery used as an
expression
+
+SELECT
+ (SELECT outt FROM evilfunction((SELECT MAX(t1.col1) FROM
tbl_ProductSales)))
+FROM another_T t1; --error, more than one row returned by a subquery used as
an expression
+
+SELECT
+ (SELECT outt FROM evilfunction((SELECT MIN(t2.col1) FROM another_T
t2)))
+FROM another_T; --error, more than one row returned by a subquery used as an
expression
+
/* We shouldn't allow the following internal functions/procedures to be called
from regular queries */
--SELECT "identity"(col1) FROM another_T;
--SELECT "rowid"(col1) FROM another_T;
diff --git a/sql/test/subquery/Tests/subquery3.stable.err
b/sql/test/subquery/Tests/subquery3.stable.err
--- a/sql/test/subquery/Tests/subquery3.stable.err
+++ b/sql/test/subquery/Tests/subquery3.stable.err
@@ -242,6 +242,30 @@ QUERY = SELECT
FROM another_T t1; --error, more than one row returned by a subquery
used as an expression
ERROR = !zero_or_one: cardinality violation, scalar expression expected
CODE = M0M29
+MAPI = (monetdb) /var/tmp/mtest-123694/.s.monetdb.33701
+QUERY = SELECT
+ (SELECT outt FROM evilfunction((SELECT MIN(col1))))
+ FROM another_T; --error, more than one row returned by a subquery used
as an expression
+ERROR = !zero_or_one: cardinality violation, scalar expression expected
+CODE = M0M29
+MAPI = (monetdb) /var/tmp/mtest-123694/.s.monetdb.33701
+QUERY = SELECT
+ (SELECT outt FROM evilfunction((SELECT MAX(ColID) FROM
tbl_ProductSales)))
+ FROM another_T; --error, more than one row returned by a subquery used
as an expression
+ERROR = !Cardinality violation, scalar value expected
+CODE = 21000
+MAPI = (monetdb) /var/tmp/mtest-123694/.s.monetdb.33701
+QUERY = SELECT
+ (SELECT outt FROM evilfunction((SELECT MAX(t1.col1) FROM
tbl_ProductSales)))
+ FROM another_T t1; --error, more than one row returned by a subquery
used as an expression
+ERROR = !zero_or_one: cardinality violation, scalar expression expected
+CODE = M0M29
+MAPI = (monetdb) /var/tmp/mtest-123694/.s.monetdb.33701
+QUERY = SELECT
+ (SELECT outt FROM evilfunction((SELECT MIN(t2.col1) FROM
another_T t2)))
+ FROM another_T; --error, more than one row returned by a subquery used
as an expression
+ERROR = !Cardinality violation, scalar value expected
+CODE = 21000
# 17:40:41 >
# 17:40:41 > "Done."
diff --git a/sql/test/subquery/Tests/subquery3.stable.out
b/sql/test/subquery/Tests/subquery3.stable.out
--- a/sql/test/subquery/Tests/subquery3.stable.out
+++ b/sql/test/subquery/Tests/subquery3.stable.out
@@ -458,6 +458,14 @@ stdout of test 'subquery3` in directory
[ 1 ]
[ 1 ]
[ 1 ]
+#CREATE OR REPLACE FUNCTION evilfunction(input INT) RETURNS TABLE (outt INT)
BEGIN RETURN TABLE(VALUES (input), (input)); END;
+#SELECT * FROM evilfunction(1);
+% .%2 # table_name
+% outt # name
+% int # type
+% 1 # length
+[ 1 ]
+[ 1 ]
#DROP FUNCTION evilfunction(INT);
#DROP TABLE tbl_ProductSales;
#DROP TABLE another_T;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list