Changeset: 0abd0fcb3388 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0abd0fcb3388
Modified Files:
sql/server/rel_select.c
sql/test/subquery/Tests/subquery3.sql
sql/test/subquery/Tests/subquery3.stable.out
Branch: default
Log Message:
Merge heads.
diffs (153 lines):
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
@@ -3211,7 +3211,7 @@ static sql_exp *
return e;
}
- if (is_sql_groupby(f)) {
+ if (!query_has_outer(query) && is_sql_groupby(f)) {
char *uaname = GDKmalloc(strlen(aname) + 1);
sql_exp *e = sql_error(sql, 02, SQLSTATE(42000) "%s: aggregate
function '%s' not allowed in GROUP BY clause",
uaname ?
toUpperCopy(uaname, aname) : aname, aname);
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
@@ -318,6 +318,11 @@ SELECT
FROM another_T t1
GROUP BY t1.col7, t1.col6; --error, subquery uses ungrouped column "t1.col2"
from outer query
+SELECT
+ (SELECT 1 FROM integers i2 GROUP BY SUM(i1.i))
+FROM integers i1; --The sum at group by is a correlation from the outer query,
so it's allowed inside the GROUP BY at this case
+ -- 1
+
/* 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.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
@@ -35,7 +35,7 @@ stdout of test 'subquery3` in directory
# NOT MAX(t1.col6) IN (SELECT SUM(t1.col6) FROM tbl_ProductSales tp HAVING
MAX(t1.col1) > MIN(tp.colID))
#FROM another_T t1
#GROUP BY t1.col6, t1.col7;
-% .%31 # table_name
+% . # table_name
% %31 # name
% boolean # type
% 5 # length
@@ -49,7 +49,7 @@ stdout of test 'subquery3` in directory
# MAX(col3) / 10 + SUM(col1) * 10
#FROM another_T
#GROUP BY col1, col2, col5, col8;
-% .%34, .%35, .%36 # table_name
+% ., ., . # table_name
% %34, evil, %36 # name
% bigint, double, bigint # type
% 4, 24, 5 # length
@@ -62,7 +62,7 @@ stdout of test 'subquery3` in directory
# CAST (EXISTS (SELECT MAX(col5) * MAX(col4) FROM another_T GROUP BY col5,
col4) AS INTEGER) & CAST (SUM(col4) IN (SELECT DISTINCT col2 FROM another_T
GROUP BY col2) AS INTEGER)
#FROM another_T
#GROUP BY col1, col2, col5;
-% .%45, .%46 # table_name
+% ., . # table_name
% %45, %46 # name
% int, int # type
% 1, 1 # length
@@ -78,7 +78,7 @@ stdout of test 'subquery3` in directory
# NOT EXISTS (SELECT col1 WHERE FALSE),
# NOT EXISTS (SELECT col1 WHERE NULL)
#FROM another_T t1;
-% .%240, .%241, .%242, .%243, .%244, .%245 # table_name
+% ., ., ., ., ., . # table_name
% %240, %241, %242, %243, %244, %245 # name
% boolean, boolean, boolean, boolean, boolean,
boolean # type
% 5, 5, 5, 5, 5, 5 # length
@@ -94,7 +94,7 @@ stdout of test 'subquery3` in directory
# NOT EXISTS (SELECT AVG(col1) WHERE FALSE),
# NOT EXISTS (SELECT AVG(col1) WHERE NULL)
#FROM another_T t1;
-% .%240, .%241, .%242, .%243, .%244, .%245 # table_name
+% ., ., ., ., ., . # table_name
% %240, %241, %242, %243, %244, %245 # name
% boolean, boolean, boolean, boolean, boolean,
boolean # type
% 5, 5, 5, 5, 5, 5 # length
@@ -102,7 +102,7 @@ stdout of test 'subquery3` in directory
#SELECT
# EXISTS (SELECT RANK() OVER (PARTITION BY SUM(DISTINCT col5)))
#FROM another_T t1;
-% .%24 # table_name
+% . # table_name
% %24 # name
% boolean # type
% 5 # length
@@ -206,7 +206,7 @@ stdout of test 'subquery3` in directory
# CASE WHEN NOT t1.col2 NOT IN (SELECT (SELECT MAX(t1.col7)) UNION (SELECT
MIN(ColID) FROM tbl_ProductSales tp LEFT JOIN another_T t2 ON tp.ColID =
t1.col1 AND tp.ColID = t2.col2)) THEN 1 ELSE 2 END
#FROM another_T t1
#GROUP BY t1.col1, t1.col2;
-% .%203, .%204 # table_name
+% ., . # table_name
% %203, %204 # name
% tinyint, tinyint # type
% 1, 1 # length
@@ -218,7 +218,7 @@ stdout of test 'subquery3` in directory
# SUM(t1.col6) <> ANY (SELECT t1.col7 INTERSECT SELECT t1.col6)
#FROM another_T t1
#GROUP BY t1.col7, t1.col6;
-% .%37 # table_name
+% . # table_name
% %37 # name
% boolean # type
% 5 # length
@@ -230,7 +230,7 @@ stdout of test 'subquery3` in directory
# CASE WHEN t1.col1 IN (SELECT 1 FROM tbl_ProductSales tp LEFT JOIN
another_T t2 ON tp.ColID = t1.col1) THEN 1 ELSE 2 END
#FROM another_T t1
#GROUP BY t1.col1;
-% .%25 # table_name
+% . # table_name
% %25 # name
% tinyint # type
% 1 # length
@@ -298,7 +298,7 @@ stdout of test 'subquery3` in directory
# CASE WHEN NULL IN (SELECT MIN(ColID) FROM tbl_ProductSales tp LEFT JOIN
another_T t2 ON tp.ColID = t1.col1) THEN 1 ELSE 2 END
#FROM another_T t1
#GROUP BY t1.col1, t1.col2;
-% .%32 # table_name
+% . # table_name
% %32 # name
% tinyint # type
% 1 # length
@@ -309,7 +309,7 @@ stdout of test 'subquery3` in directory
#SELECT
# CASE WHEN NULL NOT IN (SELECT 1 FROM tbl_ProductSales tp FULL OUTER JOIN
another_T t2 ON tp.ColID = t1.col1) THEN 1 ELSE 2 END
#FROM another_T t1;
-% .%34 # table_name
+% . # table_name
% %34 # name
% tinyint # type
% 1 # length
@@ -360,7 +360,7 @@ stdout of test 'subquery3` in directory
# SUM(CAST(SUM(CAST (NOT t1.col1 IN (SELECT 1) AS INTEGER)) < ANY (SELECT
1) AS INT)) OVER ()
#FROM another_T t1
#GROUP BY t1.col6;
-% .%26 # table_name
+% . # table_name
% %26 # name
% bigint # type
% 1 # length
@@ -368,6 +368,14 @@ stdout of test 'subquery3` in directory
[ 1 ]
[ 1 ]
[ 1 ]
+#SELECT
+# (SELECT 1 FROM integers i2 GROUP BY SUM(i1.i))
+#FROM integers i1; --The sum at group by is a correlation from the outer
query, so it's allowed inside the GROUP BY at this case
+% .%3 # table_name
+% %3 # name
+% tinyint # type
+% 1 # length
+[ 1 ]
#DROP TABLE tbl_ProductSales;
#DROP TABLE another_T;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list