summaryrefslogtreecommitdiff
path: root/strings
diff options
context:
space:
mode:
authorbar@bar.intranet.mysql.r18.ru <>2004-03-19 10:00:46 +0400
committerbar@bar.intranet.mysql.r18.ru <>2004-03-19 10:00:46 +0400
commitfc17aad767fa91ce94864c350c9f29aadcf769d8 (patch)
tree5690da4c222d717abdb084781be1e8a4bcec8d20 /strings
parent698217c8d50520adccaf2882438b3a0f14aff19d (diff)
downloadmariadb-git-fc17aad767fa91ce94864c350c9f29aadcf769d8.tar.gz
min_sort_char was added, for the future UCA implementation.
UCS2 now has its own my_like_range function.
Diffstat (limited to 'strings')
-rw-r--r--strings/ctype-big5.c6
-rw-r--r--strings/ctype-bin.c3
-rw-r--r--strings/ctype-czech.c3
-rw-r--r--strings/ctype-euc_kr.c6
-rw-r--r--strings/ctype-extra.c1
-rw-r--r--strings/ctype-gb2312.c6
-rw-r--r--strings/ctype-gbk.c6
-rw-r--r--strings/ctype-latin1.c9
-rw-r--r--strings/ctype-simple.c4
-rw-r--r--strings/ctype-sjis.c6
-rw-r--r--strings/ctype-tis620.c6
-rw-r--r--strings/ctype-ucs2.c89
-rw-r--r--strings/ctype-ujis.c6
-rw-r--r--strings/ctype-utf8.c6
-rw-r--r--strings/ctype-win1250ch.c3
15 files changed, 133 insertions, 27 deletions
diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c
index 712f909ae47..ee55cfda6c1 100644
--- a/strings/ctype-big5.c
+++ b/strings/ctype-big5.c
@@ -6284,7 +6284,8 @@ CHARSET_INFO my_charset_big5_chinese_ci=
1, /* strxfrm_multiply */
1, /* mbminlen */
2, /* mbmaxlen */
- 0,
+ 0, /* min_sort_char */
+ 0, /* max_sort_char */
&my_charset_big5_handler,
&my_collation_big5_chinese_ci_handler
};
@@ -6308,7 +6309,8 @@ CHARSET_INFO my_charset_big5_bin=
1, /* strxfrm_multiply */
1, /* mbminlen */
2, /* mbmaxlen */
- 0,
+ 0, /* min_sort_char */
+ 0, /* max_sort_char */
&my_charset_big5_handler,
&my_collation_mb_bin_handler
};
diff --git a/strings/ctype-bin.c b/strings/ctype-bin.c
index ea7777aabc0..ea0a471ef74 100644
--- a/strings/ctype-bin.c
+++ b/strings/ctype-bin.c
@@ -388,7 +388,8 @@ CHARSET_INFO my_charset_bin =
1, /* strxfrm_multiply */
1, /* mbminlen */
1, /* mbmaxlen */
- (char) 255, /* max_sort_char */
+ 0, /* min_sort_char */
+ 255, /* max_sort_char */
&my_charset_handler,
&my_collation_8bit_bin_handler
};
diff --git a/strings/ctype-czech.c b/strings/ctype-czech.c
index 8aea7358a9c..ed8c0b5b415 100644
--- a/strings/ctype-czech.c
+++ b/strings/ctype-czech.c
@@ -634,7 +634,8 @@ CHARSET_INFO my_charset_latin2_czech_ci =
4, /* strxfrm_multiply */
1, /* mbminlen */
1, /* mbmaxlen */
- 0,
+ 0, /* min_sort_char */
+ 0, /* max_sort_char */
&my_charset_8bit_handler,
&my_collation_latin2_czech_ci_handler
};
diff --git a/strings/ctype-euc_kr.c b/strings/ctype-euc_kr.c
index ce6f695059f..7f89b8152e8 100644
--- a/strings/ctype-euc_kr.c
+++ b/strings/ctype-euc_kr.c
@@ -8692,7 +8692,8 @@ CHARSET_INFO my_charset_euckr_korean_ci=
1, /* strxfrm_multiply */
1, /* mbminlen */
2, /* mbmaxlen */
- 0,
+ 0, /* min_sort_char */
+ 0, /* max_sort_char */
&my_charset_handler,
&my_collation_ci_handler
};
@@ -8716,7 +8717,8 @@ CHARSET_INFO my_charset_euckr_bin=
1, /* strxfrm_multiply */
1, /* mbminlen */
2, /* mbmaxlen */
- 0,
+ 0, /* min_sort_char */
+ 0, /* max_sort_char */
&my_charset_handler,
&my_collation_mb_bin_handler
};
diff --git a/strings/ctype-extra.c b/strings/ctype-extra.c
index 0085d264416..55dab3ca2a8 100644
--- a/strings/ctype-extra.c
+++ b/strings/ctype-extra.c
@@ -35,6 +35,7 @@ CHARSET_INFO compiled_charsets[] = {
0,
0,
0,
+ 0,
NULL,
NULL
}
diff --git a/strings/ctype-gb2312.c b/strings/ctype-gb2312.c
index 9f663f0b1ce..e5dfaf45276 100644
--- a/strings/ctype-gb2312.c
+++ b/strings/ctype-gb2312.c
@@ -5743,7 +5743,8 @@ CHARSET_INFO my_charset_gb2312_chinese_ci=
1, /* strxfrm_multiply */
1, /* mbminlen */
2, /* mbmaxlen */
- 0,
+ 0, /* min_sort_char */
+ 0, /* max_sort_char */
&my_charset_handler,
&my_collation_ci_handler
};
@@ -5766,7 +5767,8 @@ CHARSET_INFO my_charset_gb2312_bin=
1, /* strxfrm_multiply */
1, /* mbminlen */
2, /* mbmaxlen */
- 0,
+ 0, /* min_sort_char */
+ 0, /* max_sort_char */
&my_charset_handler,
&my_collation_mb_bin_handler
};
diff --git a/strings/ctype-gbk.c b/strings/ctype-gbk.c
index f49bc5d360b..98511406ba9 100644
--- a/strings/ctype-gbk.c
+++ b/strings/ctype-gbk.c
@@ -9939,7 +9939,8 @@ CHARSET_INFO my_charset_gbk_chinese_ci=
1, /* strxfrm_multiply */
1, /* mbminlen */
2, /* mbmaxlen */
- 0,
+ 0, /* min_sort_char */
+ 0, /* max_sort_char */
&my_charset_handler,
&my_collation_ci_handler
};
@@ -9962,7 +9963,8 @@ CHARSET_INFO my_charset_gbk_bin=
1, /* strxfrm_multiply */
1, /* mbminlen */
2, /* mbmaxlen */
- 0,
+ 0, /* min_sort_char */
+ 0, /* max_sort_char */
&my_charset_handler,
&my_collation_mb_bin_handler
};
diff --git a/strings/ctype-latin1.c b/strings/ctype-latin1.c
index eaef5441a65..0682b15d135 100644
--- a/strings/ctype-latin1.c
+++ b/strings/ctype-latin1.c
@@ -218,7 +218,8 @@ CHARSET_INFO my_charset_latin1=
1, /* strxfrm_multiply */
1, /* mbminlen */
1, /* mbmaxlen */
- 0,
+ 0, /* min_sort_char */
+ 0, /* max_sort_char */
&my_charset_handler,
&my_collation_8bit_simple_ci_handler
};
@@ -414,7 +415,8 @@ CHARSET_INFO my_charset_latin1_german2_ci=
2, /* strxfrm_multiply */
1, /* mbminlen */
1, /* mbmaxlen */
- 0,
+ 0, /* min_sort_char */
+ 0, /* max_sort_char */
&my_charset_handler,
&my_collation_german2_ci_handler
};
@@ -438,7 +440,8 @@ CHARSET_INFO my_charset_latin1_bin=
1, /* strxfrm_multiply */
1, /* mbminlen */
1, /* mbmaxlen */
- 0,
+ 0, /* min_sort_char */
+ 0, /* max_sort_char */
&my_charset_handler,
&my_collation_8bit_bin_handler
};
diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c
index 6e7d0b849e2..0aae60a0b56 100644
--- a/strings/ctype-simple.c
+++ b/strings/ctype-simple.c
@@ -946,7 +946,7 @@ my_bool my_like_range_simple(CHARSET_INFO *cs,
if (*ptr == w_one) /* '_' in SQL */
{
*min_str++='\0'; /* This should be min char */
- *max_str++=cs->max_sort_char;
+ *max_str++= (char) cs->max_sort_char;
continue;
}
if (*ptr == w_many) /* '%' in SQL */
@@ -955,7 +955,7 @@ my_bool my_like_range_simple(CHARSET_INFO *cs,
*max_length=res_length;
do {
*min_str++ = ' '; /* Because if key compression */
- *max_str++ = cs->max_sort_char;
+ *max_str++ = (char) cs->max_sort_char;
} while (min_str != min_end);
return 0;
}
diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c
index a4a8b3d4b2c..c337b8122fb 100644
--- a/strings/ctype-sjis.c
+++ b/strings/ctype-sjis.c
@@ -4528,7 +4528,8 @@ CHARSET_INFO my_charset_sjis_japanese_ci=
1, /* strxfrm_multiply */
1, /* mbminlen */
2, /* mbmaxlen */
- 0,
+ 0, /* min_sort_char */
+ 0, /* max_sort_char */
&my_charset_handler,
&my_collation_ci_handler
};
@@ -4551,7 +4552,8 @@ CHARSET_INFO my_charset_sjis_bin=
1, /* strxfrm_multiply */
1, /* mbminlen */
2, /* mbmaxlen */
- 0,
+ 0, /* min_sort_char */
+ 0, /* max_sort_char */
&my_charset_handler,
&my_collation_mb_bin_handler
};
diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c
index abe9972cfd6..59be820863a 100644
--- a/strings/ctype-tis620.c
+++ b/strings/ctype-tis620.c
@@ -913,7 +913,8 @@ CHARSET_INFO my_charset_tis620_thai_ci=
4, /* strxfrm_multiply */
1, /* mbminlen */
1, /* mbmaxlen */
- 0,
+ 0, /* min_sort_char */
+ 0, /* max_sort_char */
&my_charset_handler,
&my_collation_ci_handler
};
@@ -936,7 +937,8 @@ CHARSET_INFO my_charset_tis620_bin=
1, /* strxfrm_multiply */
1, /* mbminlen */
1, /* mbmaxlen */
- 0,
+ 0, /* min_sort_char */
+ 0, /* max_sort_char */
&my_charset_handler,
&my_collation_8bit_bin_handler
};
diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c
index 908d27859ff..f4c1a22939a 100644
--- a/strings/ctype-ucs2.c
+++ b/strings/ctype-ucs2.c
@@ -1284,13 +1284,94 @@ void my_hash_sort_ucs2_bin(CHARSET_INFO *cs __attribute__((unused)),
}
}
+/*
+** Calculate min_str and max_str that ranges a LIKE string.
+** Arguments:
+** ptr Pointer to LIKE string.
+** ptr_length Length of LIKE string.
+** escape Escape character in LIKE. (Normally '\').
+** All escape characters should be removed from min_str and max_str
+** res_length Length of min_str and max_str.
+** min_str Smallest case sensitive string that ranges LIKE.
+** Should be space padded to res_length.
+** max_str Largest case sensitive string that ranges LIKE.
+** Normally padded with the biggest character sort value.
+**
+** The function should return 0 if ok and 1 if the LIKE string can't be
+** optimized !
+*/
+
+my_bool my_like_range_ucs2(CHARSET_INFO *cs,
+ const char *ptr,uint ptr_length,
+ pbool escape, pbool w_one, pbool w_many,
+ uint res_length,
+ char *min_str,char *max_str,
+ uint *min_length,uint *max_length)
+{
+ const char *end=ptr+ptr_length;
+ char *min_org=min_str;
+ char *min_end=min_str+res_length;
+
+ for (; ptr + 1 < end && min_str + 1 < min_end ; ptr+=2)
+ {
+ if (ptr[0] == '\0' && ptr[1] == escape && ptr+2 < end)
+ {
+ ptr+=2; /* Skip escape */
+ *min_str++= *max_str++ = ptr[0];
+ *min_str++= *max_str++ = ptr[1];
+ continue;
+ }
+ if (ptr[0] == '\0' && ptr[1] == w_one) /* '_' in SQL */
+ {
+ *min_str++= (char) cs->min_sort_char >> 8;
+ *min_str++= (char) cs->min_sort_char & 255;
+ *max_str++= (char) cs->max_sort_char >> 8;
+ *max_str++= (char) cs->max_sort_char & 255;
+ continue;
+ }
+ if (ptr[0] == '\0' && ptr[1] == w_many) /* '%' in SQL */
+ {
+ *min_length= (uint) (min_str - min_org);
+ *max_length=res_length;
+ do {
+ *min_str++ = '\0';
+ *min_str++ = ' '; /* Because if key compression */
+ *max_str++ = (char) cs->max_sort_char >>8;
+ *max_str++ = (char) cs->max_sort_char & 255;
+ } while (min_str + 1 < min_end);
+ return 0;
+ }
+ *min_str++= *max_str++ = ptr[0];
+ *min_str++= *max_str++ = ptr[1];
+ }
+ *min_length= *max_length = (uint) (min_str - min_org);
+
+ /* Temporary fix for handling w_one at end of string (key compression) */
+ {
+ char *tmp;
+ for (tmp= min_str ; tmp-1 > min_org && tmp[-1] == '\0' && tmp[-2]=='\0';)
+ {
+ *--tmp=' ';
+ *--tmp='\0';
+ }
+ }
+
+ while (min_str + 1 < min_end)
+ {
+ *min_str++ = *max_str++ = '\0';
+ *min_str++ = *max_str++ = ' '; /* Because if key compression */
+ }
+ return 0;
+}
+
+extern MY_COLLATION_HANDLER my_collation_uca_handler;
static MY_COLLATION_HANDLER my_collation_ucs2_general_ci_handler =
{
my_strnncoll_ucs2,
my_strnncoll_ucs2,
my_strnxfrm_ucs2,
- my_like_range_simple,
+ my_like_range_ucs2,
my_wildcmp_ucs2_ci,
my_strcasecmp_ucs2,
my_instr_mb,
@@ -1356,7 +1437,8 @@ CHARSET_INFO my_charset_ucs2_general_ci=
1, /* strxfrm_multiply */
2, /* mbminlen */
2, /* mbmaxlen */
- 0,
+ 0, /* min_sort_char */
+ 0xFFFF, /* max_sort_char */
&my_charset_ucs2_handler,
&my_collation_ucs2_general_ci_handler
};
@@ -1380,7 +1462,8 @@ CHARSET_INFO my_charset_ucs2_bin=
1, /* strxfrm_multiply */
2, /* mbminlen */
2, /* mbmaxlen */
- 0,
+ 0, /* min_sort_char */
+ 0xFFFF, /* max_sort_char */
&my_charset_ucs2_handler,
&my_collation_ucs2_bin_handler
};
diff --git a/strings/ctype-ujis.c b/strings/ctype-ujis.c
index acb1d049a03..997618d7645 100644
--- a/strings/ctype-ujis.c
+++ b/strings/ctype-ujis.c
@@ -8483,7 +8483,8 @@ CHARSET_INFO my_charset_ujis_japanese_ci=
1, /* strxfrm_multiply */
1, /* mbminlen */
3, /* mbmaxlen */
- 0,
+ 0, /* min_sort_char */
+ 0, /* max_sort_char */
&my_charset_handler,
&my_collation_ci_handler
};
@@ -8506,7 +8507,8 @@ CHARSET_INFO my_charset_ujis_bin=
1, /* strxfrm_multiply */
1, /* mbminlen */
3, /* mbmaxlen */
- 0,
+ 0, /* min_sort_char */
+ 0, /* max_sort_char */
&my_charset_handler,
&my_collation_mb_bin_handler
};
diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c
index cafc43f3f70..dca73e5a79f 100644
--- a/strings/ctype-utf8.c
+++ b/strings/ctype-utf8.c
@@ -2009,7 +2009,8 @@ CHARSET_INFO my_charset_utf8_general_ci=
1, /* strxfrm_multiply */
1, /* mbminlen */
3, /* mbmaxlen */
- 0,
+ 0, /* min_sort_char */
+ 0, /* max_sort_char */
&my_charset_handler,
&my_collation_ci_handler
};
@@ -2033,7 +2034,8 @@ CHARSET_INFO my_charset_utf8_bin=
1, /* strxfrm_multiply */
1, /* mbminlen */
3, /* mbmaxlen */
- 0,
+ 0, /* min_sort_char */
+ 0, /* max_sort_char */
&my_charset_handler,
&my_collation_mb_bin_handler
};
diff --git a/strings/ctype-win1250ch.c b/strings/ctype-win1250ch.c
index 889cf2d2dae..bda349f1988 100644
--- a/strings/ctype-win1250ch.c
+++ b/strings/ctype-win1250ch.c
@@ -629,7 +629,8 @@ CHARSET_INFO my_charset_cp1250_czech_ci =
2, /* strxfrm_multiply */
1, /* mbminlen */
1, /* mbmaxlen */
- 0,
+ 0, /* min_sort_char */
+ 0, /* max_sort_char */
&my_charset_8bit_handler,
&my_collation_czech_ci_handler
};