Commit dd1c1c1b authored by Otto Kekäläinen's avatar Otto Kekäläinen
Browse files

Merge tag 'upstream/5.5.57' into ubuntu-14.04

Upstream version 5.5.57

# gpg: Signature made su 23. heinäkuuta 2017 23.35.34 EEST
# gpg:                using RSA key BED8449FCEE8DA88
# gpg: Good signature from "Otto Kekäläinen <otto@seravo.fi>" [full]
# gpg:                 aka "Otto Kekäläinen <otto@kekalainen.net>" [full]
# gpg:                 aka "Otto Kekäläinen <otto@fsfe.org>" [full]
# gpg:                 aka "Otto Kekäläinen <otto@linux.com>" [full]
# gpg:                 aka "Otto Kekäläinen <otto.kekalainen@seravo.fi>" [full]
# gpg:                 aka "Otto Kekäläinen <otto@mariadb.org>" [undefined]
# gpg:                 aka "Otto Kekäläinen <otto@debian.org>" [undefined]
# gpg:                 aka "Otto Kekäläinen <otto@sange.fi>" [full]
parents fb3d7b9e 69b6b895
...@@ -5998,3 +5998,38 @@ INSERT INTO t1 VALUES ('foo','bar'); ...@@ -5998,3 +5998,38 @@ INSERT INTO t1 VALUES ('foo','bar');
SELECT * FROM t1 WHERE f2 >= SOME ( SELECT f1 FROM t1 ); SELECT * FROM t1 WHERE f2 >= SOME ( SELECT f1 FROM t1 );
SELECT * FROM t1 WHERE f2 <= SOME ( SELECT f1 FROM t1 ); SELECT * FROM t1 WHERE f2 <= SOME ( SELECT f1 FROM t1 );
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # MDEV-10146: Wrong result (or questionable result and behavior)
--echo # with aggregate function in uncorrelated SELECT subquery
--echo #
CREATE TABLE t1 (f1 INT);
CREATE VIEW v1 AS SELECT * FROM t1;
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (f2 int);
INSERT INTO t2 VALUES (3);
SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1;
SELECT ( SELECT MAX(f1) FROM t2 ) FROM v1;
INSERT INTO t2 VALUES (4);
--error ER_SUBQUERY_NO_1_ROW
SELECT ( SELECT MAX(f1) FROM t2 ) FROM v1;
--error ER_SUBQUERY_NO_1_ROW
SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1;
drop view v1;
drop table t1,t2;
#
# MDEV-7828 Assertion `key_read == 0' failed in TABLE::enable_keyread with SELECT SQ and WHERE SQ
#
CREATE TABLE t1 (f1 INT, KEY(f1)) ENGINE=MyISAM;
INSERT t1 VALUES (4),(8);
CREATE TABLE t2 (f2 INT, KEY(f2)) ENGINE=MyISAM;
INSERT t2 VALUES (6),(9);
SELECT (SELECT MAX(sq.f2) FROM t1) FROM (SELECT * FROM t2) AS sq WHERE f2 = 2;
drop table t1, t2;
...@@ -406,6 +406,8 @@ drop table t3, t4, t5; ...@@ -406,6 +406,8 @@ drop table t3, t4, t5;
--echo # LP BUG#858038 The result of a query with NOT IN subquery depends on the state of the optimizer switch --echo # LP BUG#858038 The result of a query with NOT IN subquery depends on the state of the optimizer switch
--echo # --echo #
set @optimizer_switch_save= @@optimizer_switch;
create table t1 (c1 char(2) not null, c2 char(2)); create table t1 (c1 char(2) not null, c2 char(2));
create table t2 (c3 char(2), c4 char(2)); create table t2 (c3 char(2), c4 char(2));
...@@ -424,3 +426,100 @@ explain select * from t1 where c1 = 'a2' and (c1, c2) not in (select * from t2); ...@@ -424,3 +426,100 @@ explain select * from t1 where c1 = 'a2' and (c1, c2) not in (select * from t2);
select * from t1 where c1 = 'a2' and (c1, c2) not in (select * from t2); select * from t1 where c1 = 'a2' and (c1, c2) not in (select * from t2);
drop table t1, t2; drop table t1, t2;
set optimizer_switch= @optimizer_switch_save;
--echo #
--echo # MDEV-12673: cost-based choice between materialization and in-to-exists
--echo #
CREATE TABLE t1 (
pk1 int, a1 varchar(3), b1 varchar(3), PRIMARY KEY (pk1), KEY(a1), KEY(b1)
) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1,'foo','bar'),(2,'bar','foo');
CREATE TABLE t2 (pk2 INT PRIMARY KEY, a2 VARCHAR(3), KEY(a2)) ENGINE=MyISAM;
INSERT INTO t2 VALUES (1,'abc'),(2,'xyz'),(3,'foo');
SELECT 'qux' IN ( SELECT a1 FROM t1 INNER JOIN t2 WHERE a2 = b1 AND pk2 = 3 );
SELECT 'bar' IN ( SELECT a1 FROM t1 INNER JOIN t2 WHERE a2 = b1 AND pk2 = 3 );
EXPLAIN
SELECT 'bar' IN ( SELECT a1 FROM t1 INNER JOIN t2 WHERE a2 = b1 AND pk2 = 3 );
DROP TABLE t1,t2;
CREATE TABLE t1 (i1 INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1);
CREATE TABLE t2 (i2 int, c2 varchar(3), KEY(i2,c2)) ENGINE=MyISAM;
INSERT INTO t2 VALUES (1,'abc'),(2,'foo');
CREATE TABLE t3 (pk3 int PRIMARY KEY, c3 varchar(3)) ENGINE=MyISAM;
INSERT INTO t3 VALUES (1,'foo'),(2,'bar');
SELECT * FROM t1 WHERE i1 NOT IN (
SELECT i2 FROM t2 RIGHT JOIN t3 ON (c3 = c2) WHERE pk3 = i1
);
EXPLAIN
SELECT * FROM t1 WHERE i1 NOT IN (
SELECT i2 FROM t2 RIGHT JOIN t3 ON (c3 = c2) WHERE pk3 = i1
);
DROP TABLE t1,t2,t3;
--echo #
--echo # MDEV-7599: in-to-exists chosen after min/max optimization
--echo #
set @optimizer_switch_save= @@optimizer_switch;
CREATE TABLE t1 (a INT, KEY(a)) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (b INT, c INT) ENGINE=MyISAM;
INSERT INTO t2 VALUES (1,6),(2,4), (8,9);
let $q=
SELECT * FROM t2 WHERE b != ALL (SELECT MIN(a) FROM t1, t2 WHERE t2.c = t2.b);
eval $q;
eval EXPLAIN EXTENDED $q;
set optimizer_switch= 'materialization=off';
eval $q;
eval EXPLAIN EXTENDED $q;
set optimizer_switch= @optimizer_switch_save;
DROP TABLE t1,t2;
CREATE TABLE t1 (f1 varchar(10)) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('foo'),('bar');
CREATE TABLE t2 (f2 varchar(10), key(f2)) ENGINE=MyISAM;
INSERT INTO t2 VALUES ('baz'),('qux');
CREATE TABLE t3 (f3 varchar(10)) ENGINE=MyISAM;
INSERT INTO t3 VALUES ('abc'),('def');
SELECT * FROM t1
WHERE f1 = ALL( SELECT MAX(t2a.f2)
FROM t2 AS t2a INNER JOIN t2 t2b INNER JOIN t3
ON (f3 = t2b.f2) );
DROP TABLE t1,t2,t3;
--echo #
--echo # MDEV-12963: min/max optimization optimizing away all tables employed
--echo # for uncorrelated IN subquery used in a disjunct of WHERE
--echo #
create table t1 (a int, index idx(a)) engine=myisam;
insert into t1 values (4),(7),(1),(3),(9);
select * from t1 where a in (select max(a) from t1 where a < 4) or a > 5;
explain
select * from t1 where a in (select max(a) from t1 where a < 4) or a > 5;
drop table t1;
...@@ -97,3 +97,9 @@ set optimizer_switch= @tmp_subselect_nulls; ...@@ -97,3 +97,9 @@ set optimizer_switch= @tmp_subselect_nulls;
drop table x1; drop table x1;
drop table x2; drop table x2;
#
# MDEV-7339 Server crashes in Item_func_trig_cond::val_int
#
select (select 1, 2) in (select 3, 4);
select (select NULL, NULL) in (select 3, 4);
...@@ -2769,5 +2769,77 @@ WHERE ( SELECT z.country ...@@ -2769,5 +2769,77 @@ WHERE ( SELECT z.country
drop table t1, t2, t3; drop table t1, t2, t3;
set optimizer_switch= @tmp_mdev6859; set optimizer_switch= @tmp_mdev6859;
--echo #
--echo # MDEV-12675: subquery subject to semi-join optimizations
--echo # in ON expression of INNER JOIN
--echo #
set @tmp_mdev12675=@@optimizer_switch;
set optimizer_switch=default;
create table t1 (a int) engine=myisam;
insert into t1 values (5),(3),(2),(7),(2),(5),(1);
create table t2 (b int, index idx(b)) engine=myisam;
insert into t2 values (2),(3),(2),(1),(3),(4);
insert into t2 select b+10 from t2;
insert into t2 select b+10 from t2;
insert into t2 select b+10 from t2;
insert into t2 select b+10 from t2;
insert into t2 select b+10 from t2;
insert into t2 select b+10 from t2;
insert into t2 select b+10 from t2;
insert into t2 select b+10 from t2;
insert into t2 select b+10 from t2;
insert into t2 select b+10 from t2;
insert into t2 select b+10 from t2;
analyze table t1,t2;
explain
select a from t1, t2 where b between 1 and 2 and a in (select b from t2);
explain
select a from t1 join t2 on b between 1 and 2 and a in (select b from t2);
drop table t1,t2;
set optimizer_switch= @tmp_mdev12675;
--echo #
--echo # MDEV-12817: subquery NOT subject to semi-join optimizations
--echo # in ON expression of INNER JOIN
--echo #
CREATE TABLE t1 (c1 int) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (c2 int) ENGINE=MyISAM;
INSERT INTO t2 VALUES (3),(4);
CREATE TABLE t3 (c3 int) ENGINE=MyISAM;
INSERT INTO t3 VALUES (5),(6);
CREATE TABLE t4 (c4 int) ENGINE=MyISAM;
INSERT INTO t4 VALUES (7),(8);
let $q1=
SELECT c1
FROM t1
LEFT JOIN
( t2 INNER JOIN t3 ON ( 1 IN ( SELECT c4 FROM t4 ) ) )
ON (c1 = c3);
eval $q1;
eval EXPLAIN EXTENDED $q1;
let $q2=
SELECT *
FROM t1
LEFT JOIN
( ( SELECT * FROM t2 WHERE c2 IN ( SELECT c3 FROM t3 ) ) AS sq INNER JOIN t4 )
ON (c1 = c2);
--echo # mdev-12820
eval $q2;
eval EXPLAIN EXTENDED $q2;
DROP TABLE t1,t2,t3,t4;
# The following command must be the last one the file # The following command must be the last one the file
set optimizer_switch=@subselect_sj_tmp; set optimizer_switch=@subselect_sj_tmp;
...@@ -263,3 +263,43 @@ DROP TABLE t1,t2,t3; ...@@ -263,3 +263,43 @@ DROP TABLE t1,t2,t3;
set join_cache_level= @save_join_cache_level; set join_cache_level= @save_join_cache_level;
set optimizer_switch=@save_optimizer_switch; set optimizer_switch=@save_optimizer_switch;
--echo #
--echo # mdev-7791: materialization of a semi-join subquery +
--echo # RAND() in WHERE
--echo # (materialized table is accessed last)
--echo #
set @save_optimizer_switch=@@optimizer_switch;
set optimizer_switch='materialization=on';
create table t1(i int);
insert into t1 values (1), (2), (3), (7), (9), (10);
create table t2(i int);
insert into t2 values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
select * from t1 where (rand() < 0) and i in (select i from t2);
explain extended
select * from t1 where (rand() < 0) and i in (select i from t2);
drop table t1,t2;
set optimizer_switch=@save_optimizer_switch;
--echo #
--echo # mdev-12855: materialization of a semi-join subquery + ORDER BY
--echo #
CREATE TABLE t1 (f1 varchar(8), KEY(f1)) ENGINE=InnoDB;
INSERT INTO t1 VALUES ('qux'),('foo');
CREATE TABLE t2 (f2 varchar(8)) ENGINE=InnoDB;
INSERT INTO t2 VALUES ('bar'),('foo'),('qux');
let $q=
SELECT f1 FROM t1
WHERE f1 IN ( SELECT f2 FROM t2 WHERE f2 > 'bar' )
HAVING f1 != 'foo'
ORDER BY f1;
eval $q;
eval explain $q;
DROP TABLE t1,t2;
...@@ -1944,4 +1944,211 @@ set optimizer_switch= @save_optimizer_switch; ...@@ -1944,4 +1944,211 @@ set optimizer_switch= @save_optimizer_switch;
DROP TABLE t1,t2; DROP TABLE t1,t2;
--echo #
--echo # mdev-12838: scan of materialized of semi-join subquery in join
--echo #
set @save_optimizer_switch=@@optimizer_switch;
CREATE TABLE t1 (
dispatch_group varchar(32),
assignment_group varchar(32),
sys_id char(32),
PRIMARY KEY (sys_id),
KEY idx1 (dispatch_group),
KEY idx2 (assignment_group)
) ENGINE=MyISAM;
CREATE TABLE t2 (
ugroup varchar(32),
user varchar(32),
sys_id char(32),
PRIMARY KEY (sys_id),
KEY idx3 (ugroup),
KEY idx4 (user)
) ENGINE=MyISAM;
CREATE TABLE t3 (
type mediumtext,
sys_id char(32),
PRIMARY KEY (sys_id)
) ENGINE=MyISAM;
--disable_query_log
INSERT INTO t1 VALUES
('e5d9f63237232000158bbfc8bcbe5dbf','f304ae0037332000158bbfc8bcbe5d4f',
'5398c0e037003000158bbfc8bcbe5dbb'),
('69d9f63237232000158bbfc8bcbe5dcb','7172ea0037332000158bbfc8bcbe5db6',
'5c188ca037003000158bbfc8bcbe5dbc'),
('577ed708d773020058c92cf65e61037a','699708d4d773020058c92cf65e61037c',
'623a8cd4d773020058c92cf65e6103ea'),
('96fb652637232000158bbfc8bcbe5db4','df50316637232000158bbfc8bcbe5d23',
'6835bd6637232000158bbfc8bcbe5d21'),
('e1d9f63237232000158bbfc8bcbe5db8','96346e0037332000158bbfc8bcbe5daa',
'697880e037003000158bbfc8bcbe5dcd'),
('25d9f63237232000158bbfc8bcbe5dbe','f304ae0037332000158bbfc8bcbe5d4f',
'6a9804e037003000158bbfc8bcbe5d09'),
('96fb652637232000158bbfc8bcbe5db4','e08fad2637232000158bbfc8bcbe5d39',
'6d25f96637232000158bbfc8bcbe5d79'),
('e9d9f63237232000158bbfc8bcbe5dc6','7172ea0037332000158bbfc8bcbe5db6',
'702880e037003000158bbfc8bcbe5d94'),
('a5d9f63237232000158bbfc8bcbe5dca','f304ae0037332000158bbfc8bcbe5d4f',
'7188c0e037003000158bbfc8bcbe5d75'),
('65d9f63237232000158bbfc8bcbe5dc4','f304ae0037332000158bbfc8bcbe5d4f',
'778880e037003000158bbfc8bcbe5d9e'),
('a1d9f63237232000158bbfc8bcbe5dc3','7172ea0037332000158bbfc8bcbe5db6',
'7d0840e037003000158bbfc8bcbe5dde'),
('21d9f63237232000158bbfc8bcbe5db7','96346e0037332000158bbfc8bcbe5daa',
'7f6880e037003000158bbfc8bcbe5da7'),
('96fb652637232000158bbfc8bcbe5db4','ec70316637232000158bbfc8bcbe5d60',
'8025f96637232000158bbfc8bcbe5dd0'),
('3dd9f63237232000158bbfc8bcbe5dcc','7172ea0037332000158bbfc8bcbe5db6',
'823880e037003000158bbfc8bcbe5ded'),
('96fb652637232000158bbfc8bcbe5db4','7b10fd2637232000158bbfc8bcbe5d30',
'9a353d6637232000158bbfc8bcbe5dee'),
('75d9f63237232000158bbfc8bcbe5dd0','ebb4620037332000158bbfc8bcbe5d89',
'a558c0e037003000158bbfc8bcbe5d36'),
('6dd9f63237232000158bbfc8bcbe5db5','96346e0037332000158bbfc8bcbe5daa',
'bc78cca037003000158bbfc8bcbe5d74'),
('add9f63237232000158bbfc8bcbe5dc7','7172ea0037332000158bbfc8bcbe5db6',
'c53804a037003000158bbfc8bcbe5db8'),
('fdd9f63237232000158bbfc8bcbe5dcd','7864ae0037332000158bbfc8bcbe5db8',
'cfe740e037003000158bbfc8bcbe5de8'),
('96fb652637232000158bbfc8bcbe5db4','3120fd2637232000158bbfc8bcbe5d42',
'e2257d6637232000158bbfc8bcbe5ded'),
('3c3725e237232000158bbfc8bcbe5da1','96346e0037332000158bbfc8bcbe5daa',
'ee78c0e037003000158bbfc8bcbe5db5'),
('a9d9f63237232000158bbfc8bcbe5dc0','7172ea0037332000158bbfc8bcbe5db6',
'f00888a037003000158bbfc8bcbe5dd3'),
('29d9f63237232000158bbfc8bcbe5db9','7172ea0037332000158bbfc8bcbe5db6',
'fa0880e037003000158bbfc8bcbe5d70'),
('b1d9f63237232000158bbfc8bcbe5dcf','ebb4620037332000158bbfc8bcbe5d89',
'fa48c0e037003000158bbfc8bcbe5d28');
INSERT INTO t2 VALUES
('17801ac21b13200050fdfbcd2c0713e8','8e826bf03710200044e0bfc8bcbe5d86',
'14c19a061b13200050fdfbcd2c07134b'),
('577ed708d773020058c92cf65e61037a','931644d4d773020058c92cf65e61034c',
'339888d4d773020058c92cf65e6103aa'),
('df50316637232000158bbfc8bcbe5d23','92826bf03710200044e0bfc8bcbe5da9',
'3682f56637232000158bbfc8bcbe5d44'),
('b4f342b237232000158bbfc8bcbe5def','86826bf03710200044e0bfc8bcbe5d70',
'38e4c2b237232000158bbfc8bcbe5dea'),
('7b10fd2637232000158bbfc8bcbe5d30','8a826bf03710200044e0bfc8bcbe5d72',
'4442b56637232000158bbfc8bcbe5d43'),
('3120fd2637232000158bbfc8bcbe5d42','82826bf03710200044e0bfc8bcbe5d89',
'49d2396637232000158bbfc8bcbe5d12'),
('96fb652637232000158bbfc8bcbe5db4','86826bf03710200044e0bfc8bcbe5d79',
'4e3ca52637232000158bbfc8bcbe5d3e'),
('17801ac21b13200050fdfbcd2c0713e8','824fd523bf4320007a6d257b3f073963',
'58c19a061b13200050fdfbcd2c07134e'),
('699708d4d773020058c92cf65e61037c','901784d4d773020058c92cf65e6103da',
'5bc708d4d773020058c92cf65e6103d5'),
('75d9f63237232000158bbfc8bcbe5dd0','86826bf03710200044e0bfc8bcbe5d79',
'6b52cb7237232000158bbfc8bcbe5ded'),
('f253da061b13200050fdfbcd2c0713ab','8e826bf03710200044e0bfc8bcbe5d86',
'81045e061b13200050fdfbcd2c071373'),
('7b10fd2637232000158bbfc8bcbe5d30','8e826bf03710200044e0bfc8bcbe5d74',
'8c42b56637232000158bbfc8bcbe5d3f'),
('e5d9f63237232000158bbfc8bcbe5dbf','7a826bf03710200044e0bfc8bcbe5df5',
'a7acfe3237232000158bbfc8bcbe5d78'),
('8a5055c9c61122780043563ef53438e3','9ee1b13dc6112271007f9d0efdb69cd0',
'a9aff553c6112276015a8006174bee21'),
('8a4dde73c6112278017a6a4baf547aa7','9ee1b13dc6112271007f9d0efdb69cd0',
'a9b2f526c61122760003ae07349d294f'),
('aaccc971c0a8001500fe1ff4302de101','9ee1b13dc6112271007f9d0efdb69cd0',
'aacceed3c0a80015009069bba51c4e21'),
('65d9f63237232000158bbfc8bcbe5dc4','8d56406a0a0a0a6b004070b354aada28',
'ac1bfa3237232000158bbfc8bcbe5dc3'),
('b85d44954a3623120004689b2d5dd60a','97000fcc0a0a0a6e0104ca999f619e5b',
'b77bc032cbb00200d71cb9c0c24c9c45'),
('220f8e71c61122840197e57c33464f70','8d56406a0a0a0a6b004070b354aada28',
'b9b74f080a0a0b343ba75b95bdb27056'),
('e08fad2637232000158bbfc8bcbe5d39','82826bf03710200044e0bfc8bcbe5d80',
'be02756637232000158bbfc8bcbe5d8b'),
('ebb4620037332000158bbfc8bcbe5d89','7682abf03710200044e0bfc8bcbe5d25',
'c0122f4437732000158bbfc8bcbe5d7d'),
('96fb652637232000158bbfc8bcbe5db4','7a82abf03710200044e0bfc8bcbe5d27',
'c23ca52637232000158bbfc8bcbe5d3b'),
('22122b37c611228400f9ff91c857581d','9ee1b13dc6112271007f9d0efdb69cd0',
'd23bbf5dac14641866947512bde59dc5'),
('db53a9290a0a0a650091abebccf833c6','9ee1b13dc6112271007f9d0efdb69cd0',
'db54a0f60a0a0a65002c54dcb72b4f41'),
('e08fad2637232000158bbfc8bcbe5d39','8e826bf03710200044e0bfc8bcbe5d86',
'f602756637232000158bbfc8bcbe5d88'),
('699708d4d773020058c92cf65e61037c','8d59d601d7b3020058c92cf65e6103c2',
'f718a241d7b3020058c92cf65e610332'),
('df50316637232000158bbfc8bcbe5d23','9e826bf03710200044e0bfc8bcbe5da6',
'fe82f56637232000158bbfc8bcbe5d4e'),
('f972d6061b13200050fdfbcd2c0713e5','780395f0df031100a9e78b6c3df2631f',
'ff4395f0df031100a9e78b6c3df2637e');
INSERT INTO t3 VALUES
('87245e061b13200050fdfbcd2c0713cc','7172ea0037332000158bbfc8bcbe5db6'),
('74af88c6c611227d0066386e74dc853d','74ad1ff3c611227d01d25feac2af603f'),
('59e22fb137032000158bbfc8bcbe5d52','75d9f63237232000158bbfc8bcbe5dd0'),
('98906fb137032000158bbfc8bcbe5d65','781da52637232000158bbfc8bcbe5db8'),
('87245e061b13200050fdfbcd2c0713cc','7864ae0037332000158bbfc8bcbe5db8'),
('87245e061b13200050fdfbcd2c0713cc','7b10fd2637232000158bbfc8bcbe5d30'),
('59e22fb137032000158bbfc8bcbe5d52','81a880e037003000158bbfc8bcbe5df8'),
('74af88c6c611227d0066386e74dc853d','8a4cb6d4c61122780043b1642efcd52b'),
('1cb8ab9bff500200158bffffffffff62','8a4dde73c6112278017a6a4baf547aa7'),
('1cb8ab9bff500200158bffffffffff62','8a5055c9c61122780043563ef53438e3'),
('87245e061b13200050fdfbcd2c0713cc','96346e0037332000158bbfc8bcbe5daa'),
('59e22fb137032000158bbfc8bcbe5d52','96fb652637232000158bbfc8bcbe5db4'),
('59e22fb137032000158bbfc8bcbe5d52','a1d9f63237232000158bbfc8bcbe5dc3'),
('59e22fb137032000158bbfc8bcbe5d52','a5d9f63237232000158bbfc8bcbe5dca'),
('1cb8ab9bff500200158bffffffffff62','a715cd759f2002002920bde8132e7018'),
('59e22fb137032000158bbfc8bcbe5d52','a9d9f63237232000158bbfc8bcbe5dc0'),
('74af88c6c611227d0066386e74dc853d','aacb62e2c0a80015007f67f752c2b12c'),
('74af88c6c611227d0066386e74dc853d','aaccc971c0a8001500fe1ff4302de101'),
('59e22fb137032000158bbfc8bcbe5d52','add9f63237232000158bbfc8bcbe5dbb'),
('59e22fb137032000158bbfc8bcbe5d52','add9f63237232000158bbfc8bcbe5dc7'),
('59e22fb137032000158bbfc8bcbe5d52','b1d9f63237232000158bbfc8bcbe5dcf'),
('1cb8ab9bff500200158bffffffffff62','b85d44954a3623120004689b2d5dd60a'),
('1cb8ab9bff500200158bffffffffff62','b97e89b94a36231201676b73322a0311'),
('1cb8ab9bff500200158bffffffffff62','cfcbad03d711110050f5edcb9e61038f'),
('1cb8ab9bff500200158bffffffffff62','d625dccec0a8016700a222a0f7900d06'),
('1cb8ab9bff500200158bffffffffff62','db53580b0a0a0a6501aa37c294a2ba6b'),
('1cb8ab9bff500200158bffffffffff62','db53a9290a0a0a650091abebccf833c6'),
('1cb8ab9bff500200158bffffffffff62','dc0db135c332010016194ffe5bba8f23'),
('87245e061b13200050fdfbcd2c0713cc','df50316637232000158bbfc8bcbe5d23'),
('87245e061b13200050fdfbcd2c0713cc','e08fad2637232000158bbfc8bcbe5d39'),
('59e22fb137032000158bbfc8bcbe5d52','e1d9f63237232000158bbfc8bcbe5db8'),
('59e22fb137032000158bbfc8bcbe5d52','e5d9f63237232000158bbfc8bcbe5db4'),
('59e22fb137032000158bbfc8bcbe5d52','e5d9f63237232000158bbfc8bcbe5dbf'),
('59e22fb137032000158bbfc8bcbe5d52','e9d9f63237232000158bbfc8bcbe5dba'),
('59e22fb137032000158bbfc8bcbe5d52','e9d9f63237232000158bbfc8bcbe5dc6'),
('87245e061b13200050fdfbcd2c0713cc','ebb4620037332000158bbfc8bcbe5d89'),
('87245e061b13200050fdfbcd2c0713cc','ec70316637232000158bbfc8bcbe5d60'),
('87245e061b13200050fdfbcd2c0713cc','f253da061b13200050fdfbcd2c0713ab'),
('87245e061b13200050fdfbcd2c0713cc','f304ae0037332000158bbfc8bcbe5d4f'),
('98906fb137032000158bbfc8bcbe5d65','f972d6061b13200050fdfbcd2c0713e5'),
('59e22fb137032000158bbfc8bcbe5d52','fdd9f63237232000158bbfc8bcbe5dcd');
--enable_query_log
let $q=
SELECT t1.assignment_group
FROM t1, t3
WHERE t1.assignment_group = t3.sys_id AND
t1.dispatch_group IN
(SELECT t2.ugroup
FROM t2, t3 t3_i
WHERE t2.ugroup = t3_i.sys_id AND
t3_i.type LIKE '59e22fb137032000158bbfc8bcbe5d52' AND
t2.user = '86826bf03710200044e0bfc8bcbe5d79');
set optimizer_switch='materialization=off';
eval explain $q;
eval $q;
set optimizer_switch='materialization=on';
eval explain $q;
eval $q;
DROP TABLE t1,t2,t3;
set optimizer_switch=@save_optimizer_switch;
--echo # End of 5.5 tests --echo # End of 5.5 tests
...@@ -1370,3 +1370,18 @@ order by d; ...@@ -1370,3 +1370,18 @@ order by d;
drop table t1; drop table t1;
--echo End of 5.0 tests --echo End of 5.0 tests
#
# Bug #24595639: INCORRECT BEHAVIOR IN QUERY WITH UNION AND GROUP BY
#
create table t1 (a int, b int);
insert into t1 values (1,1),(2,2),(3,3);
create table t2 (c varchar(30), d varchar(30));
insert into t1 values ('1','1'),('2','2'),('4','4');
create table t3 (e int, f int);
insert into t3 values (1,1),(2,2),(31,31),(32,32);
select e,f, (e , f) in (select e,b from t1 union select c,d from t2) as sub from t3;
select avg(f), (e , f) in (select e,b from t1 union select c,d from t2) as sub from t3 group by sub;
drop table t1,t2,t3;
--echo End of 5.5 tests
...@@ -5565,6 +5565,22 @@ select * ...@@ -5565,6 +5565,22 @@ select *
drop view v1; drop view v1;
drop table t1,t2,t3; drop table t1,t2,t3;
--echo #
--echo # MDEV-11240: Server crashes in check_view_single_update or
--echo # Assertion `derived->table' failed in mysql_derived_merge_for_insert
--echo #
CREATE TABLE t3 (a INT);
CREATE ALGORITHM = MERGE VIEW v1 AS SELECT t2.a FROM t3 AS t1, t3 AS t2;
CREATE ALGORITHM = MERGE VIEW v2 AS SELECT * FROM v1;
PREPARE stmt FROM 'REPLACE INTO v2 SELECT a FROM t3';
--error ER_VIEW_NO_INSERT_FIELD_LIST
EXECUTE stmt;
--error ER_VIEW_NO_INSERT_FIELD_LIST
EXECUTE stmt;
drop view v1,v2;
drop table t3;
--echo # ----------------------------------------------------------------- --echo # -----------------------------------------------------------------
--echo # -- End of 5.5 tests. --echo # -- End of 5.5 tests.
--echo # ----------------------------------------------------------------- --echo # -----------------------------------------------------------------
......
...@@ -143,7 +143,7 @@ static int no_close(void *cookie __attribute__((unused))) ...@@ -143,7 +143,7 @@ static int no_close(void *cookie __attribute__((unused)))
/* /*
A hack around a race condition in the implementation of freopen. A hack around a race condition in the implementation of freopen.
The race condition steams from the fact that the current fd of The race condition stems from the fact that the current fd of
the stream is closed before its number is used to duplicate the the stream is closed before its number is used to duplicate the
new file descriptor. This defeats the desired atomicity of the new file descriptor. This defeats the desired atomicity of the
close and duplicate of dup2(). close and duplicate of dup2().
......
...@@ -129,6 +129,31 @@ ulonglong my_timer_cycles_il_x86_64(); ...@@ -129,6 +129,31 @@ ulonglong my_timer_cycles_il_x86_64();
clock_gettime(CLOCK_SGI_CYCLE) for Irix platforms, clock_gettime(CLOCK_SGI_CYCLE) for Irix platforms,
or on read_real_time for aix platforms. There is or on read_real_time for aix platforms. There is
nothing for Alpha platforms, they would be tricky. nothing for Alpha platforms, they would be tricky.
On the platforms that do not have a CYCLE timer,
"wait" events are initialized to use NANOSECOND instead of CYCLE
during performance_schema initialization (at the server startup).
Linux performance monitor (see "man perf_event_open") can
provide cycle counter on the platforms that do not have
other kinds of cycle counters. But we don't use it so far.
ARM notes
---------
During tests on ARMv7 Debian, perf_even_open() based cycle counter provided
too low frequency with too high overhead:
MariaDB [performance_schema]> SELECT * FROM performance_timers;
+-------------+-----------------+------------------+----------------+
| TIMER_NAME | TIMER_FREQUENCY | TIMER_RESOLUTION | TIMER_OVERHEAD |
+-------------+-----------------+------------------+----------------+
| CYCLE | 689368159 | 1 | 970 |
| NANOSECOND | 1000000000 | 1 | 308 |
| MICROSECOND | 1000000 | 1 | 417 |
| MILLISECOND | 1000 | 1000 | 407 |
| TICK | 127 | 1 | 612 |
+-------------+-----------------+------------------+----------------+
Therefore, it was decided not to use perf_even_open() on ARM
(i.e. go without CYCLE and have "wait" events use NANOSECOND by default).
*/ */
ulonglong my_timer_cycles(void) ulonglong my_timer_cycles(void)
......
...@@ -197,7 +197,7 @@ int my_realpath(char *to, const char *filename, myf MyFlags) ...@@ -197,7 +197,7 @@ int my_realpath(char *to, const char *filename, myf MyFlags)
const char *my_open_parent_dir_nosymlinks(const char *pathname, int *pdfd) const char *my_open_parent_dir_nosymlinks(const char *pathname, int *pdfd)
{ {
char buf[PATH_MAX+1]; char buf[FN_REFLEN + 1];
char *s= buf, *e= buf+1, *end= strnmov(buf, pathname, sizeof(buf)); char *s= buf, *e= buf+1, *end= strnmov(buf, pathname, sizeof(buf));
int fd, dfd= -1; int fd, dfd= -1;
......
...@@ -107,12 +107,21 @@ const char *my_open_parent_dir_nosymlinks(const char *pathname, int *pdfd); ...@@ -107,12 +107,21 @@ const char *my_open_parent_dir_nosymlinks(const char *pathname, int *pdfd);
res= AT; \ res= AT; \
if (dfd >= 0) close(dfd); \ if (dfd >= 0) close(dfd); \
return res; return res;
#elif defined(HAVE_REALPATH) #elif defined(HAVE_REALPATH) && defined(PATH_MAX)
#define NOSYMLINK_FUNCTION_BODY(AT,NOAT) \ #define NOSYMLINK_FUNCTION_BODY(AT,NOAT) \
char buf[PATH_MAX+1]; \ char buf[PATH_MAX+1]; \
if (realpath(pathname, buf) == NULL) return -1; \ if (realpath(pathname, buf) == NULL) return -1; \
if (strcmp(pathname, buf)) { errno= ENOTDIR; return -1; } \ if (strcmp(pathname, buf)) { errno= ENOTDIR; return -1; } \
return NOAT; return NOAT;
#elif defined(HAVE_REALPATH)
#define NOSYMLINK_FUNCTION_BODY(AT,NOAT) \
char *buf= realpath(pathname, NULL); \
int res; \
if (buf == NULL) return -1; \
if (strcmp(pathname, buf)) { errno= ENOTDIR; res= -1; } \
else res= NOAT; \
free(buf); \
return res;
#else #else
#define NOSYMLINK_FUNCTION_BODY(AT,NOAT) \ #define NOSYMLINK_FUNCTION_BODY(AT,NOAT) \
return NOAT; return NOAT;
......
...@@ -744,7 +744,7 @@ void my_safe_print_str(const char *val, int len) ...@@ -744,7 +744,7 @@ void my_safe_print_str(const char *val, int len)
size_t my_write_stderr(const void *buf, size_t count) size_t my_write_stderr(const void *buf, size_t count)
{ {
return (size_t) write(STDERR_FILENO, buf, count); return (size_t) write(fileno(stderr), buf, count);
} }
......
...@@ -552,7 +552,7 @@ int ReplSemiSyncMaster::reportReplyBinlog(uint32 server_id, ...@@ -552,7 +552,7 @@ int ReplSemiSyncMaster::reportReplyBinlog(uint32 server_id,
if (need_copy_send_pos) if (need_copy_send_pos)
{ {
strcpy(reply_file_name_, log_file_name); strmake_buf(reply_file_name_, log_file_name);
reply_file_pos_ = log_file_pos; reply_file_pos_ = log_file_pos;
reply_file_name_inited_ = true; reply_file_name_inited_ = true;
...@@ -659,7 +659,7 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name, ...@@ -659,7 +659,7 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name,
if (cmp <= 0) if (cmp <= 0)
{ {
/* This thd has a lower position, let's update the minimum info. */ /* This thd has a lower position, let's update the minimum info. */
strcpy(wait_file_name_, trx_wait_binlog_name); strmake_buf(wait_file_name_, trx_wait_binlog_name);
wait_file_pos_ = trx_wait_binlog_pos; wait_file_pos_ = trx_wait_binlog_pos;
rpl_semi_sync_master_wait_pos_backtraverse++; rpl_semi_sync_master_wait_pos_backtraverse++;
...@@ -670,7 +670,7 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name, ...@@ -670,7 +670,7 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name,
} }
else else
{ {
strcpy(wait_file_name_, trx_wait_binlog_name); strmake_buf(wait_file_name_, trx_wait_binlog_name);
wait_file_pos_ = trx_wait_binlog_pos; wait_file_pos_ = trx_wait_binlog_pos;
wait_file_name_inited_ = true; wait_file_name_inited_ = true;
......
# Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2006, 2017, Oracle and/or its affiliates.
# Copyright (c) 2011, 2017, MariaDB Corporation
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
...@@ -95,6 +96,13 @@ IF(CMAKE_GENERATOR MATCHES "Makefiles") ...@@ -95,6 +96,13 @@ IF(CMAKE_GENERATOR MATCHES "Makefiles")
ENDFOREACH() ENDFOREACH()
ENDIF() ENDIF()
IF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
SET (PERL_PATH "/usr/local/bin/perl")
ELSE()
SET (PERL_PATH "/usr/bin/perl")
ENDIF()
IF(UNIX) IF(UNIX)
# FIND_PROC and CHECK_PID are used by mysqld_safe # FIND_PROC and CHECK_PID are used by mysqld_safe
IF(CMAKE_SYSTEM_NAME MATCHES "Linux") IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
...@@ -379,4 +387,3 @@ IF(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_FLAGS MATCHES "-static") ...@@ -379,4 +387,3 @@ IF(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_FLAGS MATCHES "-static")
COMPONENT Development) COMPONENT Development)
ENDIF() ENDIF()
ENDIF() ENDIF()
#!/usr/bin/perl -w # Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
#
# Copyright (c) 2008, 2009 Sun Microsystems, Inc.
# Use is subject to license terms.
#
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:
......
#!/usr/bin/perl #!@PERL_PATH@
# -*- cperl -*- # -*- cperl -*-
# #
# Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
......
#!/usr/bin/perl #!@PERL_PATH@
# Copyright (c) 2000-2002, 2006, 2007 MySQL AB, 2009 Sun Microsystems, Inc. # Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
# Use is subject to license terms.
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
......
#!/usr/bin/perl #!@PERL_PATH@
# Copyright (c) 2000, 2004, 2006 MySQL AB, 2009 Sun Microsystems, Inc. # Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
# Use is subject to license terms.
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
......
#!/usr/bin/perl #!@PERL_PATH@
# Copyright (c) 2001 MySQL AB, 2009 Sun Microsystems, Inc. # Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
# Use is subject to license terms.
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public # modify it under the terms of the GNU Library General Public
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment