Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-4201 LevelDB Storage Engine MS2
  3. MDEV-4306

LevelDB (and MyISAM): Wrong result (missing rows) with range access, prefix key on a char column

    Details

    • Type: Technical task
    • Status: Closed
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:

      Description

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (pk INT PRIMARY KEY, c CHAR(10), KEY(c(1))) ENGINE=LevelDB;
      INSERT INTO t1 VALUES (40,'october'),(41,'february');
      SELECT * FROM t1 WHERE c NOT IN ('l', 'f', 'w');
      

      Actual result:

      +----+---------+
      | pk | c       |
      +----+---------+
      | 40 | october |
      +----+---------+
      

      Expected result:

      +----+----------+
      | pk | c        |
      +----+----------+
      | 41 | february |
      | 40 | october  |
      +----+----------+
      

      EXPLAIN:

      +----+-------------+-------+-------+---------------+------+---------+------+------+----------+-------------+
      | id | select_type | table | type  | possible_keys | key  | key_len | ref  | rows | filtered | Extra       |
      +----+-------------+-------+-------+---------------+------+---------+------+------+----------+-------------+
      |  1 | SIMPLE      | t1    | range | c             | c    | 2       | NULL |   30 |   100.00 | Using where |
      +----+-------------+-------+-------+---------------+------+---------+------+------+----------+-------------+
      
      revision-id: psergey@askmonty.org-20130319110939-z2fi30aslmhwxslk
      revno: 4611
      branch-nick: mysql-5.6-leveldb
      

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            psergey Sergei Petrunia added a comment -

            List of ranges to be scanned (it is surprising that 'w' is not in the list of endpoints, but that itself is not a bug):

            "ranges": [
            "NULL < c < f",
            "f < c < l", — 'february' record falls here
            "l < c" — 'october' record falls here
            ]

            The following happens:
            ...
            > ha_leveldb->index_read_map(key='F', find_flag=HA_READ_AFTER_KEY)
            get an index record with rkey='F'.
            We figure that rkey=key , and since flag=HA_READ_AFTER_KEY, we should step one record forward.

            However, HA_READ_AFTER_KEY in the parameter refers to the whole lookup tuple, not to the prefix that's stored in the index.

            Show
            psergey Sergei Petrunia added a comment - List of ranges to be scanned (it is surprising that 'w' is not in the list of endpoints, but that itself is not a bug): "ranges": [ "NULL < c < f", "f < c < l", — 'february' record falls here "l < c" — 'october' record falls here ] The following happens: ... > ha_leveldb->index_read_map(key='F', find_flag=HA_READ_AFTER_KEY) get an index record with rkey='F'. We figure that rkey=key , and since flag=HA_READ_AFTER_KEY, we should step one record forward. However, HA_READ_AFTER_KEY in the parameter refers to the whole lookup tuple, not to the prefix that's stored in the index.
            Hide
            psergey Sergei Petrunia added a comment -

            The problem can be observed on MyISAM, too! http://bugs.mysql.com/bug.php?id=68750

            Show
            psergey Sergei Petrunia added a comment - The problem can be observed on MyISAM, too! http://bugs.mysql.com/bug.php?id=68750

              People

              • Assignee:
                psergey Sergei Petrunia
                Reporter:
                elenst Elena Stepanova
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 2 hours, 30 minutes
                  2h 30m