Commit c3803914 authored by Sergei Petrunia's avatar Sergei Petrunia

MDEV-14433: RocksDB may show empty or incorrect output with rocksdb_strict_collation_check=off

Part#1: Set field->part_of_key correctly for PK fields.
parent f1f2b774
......@@ -5698,6 +5698,27 @@ int ha_rocksdb::open(const char *const name, int mode, uint test_if_locked) {
setup_field_converters();
/*
MariaDB: adjust field->part_of_key for PK columns. We can only do it here
because SE API is just relying on the HA_PRIMARY_KEY_IN_READ_INDEX which
does not allow to distinguish between unpack'able and non-unpack'able
columns.
Upstream uses handler->init_with_fields() but we don't have that call.
*/
{
if (!has_hidden_pk(table)) {
KEY *const pk_info = &table->key_info[table->s->primary_key];
for (uint kp = 0; kp < pk_info->user_defined_key_parts; kp++) {
if (!m_pk_descr->can_unpack(kp)) {
//
uint field_index= pk_info->key_part[kp].field->field_index;
table->field[field_index]->part_of_key.clear_all();
table->field[field_index]->part_of_key.set_bit(table->s->primary_key);
}
}
}
}
info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST);
/*
......
#
# MDEV-14433: RocksDB may show empty or incorrect output with rocksdb_strict_collation_check=off
#
set global rocksdb_strict_collation_check=off;
set @tmp_rscc=@@rocksdb_strict_collation_check;
CREATE TABLE t1(
a varchar(10) NOT NULL,
b char(1) DEFAULT 'X',
c char(2) NOT NULL DEFAULT '??',
d varchar(10) NOT NULL,
e int(11) DEFAULT 0,
PRIMARY KEY (a,d),
KEY (e)
) ENGINE=ROCKSDB DEFAULT CHARSET=utf8;
insert into t1 select 1,1,1,1,0;
insert into t1 select 2,1,1,1,0;
insert into t1 select 3,1,1,1,0;
explain
select a from t1 force index(e) where e<10000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range e e 5 NULL # Using index condition
select a from t1;
a
1
2
3
select * from t1;
a b c d e
1 1 1 1 0
2 1 1 1 0
3 1 1 1 0
DROP TABLE t1;
set global rocksdb_strict_collation_check=@tmp_rscc;
--source include/have_rocksdb.inc
--echo #
--echo # MDEV-14433: RocksDB may show empty or incorrect output with rocksdb_strict_collation_check=off
--echo #
set global rocksdb_strict_collation_check=off;
set @tmp_rscc=@@rocksdb_strict_collation_check;
CREATE TABLE t1(
a varchar(10) NOT NULL,
b char(1) DEFAULT 'X',
c char(2) NOT NULL DEFAULT '??',
d varchar(10) NOT NULL,
e int(11) DEFAULT 0,
PRIMARY KEY (a,d),
KEY (e)
) ENGINE=ROCKSDB DEFAULT CHARSET=utf8;
insert into t1 select 1,1,1,1,0;
insert into t1 select 2,1,1,1,0;
insert into t1 select 3,1,1,1,0;
--replace_column 9 #
explain
select a from t1 force index(e) where e<10000;
select a from t1;
select * from t1;
DROP TABLE t1;
set global rocksdb_strict_collation_check=@tmp_rscc;
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