Skip to content

Commit 270eeeb

Browse files
committed
Merge 10.5 into 10.6
2 parents b0c285b + 9c35f9c commit 270eeeb

26 files changed

+601
-154
lines changed

include/m_string.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -249,14 +249,15 @@ static inline void lex_string_set3(LEX_CSTRING *lex_str, const char *c_str,
249249
*/
250250
static inline int safe_strcpy(char *dst, size_t dst_size, const char *src)
251251
{
252-
memset(dst, '\0', dst_size);
253-
strncpy(dst, src, dst_size - 1);
254-
/*
255-
If the first condition is true, we are guaranteed to have src length
256-
>= (dst_size - 1), hence safe to access src[dst_size - 1].
257-
*/
258-
if (dst[dst_size - 2] != '\0' && src[dst_size - 1] != '\0')
259-
return 1; /* Truncation of src. */
252+
DBUG_ASSERT(dst_size > 0);
253+
/* Note, strncpy will zerofill end of dst if src shorter than dst_size */
254+
strncpy(dst, src, dst_size);
255+
if (dst[dst_size-1])
256+
{
257+
/* Ensure string is zero terminated */
258+
dst[dst_size-1]= 0;
259+
return 1;
260+
}
260261
return 0;
261262
}
262263

include/myisammrg.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ typedef struct st_myrg_info
7171
ulong cache_size;
7272
uint merge_insert_method;
7373
uint tables,options,reclength,keys;
74+
uint key_parts;
7475
my_bool cache_in_use;
7576
/* If MERGE children attached to parent. See top comment in ha_myisammrg.cc */
7677
my_bool children_attached;

mysql-test/lib/My/File/Path.pm

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use strict;
3434

3535
use Exporter;
3636
use base "Exporter";
37-
our @EXPORT= qw /rmtree mkpath copytree/;
37+
our @EXPORT= qw /rmtree mkpath copytree make_readonly/;
3838

3939
use File::Find;
4040
use File::Copy;
@@ -184,6 +184,10 @@ sub copytree {
184184
# Only copy plain files
185185
next unless -f "$from_dir/$_";
186186
copy("$from_dir/$_", "$to_dir/$_");
187+
if (!$use_umask)
188+
{
189+
chmod(0666, "$to_dir/$_");
190+
}
187191
}
188192
closedir(DIR);
189193

@@ -193,4 +197,29 @@ sub copytree {
193197
}
194198
}
195199

200+
201+
sub make_readonly {
202+
my ($dir) = @_;
203+
204+
die "Usage: make_readonly(<dir>])"
205+
unless @_ == 1;
206+
207+
opendir(DIR, "$dir")
208+
or croak("Can't find $dir$!");
209+
for(readdir(DIR)) {
210+
211+
next if "$_" eq "." or "$_" eq "..";
212+
213+
if ( -d "$dir/$_" )
214+
{
215+
make_readonly("$dir/$_");
216+
next;
217+
}
218+
219+
# Only copy plain files
220+
next unless -f "$dir/$_";
221+
chmod 0444, "$dir/$_";
222+
}
223+
closedir(DIR);
224+
}
196225
1;

