Skip to content

Commit

Permalink
Merge branch '10.2' of github.com:MariaDB/server into bb-10.2-mariarocks
Browse files Browse the repository at this point in the history
  • Loading branch information
spetrunia committed Nov 4, 2017
2 parents 80d6151 + beac522 commit 8f2e8cf
Show file tree
Hide file tree
Showing 26 changed files with 434 additions and 240 deletions.
2 changes: 1 addition & 1 deletion VERSION
@@ -1,3 +1,3 @@
MYSQL_VERSION_MAJOR=10
MYSQL_VERSION_MINOR=2
MYSQL_VERSION_PATCH=10
MYSQL_VERSION_PATCH=11
73 changes: 73 additions & 0 deletions mysql-test/r/having.result
Expand Up @@ -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;
4 changes: 2 additions & 2 deletions mysql-test/suite/encryption/r/encryption_force.result
Expand Up @@ -34,11 +34,11 @@ t4 CREATE TABLE `t4` (
PARTITION BY HASH (`a`)
PARTITIONS 2
alter table t1 encrypted=no;
ERROR HY000: Can't create table `test`.`#sql-temporary` (errno: 140 "Wrong create options")
ERROR HY000: Table storage engine 'InnoDB' does not support the create option 'ENCRYPTED'
alter table t2 encrypted=yes;
alter table t3 encrypted=default;
alter table t4 encrypted=no;
ERROR HY000: Can't create table `test`.`#sql-temporary` (errno: 140 "Wrong create options")
ERROR HY000: Table storage engine 'InnoDB' does not support the create option 'ENCRYPTED'
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/suite/encryption/r/filekeys_encfile.result
Expand Up @@ -14,7 +14,7 @@ t1 CREATE TABLE `t1` (
`b` char(200) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 `encrypted`=yes `encryption_key_id`=2
alter table t1 encryption_key_id=3;
ERROR HY000: Can't create table `test`.`#sql-temporary` (errno: 140 "Wrong create options")
ERROR HY000: Table storage engine 'InnoDB' does not support the create option 'ENCRYPTION_KEY_ID'
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/suite/encryption/r/filekeys_encfile_file.result
Expand Up @@ -14,7 +14,7 @@ t1 CREATE TABLE `t1` (
`b` char(200) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 `encrypted`=yes `encryption_key_id`=2
alter table t1 encryption_key_id=3;
ERROR HY000: Can't create table `test`.`#sql-temporary` (errno: 140 "Wrong create options")
ERROR HY000: Table storage engine 'InnoDB' does not support the create option 'ENCRYPTION_KEY_ID'
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
Expand Down
5 changes: 2 additions & 3 deletions mysql-test/suite/encryption/r/innodb-encryption-alter.result
Expand Up @@ -41,11 +41,10 @@ CREATE TABLE t2 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNOD
Warnings:
Warning 140 InnoDB: Ignored ENCRYPTION_KEY_ID 1 when encryption is disabled
ALTER TABLE t1 ENCRYPTION_KEY_ID=99;
ERROR HY000: Can't create table `test`.`#sql-temporary` (errno: 140 "Wrong create options")
ERROR HY000: Table storage engine 'InnoDB' does not support the create option 'ENCRYPTION_KEY_ID'
SHOW WARNINGS;
Level Code Message
Warning 140 InnoDB: ENCRYPTION_KEY_ID 99 not available
Error 1005 Can't create table `test`.`#sql-temporary` (errno: 140 "Wrong create options")
Warning 1030 Got error 140 "Wrong create options" from storage engine InnoDB
Error 1478 Table storage engine 'InnoDB' does not support the create option 'ENCRYPTION_KEY_ID'
set innodb_default_encryption_key_id = 1;
drop table t1,t2;
2 changes: 1 addition & 1 deletion mysql-test/suite/encryption/r/innodb-spatial-index.result
Expand Up @@ -5,7 +5,7 @@ ERROR HY000: Can't create table `test`.`t1` (errno: 140 "Wrong create options")
CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT,
c VARCHAR(256), coordinate POINT NOT NULL, SPATIAL index(coordinate)) ENGINE=INNODB;
ALTER TABLE t1 ENCRYPTED=YES;
ERROR HY000: Can't create table `test`.`#sql-temporary` (errno: 140 "Wrong create options")
ERROR HY000: Table storage engine 'InnoDB' does not support the create option 'ENCRYPTED'
DROP TABLE t1;
CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT,
c VARCHAR(256), coordinate POINT NOT NULL) ENCRYPTED=YES ENGINE=INNODB;
Expand Down
6 changes: 2 additions & 4 deletions mysql-test/suite/encryption/t/encryption_force.test
Expand Up @@ -22,13 +22,11 @@ show create table t2;
show create table t3;
show create table t4;

--replace_regex /#sql-[0-9a-f_]*/#sql-temporary/
--error ER_CANT_CREATE_TABLE
--error ER_ILLEGAL_HA_CREATE_OPTION
alter table t1 encrypted=no;
alter table t2 encrypted=yes;
alter table t3 encrypted=default;
--replace_regex /#sql-[0-9a-f_]*/#sql-temporary/
--error ER_CANT_CREATE_TABLE
--error ER_ILLEGAL_HA_CREATE_OPTION
alter table t4 encrypted=no;

show create table t1;
Expand Down
4 changes: 1 addition & 3 deletions mysql-test/suite/encryption/t/filekeys_goodtest.inc
Expand Up @@ -7,8 +7,7 @@ insert t1 values (12345, repeat('1234567890', 20));

alter table t1 encryption_key_id=2;
show create table t1;
--replace_regex /#sql-[0-9a-f_]*/#sql-temporary/
--error ER_CANT_CREATE_TABLE
--error ER_ILLEGAL_HA_CREATE_OPTION
alter table t1 encryption_key_id=3;
show create table t1;
alter table t1 encryption_key_id=33;
Expand All @@ -17,4 +16,3 @@ alter table t1 encryption_key_id=4;
show create table t1;

drop table t1;

4 changes: 1 addition & 3 deletions mysql-test/suite/encryption/t/innodb-encryption-alter.test
Expand Up @@ -27,10 +27,8 @@ DROP TABLE t1;
CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNODB;
SHOW CREATE TABLE t1;
CREATE TABLE t2 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNODB ENCRYPTED=NO ENCRYPTION_KEY_ID=1;
--replace_regex /#sql-[0-9a-f_]*/#sql-temporary/
--error 1005
--error ER_ILLEGAL_HA_CREATE_OPTION
ALTER TABLE t1 ENCRYPTION_KEY_ID=99;
--replace_regex /#sql-[0-9a-f_]*/#sql-temporary/
SHOW WARNINGS;
set innodb_default_encryption_key_id = 1;

Expand Down
4 changes: 1 addition & 3 deletions mysql-test/suite/encryption/t/innodb-spatial-index.test
Expand Up @@ -20,10 +20,8 @@ ENCRYPTED=YES;
#
CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT,
c VARCHAR(256), coordinate POINT NOT NULL, SPATIAL index(coordinate)) ENGINE=INNODB;
--replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/
--error ER_CANT_CREATE_TABLE
--error ER_ILLEGAL_HA_CREATE_OPTION
ALTER TABLE t1 ENCRYPTED=YES;
--replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/
DROP TABLE t1;

