Skip to content

Commit 3b6dadb

Browse files
committed
Merge 10.1 into 10.2
2 parents 0460d42 + 7f67ef1 commit 3b6dadb

19 files changed

+412
-410
lines changed

mysql-test/r/mysqld--help,win.rdiff

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -101,18 +101,7 @@
101101
sort-buffer-size 2097152
102102
sql-mode STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
103103
stack-trace TRUE
104-
@@ -1516,14 +1532,16 @@
105-
sync-relay-log 10000
106-
sync-relay-log-info 10000
107-
sysdate-is-now FALSE
108-
-table-cache 421
109-
+table-cache 2000
110-
table-definition-cache 400
111-
-table-open-cache 421
112-
-table-open-cache-instances 1
113-
+table-open-cache 2000
114-
+table-open-cache-instances 8
115-
tc-heuristic-recover OFF
104+
@@ -1516,6 +1532,8 @@
116105
thread-cache-size 151
117106
thread-pool-idle-timeout 60
118107
thread-pool-max-threads 65536

mysql-test/r/mysqld--help.result

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,7 +1343,6 @@ max-binlog-cache-size 18446744073709547520
13431343
max-binlog-size 1073741824
13441344
max-binlog-stmt-cache-size 18446744073709547520
13451345
max-connect-errors 100
1346-
max-connections 151
13471346
max-delayed-threads 20
13481347
max-digest-length 1024
13491348
max-error-count 64
@@ -1516,10 +1515,7 @@ sync-master-info 10000
15161515
sync-relay-log 10000
15171516
sync-relay-log-info 10000
15181517
sysdate-is-now FALSE
1519-
table-cache 421
15201518
table-definition-cache 400
1521-
table-open-cache 421
1522-
table-open-cache-instances 1
15231519
tc-heuristic-recover OFF
15241520
thread-cache-size 151
15251521
thread-pool-idle-timeout 60

mysql-test/r/subselect4.result

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2609,6 +2609,47 @@ Central America and the Caribbean 442 66422
26092609
SET @@optimizer_switch= @save_optimizer_switch;
26102610
DROP TABLE t1;
26112611
#
2612+
# MDEV-9513: Assertion `join->group_list || !join->is_in_subquery()' failed in create_sort_index
2613+
#
2614+
CREATE TABLE t1 (a INT);
2615+
INSERT INTO t1 VALUES (1),(2);
2616+
CREATE TABLE t2 (a INT);
2617+
INSERT INTO t2 VALUES (2),(3);
2618+
EXPLAIN
2619+
SELECT t1.a FROM t1 WHERE t1.a IN ( SELECT A.a FROM t1 A UNION SELECT B.a FROM t2 B ORDER BY 1);
2620+
id select_type table type possible_keys key key_len ref rows Extra
2621+
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
2622+
2 DEPENDENT SUBQUERY A ALL NULL NULL NULL NULL 2 Using where
2623+
3 DEPENDENT UNION B ALL NULL NULL NULL NULL 2 Using where
2624+
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
2625+
SELECT t1.a FROM t1 WHERE t1.a IN ( SELECT A.a FROM t1 A UNION SELECT B.a FROM t2 B ORDER BY 1);
2626+
a
2627+
1
2628+
2
2629+
EXPLAIN
2630+
SELECT t1.a FROM t1 WHERE EXISTS (SELECT A.a FROM t1 A UNION SELECT B.a FROM t2 B ORDER BY 1);
2631+
id select_type table type possible_keys key key_len ref rows Extra
2632+
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
2633+
2 SUBQUERY A ALL NULL NULL NULL NULL 2
2634+
3 UNION B ALL NULL NULL NULL NULL 2
2635+
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
2636+
SELECT t1.a FROM t1 WHERE EXISTS (SELECT A.a FROM t1 A UNION SELECT B.a FROM t2 B ORDER BY 1);
2637+
a
2638+
1
2639+
2
2640+
EXPLAIN
2641+
SELECT t1.a FROM t1 WHERE t1.a IN ( SELECT A.a FROM t1 A UNION ALL SELECT B.a FROM t2 B ORDER BY 1);
2642+
id select_type table type possible_keys key key_len ref rows Extra
2643+
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
2644+
2 DEPENDENT SUBQUERY A ALL NULL NULL NULL NULL 2 Using where
2645+
3 DEPENDENT UNION B ALL NULL NULL NULL NULL 2 Using where
2646+
SELECT t1.a FROM t1 WHERE t1.a IN ( SELECT A.a FROM t1 A UNION ALL SELECT B.a FROM t2 B ORDER BY 1);
2647+
a
2648+
1
2649+
2
2650+
DROP TABLE t1,t2;
2651+
# end of 10.1 tests
2652+
#
26122653
# MDEV-22852: SIGSEGV in sortlength (optimized builds)
26132654
#
26142655
SET @save_optimizer_switch=@@optimizer_switch;

