Skip to content

Commit 62e137d

Browse files
committed
Merge remote-tracking branch 'origin/10.4' into 10.5
2 parents afdf19c + 06393cd commit 62e137d

35 files changed

+918
-269
lines changed

client/mysqltest.cc

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3815,9 +3815,21 @@ void do_move_file(struct st_command *command)
38153815
sizeof(move_file_args)/sizeof(struct command_arg),
38163816
' ');
38173817

3818-
if (bad_path(ds_to_file.str))
3819-
DBUG_VOID_RETURN;
3818+
size_t from_plen = strlen(ds_from_file.str);
3819+
size_t to_plen = strlen(ds_to_file.str);
3820+
const char *vardir= getenv("MYSQLTEST_VARDIR");
3821+
const char *tmpdir= getenv("MYSQL_TMP_DIR");
38203822

3823+
if (!((is_sub_path(ds_from_file.str, from_plen, vardir) &&
3824+
is_sub_path(ds_to_file.str, to_plen, vardir)) ||
3825+
(is_sub_path(ds_from_file.str, from_plen, tmpdir) &&
3826+
is_sub_path(ds_to_file.str, to_plen, tmpdir)))) {
3827+
report_or_die("Paths '%s' and '%s' are not both under MYSQLTEST_VARDIR '%s'"
3828+
"or both under MYSQL_TMP_DIR '%s'",
3829+
ds_from_file, ds_to_file, vardir, tmpdir);
3830+
DBUG_VOID_RETURN;
3831+
}
3832+
38213833
DBUG_PRINT("info", ("Move %s to %s", ds_from_file.str, ds_to_file.str));
38223834
error= (my_rename(ds_from_file.str, ds_to_file.str,
38233835
MYF(disable_warnings ? 0 : MY_WME)) != 0);

include/m_ctype.h

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,28 @@ typedef enum enum_repertoire_t
267267
#define MY_STRXFRM_REVERSE_LEVEL6 0x00200000 /* if reverse order for level6 */
268268
#define MY_STRXFRM_REVERSE_SHIFT 16
269269

