Commit 9ce639af authored by Sergei Golubchik's avatar Sergei Golubchik

don't export all charsets to plugins

don't use internal server collation symbol names, use collation
properties and collation IDs, they are much more stable.
parent 76a262cd
This diff is collapsed.
......@@ -4827,8 +4827,8 @@ bool ha_rocksdb::get_error_message(const int error, String *const buf) {
}
/* MyRocks supports only the following collations for indexed columns */
static const std::set<const my_core::CHARSET_INFO *> RDB_INDEX_COLLATIONS = {
&my_charset_bin, &my_charset_utf8_bin, &my_charset_latin1_bin};
static const std::set<uint> RDB_INDEX_COLLATIONS = {
COLLATION_BINARY, COLLATION_UTF8_BIN, COLLATION_LATIN1_BIN};
static bool
rdb_is_index_collation_supported(const my_core::Field *const field) {
......@@ -4836,7 +4836,7 @@ rdb_is_index_collation_supported(const my_core::Field *const field) {
/* Handle [VAR](CHAR|BINARY) or TEXT|BLOB */
if (type == MYSQL_TYPE_VARCHAR || type == MYSQL_TYPE_STRING ||
type == MYSQL_TYPE_BLOB) {
return RDB_INDEX_COLLATIONS.find(field->charset()) !=
return RDB_INDEX_COLLATIONS.find(field->charset()->number) !=
RDB_INDEX_COLLATIONS.end();
}
return true;
......@@ -4971,7 +4971,7 @@ int ha_rocksdb::create_cfs(
if (collation_err != "") {
collation_err += ", ";
}
collation_err += coll->name;
collation_err += get_charset_name(coll);
}
my_printf_error(
ER_UNKNOWN_ERROR, "Unsupported collation on string indexed "
......
......@@ -201,6 +201,17 @@ const char *const RDB_CF_NAME_QUALIFIER = "cfname";
#define RDB_BQUAL_SZ 1
#define RDB_XIDHDR_LEN (RDB_FORMATID_SZ + RDB_GTRID_SZ + RDB_BQUAL_SZ)
/* collations, used in MariaRocks */
enum collations_used {
COLLATION_UTF8MB4_BIN = 46,
COLLATION_LATIN1_BIN = 47,
COLLATION_UTF16LE_BIN = 55,
COLLATION_UTF32_BIN = 61,
COLLATION_UTF16_BIN = 62,
COLLATION_BINARY = 63,
COLLATION_UTF8_BIN = 83
};
/*
To fix an unhandled exception we specify the upper bound as LONGLONGMAX
instead of ULONGLONGMAX because the latter is -1 and causes an exception when
......
......@@ -280,7 +280,7 @@ set @tmp_rocksdb_strict_collation_check= @@rocksdb_strict_collation_check;
set global rocksdb_strict_collation_check=1;
CREATE TABLE t1 (a INT, b TEXT);
ALTER TABLE t1 ADD KEY kb(b(10));
ERROR HY000: Unsupported collation on string indexed column test.t1.b Use binary collation (binary, latin1_bin, utf8_bin).
ERROR HY000: Unsupported collation on string indexed column test.t1.b Use binary collation (latin1_bin, binary, utf8_bin).
ALTER TABLE t1 ADD PRIMARY KEY(a);
DROP TABLE t1;
set global rocksdb_strict_collation_check= @tmp_rocksdb_strict_collation_check;
......
......@@ -1690,7 +1690,7 @@ static int rdb_unpack_binary_or_utf8_varchar(
/*
Now, we need to decode used_bytes of data and append them to the value.
*/
if (fpi->m_varchar_charset == &my_charset_utf8_bin) {
if (fpi->m_varchar_charset->number == COLLATION_UTF8_BIN) {
if (used_bytes & 1) {
/*
UTF-8 characters are encoded into two-byte entities. There is no way
......@@ -1793,7 +1793,7 @@ static int rdb_unpack_binary_or_utf8_varchar_space_pad(
}
// Now, need to decode used_bytes of data and append them to the value.
if (fpi->m_varchar_charset == &my_charset_utf8_bin) {
if (fpi->m_varchar_charset->number == COLLATION_UTF8_BIN) {
if (used_bytes & 1) {
/*
UTF-8 characters are encoded into two-byte entities. There is no way
......@@ -2239,7 +2239,8 @@ std::array<const Rdb_collation_codec *, MY_ALL_CHARSETS_SIZE>
mysql_mutex_t rdb_collation_data_mutex;
static bool rdb_is_collation_supported(const my_core::CHARSET_INFO *const cs) {
return (cs->coll == &my_collation_8bit_simple_ci_handler);
return cs->strxfrm_multiply==1 && cs->mbmaxlen == 1 &&
!(cs->state & (MY_CS_BINSORT | MY_CS_NOPAD));
}
static const Rdb_collation_codec *
......@@ -2255,7 +2256,7 @@ rdb_init_collation_mapping(const my_core::CHARSET_INFO *const cs) {
Rdb_collation_codec *cur = nullptr;
// Compute reverse mapping for simple collations.
if (cs->coll == &my_collation_8bit_simple_ci_handler) {
if (rdb_is_collation_supported(cs)) {
cur = new Rdb_collation_codec;
std::map<uchar, std::vector<uchar>> rev_map;
size_t max_conflict_size = 0;
......@@ -2302,8 +2303,8 @@ rdb_init_collation_mapping(const my_core::CHARSET_INFO *const cs) {
static int get_segment_size_from_collation(const CHARSET_INFO *const cs) {
int ret;
if (cs == &my_charset_utf8mb4_bin || cs == &my_charset_utf16_bin ||
cs == &my_charset_utf16le_bin || cs == &my_charset_utf32_bin) {
if (cs->number == COLLATION_UTF8MB4_BIN || cs->number == COLLATION_UTF16_BIN ||
cs->number == COLLATION_UTF16LE_BIN || cs->number == COLLATION_UTF32_BIN) {
/*
In these collations, a character produces one weight, which is 3 bytes.
Segment has 3 characters, add one byte for VARCHAR_CMP_* marker, and we
......@@ -2424,7 +2425,7 @@ bool Rdb_field_packing::setup(const Rdb_key_def *const key_descr,
//
// See Field_blob::make_sort_key for details.
m_max_image_len =
key_length + (field->charset() == &my_charset_bin
key_length + (field->charset()->number == COLLATION_BINARY
? reinterpret_cast<const Field_blob *>(field)
->pack_length_no_ptr()
: 0);
......@@ -2475,7 +2476,7 @@ bool Rdb_field_packing::setup(const Rdb_key_def *const key_descr,
DBUG_EXECUTE_IF("myrocks_enable_unknown_collation_index_only_scans",
use_unknown_collation = true;);
if (cs == &my_charset_bin) {
if (cs->number == COLLATION_BINARY) {
// - SQL layer pads BINARY(N) so that it always is N bytes long.
// - For VARBINARY(N), values may have different lengths, so we're using
// variable-length encoding. This is also the only charset where the
......@@ -2483,7 +2484,7 @@ bool Rdb_field_packing::setup(const Rdb_key_def *const key_descr,
m_unpack_func = is_varchar ? rdb_unpack_binary_or_utf8_varchar
: rdb_unpack_binary_str;
res = true;
} else if (cs == &my_charset_latin1_bin || cs == &my_charset_utf8_bin) {
} else if (cs->number == COLLATION_LATIN1_BIN || cs->number == COLLATION_UTF8_BIN) {
// For _bin collations, mem-comparable form of the string is the string
// itself.
......@@ -2504,7 +2505,7 @@ bool Rdb_field_packing::setup(const Rdb_key_def *const key_descr,
} else {
// SQL layer pads CHAR(N) values to their maximum length.
// We just store that and restore it back.
m_unpack_func = (cs == &my_charset_latin1_bin) ? rdb_unpack_binary_str
m_unpack_func = (cs->number == COLLATION_LATIN1_BIN) ? rdb_unpack_binary_str
: rdb_unpack_utf8_str;
}
res = true;
......
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