mysql-test/r/type_newdecimal.result

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2340,6 +2340,53 @@ t1 CREATE TABLE `t1` (
23402340
) ENGINE=MyISAM DEFAULT CHARSET=latin1
23412341
DROP TABLE t1;
23422342
#
2343+
# MDEV-23105 Cast number string with many leading zeros to decimal gives unexpected result
2344+
#
2345+
SELECT CAST(0000000000000000000000000000000000000000000000000000000000000000000000000000000020.01 AS DECIMAL(15,2)) as val;
2346+
val
2347+
20.01
2348+
SET sql_mode='';
2349+
CREATE TABLE t1 (a TEXT);
2350+
INSERT INTO t1 VALUES (CONCAT(REPEAT('0',100),1));
2351+
INSERT INTO t1 VALUES (CONCAT(REPEAT('0',100),1,'.0'));
2352+
INSERT INTO t1 VALUES (CONCAT(REPEAT('0',100),1,'.9'));
2353+
INSERT INTO t1 VALUES (CONCAT(REPEAT('0',100),1,'.99'));
2354+
INSERT INTO t1 VALUES (CONCAT(REPEAT('0',100),1,'.994'));
2355+
INSERT INTO t1 VALUES (CONCAT(REPEAT('0',100),1,'.995'));
2356+
INSERT INTO t1 VALUES (CONCAT(REPEAT('0',100),1,'.999'));
2357+
CREATE TABLE t2 (a TEXT, d DECIMAL(15,2));
2358+
INSERT IGNORE INTO t2 (a,d) SELECT a, a FROM t1;
2359+
Warnings:
2360+
Note 1265 Data truncated for column 'd' at row 5
2361+
Note 1265 Data truncated for column 'd' at row 6
2362+
Note 1265 Data truncated for column 'd' at row 7
2363+
INSERT IGNORE INTO t2 (a,d) SELECT CONCAT('-',a), CONCAT('-',a) FROM t1;
2364+
Warnings:
2365+
Note 1265 Data truncated for column 'd' at row 5
2366+
Note 1265 Data truncated for column 'd' at row 6
2367+
Note 1265 Data truncated for column 'd' at row 7
2368+
SELECT d, a FROM t2 ORDER BY d,a;
2369+
d a
2370+
-2.00 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001.995
2371+
-2.00 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001.999
2372+
-1.99 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001.99
2373+
-1.99 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001.994
2374+
-1.90 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001.9
2375+
-1.00 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
2376+
-1.00 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001.0
2377+
1.00 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
2378+
1.00 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001.0
2379+
1.90 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001.9
2380+
1.99 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001.99
2381+
1.99 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001.994
2382+
2.00 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001.995
2383+
2.00 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001.999
2384+
DROP TABLE t1, t2;
2385+
SET sql_mode=DEFAULT;
2386+
#
2387+
# End of 10.1 tests
2388+
#
2389+
#
23432390
# Bug#18408499 UNSIGNED BIGINT HIGH VALUES
23442391
# WRONG NUMERICAL COMPARISON RESULTS
23452392
#

mysql-test/t/mysqld--help.test

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ perl;
2323
log-slow-queries pid-file slow-query-log-file log-basename
2424
datadir slave-load-tmpdir tmpdir socket thread-pool-size
2525
large-files-support lower-case-file-system system-time-zone
26-
collation-server character-set-server log-tc-size version.*/;
26+
collation-server character-set-server log-tc-size table-cache
27+
table-open-cache table-open-cache-instances max-connections
28+
version.*/;
2729

2830
# Plugins which may or may not be there:
2931
@plugins=qw/innodb archive blackhole federated partition

mysql-test/t/subselect4.test

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2143,6 +2143,31 @@ SET @@optimizer_switch= @save_optimizer_switch;
21432143

21442144
DROP TABLE t1;
21452145

2146+
--echo #
2147+
--echo # MDEV-9513: Assertion `join->group_list || !join->is_in_subquery()' failed in create_sort_index
2148+
--echo #
2149+
2150+
CREATE TABLE t1 (a INT);
2151+
INSERT INTO t1 VALUES (1),(2);
2152+
2153+
CREATE TABLE t2 (a INT);
2154+
INSERT INTO t2 VALUES (2),(3);
2155+
EXPLAIN
2156+
SELECT t1.a FROM t1 WHERE t1.a IN ( SELECT A.a FROM t1 A UNION SELECT B.a FROM t2 B ORDER BY 1);
2157+
SELECT t1.a FROM t1 WHERE t1.a IN ( SELECT A.a FROM t1 A UNION SELECT B.a FROM t2 B ORDER BY 1);
2158+
2159+
EXPLAIN
2160+
SELECT t1.a FROM t1 WHERE EXISTS (SELECT A.a FROM t1 A UNION SELECT B.a FROM t2 B ORDER BY 1);
2161+
SELECT t1.a FROM t1 WHERE EXISTS (SELECT A.a FROM t1 A UNION SELECT B.a FROM t2 B ORDER BY 1);
2162+
2163+
EXPLAIN
2164+
SELECT t1.a FROM t1 WHERE t1.a IN ( SELECT A.a FROM t1 A UNION ALL SELECT B.a FROM t2 B ORDER BY 1);
2165+
SELECT t1.a FROM t1 WHERE t1.a IN ( SELECT A.a FROM t1 A UNION ALL SELECT B.a FROM t2 B ORDER BY 1);
2166+
2167+
DROP TABLE t1,t2;
2168+
2169+
--echo # end of 10.1 tests
2170+
21462171
--echo #
21472172
--echo # MDEV-22852: SIGSEGV in sortlength (optimized builds)
21482173
--echo #