#
Expand Down
Expand Up @@ -36,12 +36,11 @@ innodb_redundant CREATE TABLE `innodb_redundant` (
`b` char(200) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=REDUNDANT
alter table innodb_redundant page_compressed=1;
ERROR HY000: Can't create table `test`.`#sql-temporary` (errno: 140 "Wrong create options")
ERROR HY000: Table storage engine 'InnoDB' does not support the create option 'PAGE_COMPRESSED'
show warnings;
Level Code Message
Warning 140 InnoDB: PAGE_COMPRESSED table can't have ROW_TYPE=REDUNDANT
Error 1005 Can't create table `test`.`#sql-temporary` (errno: 140 "Wrong create options")
Warning 1030 Got error 140 "Wrong create options" from storage engine InnoDB
Error 1478 Table storage engine 'InnoDB' does not support the create option 'PAGE_COMPRESSED'
show create table innodb_redundant;
Table Create Table
innodb_redundant CREATE TABLE `innodb_redundant` (
Expand Down
3 changes: 2 additions & 1 deletion mysql-test/suite/innodb/r/innodb-table-online.result
Expand Up @@ -235,7 +235,8 @@ t1 CREATE TABLE `t1` (
ALTER TABLE t1 ROW_FORMAT=REDUNDANT;
SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL rebuilt2 WAIT_FOR dml2_done';
SET lock_wait_timeout = 10;
ALTER TABLE t1 ROW_FORMAT=COMPACT, ALGORITHM = INPLACE;
ALTER TABLE t1 ROW_FORMAT=COMPACT
PAGE_COMPRESSED = YES PAGE_COMPRESSION_LEVEL = 1, ALGORITHM = INPLACE;
# session default
connection default;
INSERT INTO t1 SELECT 80 + c1, c2, c3 FROM t1;
Expand Down
Expand Up @@ -26,10 +26,8 @@ create table innodb_redundant(c1 bigint not null, b char(200)) engine=innodb row
show warnings;
create table innodb_redundant(c1 bigint not null, b char(200)) engine=innodb row_format=redundant;
show create table innodb_redundant;
--replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/
--error 1005
--error ER_ILLEGAL_HA_CREATE_OPTION
alter table innodb_redundant page_compressed=1;
--replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/
show warnings;
show create table innodb_redundant;
alter table innodb_redundant row_format=compact page_compressed=1;
Expand Down
3 changes: 2 additions & 1 deletion mysql-test/suite/innodb/t/innodb-table-online.test
Expand Up @@ -215,7 +215,8 @@ SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL rebuilt2 WAIT_FOR dml2_done
# Ensure that the ALTER TABLE will be executed even with some concurrent DML.
SET lock_wait_timeout = 10;
--send
ALTER TABLE t1 ROW_FORMAT=COMPACT, ALGORITHM = INPLACE;
ALTER TABLE t1 ROW_FORMAT=COMPACT
PAGE_COMPRESSED = YES PAGE_COMPRESSION_LEVEL = 1, ALGORITHM = INPLACE;

# Generate some log (delete-mark, delete-unmark, insert etc.)
# while the index creation is blocked. Some of this may run
Expand Down
80 changes: 80 additions & 0 deletions mysql-test/t/having.test
Expand Up @@ -758,3 +758,83 @@ DROP VIEW v1;
DROP TABLE t1;

--echo End of 10.1 tests

--echo #
--echo # MDEV-14093: GROUP BY with HAVING over function + ORDER BY
--echo #

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;

DROP TABLE _authors, _books, _books2authors;

--echo #
--echo # Bug#17055185: WRONG RESULTS WHEN RUNNING A SELECT THAT INCLUDE
--echo # A HAVING BASED ON A FUNCTION.
--echo #

# Generate series 1, 0, 1, 0....
CREATE TABLE series (
val INT(10) UNSIGNED NOT NULL
);
INSERT INTO series VALUES(1);

DELIMITER |;
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;
|
DELIMITER ;|

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;
SELECT t, next_seq_value() r FROM t1 FORCE INDEX(t)
GROUP BY t HAVING r = 1 ORDER BY t1.u;

DROP TABLE t1;
DROP FUNCTION next_seq_value;
DROP TABLE series;

0 comments on commit 8f2e8cf

Please sign in to comment.