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

ha_tina (CSV) deletes wrong records

    XMLWordPrintable

Details

    • Bug
    • Status: In Review (View Workflow)
    • Major
    • Resolution: Unresolved
    • 11.4
    • 11.4
    • None
    • None
    • Q4/2026 Server Maintenance, Q1/2027 Server Maintenance

    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

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

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - 2h 17m Original Estimate - 2h 17m
                  2h 17m
                  Remaining:
                  Time Spent - 2d 1.75h Remaining Estimate - 2h 17m
                  2h 17m
                  Logged:
                  Time Spent - 2d 1.75h Remaining Estimate - 2h 17m
                  2d 1.75h

                  Git Integration

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