270+
/* Flags to strnncollsp_nchars */
271+
/*
272+
MY_STRNNCOLLSP_NCHARS_EMULATE_TRIMMED_TRAILING_SPACES -
273+
defines if inside strnncollsp_nchars()
274+
short strings should be virtually extended to "nchars"
275+
characters by emulating trimmed trailing spaces.
276+
277+
This flag is needed when comparing packed strings of the CHAR
278+
data type, when trailing spaces are trimmed on storage (like in InnoDB),
279+
however the actual values (after unpacking) will have those trailing
280+
spaces.
281+
282+
If this flag is passed, strnncollsp_nchars() performs both
283+
truncating longer strings and extending shorter strings
284+
to exactly "nchars".
285+
286+
If this flag is not passed, strnncollsp_nchars() only truncates longer
287+
strings to "nchars", but does not extend shorter strings to "nchars".
288+
*/
289+
#define MY_STRNNCOLLSP_NCHARS_EMULATE_TRIMMED_TRAILING_SPACES 1
290+
291+
270292
/*
271293
Collation IDs for MariaDB that should not conflict with MySQL.
272294
We reserve 256..511, because MySQL will most likely use this range
@@ -402,7 +424,8 @@ struct my_collation_handler_st
402424
int (*strnncollsp_nchars)(CHARSET_INFO *,
403425
const uchar *str1, size_t len1,
404426
const uchar *str2, size_t len2,
405-
size_t nchars);
427+
size_t nchars,
428+
uint flags);
406429
size_t (*strnxfrm)(CHARSET_INFO *,
407430
uchar *dst, size_t dstlen, uint nweights,
408431
const uchar *src, size_t srclen, uint flags);
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
--echo #
2+
--echo # MDEV-30034 UNIQUE USING HASH accepts duplicate entries for tricky collations
3+
--echo #
4+
5+
# TEXT
6+
7+
if (`SELECT UPPER(@@storage_engine) != 'MEMORY'`)
8+
{
9+
EXECUTE IMMEDIATE REPLACE(
10+
'CREATE TABLE t1 ( '
11+
' a TEXT COLLATE <COLLATION>,'
12+
'UNIQUE(a(3)))',
13+
'<COLLATION>', @@collation_connection);
14+
SHOW CREATE TABLE t1;
15+
INSERT INTO t1 VALUES ('ss ');
16+
--error ER_DUP_ENTRY
17+
INSERT INTO t1 VALUES (_utf8mb3 0xC39F20)/*SZ+SPACE*/;
18+
DROP TABLE t1;
19+
20+
21+
EXECUTE IMMEDIATE REPLACE(
22+
'CREATE TABLE t1 ( '
23+
' a TEXT COLLATE <COLLATION>,'
24+
'UNIQUE(a(3)) USING HASH)',
25+
'<COLLATION>', @@collation_connection);
26+
SHOW CREATE TABLE t1;
27+
INSERT INTO t1 VALUES ('ss ');
28+
--error ER_DUP_ENTRY
29+
INSERT INTO t1 VALUES (_utf8mb3 0xC39F20)/*SZ+SPACE*/;
30+
DROP TABLE t1;
31+
}
32+
33+
34+
# VARCHAR
35+
36+
EXECUTE IMMEDIATE REPLACE(
37+
'CREATE TABLE t1 ( '
38+
' a VARCHAR(2000) COLLATE <COLLATION>,'
39+
'UNIQUE(a(3)))',
40+
'<COLLATION>', @@collation_connection);
41+
SHOW CREATE TABLE t1;
42+
INSERT INTO t1 VALUES ('ss ');
43+
--error ER_DUP_ENTRY
44+
INSERT INTO t1 VALUES (_utf8mb3 0xC39F20)/*SZ+SPACE*/;
45+
DROP TABLE t1;
46+
47+
48+
EXECUTE IMMEDIATE REPLACE(
49+
'CREATE TABLE t1 ( '
50+
' a VARCHAR(2000) COLLATE <COLLATION>,'
51+
'UNIQUE(a(3)) USING HASH)',
52+
'<COLLATION>', @@collation_connection);
53+
SHOW CREATE TABLE t1;
54+
INSERT INTO t1 VALUES ('ss ');
55+
--error ER_DUP_ENTRY
56+
INSERT INTO t1 VALUES (_utf8mb3 0xC39F20)/*SZ+SPACE*/;
57+
DROP TABLE t1;
58+
59+
# CHAR
60+
61+
# MyISAM is buggy on CHAR+BTREE+UNIQUE+PREFIX (see MDEV-30048), disable for now
62+
# Other engines work fine
63+
64+
if (`SELECT UPPER(@@storage_engine) != 'MYISAM'`)
65+
{
66+
EXECUTE IMMEDIATE REPLACE(
67+
'CREATE TABLE t1 ( '
68+
' a CHAR(20) COLLATE <COLLATION>,'
69+
'UNIQUE(a(3)))',
70+
'<COLLATION>', @@collation_connection);
71+
SHOW CREATE TABLE t1;
72+
INSERT INTO t1 VALUES ('ss ');
73+
INSERT INTO t1 VALUES (_utf8mb3 0xC39F20)/*SZ+SPACE*/;
74+
DROP TABLE t1;
75+
}
76+
77+
EXECUTE IMMEDIATE REPLACE(
78+
'CREATE TABLE t1 ( '
79+
' a CHAR(20) COLLATE <COLLATION>,'
80+
'UNIQUE(a(3)) USING HASH)',
81+
'<COLLATION>', @@collation_connection);
82+
SHOW CREATE TABLE t1;
83+
INSERT INTO t1 VALUES ('ss ');
84+
INSERT INTO t1 VALUES (_utf8mb3 0xC39F20)/*SZ+SPACE*/;
85+
DROP TABLE t1;