mysql-test/t/type_newdecimal.test

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1824,6 +1824,32 @@ CREATE TABLE t1 (a DECIMAL(2,1) DEFAULT 0.10001e0);
18241824
SHOW CREATE TABLE t1;
18251825
DROP TABLE t1;
18261826

1827+
--echo #
1828+
--echo # MDEV-23105 Cast number string with many leading zeros to decimal gives unexpected result
1829+
--echo #
1830+
1831+
SELECT CAST(0000000000000000000000000000000000000000000000000000000000000000000000000000000020.01 AS DECIMAL(15,2)) as val;
1832+
1833+
SET sql_mode='';
1834+
CREATE TABLE t1 (a TEXT);
1835+
INSERT INTO t1 VALUES (CONCAT(REPEAT('0',100),1));
1836+
INSERT INTO t1 VALUES (CONCAT(REPEAT('0',100),1,'.0'));
1837+
INSERT INTO t1 VALUES (CONCAT(REPEAT('0',100),1,'.9'));
1838+
INSERT INTO t1 VALUES (CONCAT(REPEAT('0',100),1,'.99'));
1839+
INSERT INTO t1 VALUES (CONCAT(REPEAT('0',100),1,'.994'));
1840+
INSERT INTO t1 VALUES (CONCAT(REPEAT('0',100),1,'.995'));
1841+
INSERT INTO t1 VALUES (CONCAT(REPEAT('0',100),1,'.999'));
1842+
CREATE TABLE t2 (a TEXT, d DECIMAL(15,2));
1843+
INSERT IGNORE INTO t2 (a,d) SELECT a, a FROM t1;
1844+
INSERT IGNORE INTO t2 (a,d) SELECT CONCAT('-',a), CONCAT('-',a) FROM t1;
1845+
SELECT d, a FROM t2 ORDER BY d,a;
1846+
DROP TABLE t1, t2;
1847+
SET sql_mode=DEFAULT;
1848+
1849+
--echo #
1850+
--echo # End of 10.1 tests
1851+
--echo #
1852+
18271853
--echo #
18281854
--echo # Bug#18408499 UNSIGNED BIGINT HIGH VALUES
18291855
--echo # WRONG NUMERICAL COMPARISON RESULTS

sql/item_subselect.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ class Item_subselect :public Item_result_field,
145145
Item_subselect(THD *thd);
146146

147147
virtual subs_type substype() { return UNKNOWN_SUBS; }
148+
bool is_exists_predicate()
149+
{
150+
return substype() == Item_subselect::EXISTS_SUBS;
151+
}
148152
bool is_in_predicate()
149153
{
150154
return (substype() == Item_subselect::IN_SUBS ||

sql/sql_union.cc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,25 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
514514
found_rows_for_union= first_sl->options & OPTION_FOUND_ROWS;
515515
is_union_select= is_union() || fake_select_lex;
516516

517+
/*
518+
If we are reading UNION output and the UNION is in the
519+
IN/ANY/ALL/EXISTS subquery, then ORDER BY is redundant and hence should
520+
be removed.
521+
Example:
522+
select ... col IN (select col2 FROM t1 union select col3 from t2 ORDER BY 1)
523+
524+
(as for ORDER BY ... LIMIT, it currently not supported inside
525+
IN/ALL/ANY subqueries)
526+
(For non-UNION this removal of ORDER BY clause is done in
527+
check_and_do_in_subquery_rewrites())
528+
*/
529+
if (is_union() && item &&
530+
(item->is_in_predicate() || item->is_exists_predicate()))
531+
{
532+
global_parameters()->order_list.first= NULL;
533+
global_parameters()->order_list.elements= 0;
534+
}
535+
517536
/* Global option */
518537

519538
if (is_union_select || is_recursive)

sql/table.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,9 +1281,16 @@ struct TABLE
12811281
/* number of select if it is derived table */
12821282
uint derived_select_number;
12831283
/*
1284-
0 or JOIN_TYPE_{LEFT|RIGHT}. Currently this is only compared to 0.
1285-
If maybe_null !=0, this table is inner w.r.t. some outer join operation,
1286-
and null_row may be true.
1284+
Possible values:
1285+
- 0 by default
1286+
- JOIN_TYPE_{LEFT|RIGHT} if the table is inner w.r.t an outer join
1287+
operation
1288+
- 1 if the SELECT has mixed_implicit_grouping=1. example:
1289+
select max(col1), col2 from t1. In this case, the query produces
1290+
one row with all columns having NULL values.
1291+
1292+
Interpetation: If maybe_null!=0, all fields of the table are considered
1293+
NULLable (and have NULL values when null_row=true)
12871294
*/
12881295
uint maybe_null;
12891296
int current_lock; /* Type of lock on table */

0 commit comments

Comments
 (0)