summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Petrunia <psergey@askmonty.org>2017-12-12 01:33:03 +0300
committerSergei Petrunia <psergey@askmonty.org>2017-12-12 01:33:03 +0300
commite12f77a7e3c29a1c1418e2b87194d0f06e2711e2 (patch)
tree986f955f0a4713c851fda6937e4ac04a183cb58e
parent13b9ec651a807be59139fc295431d7ad14d3c8db (diff)
downloadmariadb-git-e12f77a7e3c29a1c1418e2b87194d0f06e2711e2.tar.gz
MDEV-14389: MyRocks and NOPAD collations
Disallow use of NOPAD collations in indexed columns.
-rw-r--r--sql/share/errmsg-utf8.txt4
-rw-r--r--storage/rocksdb/ha_rocksdb.cc27
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/mariadb_port_fixes.result9
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/mariadb_port_fixes.test13
4 files changed, 50 insertions, 3 deletions
diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt
index 32f1a25e126..528dc7107e6 100644
--- a/sql/share/errmsg-utf8.txt
+++ b/sql/share/errmsg-utf8.txt
@@ -7749,3 +7749,7 @@ ER_NET_OK_PACKET_TOO_LARGE
ER_GEOJSON_EMPTY_COORDINATES
eng "Incorrect GeoJSON format - empty 'coordinates' array."
+
+ER_MYROCKS_CANT_NOPAD_COLLATION
+ eng "MyRocks doesn't currently support collations with \"No pad\" attribute."
+
diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc
index e08329ab61e..564832993ce 100644
--- a/storage/rocksdb/ha_rocksdb.cc
+++ b/storage/rocksdb/ha_rocksdb.cc
@@ -5964,6 +5964,19 @@ rdb_is_index_collation_supported(const my_core::Field *const field) {
return true;
}
+
+static bool
+rdb_field_uses_nopad_collation(const my_core::Field *const field) {
+ const my_core::enum_field_types type = field->real_type();
+ /* Handle [VAR](CHAR|BINARY) or TEXT|BLOB */
+ if (type == MYSQL_TYPE_VARCHAR || type == MYSQL_TYPE_STRING ||
+ type == MYSQL_TYPE_BLOB) {
+ return (field->charset()->state & MY_CS_NOPAD);
+ }
+ return false;
+}
+
+
/*
Create structures needed for storing data in rocksdb. This is called when the
table is created. The structures will be shared by all TABLE* objects.
@@ -6072,8 +6085,7 @@ int ha_rocksdb::create_cfs(
for (uint i = 0; i < tbl_def_arg->m_key_count; i++) {
rocksdb::ColumnFamilyHandle *cf_handle;
- if (rocksdb_strict_collation_check &&
- !is_hidden_pk(i, table_arg, tbl_def_arg) &&
+ if (!is_hidden_pk(i, table_arg, tbl_def_arg) &&
tbl_def_arg->base_tablename().find(tmp_file_prefix) != 0) {
if (!tsys_set)
{
@@ -6085,7 +6097,16 @@ int ha_rocksdb::create_cfs(
for (uint part = 0; part < table_arg->key_info[i].ext_key_parts;
part++)
{
- if (!rdb_is_index_collation_supported(
+ /* MariaDB: disallow NOPAD collations */
+ if (rdb_field_uses_nopad_collation(
+ table_arg->key_info[i].key_part[part].field))
+ {
+ my_error(ER_MYROCKS_CANT_NOPAD_COLLATION, MYF(0));
+ DBUG_RETURN(HA_EXIT_FAILURE);
+ }
+
+ if (rocksdb_strict_collation_check &&
+ !rdb_is_index_collation_supported(
table_arg->key_info[i].key_part[part].field) &&
!rdb_collation_exceptions->matches(tablename_sys)) {
std::string collation_err;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/mariadb_port_fixes.result b/storage/rocksdb/mysql-test/rocksdb/r/mariadb_port_fixes.result
index 686b5637f7d..f590fd22dff 100644
--- a/storage/rocksdb/mysql-test/rocksdb/r/mariadb_port_fixes.result
+++ b/storage/rocksdb/mysql-test/rocksdb/r/mariadb_port_fixes.result
@@ -55,3 +55,12 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range a a 32 NULL # Using where
drop table t1,t2;
set global rocksdb_strict_collation_check=@tmp_rscc;
+#
+# MDEV-14389: MyRocks and NOPAD collations
+#
+create table t1 (pk varchar(10) collate latin1_nopad_bin, primary key(pk)) engine=rocksdb;
+ERROR HY000: MyRocks doesn't currently support collations with "No pad" attribute.
+set global rocksdb_strict_collation_check=off;
+create table t1 (pk varchar(10) collate latin1_nopad_bin, primary key(pk)) engine=rocksdb;
+ERROR HY000: MyRocks doesn't currently support collations with "No pad" attribute.
+set global rocksdb_strict_collation_check=@tmp_rscc;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/mariadb_port_fixes.test b/storage/rocksdb/mysql-test/rocksdb/t/mariadb_port_fixes.test
index f003aaf2032..70a4f5b05cb 100644
--- a/storage/rocksdb/mysql-test/rocksdb/t/mariadb_port_fixes.test
+++ b/storage/rocksdb/mysql-test/rocksdb/t/mariadb_port_fixes.test
@@ -54,3 +54,16 @@ explain select a from t2 where a <'zzz';
drop table t1,t2;
set global rocksdb_strict_collation_check=@tmp_rscc;
+
+--echo #
+--echo # MDEV-14389: MyRocks and NOPAD collations
+--echo #
+
+--error ER_MYROCKS_CANT_NOPAD_COLLATION
+create table t1 (pk varchar(10) collate latin1_nopad_bin, primary key(pk)) engine=rocksdb;
+
+set global rocksdb_strict_collation_check=off;
+--error ER_MYROCKS_CANT_NOPAD_COLLATION
+create table t1 (pk varchar(10) collate latin1_nopad_bin, primary key(pk)) engine=rocksdb;
+
+set global rocksdb_strict_collation_check=@tmp_rscc;