Commit 426d246f authored by Alexander Barkov's avatar Alexander Barkov

MDEV-5163 Merge WEIGHT_STRING function from MySQL-5.6

parent de8e306b
......@@ -285,7 +285,8 @@ struct my_collation_handler_st
const uchar *, size_t, const uchar *, size_t,
my_bool diff_if_only_endspace_difference);
size_t (*strnxfrm)(CHARSET_INFO *,
uchar *, size_t, const uchar *, size_t);
uchar *dst, size_t dstlen, uint nweights,
const uchar *src, size_t srclen, uint flags);
size_t (*strnxfrmlen)(CHARSET_INFO *, size_t);
my_bool (*like_range)(CHARSET_INFO *,
const char *s, size_t s_length,
......@@ -428,6 +429,7 @@ struct charset_info_st
my_wc_t max_sort_char; /* For LIKE optimization */
uchar pad_char;
my_bool escape_with_backslash_is_dangerous;
uchar levels_for_order;
MY_CHARSET_HANDLER *cset;
MY_COLLATION_HANDLER *coll;
......@@ -492,8 +494,9 @@ const uint16 *my_cs_contraction2_weight(CHARSET_INFO *cs, my_wc_t wc1,
my_wc_t wc2);
/* declarations for simple charsets */
extern size_t my_strnxfrm_simple(CHARSET_INFO *, uchar *, size_t,
const uchar *, size_t);
extern size_t my_strnxfrm_simple(CHARSET_INFO *,
uchar *dst, size_t dstlen, uint nweights,
const uchar *src, size_t srclen, uint flags);
size_t my_strnxfrmlen_simple(CHARSET_INFO *, size_t);
extern int my_strnncoll_simple(CHARSET_INFO *, const uchar *, size_t,
const uchar *, size_t, my_bool);
......@@ -662,13 +665,17 @@ int my_strcasecmp_mb_bin(CHARSET_INFO * cs __attribute__((unused)),
void my_hash_sort_mb_bin(CHARSET_INFO *cs __attribute__((unused)),
const uchar *key, size_t len,ulong *nr1, ulong *nr2);
size_t my_strnxfrm_mb(CHARSET_INFO *,
uchar *dst, size_t dstlen, uint nweights,
const uchar *src, size_t srclen, uint flags);
size_t my_strnxfrm_unicode(CHARSET_INFO *,
uchar *dst, size_t dstlen,
const uchar *src, size_t srclen);
uchar *dst, size_t dstlen, uint nweights,
const uchar *src, size_t srclen, uint flags);
size_t my_strnxfrm_unicode_full_bin(CHARSET_INFO *,
uchar *dst, size_t dstlen,
const uchar *src, size_t srclen);
uchar *dst, size_t dstlen, uint nweights,
const uchar *src, size_t srclen, uint flags);
size_t my_strnxfrmlen_unicode_full_bin(CHARSET_INFO *, size_t);
int my_wildcmp_unicode(CHARSET_INFO *cs,
......@@ -693,6 +700,13 @@ my_bool my_charset_is_ascii_based(CHARSET_INFO *cs);
my_bool my_charset_is_8bit_pure_ascii(CHARSET_INFO *cs);
uint my_charset_repertoire(CHARSET_INFO *cs);
uint my_strxfrm_flag_normalize(uint flags, uint nlevels);
void my_strxfrm_desc_and_reverse(uchar *str, uchar *strend,
uint flags, uint level);
size_t my_strxfrm_pad_desc_and_reverse(CHARSET_INFO *cs,
uchar *str, uchar *frmend, uchar *strend,
uint nweights, uint flags, uint level);
my_bool my_charset_is_ascii_compatible(CHARSET_INFO *cs);
const MY_CONTRACTIONS *my_charset_get_contractions(const CHARSET_INFO *cs,
......@@ -739,7 +753,8 @@ uint32 my_convert(char *to, uint32 to_length, CHARSET_INFO *to_cs,
#define my_binary_compare(s) ((s)->state & MY_CS_BINSORT)
#define use_strnxfrm(s) ((s)->state & MY_CS_STRNXFRM)
#define my_strnxfrm(s, a, b, c, d) ((s)->coll->strnxfrm((s), (a), (b), (c), (d)))
#define my_strnxfrm(cs, d, dl, s, sl) \
((cs)->coll->strnxfrm((cs), (d), (dl), (dl), (s), (sl), MY_STRXFRM_PAD_WITH_SPACE))
#define my_strnncoll(s, a, b, c, d) ((s)->coll->strnncoll((s), (a), (b), (c), (d), 0))
#define my_like_range(s, a, b, c, d, e, f, g, h, i, j) \
((s)->coll->like_range((s), (a), (b), (c), (d), (e), (f), (g), (h), (i), (j)))
......
......@@ -38,3 +38,17 @@ insert into t1 values ('u'),('ue'),(_latin1 0xFC);
select s1, hex(s1) from t1 order by s1, binary s1;
select group_concat(s1 order by binary s1) from t1 group by s1;
drop table t1;
#
# Check filesort for 'S' and "U+00DF SHARP S",
# for field and for item.
#
CREATE TABLE t1 AS SELECT REPEAT('a',1) AS a, 1 AS b LIMIT 0;
SHOW CREATE TABLE t1;
INSERT INTO t1 VALUES ('s',0),(_latin1 0xDF,1);
SELECT * FROM t1 ORDER BY a, b;
SELECT * FROM t1 ORDER BY a DESC, b;
SELECT * FROM t1 ORDER BY CONCAT(a), b;
SELECT * FROM t1 ORDER BY CONCAT(a) DESC, b;
DROP TABLE t1;
SELECT strcmp('a','a ');
SELECT strcmp('a\0','a' );
SELECT strcmp('a\0','a ');
SELECT strcmp('a\t','a' );
SELECT strcmp('a\t','a ');
select @@collation_connection;
select hex(weight_string('a'));
select hex(weight_string('A'));
select hex(weight_string('abc'));
select hex(weight_string('abc' as char(2)));
select hex(weight_string('abc' as char(3)));
select hex(weight_string('abc' as char(5)));
# Read 2 characters from the source string (the last character is not used).
select hex(weight_string('abc', 1, 2, 0xC0));
select hex(weight_string('abc', 2, 2, 0xC0));
select hex(weight_string('abc', 3, 2, 0xC0));
select hex(weight_string('abc', 4, 2, 0xC0));
select hex(weight_string('abc', 5, 2, 0xC0));
select hex(weight_string('abc',25, 2, 0xC0));
# Read 3 characters from the source string (the entire string is used).
select hex(weight_string('abc', 1, 3, 0xC0));
select hex(weight_string('abc', 2, 3, 0xC0));
select hex(weight_string('abc', 3, 3, 0xC0));
select hex(weight_string('abc', 4, 3, 0xC0));
select hex(weight_string('abc', 5, 3, 0xC0));
select hex(weight_string('abc',25, 3, 0xC0));
# Read 4 characters from the source string (extra space is added)
select hex(weight_string('abc', 1, 4, 0xC0));
select hex(weight_string('abc', 2, 4, 0xC0));
select hex(weight_string('abc', 3, 4, 0xC0));
select hex(weight_string('abc', 4, 4, 0xC0));
select hex(weight_string('abc', 5, 4, 0xC0));
select hex(weight_string('abc',25, 4, 0xC0));
select collation(cast(0x8140 as char));
select hex(weight_string(cast(0x6141 as char)));
select hex(weight_string(cast(0x8140 as char)));
select hex(weight_string(cast(0x8140 as char) as char(1)));
select hex(weight_string(cast(0x81408140 as char) as char(1)));
select hex(weight_string(cast(0x8140 as char) as char(3)));
select hex(weight_string(cast(0x81408140 as char) as char(3)));
select hex(weight_string(cast(0x408140 as char) as char(3)));
select hex(weight_string(cast(0x4081408140 as char) as char(3)));
select hex(weight_string(cast(0x40814081408140 as char) as char(3)));
select hex(weight_string(cast(0x4040814081408140 as char) as char(3)));
# Read 2 characters from the source string (the last character is not used)
select hex(weight_string(cast(0x814081408140 as char), 1, 2, 0xC0));
select hex(weight_string(cast(0x814081408140 as char), 2, 2, 0xC0));
select hex(weight_string(cast(0x814081408140 as char), 3, 2, 0xC0));
select hex(weight_string(cast(0x814081408140 as char), 4, 2, 0xC0));
select hex(weight_string(cast(0x814081408140 as char), 5, 2, 0xC0));
select hex(weight_string(cast(0x814081408140 as char),25, 2, 0xC0));
# Read 3 characters from the source string (the entire string is used)
select hex(weight_string(cast(0x814081408140 as char), 1, 3, 0xC0));
select hex(weight_string(cast(0x814081408140 as char), 2, 3, 0xC0));
select hex(weight_string(cast(0x814081408140 as char), 3, 3, 0xC0));
select hex(weight_string(cast(0x814081408140 as char), 4, 3, 0xC0));
select hex(weight_string(cast(0x814081408140 as char), 5, 3, 0xC0));
select hex(weight_string(cast(0x814081408140 as char),25, 3, 0xC0));
# Read 4 characters from the source string (extra space is added)
select hex(weight_string(cast(0x814081408140 as char), 1, 4, 0xC0));
select hex(weight_string(cast(0x814081408140 as char), 2, 4, 0xC0));
select hex(weight_string(cast(0x814081408140 as char), 3, 4, 0xC0));
select hex(weight_string(cast(0x814081408140 as char), 4, 4, 0xC0));
select hex(weight_string(cast(0x814081408140 as char), 5, 4, 0xC0));
select hex(weight_string(cast(0x814081408140 as char),25, 4, 0xC0));
select collation(cast(0xA1A1 as char));
select hex(weight_string(cast(0x6141 as char)));
select hex(weight_string(cast(0x8EA1 as char)));
select hex(weight_string(cast(0x8EA1 as char) as char(1)));
select hex(weight_string(cast(0x8EA18EA1 as char) as char(1)));
select hex(weight_string(cast(0x8EA1 as char) as char(3)));
select hex(weight_string(cast(0x8EA18EA1 as char) as char(3)));
select hex(weight_string(cast(0x408EA1 as char) as char(3)));
select hex(weight_string(cast(0x408EA18EA1 as char) as char(3)));
select hex(weight_string(cast(0x408EA18EA18EA1 as char) as char(3)));
select hex(weight_string(cast(0x40408EA18EA18EA1 as char) as char(3)));
# Read 2 characters from the source string (the last character is not used)
select hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 2, 0xC0));
select hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 2, 0xC0));
select hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 2, 0xC0));
select hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 2, 0xC0));
select hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 2, 0xC0));
select hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 2, 0xC0));
# Read 3 characters from the source string (the entire string is used)
select hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 3, 0xC0));
select hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 3, 0xC0));
select hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 3, 0xC0));
select hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 3, 0xC0));
select hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 3, 0xC0));
select hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 3, 0xC0));
# Read 4 characters from the source string (extra space is added)
select hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 4, 0xC0));
select hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 4, 0xC0));
select hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 4, 0xC0));
select hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 4, 0xC0));
select hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 4, 0xC0));
select hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 4, 0xC0));
select collation(cast(0x8FA2C3 as char));
select hex(weight_string(cast(0x6141 as char)));
select hex(weight_string(cast(0x8FA2C3 as char)));
select hex(weight_string(cast(0x8FA2C3 as char) as char(1)));
select hex(weight_string(cast(0x8FA2C38FA2C3 as char) as char(1)));
select hex(weight_string(cast(0x8FA2C3 as char) as char(3)));
select hex(weight_string(cast(0x8FA2C38FA2C3 as char) as char(3)));
select hex(weight_string(cast(0x408FA2C3 as char) as char(3)));
select hex(weight_string(cast(0x408FA2C38FA2C3 as char) as char(3)));
select hex(weight_string(cast(0x408FA2C38FA2C38FA2C3 as char) as char(3)));
select hex(weight_string(cast(0x40408FA2C38FA2C38FA2C3 as char) as char(3)));
# Read 2 characters from the source string (the last character is not used)
select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 1, 2, 0xC0));
select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 2, 2, 0xC0));
select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 3, 2, 0xC0));
select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 4, 2, 0xC0));
select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 5, 2, 0xC0));
select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char),25, 2, 0xC0));
# Read 3 characters from the source string (the entire string is used)
select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 1, 3, 0xC0));
select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 2, 3, 0xC0));
select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 3, 3, 0xC0));
select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 4, 3, 0xC0));
select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 5, 3, 0xC0));
select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char),25, 3, 0xC0));
# Read 4 characters from the source string (extra space is added)
select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 1, 4, 0xC0));
select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 2, 4, 0xC0));
select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 3, 4, 0xC0));
select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 4, 4, 0xC0));
select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 5, 4, 0xC0));
select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char),25, 4, 0xC0));
select collation(cast(0xA1A1 as char));
select hex(weight_string(cast(0x6141 as char)));
select hex(weight_string(cast(0xA1A1 as char)));
select hex(weight_string(cast(0xA1A1 as char) as char(1)));
select hex(weight_string(cast(0xA1A1A1A1 as char) as char(1)));
select hex(weight_string(cast(0xA1A1 as char) as char(3)));
select hex(weight_string(cast(0xA1A1A1A1 as char) as char(3)));
select hex(weight_string(cast(0x40A1A1 as char) as char(3)));
select hex(weight_string(cast(0x40A1A1A1A1 as char) as char(3)));
select hex(weight_string(cast(0x40A1A1A1A1A1A1 as char) as char(3)));
select hex(weight_string(cast(0x4040A1A1A1A1A1A1 as char) as char(3)));
# Read 2 characters from the source string (the last character is not used)
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 2, 0xC0));
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 2, 0xC0));
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 2, 0xC0));
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 2, 0xC0));
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 2, 0xC0));
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 2, 0xC0));
# Read 3 characters from the source string (the entire string is used)
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 3, 0xC0));
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 3, 0xC0));
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 3, 0xC0));
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 3, 0xC0));
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 3, 0xC0));
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 3, 0xC0));
# Read 4 characters from the source string (extra space is added)
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 4, 0xC0));
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 4, 0xC0));
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 4, 0xC0));
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 4, 0xC0));
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 4, 0xC0));
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 4, 0xC0));
select @@collation_connection;
select collation(cast(_latin1 0xDF as char));
select hex(weight_string('s'));
select hex(weight_string(cast(_latin1 0xDF as char)));
select hex(weight_string(cast(_latin1 0xDF as char) as char(1)));
select hex(weight_string('c'));
select hex(weight_string('h'));
select hex(weight_string('ch'));
select hex(weight_string('i'));
# contraction 'ch' plus expansion 'sharp s'
select hex(weight_string(cast(_latin1 0x6368DF as char)));
select hex(weight_string(cast(_latin1 0x6368DF as char) as char(1)));
select hex(weight_string(cast(_latin1 0x6368DF as char) as char(2)));
select hex(weight_string(cast(_latin1 0x6368DF as char) as char(3)));
select hex(weight_string(cast(_latin1 0x6368DF as char) as char(4)));
# expansion 'sharp s' plus contraction 'ch'
select hex(weight_string(cast(_latin1 0xDF6368 as char)));
select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(1)));
select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(2)));
select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(3)));
select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(4)));
# contraction 'ch' plus expansion 'sharp s'
select hex(weight_string(cast(_latin1 0x6368DF as char), 1, 2, 0xC0));
select hex(weight_string(cast(_latin1 0x6368DF as char), 2, 2, 0xC0));
select hex(weight_string(cast(_latin1 0x6368DF as char), 3, 2, 0xC0));
select hex(weight_string(cast(_latin1 0x6368DF as char), 4, 2, 0xC0));
select hex(weight_string(cast(_latin1 0x6368DF as char),25, 2, 0xC0));
select hex(weight_string(cast(_latin1 0x6368DF as char), 1, 3, 0xC0));
select hex(weight_string(cast(_latin1 0x6368DF as char), 2, 3, 0xC0));
select hex(weight_string(cast(_latin1 0x6368DF as char), 3, 3, 0xC0));
select hex(weight_string(cast(_latin1 0x6368DF as char), 4, 3, 0xC0));
select hex(weight_string(cast(_latin1 0x6368DF as char),25, 3, 0xC0));
select hex(weight_string(cast(_latin1 0x6368DF as char), 1, 4, 0xC0));
select hex(weight_string(cast(_latin1 0x6368DF as char), 2, 4, 0xC0));
select hex(weight_string(cast(_latin1 0x6368DF as char), 3, 4, 0xC0));
select hex(weight_string(cast(_latin1 0x6368DF as char), 4, 4, 0xC0));
select hex(weight_string(cast(_latin1 0x6368DF as char),25, 4, 0xC0));
# expansion 'sharp s' plus contraction 'ch'
select hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 2,0xC0));
select hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 2,0xC0));
select hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 2,0xC0));
select hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 2,0xC0));
select hex(weight_string(cast(_latin1 0xDF6368 as char),25, 2,0xC0));
select hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 3,0xC0));
select hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 3,0xC0));
select hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 3,0xC0));
select hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 3,0xC0));
select hex(weight_string(cast(_latin1 0xDF6368 as char),25, 3,0xC0));
select hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 4,0xC0));
select hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 4,0xC0));
select hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 4,0xC0));
select hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 4,0xC0));
select hex(weight_string(cast(_latin1 0xDF6368 as char),25, 4,0xC0));
select @@collation_connection;
select hex(weight_string(cast(_latin1 0x80 as char)));
select hex(weight_string(cast(_latin1 0x808080 as char)));
select hex(weight_string(cast(_latin1 0x808080 as char) as char(2)));
select hex(weight_string(cast(_latin1 0x808080 as char) as char(3)));
select hex(weight_string(cast(_latin1 0x808080 as char) as char(5)));
# Read 2 characters from the source string (the last character is not used).
select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0));
select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0));
select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0));
select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0));
select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0));
select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0));
# Read 3 characters from the source string (the entire string is used).
select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0));
select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0));
select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0));
select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0));
select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0));
select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0));
# Read 4 characters from the source string (extra space is added)
select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0));
select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0));
select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0));
select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0));
select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0));
select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0));
select @@collation_connection;
select hex(weight_string('a' LEVEL 1));
select hex(weight_string('A' LEVEL 1));
select hex(weight_string('abc' LEVEL 1));
select hex(weight_string('abc' as char(2) LEVEL 1));
select hex(weight_string('abc' as char(3) LEVEL 1));
select hex(weight_string('abc' as char(5) LEVEL 1));
select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
select @@collation_connection;
select hex(weight_string('a' LEVEL 1,2));
select hex(weight_string('a' LEVEL 1-2));
select hex(weight_string('A' LEVEL 1,2));
select hex(weight_string('A' LEVEL 1-2));
select @@collation_connection;
select hex(weight_string('a' LEVEL 1,3));
select hex(weight_string('a' LEVEL 1-3));
select hex(weight_string('A' LEVEL 1,3));
select hex(weight_string('A' LEVEL 1-3));
select hex(weight_string('a' LEVEL 1,4));
select hex(weight_string('a' LEVEL 1-4));
select hex(weight_string('A' LEVEL 1,4));
select hex(weight_string('A' LEVEL 1-4));
select hex(weight_string('a' LEVEL 2,3));
select hex(weight_string('a' LEVEL 2-3));
select hex(weight_string('A' LEVEL 2,3));
select hex(weight_string('A' LEVEL 2-3));
select hex(weight_string('a' LEVEL 2,4));
select hex(weight_string('a' LEVEL 2-4));
select hex(weight_string('A' LEVEL 2,4));
select hex(weight_string('A' LEVEL 2-4));
select hex(weight_string('a' LEVEL 3,4));
select hex(weight_string('a' LEVEL 3-4));
select hex(weight_string('A' LEVEL 3,4));
select hex(weight_string('A' LEVEL 3-4));
select hex(weight_string('a' LEVEL 1,2,3,4));
select hex(weight_string('a' LEVEL 2,3,4));
select hex(weight_string('a' LEVEL 1,3,4));
select hex(weight_string('a' LEVEL 1,2,3));
# If any number is less than 1, it is treated as 1.
select hex(weight_string('a' LEVEL 0));
#If any number is greater than the maximum, it is treated as the maximum.
select hex(weight_string('a' LEVEL 8));
select hex(weight_string('a' LEVEL 1,8));
select @@collation_connection;
select hex(weight_string('a' LEVEL 2));
select hex(weight_string('A' LEVEL 2));
select hex(weight_string('abc' LEVEL 2));
select hex(weight_string('abc' as char(2) LEVEL 2));
select hex(weight_string('abc' as char(3) LEVEL 2));
select hex(weight_string('abc' as char(5) LEVEL 2));
select @@collation_connection;
select hex(weight_string('a' LEVEL 3));
select hex(weight_string('A' LEVEL 3));
select hex(weight_string('abc' LEVEL 3));
select hex(weight_string('abc' as char(2) LEVEL 3));
select hex(weight_string('abc' as char(3) LEVEL 3));
select hex(weight_string('Abc' as char(5) LEVEL 3));
select hex(weight_string('Abc' as char(5) LEVEL 3 REVERSE));
select hex(weight_string('Abc' as char(5) LEVEL 3 DESC));
select hex(weight_string('Abc' as char(5) LEVEL 3 DESC REVERSE));
select @@collation_connection;
select hex(weight_string('a' LEVEL 4));
select hex(weight_string('A' LEVEL 4));
select hex(weight_string('abc' LEVEL 4));
select hex(weight_string('abc' as char(2) LEVEL 4));
select hex(weight_string('abc' as char(3) LEVEL 4));
select hex(weight_string('abc' as char(5) LEVEL 4));
select hex(weight_string('abc' as char(5) LEVEL 4 REVERSE));
select hex(weight_string('abc' as char(5) LEVEL 4 DESC));
select hex(weight_string('abc' as char(5) LEVEL 4 DESC REVERSE));
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -361,6 +361,31 @@ ss,
u
ue,
drop table t1;
CREATE TABLE t1 AS SELECT REPEAT('a',1) AS a, 1 AS b LIMIT 0;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varchar(1) COLLATE latin1_german2_ci NOT NULL DEFAULT '',
`b` int(1) NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci
INSERT INTO t1 VALUES ('s',0),(_latin1 0xDF,1);
SELECT * FROM t1 ORDER BY a, b;
a b
s 0
1
SELECT * FROM t1 ORDER BY a DESC, b;
a b
1
s 0
SELECT * FROM t1 ORDER BY CONCAT(a), b;
a b
s 0
1
SELECT * FROM t1 ORDER BY CONCAT(a) DESC, b;
a b
1
s 0
DROP TABLE t1;
SET NAMES latin1;
CREATE TABLE t1 (
col1 varchar(255) NOT NULL default ''
......@@ -379,3 +404,242 @@ select * from t1 where length(s1)=1 and s1='oe';
s1
drop table t1;
End of 5.1 tests
#
# Start of 5.6 tests
#
#
# WL#3664 WEIGHT_STRING
#
set @@collation_connection=latin1_german2_ci;
select @@collation_connection;
@@collation_connection
latin1_german2_ci
select hex(weight_string('a'));
hex(weight_string('a'))
41
select hex(weight_string('A'));
hex(weight_string('A'))
41
select hex(weight_string('abc'));
hex(weight_string('abc'))
414243
select hex(weight_string('abc' as char(2)));
hex(weight_string('abc' as char(2)))
4142
select hex(weight_string('abc' as char(3)));
hex(weight_string('abc' as char(3)))
414243
select hex(weight_string('abc' as char(5)));
hex(weight_string('abc' as char(5)))
4142432020
select hex(weight_string('abc', 1, 2, 0xC0));
hex(weight_string('abc', 1, 2, 0xC0))
41
select hex(weight_string('abc', 2, 2, 0xC0));
hex(weight_string('abc', 2, 2, 0xC0))
4142
select hex(weight_string('abc', 3, 2, 0xC0));
hex(weight_string('abc', 3, 2, 0xC0))
414220
select hex(weight_string('abc', 4, 2, 0xC0));
hex(weight_string('abc', 4, 2, 0xC0))
41422020
select hex(weight_string('abc', 5, 2, 0xC0));
hex(weight_string('abc', 5, 2, 0xC0))
4142202020
select hex(weight_string('abc',25, 2, 0xC0));
hex(weight_string('abc',25, 2, 0xC0))
41422020202020202020202020202020202020202020202020
select hex(weight_string('abc', 1, 3, 0xC0));
hex(weight_string('abc', 1, 3, 0xC0))
41
select hex(weight_string('abc', 2, 3, 0xC0));
hex(weight_string('abc', 2, 3, 0xC0))
4142
select hex(weight_string('abc', 3, 3, 0xC0));
hex(weight_string('abc', 3, 3, 0xC0))
414243
select hex(weight_string('abc', 4, 3, 0xC0));
hex(weight_string('abc', 4, 3, 0xC0))
41424320
select hex(weight_string('abc', 5, 3, 0xC0));
hex(weight_string('abc', 5, 3, 0xC0))
4142432020
select hex(weight_string('abc',25, 3, 0xC0));
hex(weight_string('abc',25, 3, 0xC0))
41424320202020202020202020202020202020202020202020
select hex(weight_string('abc', 1, 4, 0xC0));
hex(weight_string('abc', 1, 4, 0xC0))
41
select hex(weight_string('abc', 2, 4, 0xC0));
hex(weight_string('abc', 2, 4, 0xC0))
4142
select hex(weight_string('abc', 3, 4, 0xC0));
hex(weight_string('abc', 3, 4, 0xC0))
414243
select hex(weight_string('abc', 4, 4, 0xC0));
hex(weight_string('abc', 4, 4, 0xC0))
41424320
select hex(weight_string('abc', 5, 4, 0xC0));
hex(weight_string('abc', 5, 4, 0xC0))
4142432020
select hex(weight_string('abc',25, 4, 0xC0));
hex(weight_string('abc',25, 4, 0xC0))
41424320202020202020202020202020202020202020202020
select @@collation_connection;
@@collation_connection
latin1_german2_ci
select hex(weight_string(cast(_latin1 0x80 as char)));
hex(weight_string(cast(_latin1 0x80 as char)))
80
select hex(weight_string(cast(_latin1 0x808080 as char)));
hex(weight_string(cast(_latin1 0x808080 as char)))
808080
select hex(weight_string(cast(_latin1 0x808080 as char) as char(2)));
hex(weight_string(cast(_latin1 0x808080 as char) as char(2)))
8080
select hex(weight_string(cast(_latin1 0x808080 as char) as char(3)));
hex(weight_string(cast(_latin1 0x808080 as char) as char(3)))
808080
select hex(weight_string(cast(_latin1 0x808080 as char) as char(5)));
hex(weight_string(cast(_latin1 0x808080 as char) as char(5)))
8080802020
select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0));
hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0))
80
select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0));
hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0))
8080
select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0));
hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0))
808020
select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0));
hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0))
80802020
select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0));
hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0))
8080202020
select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0));
hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0))
80802020202020202020202020202020202020202020202020
select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0));
hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0))
80
select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0));
hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0))
8080
select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0));
hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0))
808080
select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0));
hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0))
80808020
select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0));
hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0))
8080802020
select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0));
hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0))
80808020202020202020202020202020202020202020202020
select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0));
hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0))
80
select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0));
hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0))
8080
select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0));
hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0))
808080
select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0));
hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0))
80808020
select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0));
hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0))
8080802020
select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0));
hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0))
80808020202020202020202020202020202020202020202020
select @@collation_connection;
@@collation_connection
latin1_german2_ci
select hex(weight_string('a' LEVEL 1));
hex(weight_string('a' LEVEL 1))
41
select hex(weight_string('A' LEVEL 1));
hex(weight_string('A' LEVEL 1))
41
select hex(weight_string('abc' LEVEL 1));
hex(weight_string('abc' LEVEL 1))
414243
select hex(weight_string('abc' as char(2) LEVEL 1));
hex(weight_string('abc' as char(2) LEVEL 1))
4142
select hex(weight_string('abc' as char(3) LEVEL 1));
hex(weight_string('abc' as char(3) LEVEL 1))
414243
select hex(weight_string('abc' as char(5) LEVEL 1));
hex(weight_string('abc' as char(5) LEVEL 1))
4142432020
select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
2020434241
select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
hex(weight_string('abc' as char(5) LEVEL 1 DESC))
BEBDBCDFDF
select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
DFDFBCBDBE
select hex(weight_string(''));
hex(weight_string(''))
4145
select hex(weight_string(''));
hex(weight_string(''))
4145
select hex(weight_string(''));
hex(weight_string(''))
4F45
select hex(weight_string(''));
hex(weight_string(''))
4F45
select hex(weight_string(''));
hex(weight_string(''))
5545
select hex(weight_string(''));
hex(weight_string(''))
5545
select hex(weight_string('S'));
hex(weight_string('S'))
53
select hex(weight_string('s'));
hex(weight_string('s'))
53
select hex(weight_string(''));
hex(weight_string(''))
5353
select hex(weight_string('' as char(1)));
hex(weight_string('' as char(1)))
41
select hex(weight_string('' as char(1)));
hex(weight_string('' as char(1)))
4F
select hex(weight_string('' as char(1)));
hex(weight_string('' as char(1)))
55
select hex(weight_string('' as char(1)));
hex(weight_string('' as char(1)))
53
select hex(weight_string('x' as char(2)));
hex(weight_string('x' as char(2)))
5841
select hex(weight_string('x' as char(2)));
hex(weight_string('x' as char(2)))
584F
select hex(weight_string('x' as char(2)));
hex(weight_string('x' as char(2)))
5855
select hex(weight_string('x' as char(2)));
hex(weight_string('x' as char(2)))
5853
#
# End of 5.6 tests
#
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -977,6 +977,31 @@ ss
u,ü
ue
drop table t1;
CREATE TABLE t1 AS SELECT REPEAT('a',1) AS a, 1 AS b LIMIT 0;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varchar(1) CHARACTER SET utf8mb4 NOT NULL DEFAULT '',
`b` int(1) NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES ('s',0),(_latin1 0xDF,1);
SELECT * FROM t1 ORDER BY a, b;
a b
s 0
ß 1
SELECT * FROM t1 ORDER BY a DESC, b;
a b
s 0
ß 1
SELECT * FROM t1 ORDER BY CONCAT(a), b;
a b
s 0
ß 1
SELECT * FROM t1 ORDER BY CONCAT(a) DESC, b;
a b
s 0
ß 1
DROP TABLE t1;
SET collation_connection='utf8mb4_bin';
create table t1 select repeat('a',4000) a;
delete from t1;
......
......@@ -916,6 +916,31 @@ ss
u,ü
ue
drop table t1;
CREATE TABLE t1 AS SELECT REPEAT('a',1) AS a, 1 AS b LIMIT 0;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varchar(1) CHARACTER SET utf8mb4 NOT NULL DEFAULT '',
`b` int(1) NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES ('s',0),(_latin1 0xDF,1);
SELECT * FROM t1 ORDER BY a, b;
a b
s 0
ß 1
SELECT * FROM t1 ORDER BY a DESC, b;
a b
s 0
ß 1
SELECT * FROM t1 ORDER BY CONCAT(a), b;
a b
s 0
ß 1
SELECT * FROM t1 ORDER BY CONCAT(a) DESC, b;
a b
s 0
ß 1
DROP TABLE t1;
SET collation_connection='utf8mb4_bin';
create table t1 select repeat('a',4000) a;
delete from t1;
......
......@@ -977,6 +977,31 @@ ss
u,ü
ue
drop table t1;
CREATE TABLE t1 AS SELECT REPEAT('a',1) AS a, 1 AS b LIMIT 0;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varchar(1) CHARACTER SET utf8mb4 NOT NULL DEFAULT '',
`b` int(1) NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES ('s',0),(_latin1 0xDF,1);
SELECT * FROM t1 ORDER BY a, b;
a b
s 0
ß 1
SELECT * FROM t1 ORDER BY a DESC, b;
a b
s 0
ß 1
SELECT * FROM t1 ORDER BY CONCAT(a), b;
a b
s 0
ß 1
SELECT * FROM t1 ORDER BY CONCAT(a) DESC, b;
a b
s 0
ß 1
DROP TABLE t1;
SET collation_connection='utf8mb4_bin';
create table t1 select repeat('a',4000) a;
delete from t1;
......
This diff is collapsed.
This diff is collapsed.
......@@ -307,6 +307,7 @@
<alias>l1</alias>
<alias>latin1</alias>
<collation name="latin1_test" id="99" order="test"/>
<collation name="latin1_test2" id="332" order="test"/>
</charset>
<charset name="utf8">
......
This diff is collapsed.
This diff is collapsed.
--character-sets-dir=$MYSQL_TEST_DIR/std_data/
--default-storage-engine=InnoDB
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment