revision-id: fceda2dab6f8ea6c042f910cbc1d07d5df0cbc3c (mariadb-5.5.60-51-gfceda2dab6f) parent(s): bd0b368119b48ffbb1e5ab3cd2887270c5c6840e e48d775c6f066add457fa8cfb2ebc4d5ff0c7613 author: Oleksandr Byelkin committer: Oleksandr Byelkin timestamp: 2018-07-29 13:10:29 +0200 message: Merge remote-tracking branch 'mysql/5.5' into 5.5 We do not accept: 1. We did not have this problem (fixed earlier and better) d982e717aba67227ec40761a21a4211db91aa0e2 Bug#27510150: MYSQLDUMP FAILS FOR SPECIFIC --WHERE CLAUSES 2. We do not have such options (an DBUG_ASSERT put just in case) bbc2e37fe4e0ca3a7cfa1437a763dc43829e98e2 Bug#27759871: BACKRONYM ISSUE IS STILL IN MYSQL 5.7 3. Serg fixed it in other way in this release: e48d775c6f066add457fa8cfb2ebc4d5ff0c7613 Bug#27980823: HEAP OVERFLOW VULNERABILITIES IN MYSQL CLIENT LIBRARY include/sql_common.h | 2 +- mysql-test/r/grant.result | 4 +- mysql-test/r/union.result | 16 +++++++ mysql-test/t/grant.test | 3 ++ mysql-test/t/union.test | 15 +++++++ sql-common/client.c | 4 ++ sql/item.cc | 3 +- sql/sql_acl.cc | 105 +++++++++++++++++++++++++++----------------- storage/myisam/ha_myisam.cc | 6 ++- storage/myisam/mi_check.c | 6 ++- storage/myisam/mi_locking.c | 6 ++- 11 files changed, 123 insertions(+), 47 deletions(-) diff --cc include/sql_common.h index 5bfe5ba8969,9571dff9778..ba0e898d526 --- a/include/sql_common.h +++ b/include/sql_common.h @@@ -1,8 -1,8 +1,8 @@@ #ifndef SQL_COMMON_INCLUDED #define SQL_COMMON_INCLUDED - /* Copyright (c) 2003, 2012, Oracle and/or its affiliates. ++/* Copyright (c) 2003, 2018, Oracle and/or its affiliates. + Copyright (c) 2010, 2018, MariaDB -/* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. - 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 the Free Software Foundation; version 2 of the License. diff --cc mysql-test/r/union.result index 83d889b7b73,c0b364d0fde..5ea0f975a91 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@@ -1914,122 -1861,18 +1914,138 @@@ SET @@long_query_time= @old_long_query_ SET @@global.log_output= @old_log_output; SET @@global.slow_query_log= @old_slow_query_log; # +# lp:1010729: Unexpected syntax error from UNION +# (bug #54382) with single-table join nest +# +CREATE TABLE t1 (a int); +CREATE TABLE t2 (b int); +CREATE TABLE t3 (c int); +SELECT a FROM t1 UNION SELECT b FROM t2 JOIN (t3) ON ( t2.b = t3.c ); +a +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (pk int NOT NULL); +CREATE TABLE t2 (pk int NOT NULL, fk int NOT NULL); +SELECT t1.pk FROM t1 LEFT JOIN (t2) ON (t1.pk = t2.fk) +UNION +SELECT t1.pk FROM t1 LEFT JOIN (t2) ON (t1.pk = t2.fk); +pk +DROP TABLE t1,t2; +create table t1 (a int); +insert t1 values (1),(2),(3),(1); +explain select 1 from dual where exists (select max(a) from t1 group by a union select a+2 from t1); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used +2 SUBQUERY t1 ALL NULL NULL NULL NULL 4 Using temporary; Using filesort +3 UNION t1 ALL NULL NULL NULL NULL 4 +NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL +drop table t1; +# +# MDEV-6868:MariaDB server crash ( select with union and order by +# with subquery ) +# +CREATE TABLE t1 ( id INTEGER, sample_name1 VARCHAR(100), sample_name2 VARCHAR(100), PRIMARY KEY(id) ); +INSERT INTO t1 ( id, sample_name1, sample_name2 ) VALUES ( 1, 'aaaa', 'bbbb' ), ( 2, 'cccc', 'dddd' ); +( +SELECT sample_name1 AS testname FROM t1 +) +UNION +( +SELECT sample_name2 AS testname FROM t1 C ORDER BY (SELECT T.sample_name1 FROM t1 T WHERE T.id = C.id) +) +; +testname +aaaa +cccc +bbbb +dddd +drop table t1; +# +# MDEV-10172: UNION query returns incorrect rows outside +# conditional evaluation +# +create table t1 (d datetime not null primary key); +insert into t1(d) values ('2016-06-01'),('2016-06-02'),('2016-06-03'),('2016-06-04'); +select * from +( +select * from t1 where d between '2016-06-02' and '2016-06-05' + union +(select * from t1 where d < '2016-06-05' order by d desc limit 1) +) onlyJun2toJun4 +order by d; +d +2016-06-02 00:00:00 +2016-06-03 00:00:00 +2016-06-04 00:00:00 +drop table t1; +End of 5.0 tests +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; +e f sub +1 1 1 +2 2 1 +31 31 0 +32 32 0 +select avg(f), (e , f) in (select e,b from t1 union select c,d from t2) as sub from t3 group by sub; +avg(f) sub +31.5000 0 +1.5000 1 +drop table t1,t2,t3; +# +# MDEV-14715 Assertion `!table || (!table->read_set || +# bitmap_is_set(table->read_set, field_index))' +# failed in Field_num::val_decimal +# +CREATE TABLE t1 (a INT, b INT) ENGINE=MyISAM; +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES (1, NULL),(3, 4); +(SELECT a, sum(a) AS f FROM v1 group by a ORDER BY b + sum(a)) +UNION +(SELECT 2, 2); +ERROR HY000: Invalid use of group function +(SELECT a, sum(a) AS f FROM v1 group by a ORDER BY b + 1) +UNION +(SELECT 2, 2); +a f +1 1 +3 3 +2 2 +SELECT a, b FROM t1 +UNION +(SELECT a, VAR_POP(a) AS f FROM v1 GROUP BY a ORDER BY b/a ); +a b +1 NULL +3 4 +1 0 +3 0 +DROP TABLE t1; +(SELECT a, sum(a) AS f FROM v1 group by a ORDER BY b + 1) +UNION +(SELECT 2, 2); +ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +DROP VIEW v1; +(SELECT a, sum(a) AS f FROM v1 group by a ORDER BY b + 1) +UNION +(SELECT 2, 2); +ERROR 42S02: Table 'test.v1' doesn't exist ++# + # Bug#27197235 USER VARIABLE + UINON + DECIMAL COLUMN RETURNS + # WRONG VALUES + # + SET NAMES utf8; + SET @advertAcctId = 1000003; + select @advertAcctId as a from dual union all select 1.0 from dual; + a + 1000003.0 + 1.0 + SET NAMES latin1; + SET @advertAcctId = 1000003; + select @advertAcctId as a from dual union all select 1.0 from dual; + a + 1000003.0 + 1.0 +End of 5.5 tests diff --cc mysql-test/t/union.test index 55d09a7d5ac,d7e362558e3..240115837c7 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@@ -1304,121 -1256,17 +1304,136 @@@ SET @@long_query_time= @old_long_query_ SET @@global.log_output= @old_log_output; SET @@global.slow_query_log= @old_slow_query_log; +--echo # +--echo # lp:1010729: Unexpected syntax error from UNION +--echo # (bug #54382) with single-table join nest +--echo # +CREATE TABLE t1 (a int); +CREATE TABLE t2 (b int); +CREATE TABLE t3 (c int); +SELECT a FROM t1 UNION SELECT b FROM t2 JOIN (t3) ON ( t2.b = t3.c ); + +DROP TABLE t1, t2, t3; + +CREATE TABLE t1 (pk int NOT NULL); +CREATE TABLE t2 (pk int NOT NULL, fk int NOT NULL); +SELECT t1.pk FROM t1 LEFT JOIN (t2) ON (t1.pk = t2.fk) +UNION +SELECT t1.pk FROM t1 LEFT JOIN (t2) ON (t1.pk = t2.fk); + +DROP TABLE t1,t2; + +# +# Bug #18167356: EXPLAIN W/ EXISTS(SELECT* UNION SELECT*) +# WHERE ONE OF SELECT* IS DISTINCT FAILS. +# +create table t1 (a int); +insert t1 values (1),(2),(3),(1); +explain select 1 from dual where exists (select max(a) from t1 group by a union select a+2 from t1); +drop table t1; + +--echo # +--echo # MDEV-6868:MariaDB server crash ( select with union and order by +--echo # with subquery ) +--echo # + +CREATE TABLE t1 ( id INTEGER, sample_name1 VARCHAR(100), sample_name2 VARCHAR(100), PRIMARY KEY(id) ); + +INSERT INTO t1 ( id, sample_name1, sample_name2 ) VALUES ( 1, 'aaaa', 'bbbb' ), ( 2, 'cccc', 'dddd' ); + +( + SELECT sample_name1 AS testname FROM t1 +) +UNION +( + SELECT sample_name2 AS testname FROM t1 C ORDER BY (SELECT T.sample_name1 FROM t1 T WHERE T.id = C.id) +) +; + +drop table t1; + + +--echo # +--echo # MDEV-10172: UNION query returns incorrect rows outside +--echo # conditional evaluation +--echo # + +create table t1 (d datetime not null primary key); +insert into t1(d) values ('2016-06-01'),('2016-06-02'),('2016-06-03'),('2016-06-04'); +select * from +( + select * from t1 where d between '2016-06-02' and '2016-06-05' + union + (select * from t1 where d < '2016-06-05' order by d desc limit 1) +) onlyJun2toJun4 +order by d; +drop table t1; + +--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 # +--echo # MDEV-14715 Assertion `!table || (!table->read_set || +--echo # bitmap_is_set(table->read_set, field_index))' +--echo # failed in Field_num::val_decimal +--echo # + +CREATE TABLE t1 (a INT, b INT) ENGINE=MyISAM; +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES (1, NULL),(3, 4); + +--error ER_INVALID_GROUP_FUNC_USE +(SELECT a, sum(a) AS f FROM v1 group by a ORDER BY b + sum(a)) +UNION +(SELECT 2, 2); + +(SELECT a, sum(a) AS f FROM v1 group by a ORDER BY b + 1) +UNION +(SELECT 2, 2); + +SELECT a, b FROM t1 +UNION +(SELECT a, VAR_POP(a) AS f FROM v1 GROUP BY a ORDER BY b/a ); + +DROP TABLE t1; + +--error ER_VIEW_INVALID +(SELECT a, sum(a) AS f FROM v1 group by a ORDER BY b + 1) +UNION +(SELECT 2, 2); + +DROP VIEW v1; + +--error ER_NO_SUCH_TABLE +(SELECT a, sum(a) AS f FROM v1 group by a ORDER BY b + 1) +UNION +(SELECT 2, 2); + + --echo # + --echo # Bug#27197235 USER VARIABLE + UINON + DECIMAL COLUMN RETURNS + --echo # WRONG VALUES + --echo # + + let $old_charset= `SELECT @@character_set_client`; + + SET NAMES utf8; + SET @advertAcctId = 1000003; + select @advertAcctId as a from dual union all select 1.0 from dual; + + eval SET NAMES $old_charset; + SET @advertAcctId = 1000003; + select @advertAcctId as a from dual union all select 1.0 from dual; ++ +--echo End of 5.5 tests diff --cc sql-common/client.c index ec992f80e8d,7938403db59..952b6a199ee --- a/sql-common/client.c +++ b/sql-common/client.c @@@ -2602,6 -2679,6 +2603,9 @@@ static int send_client_reply_packet(MCP enum enum_ssl_init_error ssl_init_error; const char *cert_error; unsigned long ssl_error; ++#ifdef EMBEDDED_LIBRARY ++ DBUG_ASSERT(0); // embedded should not do SSL connect ++#endif /* Send mysql->client_flag, max_packet_size - unencrypted otherwise diff --cc sql/item.cc index 135255ee21e,07d64881eeb..33c35f8c3e0 --- a/sql/item.cc +++ b/sql/item.cc @@@ -1,6 -1,5 +1,6 @@@ /* - Copyright (c) 2000, 2016, Oracle and/or its affiliates. - Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. ++ Copyright (c) 2000, 2018, Oracle and/or its affiliates. + Copyright (c) 2010, 2018, MariaDB Corporation 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 @@@ -9648,13 -8264,9 +9648,14 @@@ bool Item_type_holder::join_types(THD * item_decimals= 0; decimals= max(decimals, item_decimals); } + + if (fld_type == FIELD_TYPE_GEOMETRY) + geometry_type= + Field_geom::geometry_type_merge(geometry_type, item->get_geometry_type()); + if (Field::result_merge_type(fld_type) == DECIMAL_RESULT) { + collation.set_numeric(); decimals= min(max(decimals, item->decimals), DECIMAL_MAX_SCALE); int item_int_part= item->decimal_int_part(); int item_prec = max(prev_decimal_int_part, item_int_part) + decimals; diff --cc sql/sql_acl.cc index 14f34db6ccc,64888f7308a..24740a0695a --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@@ -1,5 -1,4 +1,5 @@@ - /* Copyright (c) 2000, 2016, Oracle and/or its affiliates. -/* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. ++/* Copyright (c) 2000, 2018, Oracle and/or its affiliates. + Copyright (c) 2009, 2018, MariaDB 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 diff --cc storage/myisam/ha_myisam.cc index 4305fab1778,6eed1be1ba9..a9e70a7b536 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@@ -1,6 -1,5 +1,6 @@@ /* - Copyright (c) 2000, 2012, Oracle and/or its affiliates. - Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. ++ Copyright (c) 2000, 2018, Oracle and/or its affiliates. + Copyright (c) 2009, 2017, MariaDB Corporation. 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 diff --cc storage/myisam/mi_check.c index 23e54966e2d,7134cfc265a..8c2411b693f --- a/storage/myisam/mi_check.c +++ b/storage/myisam/mi_check.c @@@ -1,4 -1,5 +1,4 @@@ - /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. -/* - Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. ++/* Copyright (c) 2000, 2018, Oracle and/or its affiliates. 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 diff --cc storage/myisam/mi_locking.c index 17fb92702ff,dcfeaca5b8c..f34c43cae78 --- a/storage/myisam/mi_locking.c +++ b/storage/myisam/mi_locking.c @@@ -1,5 -1,4 +1,5 @@@ - /* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. + /* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2009, 2018, MariaDB Corporation 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