mysql-test/lib/My/SafeProcess/Base.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ our @EXPORT= qw(create_process);
4040
# Retry a couple of times if fork returns EAGAIN
4141
#
4242
sub _safe_fork {
43-
my $retries= 5;
43+
my $retries= 100;
4444
my $pid;
4545

4646
FORK:

mysql-test/main/distinct.result

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,3 +1157,28 @@ explain select * from t1 limit 0 offset 10;
11571157
id select_type table type possible_keys key key_len ref rows Extra
11581158
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Zero limit
11591159
drop table t1, t2;
1160+
#
1161+
# MDEV-28285 Unexpected result when combining DISTINCT, subselect
1162+
# and LIMIT
1163+
#
1164+
create table t1 (a int primary key);
1165+
create table t2 (a int primary key, b int not null);
1166+
insert into t1 select seq from seq_1_to_10;
1167+
insert into t2 select seq,seq from seq_1_to_10;
1168+
select distinct a from t1 where t1.a=1 and t1.a in (select a from t2 where t2.b in (1,2));
1169+
a
1170+
1
1171+
explain select distinct a from t1 where t1.a=1 and t1.a in (select a+0 from t2 where t2.b in (1,2)) limit 10,10;
1172+
id select_type table type possible_keys key key_len ref rows Extra
1173+
1 PRIMARY t1 const PRIMARY PRIMARY 4 const 1 Using index; Using temporary
1174+
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 func 1
1175+
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 10 Using where
1176+
select distinct a from t1 where t1.a=1 and t1.a in (select a+0 from t2 where t2.b in (1,2)) limit 10,10;
1177+
a
1178+
select distinct a from t1 where t1.a=1 and t1.a in (select a+0 from t2 where t2.b in (1,2)) limit 0,1;
1179+
a
1180+
1
1181+
drop table t1,t2;
1182+
#
1183+
# end of 10.5 tests
1184+
#

mysql-test/main/distinct.test

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -892,3 +892,24 @@ explain select * from t1 limit 0;
892892
explain select * from t1 limit 0 offset 10;
893893

894894
drop table t1, t2;
895+
896+
--echo #
897+
--echo # MDEV-28285 Unexpected result when combining DISTINCT, subselect
898+
--echo # and LIMIT
899+
--echo #
900+
901+
create table t1 (a int primary key);
902+
create table t2 (a int primary key, b int not null);
903+
904+
insert into t1 select seq from seq_1_to_10;
905+
insert into t2 select seq,seq from seq_1_to_10;
906+
907+
select distinct a from t1 where t1.a=1 and t1.a in (select a from t2 where t2.b in (1,2));
908+
explain select distinct a from t1 where t1.a=1 and t1.a in (select a+0 from t2 where t2.b in (1,2)) limit 10,10;
909+
select distinct a from t1 where t1.a=1 and t1.a in (select a+0 from t2 where t2.b in (1,2)) limit 10,10;
910+
select distinct a from t1 where t1.a=1 and t1.a in (select a+0 from t2 where t2.b in (1,2)) limit 0,1;
911+
drop table t1,t2;
912+
913+
--echo #
914+
--echo # end of 10.5 tests
915+
--echo #

mysql-test/main/group_min_max.result

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4095,6 +4095,116 @@ MIN(pk) a
40954095
5 10
40964096
DROP TABLE t1;
40974097
#
4098+
# MDEV-6768 Wrong result with agregate with join with no resultset
4099+
#
4100+
create table t1
4101+
(
4102+
PARENT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
4103+
PARENT_FIELD VARCHAR(10),
4104+
PRIMARY KEY (PARENT_ID)
4105+
) engine=innodb;
4106+
create table t2
4107+
(
4108+
CHILD_ID INT NOT NULL AUTO_INCREMENT,
4109+
PARENT_ID INT NOT NULL,
4110+
CHILD_FIELD varchar(10),
4111+
PRIMARY KEY (CHILD_ID)
4112+
)engine=innodb;
4113+
INSERT INTO t1 (PARENT_FIELD)
4114+
SELECT 'AAAA';
4115+
INSERT INTO t2 (PARENT_ID, CHILD_FIELD)
4116+
SELECT 1, 'BBBB';
4117+
explain select
4118+
t1.PARENT_ID,
4119+
min(CHILD_FIELD)
4120+
from t1 straight_join t2
4121+
where t1.PARENT_ID = 1
4122+
and t1.PARENT_ID = t2.PARENT_ID
4123+
and t2.CHILD_FIELD = "ZZZZ";
4124+
id select_type table type possible_keys key key_len ref rows Extra
4125+
1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 Using index
4126+
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where
4127+
select
4128+
t1.PARENT_ID,
4129+
min(CHILD_FIELD)
4130+
from t1 straight_join t2
4131+
where t1.PARENT_ID = 1
4132+
and t1.PARENT_ID = t2.PARENT_ID
4133+
and t2.CHILD_FIELD = "ZZZZ";
4134+
PARENT_ID min(CHILD_FIELD)
4135+
NULL NULL
4136+
select
4137+
1,
4138+
min(CHILD_FIELD)
4139+
from t1 straight_join t2
4140+
where t1.PARENT_ID = 1
4141+
and t1.PARENT_ID = t2.PARENT_ID
4142+
and t2.CHILD_FIELD = "ZZZZ";
4143+
1 min(CHILD_FIELD)
4144+
1 NULL
4145+
select
4146+
IFNULL(t1.PARENT_ID,1),
4147+
min(CHILD_FIELD)
4148+
from t1 straight_join t2
4149+
where t1.PARENT_ID = 1
4150+
and t1.PARENT_ID = t2.PARENT_ID
4151+
and t2.CHILD_FIELD = "ZZZZ";
4152+
IFNULL(t1.PARENT_ID,1) min(CHILD_FIELD)
4153+
1 NULL
4154+
# Check that things works with MyISAM (which has different explain)
4155+
alter table t1 engine=myisam;
4156+
alter table t2 engine=myisam;
4157+
explain select
4158+
t1.PARENT_ID,
4159+
min(CHILD_FIELD)
4160+
from t1 straight_join t2
4161+
where t1.PARENT_ID = 1
4162+
and t1.PARENT_ID = t2.PARENT_ID
4163+
and t2.CHILD_FIELD = "ZZZZ";
4164+
id select_type table type possible_keys key key_len ref rows Extra
4165+
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
4166+
select
4167+
t1.PARENT_ID,
4168+
min(CHILD_FIELD)
4169+
from t1 straight_join t2
4170+
where t1.PARENT_ID = 1
4171+
and t1.PARENT_ID = t2.PARENT_ID
4172+
and t2.CHILD_FIELD = "ZZZZ";
4173+
PARENT_ID min(CHILD_FIELD)
4174+
NULL NULL
4175+
drop table t1,t2;
4176+
# Check that things works if sub queries are re-executed
4177+
create table t1 (a int primary key, b int);
4178+
create table t2 (a int primary key, b int);
4179+
create table t3 (a int primary key, b int);
4180+
insert into t1 values (1,1),(2,2),(3,3);
4181+
insert into t2 values (1,1),(2,2),(3,3);
4182+
insert into t3 values (1,1),(3,3);
4183+
explain
4184+
select *,
4185+
(select
4186+
CONCAT('t2:', IFNULL(t2.a, 't2a-null'), ';',
4187+
'min_t3_b:', IFNULL(min(t3.b), 't3b-null'))
4188+
from t2,t3
4189+
where t2.a=1 and t1.b = t3.a) as s1
4190+
from t1;
4191+
id select_type table type possible_keys key key_len ref rows Extra
4192+
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
4193+
2 DEPENDENT SUBQUERY t2 const PRIMARY PRIMARY 4 const 1 Using index
4194+
2 DEPENDENT SUBQUERY t3 eq_ref PRIMARY PRIMARY 4 test.t1.b 1
4195+
select *,
4196+
(select
4197+
CONCAT('t2:', IFNULL(t2.a, 't2a-null'), ';',
4198+
'min_t3_b:', IFNULL(min(t3.b), 't3b-null'))
4199+
from t2,t3
4200+
where t2.a=1 and t1.b = t3.a) as s1
4201+
from t1;
4202+
a b s1
4203+
1 1 t2:1;min_t3_b:1
4204+
2 2 t2:t2a-null;min_t3_b:t3b-null
4205+
3 3 t2:1;min_t3_b:3
4206+
drop table t1,t2,t3;
4207+
#
40984208
# End of 10.5 tests
40994209
#
41004210
#

mysql-test/main/group_min_max.test

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,6 +1749,116 @@ SELECT MIN(pk), a FROM t1 WHERE pk <> 1 GROUP BY a;
17491749

17501750
DROP TABLE t1;
17511751

1752+
--echo #
1753+
--echo # MDEV-6768 Wrong result with agregate with join with no resultset
1754+
--echo #
1755+
1756+
create table t1
1757+
(
1758+
PARENT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
1759+
PARENT_FIELD VARCHAR(10),
1760+
PRIMARY KEY (PARENT_ID)
1761+
) engine=innodb;
1762+
1763+
create table t2
1764+
(
1765+
CHILD_ID INT NOT NULL AUTO_INCREMENT,
1766+
PARENT_ID INT NOT NULL,
1767+
CHILD_FIELD varchar(10),
1768+
PRIMARY KEY (CHILD_ID)
1769+
)engine=innodb;
1770+
1771+
INSERT INTO t1 (PARENT_FIELD)
1772+
SELECT 'AAAA';
1773+
1774+
INSERT INTO t2 (PARENT_ID, CHILD_FIELD)
1775+
SELECT 1, 'BBBB';
1776+
1777+
explain select
1778+
t1.PARENT_ID,
1779+
min(CHILD_FIELD)
1780+
from t1 straight_join t2
1781+
where t1.PARENT_ID = 1
1782+
and t1.PARENT_ID = t2.PARENT_ID
1783+
and t2.CHILD_FIELD = "ZZZZ";
1784+
1785+
select
1786+
t1.PARENT_ID,
1787+
min(CHILD_FIELD)
1788+
from t1 straight_join t2
1789+
where t1.PARENT_ID = 1
1790+
and t1.PARENT_ID = t2.PARENT_ID
1791+
and t2.CHILD_FIELD = "ZZZZ";
1792+
1793+
select
1794+
1,
1795+
min(CHILD_FIELD)
1796+
from t1 straight_join t2
1797+
where t1.PARENT_ID = 1
1798+
and t1.PARENT_ID = t2.PARENT_ID
1799+
and t2.CHILD_FIELD = "ZZZZ";
1800+
1801+
select
1802+
IFNULL(t1.PARENT_ID,1),
1803+
min(CHILD_FIELD)
1804+
from t1 straight_join t2
1805+
where t1.PARENT_ID = 1
1806+
and t1.PARENT_ID = t2.PARENT_ID
1807+
and t2.CHILD_FIELD = "ZZZZ";
1808+
1809+
1810+
--echo # Check that things works with MyISAM (which has different explain)
1811+
1812+
alter table t1 engine=myisam;
1813+
alter table t2 engine=myisam;
1814+
1815+
explain select
1816+
t1.PARENT_ID,
1817+
min(CHILD_FIELD)
1818+
from t1 straight_join t2
1819+
where t1.PARENT_ID = 1
1820+
and t1.PARENT_ID = t2.PARENT_ID
1821+
and t2.CHILD_FIELD = "ZZZZ";
1822+
1823+
select
1824+
t1.PARENT_ID,
1825+
min(CHILD_FIELD)
1826+
from t1 straight_join t2
1827+
where t1.PARENT_ID = 1
1828+
and t1.PARENT_ID = t2.PARENT_ID
1829+
and t2.CHILD_FIELD = "ZZZZ";
1830+
1831+
drop table t1,t2;
1832+
1833+
--echo # Check that things works if sub queries are re-executed
1834+
1835+
create table t1 (a int primary key, b int);
1836+
create table t2 (a int primary key, b int);
1837+
create table t3 (a int primary key, b int);
1838+
1839+
insert into t1 values (1,1),(2,2),(3,3);
1840+
insert into t2 values (1,1),(2,2),(3,3);
1841+
insert into t3 values (1,1),(3,3);
1842+
1843+
explain
1844+
select *,
1845+
(select
1846+
CONCAT('t2:', IFNULL(t2.a, 't2a-null'), ';',
1847+
'min_t3_b:', IFNULL(min(t3.b), 't3b-null'))
1848+
from t2,t3
1849+
where t2.a=1 and t1.b = t3.a) as s1
1850+
from t1;
1851+
1852+
select *,
1853+
(select
1854+
CONCAT('t2:', IFNULL(t2.a, 't2a-null'), ';',
1855+
'min_t3_b:', IFNULL(min(t3.b), 't3b-null'))
1856+
from t2,t3
1857+
where t2.a=1 and t1.b = t3.a) as s1
1858+
from t1;
1859+
1860+
drop table t1,t2,t3;
1861+
17521862
--echo #
17531863
--echo # End of 10.5 tests
17541864
--echo #

mysql-test/main/merge.result

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3919,3 +3919,15 @@ ERROR HY000: Unable to open underlying table which is differently defined or of
39193919
DROP TRIGGER trg1;
39203920
DROP TABLE t1;
39213921
DROP TABLE m1;
3922+
#
3923+
# MDEV-31083 ASAN use-after-poison in myrg_attach_children
3924+
#
3925+
CREATE TABLE t1 (f TEXT, FULLTEXT (f)) ENGINE=MyISAM;
3926+
INSERT INTO t1 VALUES ('foo'),('bar');
3927+
CREATE TABLE mrg (f TEXT) ENGINE=MERGE, UNION(t1);
3928+
SELECT * FROM mrg;
3929+
f
3930+
foo
3931+
bar
3932+
DROP TABLE mrg, t1;
3933+
End of 10.5 tests

0 commit comments

Comments
 (0)