summaryrefslogtreecommitdiff
path: root/mysql-test/r/having.result
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.org>2017-11-03 09:29:21 +0400
committerAlexander Barkov <bar@mariadb.org>2017-11-03 09:29:21 +0400
commit5fc79476b522e6b2f5cd91ed79565fc3a09e9dd0 (patch)
tree92a82b5f5735d7ec089032e2ce07a89d077c43ed /mysql-test/r/having.result
parent7a63a7dc6d0c959c48b88dbea8e848c7bf4a0b88 (diff)
parentbeac522b550b0c8b9c7a4451bf1b851e83fd828f (diff)
downloadmariadb-git-5fc79476b522e6b2f5cd91ed79565fc3a09e9dd0.tar.gz
Merge remote-tracking branch 'origin/10.2' into bb-10.2-ext
Diffstat (limited to 'mysql-test/r/having.result')
-rw-r--r--mysql-test/r/having.result73
1 files changed, 73 insertions, 0 deletions
diff --git a/mysql-test/r/having.result b/mysql-test/r/having.result
index 4a429e1b119..8a8d6e7b2aa 100644
--- a/mysql-test/r/having.result
+++ b/mysql-test/r/having.result
@@ -727,3 +727,76 @@ A COUNT(*)
DROP VIEW v1;
DROP TABLE t1;
End of 10.1 tests
+#
+# MDEV-14093: GROUP BY with HAVING over function + ORDER BY
+#
+CREATE TABLE _authors (
+id MEDIUMINT(8) UNSIGNED AUTO_INCREMENT,
+name VARCHAR(100),
+some_field MEDIUMINT(8) UNSIGNED,
+PRIMARY KEY (id),
+index(some_field)
+);
+CREATE TABLE _books (
+id MEDIUMINT(8) UNSIGNED AUTO_INCREMENT,
+title VARCHAR(100),
+PRIMARY KEY (id)
+);
+CREATE TABLE _books2authors (
+author_id MEDIUMINT(8) DEFAULT 0,
+book_id MEDIUMINT(8) DEFAULT 0,
+index(author_id),
+index(book_id)
+);
+INSERT INTO _authors (name, some_field) VALUES
+('author1', 1),('author2', 2),('author3', 3);
+INSERT INTO _books (title) VALUES
+('book1'),('book2'),('book3');
+INSERT INTO _books2authors (author_id, book_id) VALUES
+(2,1),(3,2),(3,3);
+SELECT A.id,
+GROUP_CONCAT(B.title ORDER BY B.title DESC SEPARATOR ',') AS books,
+some_field-1 AS having_field
+FROM _authors A
+LEFT JOIN _books2authors B2A FORCE INDEX(author_id)
+ON B2A.author_id = A.id
+LEFT JOIN
+_books B ON B.id = B2A.book_id
+GROUP BY A.id
+HAVING having_field < 1
+ORDER BY having_field ASC;
+id books having_field
+1 NULL 0
+DROP TABLE _authors, _books, _books2authors;
+#
+# Bug#17055185: WRONG RESULTS WHEN RUNNING A SELECT THAT INCLUDE
+# A HAVING BASED ON A FUNCTION.
+#
+CREATE TABLE series (
+val INT(10) UNSIGNED NOT NULL
+);
+INSERT INTO series VALUES(1);
+CREATE FUNCTION next_seq_value() RETURNS INT
+BEGIN
+DECLARE next_val INT;
+SELECT val INTO next_val FROM series;
+UPDATE series SET val=mod(val + 1, 2);
+RETURN next_val;
+END;
+|
+CREATE TABLE t1 (t INT, u INT, KEY(t));
+INSERT INTO t1 VALUES(10, 10), (11, 11), (12, 12), (12, 13),(14, 15), (15, 16),
+(16, 17), (17, 17);
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status OK
+SELECT t, next_seq_value() r FROM t1 FORCE INDEX(t)
+GROUP BY t HAVING r = 1 ORDER BY t1.u;
+t r
+10 1
+12 1
+15 1
+17 1
+DROP TABLE t1;
+DROP FUNCTION next_seq_value;
+DROP TABLE series;