Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-41216

ha_tina (CSV) deletes wrong records

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • None
    • None
    • None
    • None

    Description

      --source include/have_csv.inc
       
      CREATE TABLE t1 (v INT NOT NULL) ENGINE=CSV;
      INSERT INTO t1 VALUES (1),(2),(3);
      DELETE FROM a1, a3 USING t1 AS a1 JOIN t1 AS a3 WHERE a1.v=2 AND a3.v=1;
      --echo # asked to remove v=1 and v=2, so v=3 must survive
      SELECT * FROM t1 ORDER BY v;
      DROP TABLE t1;
      

      Some pre-analysis:
      ha_tina backing CSV deletes the records physically from the file on every delete_row.
      position() literally writes a file offset.
      rnd_pos locates a record by than file offset

      Scenario:
      multi-delete records all the positions (=file offsets) to delete.
      Then it deletes by those offsets in a single pass.
      The offsets are not reverse-sorted, so when off1 < off2 and off1 is deleted first, off2 will point to a wrong record.

      The fix is either of three:
      a) Implement delete-marking in tina/csv
      b) Reverse-sort the position buffer.
      c) delete immediately after locating, skipping the buffer

      Attachments

        Issue Links

          Activity

            People

              Gosselin Dave Gosselin
              nikitamalyavin Nikita Malyavin
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.