mysql-test/main/ctype_utf8_uca.result

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,3 +761,151 @@ DROP TABLE case_folding;
761761
#
762762
# End of 10.3 tests
763763
#
764+
#
765+
# Start of 10.4 tests
766+
#
767+
SET DEFAULT_STORAGE_ENGINE=MyISAM;
768+
SET NAMES utf8mb3 COLLATE utf8mb3_unicode_nopad_ci;
769+
#
770+
# MDEV-30034 UNIQUE USING HASH accepts duplicate entries for tricky collations
771+
#
772+
EXECUTE IMMEDIATE REPLACE(
773+
'CREATE TABLE t1 ( '
774+
' a TEXT COLLATE <COLLATION>,'
775+
'UNIQUE(a(3)))',
776+
'<COLLATION>', @@collation_connection);
777+
SHOW CREATE TABLE t1;
778+
Table Create Table
779+
t1 CREATE TABLE `t1` (
780+
`a` text CHARACTER SET utf8 COLLATE utf8_unicode_nopad_ci DEFAULT NULL,
781+
UNIQUE KEY `a` (`a`(3))
782+
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
783+
INSERT INTO t1 VALUES ('ss ');
784+
INSERT INTO t1 VALUES (_utf8mb3 0xC39F20)/*SZ+SPACE*/;
785+
ERROR 23000: Duplicate entry 'ß ' for key 'a'
786+
DROP TABLE t1;
787+
EXECUTE IMMEDIATE REPLACE(
788+
'CREATE TABLE t1 ( '
789+
' a TEXT COLLATE <COLLATION>,'
790+
'UNIQUE(a(3)) USING HASH)',
791+
'<COLLATION>', @@collation_connection);
792+
SHOW CREATE TABLE t1;
793+
Table Create Table
794+
t1 CREATE TABLE `t1` (
795+
`a` text CHARACTER SET utf8 COLLATE utf8_unicode_nopad_ci DEFAULT NULL,
796+
UNIQUE KEY `a` (`a`(3)) USING HASH
797+
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
798+
INSERT INTO t1 VALUES ('ss ');
799+
INSERT INTO t1 VALUES (_utf8mb3 0xC39F20)/*SZ+SPACE*/;
800+
ERROR 23000: Duplicate entry 'ß ' for key 'a'
801+
DROP TABLE t1;
802+
EXECUTE IMMEDIATE REPLACE(
803+
'CREATE TABLE t1 ( '
804+
' a VARCHAR(2000) COLLATE <COLLATION>,'
805+
'UNIQUE(a(3)))',
806+
'<COLLATION>', @@collation_connection);
807+
SHOW CREATE TABLE t1;
808+
Table Create Table
809+
t1 CREATE TABLE `t1` (
810+
`a` varchar(2000) CHARACTER SET utf8 COLLATE utf8_unicode_nopad_ci DEFAULT NULL,
811+
UNIQUE KEY `a` (`a`(3))
812+
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
813+
INSERT INTO t1 VALUES ('ss ');
814+
INSERT INTO t1 VALUES (_utf8mb3 0xC39F20)/*SZ+SPACE*/;
815+
ERROR 23000: Duplicate entry 'ß ' for key 'a'
816+
DROP TABLE t1;
817+
EXECUTE IMMEDIATE REPLACE(
818+
'CREATE TABLE t1 ( '
819+
' a VARCHAR(2000) COLLATE <COLLATION>,'
820+
'UNIQUE(a(3)) USING HASH)',
821+
'<COLLATION>', @@collation_connection);
822+
SHOW CREATE TABLE t1;
823+
Table Create Table
824+
t1 CREATE TABLE `t1` (
825+
`a` varchar(2000) CHARACTER SET utf8 COLLATE utf8_unicode_nopad_ci DEFAULT NULL,
826+
UNIQUE KEY `a` (`a`(3)) USING HASH
827+
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
828+
INSERT INTO t1 VALUES ('ss ');
829+
INSERT INTO t1 VALUES (_utf8mb3 0xC39F20)/*SZ+SPACE*/;
830+
ERROR 23000: Duplicate entry 'ß ' for key 'a'
831+
DROP TABLE t1;
832+
EXECUTE IMMEDIATE REPLACE(
833+
'CREATE TABLE t1 ( '
834+
' a CHAR(20) COLLATE <COLLATION>,'
835+
'UNIQUE(a(3)) USING HASH)',
836+
'<COLLATION>', @@collation_connection);
837+
SHOW CREATE TABLE t1;
838+
Table Create Table
839+
t1 CREATE TABLE `t1` (
840+
`a` char(20) CHARACTER SET utf8 COLLATE utf8_unicode_nopad_ci DEFAULT NULL,
841+
UNIQUE KEY `a` (`a`(3)) USING HASH
842+
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
843+
INSERT INTO t1 VALUES ('ss ');
844+
INSERT INTO t1 VALUES (_utf8mb3 0xC39F20)/*SZ+SPACE*/;
845+
DROP TABLE t1;
846+
SET DEFAULT_STORAGE_ENGINE=HEAP;
847+
#
848+
# MDEV-30034 UNIQUE USING HASH accepts duplicate entries for tricky collations
849+
#
850+
EXECUTE IMMEDIATE REPLACE(
851+
'CREATE TABLE t1 ( '
852+
' a VARCHAR(2000) COLLATE <COLLATION>,'
853+
'UNIQUE(a(3)))',
854+
'<COLLATION>', @@collation_connection);
855+
SHOW CREATE TABLE t1;
856+
Table Create Table
857+
t1 CREATE TABLE `t1` (
858+
`a` varchar(2000) CHARACTER SET utf8 COLLATE utf8_unicode_nopad_ci DEFAULT NULL,
859+
UNIQUE KEY `a` (`a`(3))
860+
) ENGINE=MEMORY DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
861+
INSERT INTO t1 VALUES ('ss ');
862+
INSERT INTO t1 VALUES (_utf8mb3 0xC39F20)/*SZ+SPACE*/;
863+
ERROR 23000: Duplicate entry 'ß ' for key 'a'
864+
DROP TABLE t1;
865+
EXECUTE IMMEDIATE REPLACE(
866+
'CREATE TABLE t1 ( '
867+
' a VARCHAR(2000) COLLATE <COLLATION>,'
868+
'UNIQUE(a(3)) USING HASH)',
869+
'<COLLATION>', @@collation_connection);
870+
SHOW CREATE TABLE t1;
871+
Table Create Table
872+
t1 CREATE TABLE `t1` (
873+
`a` varchar(2000) CHARACTER SET utf8 COLLATE utf8_unicode_nopad_ci DEFAULT NULL,
874+
UNIQUE KEY `a` (`a`(3)) USING HASH
875+
) ENGINE=MEMORY DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
876+
INSERT INTO t1 VALUES ('ss ');
877+
INSERT INTO t1 VALUES (_utf8mb3 0xC39F20)/*SZ+SPACE*/;
878+
ERROR 23000: Duplicate entry 'ß ' for key 'a'
879+
DROP TABLE t1;
880+
EXECUTE IMMEDIATE REPLACE(
881+
'CREATE TABLE t1 ( '
882+
' a CHAR(20) COLLATE <COLLATION>,'
883+
'UNIQUE(a(3)))',
884+
'<COLLATION>', @@collation_connection);
885+
SHOW CREATE TABLE t1;
886+
Table Create Table
887+
t1 CREATE TABLE `t1` (
888+
`a` char(20) CHARACTER SET utf8 COLLATE utf8_unicode_nopad_ci DEFAULT NULL,
889+
UNIQUE KEY `a` (`a`(3))
890+
) ENGINE=MEMORY DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
891+
INSERT INTO t1 VALUES ('ss ');
892+
INSERT INTO t1 VALUES (_utf8mb3 0xC39F20)/*SZ+SPACE*/;
893+
DROP TABLE t1;
894+
EXECUTE IMMEDIATE REPLACE(
895+
'CREATE TABLE t1 ( '
896+
' a CHAR(20) COLLATE <COLLATION>,'
897+
'UNIQUE(a(3)) USING HASH)',
898+
'<COLLATION>', @@collation_connection);
899+
SHOW CREATE TABLE t1;
900+
Table Create Table
901+
t1 CREATE TABLE `t1` (
902+
`a` char(20) CHARACTER SET utf8 COLLATE utf8_unicode_nopad_ci DEFAULT NULL,
903+
UNIQUE KEY `a` (`a`(3)) USING HASH
904+
) ENGINE=MEMORY DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
905+
INSERT INTO t1 VALUES ('ss ');
906+
INSERT INTO t1 VALUES (_utf8mb3 0xC39F20)/*SZ+SPACE*/;
907+
DROP TABLE t1;
908+
SET DEFAULT_STORAGE_ENGINE=DEFAULT;
909+
#
910+
# End of 10.4 tests
911+
#

mysql-test/main/ctype_utf8_uca.test

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,21 @@ SET NAMES utf8mb3 COLLATE utf8mb3_thai_520_w2;
5050
--echo #
5151
--echo # End of 10.3 tests
5252
--echo #
53+
54+
55+
--echo #
56+
--echo # Start of 10.4 tests
57+
--echo #
58+
59+
SET DEFAULT_STORAGE_ENGINE=MyISAM;
60+
SET NAMES utf8mb3 COLLATE utf8mb3_unicode_nopad_ci;
61+
--source include/ctype_nopad_prefix_unique.inc
62+
63+
SET DEFAULT_STORAGE_ENGINE=HEAP;
64+
--source include/ctype_nopad_prefix_unique.inc
65+
66+
SET DEFAULT_STORAGE_ENGINE=DEFAULT;
67+
68+
--echo #
69+
--echo # End of 10.4 tests
70+
--echo #

mysql-test/suite/innodb/r/innodb-wl5522.result

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,24 @@ a b c
6363
# Done restarting server
6464
# List before t1 DISCARD
6565
db.opt
66+
t1.cfg.sav
6667
t1.frm
6768
t1.ibd
69+
t1.ibd.sav
70+
t2.cfg.sav
6871
t2.frm
6972
t2.ibd
73+
t2.ibd.sav
7074
ALTER TABLE t1 DISCARD TABLESPACE;
7175
# List after t1 DISCARD
7276
db.opt
77+
t1.cfg.sav
7378
t1.frm
79+
t1.ibd.sav
80+
t2.cfg.sav
7481
t2.frm
7582
t2.ibd
83+
t2.ibd.sav
7684
ALTER TABLE t1 IMPORT TABLESPACE;
7785
ALTER TABLE t1 ENGINE InnoDB;
7886
SELECT COUNT(*) FROM t1;
@@ -90,10 +98,14 @@ a b c
9098
638 Cavalry ..asdasdfaeraf
9199
db.opt
92100
t1.cfg
101+
t1.cfg.sav
93102
t1.frm
94103
t1.ibd
104+
t1.ibd.sav
105+
t2.cfg.sav
95106
t2.frm
96107
t2.ibd
108+
t2.ibd.sav
97109
SELECT COUNT(*) FROM t1;
98110
COUNT(*)
99111
640
@@ -112,7 +124,9 @@ ALTER TABLE t2 ROW_FORMAT=DYNAMIC;
112124
ALTER TABLE t2 DISCARD TABLESPACE;
113125
# List after t2 DISCARD
114126
db.opt
127+
t2.cfg.sav
115128
t2.frm
129+
t2.ibd.sav
116130
ALTER TABLE t2 IMPORT TABLESPACE;
117131
ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x21 and the meta-data file has 0x1; .cfg file uses ROW_FORMAT=COMPACT)
118132
ALTER TABLE t2 IMPORT TABLESPACE;

0 commit comments

Comments
 (0)