summaryrefslogtreecommitdiff
path: root/strings
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2023-02-28 10:49:25 +0400
committerAlexander Barkov <bar@mariadb.com>2023-03-01 15:38:02 +0400
commit965bdf3e66a9265345003c6e172aad7b1864e280 (patch)
treec69f9be115af382a2885d93701fcd7e6004ac4c0 /strings
parent841e8877ccb8ef5d692a22b4447383a360557326 (diff)
downloadmariadb-git-965bdf3e66a9265345003c6e172aad7b1864e280.tar.gz
MDEV-30746 Regression in ucs2_general_mysql500_ci
1. Adding a separate MY_COLLATION_HANDLER my_collation_ucs2_general_mysql500_ci_handler implementing a proper order for ucs2_general_mysql500_ci The problem happened because ucs2_general_mysql500_ci erroneously used my_collation_ucs2_general_ci_handler. 2. Cosmetic changes: Renaming: - plane00_mysql500 to my_unicase_mysql500_page00 - my_unicase_pages_mysql500 to my_unicase_mysql500_pages to use the same naming style with: - my_unicase_default_page00 - my_unicase_defaul_pages 3. Moving code fragments from - handler::check_collation_compatibility() in handler.cc - upgrade_collation() in table.cc into new methods in class Charset, to reuse the code easier.
Diffstat (limited to 'strings')
-rw-r--r--strings/ctype-ucs2.c39
-rw-r--r--strings/ctype-unidata.h3
-rw-r--r--strings/ctype-utf8.c18
3 files changed, 50 insertions, 10 deletions
diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c
index 2e6b1239c0a..80a267dbf1d 100644
--- a/strings/ctype-ucs2.c
+++ b/strings/ctype-ucs2.c
@@ -2987,6 +2987,14 @@ static inline int my_weight_mb2_ucs2_general_ci(uchar b0, uchar b1)
}
+static inline int my_weight_mb2_ucs2_general_mysql500_ci(uchar b0, uchar b1)
+{
+ my_wc_t wc= UCS2_CODE(b0, b1);
+ MY_UNICASE_CHARACTER *page= my_unicase_mysql500_pages[wc >> 8];
+ return (int) (page ? page[wc & 0xFF].sort : wc);
+}
+
+
#define MY_FUNCTION_NAME(x) my_ ## x ## _ucs2_general_ci
#define DEFINE_STRNXFRM_UNICODE
#define DEFINE_STRNXFRM_UNICODE_NOPAD
@@ -3000,6 +3008,18 @@ static inline int my_weight_mb2_ucs2_general_ci(uchar b0, uchar b1)
#include "strcoll.inl"
+#define MY_FUNCTION_NAME(x) my_ ## x ## _ucs2_general_mysql500_ci
+#define DEFINE_STRNXFRM_UNICODE
+#define MY_MB_WC(cs, pwc, s, e) my_mb_wc_ucs2_quick(pwc, s, e)
+#define OPTIMIZE_ASCII 0
+#define UNICASE_MAXCHAR MY_UNICASE_INFO_DEFAULT_MAXCHAR
+#define UNICASE_PAGE0 my_unicase_mysql500_page00
+#define UNICASE_PAGES my_unicase_mysql500_pages
+#define WEIGHT_ILSEQ(x) (0xFF0000 + (uchar) (x))
+#define WEIGHT_MB2(b0,b1) my_weight_mb2_ucs2_general_mysql500_ci(b0,b1)
+#include "strcoll.inl"
+
+
#define MY_FUNCTION_NAME(x) my_ ## x ## _ucs2_bin
#define DEFINE_STRNXFRM_UNICODE_BIN2
#define MY_MB_WC(cs, pwc, s, e) my_mb_wc_ucs2_quick(pwc, s, e)
@@ -3285,6 +3305,23 @@ static MY_COLLATION_HANDLER my_collation_ucs2_general_ci_handler =
};
+static MY_COLLATION_HANDLER my_collation_ucs2_general_mysql500_ci_handler =
+{
+ NULL, /* init */
+ my_strnncoll_ucs2_general_mysql500_ci,
+ my_strnncollsp_ucs2_general_mysql500_ci,
+ my_strnncollsp_nchars_ucs2_general_mysql500_ci,
+ my_strnxfrm_ucs2_general_mysql500_ci,
+ my_strnxfrmlen_unicode,
+ my_like_range_generic,
+ my_wildcmp_ucs2_ci,
+ my_strcasecmp_mb2_or_mb4,
+ my_instr_mb,
+ my_hash_sort_ucs2,
+ my_propagate_simple
+};
+
+
static MY_COLLATION_HANDLER my_collation_ucs2_bin_handler =
{
NULL, /* init */
@@ -3431,7 +3468,7 @@ struct charset_info_st my_charset_ucs2_general_mysql500_ci=
0, /* escape_with_backslash_is_dangerous */
1, /* levels_for_order */
&my_charset_ucs2_handler,
- &my_collation_ucs2_general_ci_handler
+ &my_collation_ucs2_general_mysql500_ci_handler
};
diff --git a/strings/ctype-unidata.h b/strings/ctype-unidata.h
index 6712f5e1d79..9900fd0cedd 100644
--- a/strings/ctype-unidata.h
+++ b/strings/ctype-unidata.h
@@ -21,6 +21,9 @@
extern MY_UNICASE_CHARACTER my_unicase_default_page00[256];
extern MY_UNICASE_CHARACTER *my_unicase_default_pages[256];
+extern MY_UNICASE_CHARACTER my_unicase_mysql500_page00[256];
+extern MY_UNICASE_CHARACTER *my_unicase_mysql500_pages[256];
+
size_t my_strxfrm_pad_nweights_unicode(uchar *str, uchar *strend, size_t nweights);
size_t my_strxfrm_pad_unicode(uchar *str, uchar *strend);
diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c
index 69ebb6b523e..cdac17be3c6 100644
--- a/strings/ctype-utf8.c
+++ b/strings/ctype-utf8.c
@@ -248,7 +248,7 @@ MY_UNICASE_CHARACTER my_unicase_default_page00[]={
Almost similar to my_unicase_default_page00, but maps sorting order
for U+00DF to 0x00DF instead of 0x0053.
*/
-static MY_UNICASE_CHARACTER plane00_mysql500[]={
+MY_UNICASE_CHARACTER my_unicase_mysql500_page00[]={
{0x0000,0x0000,0x0000}, {0x0001,0x0001,0x0001},
{0x0002,0x0002,0x0002}, {0x0003,0x0003,0x0003},
{0x0004,0x0004,0x0004}, {0x0005,0x0005,0x0005},
@@ -1739,8 +1739,8 @@ MY_UNICASE_INFO my_unicase_default=
/*
Reproduce old utf8_general_ci behaviour before we fixed Bug#27877.
*/
-MY_UNICASE_CHARACTER *my_unicase_pages_mysql500[256]={
- plane00_mysql500,
+MY_UNICASE_CHARACTER *my_unicase_mysql500_pages[256]={
+ my_unicase_mysql500_page00,
plane01, plane02, plane03, plane04, plane05, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
@@ -1780,7 +1780,7 @@ MY_UNICASE_CHARACTER *my_unicase_pages_mysql500[256]={
MY_UNICASE_INFO my_unicase_mysql500=
{
0xFFFF,
- my_unicase_pages_mysql500
+ my_unicase_mysql500_pages
};
@@ -5266,14 +5266,14 @@ static inline int my_weight_mb3_utf8_general_ci(uchar b0, uchar b1, uchar b2)
static inline int my_weight_mb1_utf8_general_mysql500_ci(uchar b)
{
- return (int) plane00_mysql500[b & 0xFF].sort;
+ return (int) my_unicase_mysql500_page00[b & 0xFF].sort;
}
static inline int my_weight_mb2_utf8_general_mysql500_ci(uchar b0, uchar b1)
{
my_wc_t wc= UTF8MB2_CODE(b0, b1);
- MY_UNICASE_CHARACTER *page= my_unicase_pages_mysql500[wc >> 8];
+ MY_UNICASE_CHARACTER *page= my_unicase_mysql500_pages[wc >> 8];
return (int) (page ? page[wc & 0xFF].sort : wc);
}
@@ -5282,7 +5282,7 @@ static inline int
my_weight_mb3_utf8_general_mysql500_ci(uchar b0, uchar b1, uchar b2)
{
my_wc_t wc= UTF8MB3_CODE(b0, b1, b2);
- MY_UNICASE_CHARACTER *page= my_unicase_pages_mysql500[wc >> 8];
+ MY_UNICASE_CHARACTER *page= my_unicase_mysql500_pages[wc >> 8];
return (int) (page ? page[wc & 0xFF].sort : wc);
}
@@ -5292,8 +5292,8 @@ my_weight_mb3_utf8_general_mysql500_ci(uchar b0, uchar b1, uchar b2)
#define MY_MB_WC(cs, pwc, s, e) my_mb_wc_utf8mb3_quick(pwc, s, e)
#define OPTIMIZE_ASCII 1
#define UNICASE_MAXCHAR MY_UNICASE_INFO_DEFAULT_MAXCHAR
-#define UNICASE_PAGE0 plane00_mysql500
-#define UNICASE_PAGES my_unicase_pages_mysql500
+#define UNICASE_PAGE0 my_unicase_mysql500_page00
+#define UNICASE_PAGES my_unicase_mysql500_pages
#define WEIGHT_ILSEQ(x) (0xFF0000 + (uchar) (x))
#define WEIGHT_MB1(x) my_weight_mb1_utf8_general_mysql500_ci(x)
#define WEIGHT_MB2(x,y) my_weight_mb2_utf8_general_mysql500_ci(x,y)