summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorVarun Gupta <varun.gupta@mariadb.com>2020-08-10 14:11:58 +0530
committerVarun Gupta <varun.gupta@mariadb.com>2020-08-13 12:24:14 +0530
commit696edd9e7e4119cb54fa1019b0dc7eebbfce31d6 (patch)
treee819f7605c443c1067281a722e10f3a3ca34e841 /mysql-test
parentc6686d2cd65dc31b9ec56ef695e8d2f4dc34e48f (diff)
downloadmariadb-git-10.2-varun.tar.gz
MDEV-23438: Assertion `!field->is_null()' failed in my_decimal::my_decimal fails in ONLY_FULL_GROUP_BY mode10.2-varun
The issue here is query with aggregate function and non-aggregate field in the SELECT LIST with ONLY_FULL_GROUP_BY was not disallowed. In ONLY_FULL_GROUP_BY mode non-aggregate fields are only allowed inside an aggregate functions or the non-aggregate fields are part of the GROUP BY clause. In the query for the failing assert the non-aggregate field was inside a WINDOW function and the window function was treated as an aggregate function and so no error was thrown. The fix would be to make sure to mark that a non-aggregate field is used inside a window function and not an aggregate function and throw an error then.
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/win.result13
-rw-r--r--mysql-test/t/win.test15
2 files changed, 28 insertions, 0 deletions
diff --git a/mysql-test/r/win.result b/mysql-test/r/win.result
index 018dba8ad50..394d9b852bb 100644
--- a/mysql-test/r/win.result
+++ b/mysql-test/r/win.result
@@ -3880,5 +3880,18 @@ a sum(a) bit_or(a) OVER (ORDER BY b)
NULL NULL 0
DROP TABLE t1;
#
+# MDEV-23438: Assertion `!field->is_null()' failed in my_decimal::my_decimal fails
+# in ONLY_FULL_GROUP_BY mode
+#
+CREATE TABLE t1(a INT, b DECIMAL(10, 0) NOT NULL);
+SET @save_sql_mode= @@sql_mode;
+SET sql_mode='ONLY_FULL_GROUP_BY';
+SELECT a, sum(a), bit_or(a) OVER (ORDER BY b) FROM t1;
+ERROR 42000: Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause
+SELECT sum(a), last_value(b) OVER () FROM t1;
+ERROR 42000: Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause
+SET sql_mode= @save_sql_mode;
+DROP TABLE t1;
+#
# End of 10.2 tests
#
diff --git a/mysql-test/t/win.test b/mysql-test/t/win.test
index 602fedad6ea..cda5499e749 100644
--- a/mysql-test/t/win.test
+++ b/mysql-test/t/win.test
@@ -2534,5 +2534,20 @@ SELECT a, sum(a), bit_or(a) OVER (ORDER BY b) FROM t1;
DROP TABLE t1;
--echo #
+--echo # MDEV-23438: Assertion `!field->is_null()' failed in my_decimal::my_decimal fails
+--echo # in ONLY_FULL_GROUP_BY mode
+--echo #
+
+CREATE TABLE t1(a INT, b DECIMAL(10, 0) NOT NULL);
+SET @save_sql_mode= @@sql_mode;
+SET sql_mode='ONLY_FULL_GROUP_BY';
+--error ER_MIX_OF_GROUP_FUNC_AND_FIELDS
+SELECT a, sum(a), bit_or(a) OVER (ORDER BY b) FROM t1;
+--error ER_MIX_OF_GROUP_FUNC_AND_FIELDS
+SELECT sum(a), last_value(b) OVER () FROM t1;
+SET sql_mode= @save_sql_mode;
+DROP TABLE t1;
+
+--echo #
--echo # End of 10.2 tests
--echo #