Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Clone in Desktop Download ZIP

Loading…

Unique secondary keys contain duplicate columns #66

Closed
spetrunia opened this Issue · 1 comment

1 participant

@spetrunia
Collaborator

Consider an example:

create table t4 
(
  pk1 int not null,
  pk2 int not null,
  col1 int not null,
  col2 int,
  primary key PK(pk1,pk2),
  unique key U(pk1, col1)
) engine=rocksdb;

insert into t4 values (1,1,1,1), (2,2,2,2),(3,3,3,3);
select * from t4 force index (U) where pk1 in (1,2,3);

Putting a breakpoint in ha_rocksdb::index_read_map, one can find that:

(gdb) p kd->name.c_str()
  $35 = 0x7fffa006a188 "U"
(gdb)  
(gdb) p kd->get_m_key_parts()
  $36 = 4
(gdb) p table->key_info[active_index].actual_key_parts
  $37 = 2

get_m_key_parts()==4, because the unique key has these key parts:

pk1,col1,extended(pk1,pk2)

pk1 should not be there.

@spetrunia spetrunia self-assigned this
@spetrunia spetrunia referenced this issue from a commit
@spetrunia spetrunia Issue #66: Unique secondary keys contain duplicate columns
Summary:
Fixed it: Now, a Unique secondary index has a suffix of PK columns,
but it includes only columns that are not explicitly present in the
index definition (InnoDB does the same internally).

Test Plan: Run mtr

Reviewers: hermanlee4, maykov, jtolmer, yoshinorim

Differential Revision: https://reviews.facebook.net/D38619
4d5f54a
@spetrunia spetrunia closed this
@spetrunia spetrunia referenced this issue from a commit
@spetrunia spetrunia Issue #66: Unique secondary keys contain duplicate columns
Summary:
Fixed it: Now, a Unique secondary index has a suffix of PK columns,
but it includes only columns that are not explicitly present in the
index definition (InnoDB does the same internally).

Test Plan: Run mtr

Reviewers: hermanlee4, maykov, jtolmer, yoshinorim

Differential Revision: https://reviews.facebook.net/D38619
931b8f4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.