Skip to content

Commit

Permalink
MDEV-31531 Remove my_casedn_str() and my_caseup_str()
Browse files Browse the repository at this point in the history
Under terms of MDEV 27490 we'll add support for non-BMP identifiers
and upgrade casefolding information to Unicode version 14.0.0.
In Unicode-14.0.0 conversion to lower and upper cases can increase octet length
of the string, so conversion won't be possible in-place any more.

This patch removes virtual functions performing in-place casefolding:
  - my_charset_handler_st::casedn_str()
  - my_charset_handler_st::caseup_str()
and fixes the code to use the non-inplace functions instead:
  - my_charset_handler_st::casedn()
  - my_charset_handler_st::caseup()
  • Loading branch information
abarkov committed Feb 28, 2024
1 parent de9c357 commit 929c2e0
Show file tree
Hide file tree
Showing 103 changed files with 1,286 additions and 1,252 deletions.
50 changes: 41 additions & 9 deletions include/m_ctype.h
Expand Up @@ -630,10 +630,6 @@ struct my_charset_handler_st
int (*ctype)(CHARSET_INFO *cs, int *ctype,
const uchar *s, const uchar *e);

/* Functions for case and sort conversion */
size_t (*caseup_str)(CHARSET_INFO *, char *);
size_t (*casedn_str)(CHARSET_INFO *, char *);

my_charset_conv_case caseup;
my_charset_conv_case casedn;

Expand Down Expand Up @@ -849,6 +845,39 @@ struct charset_info_st
return (cset->casedn)(this, src, srclen, dst, dstlen);
}

size_t opt_casedn(const char *src, size_t srclen,
char *dst, size_t dstlen, my_bool opt_casedn) const
{
if (opt_casedn)
return casedn(src, srclen, dst, dstlen);
if (srclen > dstlen)
srclen= dstlen;
memcpy(dst, src, srclen);
return srclen;
}

/* Convert to a lower-cased 0-terminated string */
size_t casedn_z(const char *src, size_t srclen,
char *dst, size_t dstlen) const
{
DBUG_ASSERT(dstlen);
DBUG_ASSERT(src != dst);
size_t len= casedn(src, srclen, dst, dstlen - 1);
dst[len]= '\0';
return len;
}

/* Convert to a upper-cased 0-terminated string */
size_t caseup_z(const char *src, size_t srclen,
char *dst, size_t dstlen) const
{
DBUG_ASSERT(dstlen);
DBUG_ASSERT(src != dst);
size_t len= caseup(src, srclen, dst, dstlen - 1);
dst[len]= '\0';
return len;
}

