Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Clone in Desktop Download ZIP

Loading…

Point lookup by reverse column family doesn't work #16

Closed
yoshinorim opened this Issue · 4 comments

2 participants

@yoshinorim
Owner

How to repeat:
CREATE TABLE linktable (
id1 bigint(20) unsigned NOT NULL DEFAULT '0',
id2 bigint(20) unsigned NOT NULL DEFAULT '0',
link_type bigint(20) unsigned NOT NULL DEFAULT '0',
visibility tinyint(3) NOT NULL DEFAULT '0',
data varchar(255) COLLATE latin1_bin NOT NULL DEFAULT '',
time bigint(20) unsigned NOT NULL DEFAULT '0',
version int(11) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (link_type,id1,id2) COMMENT 'rev:cf_primary',
KEY id1_type (id1,link_type,visibility,time,id2,version,data)
) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;
insert into linktable values (1,1,1,1,1,1,1),(2,2,2,2,2,2,2),(3,3,3,3,3,3,3),(4,4,4,4,4,4,4),(5,5,5,5,5,5,5),(6,6,6,6,6,6,6),(7,7,7,7,7,7,7),(8,8,8,8,8,8,8),(9,9,9,9,9,9,9),(10,10,10,10,10,10,10),(11,11,11,11,11,11,11),(12,12,12,12,12,12,12),(13,13,13,13,13,13,13),(14,14,14,14,14,14,14),(15,15,15,15,15,15,15),(16,16,16,16,16,16,16),(17,17,17,17,17,17,17),(18,18,18,18,18,18,18),(19,19,19,19,19,19,19),(20,20,20,20,20,20,20);

mysql> select * from linktable force index(PRIMARY) where link_type=1;
Empty set (0.00 sec)

mysql> select * from linktable force index(id1_type) where link_type=1;
+-----+-----+-----------+------------+------+------+---------+
| id1 | id2 | link_type | visibility | data | time | version |
+-----+-----+-----------+------------+------+------+---------+
| 1 | 1 | 1 | 1 | 1 | 1 | 1 |
+-----+-----+-----------+------------+------+------+---------+
1 row in set (0.00 sec)

mysql> update linktable set version=100 where link_type=1;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0

mysql> update linktable set version=100 where id1=1;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

It doesn't work with reverse cf on secondary index, either:
CREATE TABLE linktable (
id1 bigint(20) unsigned NOT NULL DEFAULT '0',
id2 bigint(20) unsigned NOT NULL DEFAULT '0',
link_type bigint(20) unsigned NOT NULL DEFAULT '0',
visibility tinyint(3) NOT NULL DEFAULT '0',
data varchar(255) COLLATE latin1_bin NOT NULL DEFAULT '',
time bigint(20) unsigned NOT NULL DEFAULT '0',
version int(11) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (link_type,id1,id2),
KEY id1_type (id1,link_type,visibility,time,id2,version,data) COMMENT 'rev:cf_id1_type'
) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;
insert into linktable values (1,1,1,1,1,1,1),(2,2,2,2,2,2,2),(3,3,3,3,3,3,3),(4,4,4,4,4,4,4),(5,5,5,5,5,5,5),(6,6,6,6,6,6,6),(7,7,7,7,7,7,7),(8,8,8,8,8,8,8),(9,9,9,9,9,9,9),(10,10,10,10,10,10,10),(11,11,11,11,11,11,11),(12,12,12,12,12,12,12),(13,13,13,13,13,13,13),(14,14,14,14,14,14,14),(15,15,15,15,15,15,15),(16,16,16,16,16,16,16),(17,17,17,17,17,17,17),(18,18,18,18,18,18,18),(19,19,19,19,19,19,19),(20,20,20,20,20,20,20);

mysql> select * from linktable force index(id1_type) where id1=1;
Empty set (0.00 sec)

mysql> select * from linktable force index(PRIMARY) where id1=1;
+-----+-----+-----------+------------+------+------+---------+
| id1 | id2 | link_type | visibility | data | time | version |
+-----+-----+-----------+------------+------+------+---------+
| 1 | 1 | 1 | 1 | 1 | 1 | 1 |
+-----+-----+-----------+------------+------+------+---------+
1 row in set (0.00 sec)

mysql> update linktable set version=100 where id1=10;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0

mysql> update linktable set version=100 where link_type=1;
Query OK, 1 row affected (0.03 sec)
Rows matched: 1 Changed: 1 Warnings: 0

@spetrunia spetrunia was assigned by maykov
@yoshinorim yoshinorim added the bug label
@spetrunia
Collaborator

Agreed to split the patch into smaller pieces, this is the first one: https://reviews.facebook.net/D33975

@spetrunia
Collaborator

A patch to mark HA_READ_KEY_OR_PREV as unsupported: https://reviews.facebook.net/D35337

@spetrunia
Collaborator

Fixed reverse CF handling for all kinds of index lookups.

@spetrunia spetrunia closed this
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.