uint caseup_multiply() const
{
return (cset->caseup_multiply)(this);
Expand Down Expand Up @@ -1513,6 +1542,14 @@ size_t my_copy_fix_mb(CHARSET_INFO *cs,
/* Functions for 8bit */
extern size_t my_caseup_str_8bit(CHARSET_INFO *, char *);
extern size_t my_casedn_str_8bit(CHARSET_INFO *, char *);
static inline size_t my_caseup_str_latin1(char *str)
{
return my_caseup_str_8bit(&my_charset_latin1, str);
}
static inline size_t my_casedn_str_latin1(char *str)
{
return my_casedn_str_8bit(&my_charset_latin1, str);
}
extern size_t my_caseup_8bit(CHARSET_INFO *,
const char *src, size_t srclen,
char *dst, size_t dstlen);
Expand Down Expand Up @@ -1609,8 +1646,6 @@ int my_charlen_8bit(CHARSET_INFO *, const uchar *str, const uchar *end);


/* Functions for multibyte charsets */
extern size_t my_caseup_str_mb(CHARSET_INFO *, char *);
extern size_t my_casedn_str_mb(CHARSET_INFO *, char *);
extern size_t my_caseup_mb(CHARSET_INFO *,
const char *src, size_t srclen,
char *dst, size_t dstlen);
Expand Down Expand Up @@ -1857,9 +1892,6 @@ my_well_formed_length(CHARSET_INFO *cs, const char *b, const char *e,
}


#define my_caseup_str(s, a) ((s)->cset->caseup_str((s), (a)))
#define my_casedn_str(s, a) ((s)->cset->casedn_str((s), (a)))

/* XXX: still need to take care of this one */
#ifdef MY_CHARSET_TIS620
#error The TIS620 charset is broken at the moment. Tell tim to fix it.
Expand Down
4 changes: 2 additions & 2 deletions mysql-test/main/ctype_utf16.result
Expand Up @@ -1584,7 +1584,7 @@ ORDER BY l DESC;
id l
a 512
Warnings:
Warning 1260 Row 1 was cut by GROUP_CONCAT()
Warning 1260 Row 1 was cut by group_concat()
SET STATEMENT group_concat_max_len=1024 FOR
SELECT id, CHAR_LENGTH(GROUP_CONCAT(body)) AS l
FROM (SELECT 'a' AS id, REPEAT('foo bar', 100) AS body
Expand All @@ -1593,7 +1593,7 @@ SELECT 'a' AS id, REPEAT('bla bla', 100) AS body) t1;
id l
a 512
Warnings:
Warning 1260 Row 1 was cut by GROUP_CONCAT()
Warning 1260 Row 1 was cut by group_concat()
#
# MDEV-6865 Merge Bug#18935421 RPAD DIES WITH CERTAIN PADSTR INTPUTS..
#
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/main/ctype_utf32.result
Expand Up @@ -1638,7 +1638,7 @@ ORDER BY l DESC;
id l
a 256
Warnings:
Warning 1260 Row 1 was cut by GROUP_CONCAT()
Warning 1260 Row 1 was cut by group_concat()
#
# incorrect charset for val_str_ascii
#
Expand Down
9 changes: 9 additions & 0 deletions mysql-test/main/foreign_key.result
Expand Up @@ -108,3 +108,12 @@ ALTER TABLE tfk ADD CONSTRAINT sid UNIQUE(c2);
ERROR 42000: Duplicate key name 'sid'
DROP TABLE tfk;
DROP TABLE tpk;
#
# MDEV-33223 Assertion `dst_size > 4' failed in size_t Identifier_chain2::make_sep_name_opt_casedn(char*, size_t, int, bool) const
#
CREATE DATABASE x;
USE x;
CREATE TABLE t (i INT, j INT, CONSTRAINT fk2 FOREIGN KEY(i) REFERENCES p (i)) ENGINE=InnoDB;
ERROR HY000: Can't create table `x`.`t` (errno: 150 "Foreign key constraint is incorrectly formed")
DROP DATABASE x;
USE test;
10 changes: 10 additions & 0 deletions mysql-test/main/foreign_key.test
Expand Up @@ -142,3 +142,13 @@ DROP TABLE tfk;
DROP TABLE tpk;


--echo #
--echo # MDEV-33223 Assertion `dst_size > 4' failed in size_t Identifier_chain2::make_sep_name_opt_casedn(char*, size_t, int, bool) const
--echo #

CREATE DATABASE x;
USE x;
--error ER_CANT_CREATE_TABLE
CREATE TABLE t (i INT, j INT, CONSTRAINT fk2 FOREIGN KEY(i) REFERENCES p (i)) ENGINE=InnoDB;
DROP DATABASE x;
USE test;
76 changes: 38 additions & 38 deletions mysql-test/main/func_gconcat.result
Expand Up @@ -152,10 +152,10 @@ grp group_concat(c)
4
5 NULL
Warnings:
Warning 1260 Row 4 was cut by GROUP_CONCAT()
Warning 1260 Row 4 was cut by group_concat()
show warnings;
Level Code Message
Warning 1260 Row 4 was cut by GROUP_CONCAT()
Warning 1260 Row 4 was cut by group_concat()
set group_concat_max_len = 1024;
select group_concat(sum(c)) from t1 group by grp;
ERROR HY000: Invalid use of group function
Expand Down Expand Up @@ -379,29 +379,29 @@ group_concat(b)
bb,c
BB,C
Warnings:
Warning 1260 Row 2 was cut by GROUP_CONCAT()
Warning 1260 Row 4 was cut by GROUP_CONCAT()
Warning 1260 Row 2 was cut by group_concat()
Warning 1260 Row 4 was cut by group_concat()
select group_concat(distinct b) from t1 group by a;
group_concat(distinct b)
a,bb
A,BB
Warnings:
Warning 1260 Row 3 was cut by GROUP_CONCAT()
Warning 1260 Row 6 was cut by GROUP_CONCAT()
Warning 1260 Row 3 was cut by group_concat()
Warning 1260 Row 6 was cut by group_concat()
select group_concat(b order by b) from t1 group by a;
group_concat(b order by b)
a,bb
A,BB
Warnings:
Warning 1260 Row 3 was cut by GROUP_CONCAT()
Warning 1260 Row 6 was cut by GROUP_CONCAT()
Warning 1260 Row 3 was cut by group_concat()
Warning 1260 Row 6 was cut by group_concat()
select group_concat(distinct b order by b) from t1 group by a;
group_concat(distinct b order by b)
a,bb
A,BB
Warnings:
Warning 1260 Row 3 was cut by GROUP_CONCAT()
Warning 1260 Row 6 was cut by GROUP_CONCAT()
Warning 1260 Row 3 was cut by group_concat()
Warning 1260 Row 6 was cut by group_concat()
insert into t1 values (1, concat(repeat('1', 300), '2')),
(1, concat(repeat('1', 300), '2')), (1, concat(repeat('0', 300), '1')),
(2, concat(repeat('1', 300), '2')), (2, concat(repeat('1', 300), '2')),
Expand Down Expand Up @@ -429,29 +429,29 @@ group_concat(b)
bb,ccc,a,bb,ccc,1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112,1111111111111111111111111111111111111111111111111111111111111111111111111111111111
BB,CCC,A,BB,CCC,1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112,1111111111111111111111111111111111111111111111111111111111111111111111111111111111
Warnings:
Warning 1260 Row 7 was cut by GROUP_CONCAT()
Warning 1260 Row 14 was cut by GROUP_CONCAT()
Warning 1260 Row 7 was cut by group_concat()
Warning 1260 Row 14 was cut by group_concat()
select group_concat(distinct b) from t1 group by a;
group_concat(distinct b)
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001,11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001,11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
Warnings:
Warning 1260 Row 2 was cut by GROUP_CONCAT()
Warning 1260 Row 4 was cut by GROUP_CONCAT()
Warning 1260 Row 2 was cut by group_concat()
Warning 1260 Row 4 was cut by group_concat()
select group_concat(b order by b) from t1 group by a;
group_concat(b order by b)
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001,11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001,11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
Warnings:
Warning 1260 Row 2 was cut by GROUP_CONCAT()
Warning 1260 Row 4 was cut by GROUP_CONCAT()
Warning 1260 Row 2 was cut by group_concat()
Warning 1260 Row 4 was cut by group_concat()
select group_concat(distinct b order by b) from t1 group by a;
group_concat(distinct b order by b)
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001,11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001,11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
Warnings:
Warning 1260 Row 2 was cut by GROUP_CONCAT()
Warning 1260 Row 4 was cut by GROUP_CONCAT()
Warning 1260 Row 2 was cut by group_concat()
Warning 1260 Row 4 was cut by group_concat()
drop table t1;
create table t1 (a varchar(255) character set cp1250 collate cp1250_general_ci,
b varchar(255) character set koi8r);
Expand Down Expand Up @@ -758,22 +758,22 @@ SELECT GROUP_CONCAT( a ) FROM t1;
GROUP_CONCAT( a )
aaaaaaaaaa,bbbbbbbbb
Warnings:
Warning 1260 Row 2 was cut by GROUP_CONCAT()
Warning 1260 Row 2 was cut by group_concat()
SELECT GROUP_CONCAT( DISTINCT a ) FROM t1;
GROUP_CONCAT( DISTINCT a )
aaaaaaaaaa,bbbbbbbbb
Warnings:
Warning 1260 Row 2 was cut by GROUP_CONCAT()
Warning 1260 Row 2 was cut by group_concat()
SELECT GROUP_CONCAT( a ORDER BY b ) FROM t1;
GROUP_CONCAT( a ORDER BY b )
aaaaaaaaaa,bbbbbbbbb
Warnings:
Warning 1260 Row 2 was cut by GROUP_CONCAT()
Warning 1260 Row 2 was cut by group_concat()
SELECT GROUP_CONCAT( DISTINCT a ORDER BY b ) FROM t1;
GROUP_CONCAT( DISTINCT a ORDER BY b )
aaaaaaaaaa,bbbbbbbbb
Warnings:
Warning 1260 Row 2 was cut by GROUP_CONCAT()
Warning 1260 Row 2 was cut by group_concat()
SET group_concat_max_len = DEFAULT;
DROP TABLE t1;
SET group_concat_max_len= 65535;
Expand Down Expand Up @@ -1073,15 +1073,15 @@ GROUP_CONCAT(a) b
22222 2
33333 3
Warnings:
Warning 1260 Row 1 was cut by GROUP_CONCAT()
Warning 1260 Row 2 was cut by GROUP_CONCAT()
Warning 1260 Row 3 was cut by GROUP_CONCAT()
Warning 1260 Row 1 was cut by group_concat()
Warning 1260 Row 2 was cut by group_concat()
Warning 1260 Row 3 was cut by group_concat()
INSERT INTO t2 SELECT GROUP_CONCAT(a), b FROM t1 GROUP BY b;
ERROR HY000: Row 1 was cut by GROUP_CONCAT()
ERROR HY000: Row 1 was cut by group_concat()
UPDATE t1 SET a = '11111' WHERE b = 1;
UPDATE t1 SET a = '22222' WHERE b = 2;
INSERT INTO t2 SELECT GROUP_CONCAT(a), b FROM t1 GROUP BY b;
ERROR HY000: Row 3 was cut by GROUP_CONCAT()
ERROR HY000: Row 3 was cut by group_concat()
SET group_concat_max_len = DEFAULT;
SET @@sql_mode = @old_sql_mode;
DROP TABLE t1, t2;
Expand Down Expand Up @@ -1168,22 +1168,22 @@ SELECT LENGTH(GROUP_CONCAT(f1 ORDER BY f2)) FROM t1;
LENGTH(GROUP_CONCAT(f1 ORDER BY f2))
1024
Warnings:
Warning 1260 Row 2 was cut by GROUP_CONCAT()
Warning 1260 Row 2 was cut by group_concat()
SET group_concat_max_len= 499999;
SELECT LENGTH(GROUP_CONCAT(f1 ORDER BY f2)) FROM t1 WHERE f2 = 0;
LENGTH(GROUP_CONCAT(f1 ORDER BY f2))
499999
Warnings:
Warning 1260 Row 1 was cut by GROUP_CONCAT()
Warning 1260 Row 1 was cut by group_concat()
SELECT LENGTH(GROUP_CONCAT(f1 ORDER BY f2)) FROM t1 GROUP BY f2;
LENGTH(GROUP_CONCAT(f1 ORDER BY f2))
499999
499999
499999
Warnings:
Warning 1260 Row 1 was cut by GROUP_CONCAT()
Warning 1260 Row 2 was cut by GROUP_CONCAT()
Warning 1260 Row 3 was cut by GROUP_CONCAT()
Warning 1260 Row 1 was cut by group_concat()
Warning 1260 Row 2 was cut by group_concat()
Warning 1260 Row 3 was cut by group_concat()
INSERT INTO t1 VALUES (REPEAT('a', 499999), 3), (REPEAT('b', 500000), 4);
SELECT LENGTH(GROUP_CONCAT(f1 ORDER BY f2)) FROM t1 GROUP BY f2;
LENGTH(GROUP_CONCAT(f1 ORDER BY f2))
Expand All @@ -1193,10 +1193,10 @@ LENGTH(GROUP_CONCAT(f1 ORDER BY f2))
499999
499999
Warnings:
Warning 1260 Row 1 was cut by GROUP_CONCAT()
Warning 1260 Row 2 was cut by GROUP_CONCAT()
Warning 1260 Row 3 was cut by GROUP_CONCAT()
Warning 1260 Row 5 was cut by GROUP_CONCAT()
Warning 1260 Row 1 was cut by group_concat()
Warning 1260 Row 2 was cut by group_concat()
Warning 1260 Row 3 was cut by group_concat()
Warning 1260 Row 5 was cut by group_concat()
DROP TABLE t1;
SET group_concat_max_len= DEFAULT;
set session group_concat_max_len=1024;
Expand All @@ -1206,7 +1206,7 @@ FROM seq_1_to_200000;
c
0.90910.90910.90910.90910.90910.90910.90910.9091,1.81821.81821.81821.81821.81821.81821.81821.8182,10.000010.000010.000010.000010.000010.000010.000010.0000,10.909110.909110.909110.909110.909110.909110.909110.9091,100.0000100.0000100.0000100.0000100.0000100.0000100.0000100.0000,100.9091100.9091100.9091100.9091100.9091100.9091100.9091100.9091,1000.00001000.00001000.00001000.00001000.00001000.00001000.00001000.0000,1000.90911000.90911000.90911000.90911000.90911000.90911000.90911000.9091,10000.000010000.000010000.000010000.000010000.000010000.000010000.000010000.0000,10000.909110000.909110000.909110000.909110000.909110000.909110000.909110000.9091,100000.0000100000.0000100000.0000100000.0000100000.0000100000.0000100000.0000100000.0000,100000.9091100000.9091100000.9091100000.9091100000.9091100000.9091100000.9091100000.9091,100001.8182100001.8182100001.8182100001.8182100001.8182100001.8182100001.8182100001.8182,100002.7273100002.7273100002.7273100002.7273100002.7273100002.7273100002.7273100002.7273,100003.6364100003.
Warnings:
Warning 1260 Row 15 was cut by GROUP_CONCAT()
Warning 1260 Row 15 was cut by group_concat()
set max_session_mem_used=default;
set session group_concat_max_len=default;
SET group_concat_max_len= 8;
Expand All @@ -1225,7 +1225,7 @@ GROUP BY f;
f gc
2 2019-12-
Warnings:
Warning 1260 Row 1 was cut by GROUP_CONCAT()
Warning 1260 Row 1 was cut by group_concat()
DROP TABLE t1, t2, t3, t4;
SET group_concat_max_len= default;
#
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/main/func_json.result
Expand Up @@ -1599,7 +1599,7 @@ select json_arrayagg(a) from t1;
json_arrayagg(a)
["x64-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"]
Warnings:
Warning 1260 Row 1 was cut by JSON_ARRAYAGG()
Warning 1260 Row 1 was cut by json_arrayagg()
drop table t1;
SET group_concat_max_len= default;
create table t1 (col1 json);
Expand Down
16 changes: 8 additions & 8 deletions mysql-test/main/join_outer.result
Expand Up @@ -944,29 +944,29 @@ group_concat(t1.b,t2.c)
aaaaa
bbbbb
Warnings:
Warning 1260 Row 1 was cut by GROUP_CONCAT()
Warning 1260 Row 2 was cut by GROUP_CONCAT()
Warning 1260 Row 1 was cut by group_concat()
Warning 1260 Row 2 was cut by group_concat()
select group_concat(t1.b,t2.c) from t1 inner join t2 using(a) group by t1.a;
group_concat(t1.b,t2.c)
aaaaa
bbbbb
Warnings:
Warning 1260 Row 1 was cut by GROUP_CONCAT()
Warning 1260 Row 2 was cut by GROUP_CONCAT()
Warning 1260 Row 1 was cut by group_concat()
Warning 1260 Row 2 was cut by group_concat()
select group_concat(t1.b,t2.c) from t1 left join t2 using(a) group by a;
group_concat(t1.b,t2.c)
aaaaa
bbbbb
Warnings:
Warning 1260 Row 1 was cut by GROUP_CONCAT()
Warning 1260 Row 2 was cut by GROUP_CONCAT()
Warning 1260 Row 1 was cut by group_concat()
Warning 1260 Row 2 was cut by group_concat()
select group_concat(t1.b,t2.c) from t1 inner join t2 using(a) group by a;
group_concat(t1.b,t2.c)
aaaaa
bbbbb
Warnings:
Warning 1260 Row 1 was cut by GROUP_CONCAT()
Warning 1260 Row 2 was cut by GROUP_CONCAT()
Warning 1260 Row 1 was cut by group_concat()
Warning 1260 Row 2 was cut by group_concat()
drop table t1, t2;
set group_concat_max_len=default;
create table t1 (gid smallint(5) unsigned not null, x int(11) not null, y int(11) not null, art int(11) not null, primary key (gid,x,y));
Expand Down

0 comments on commit 929c2e0

Please sign in to comment.