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

Innodb inbuilt cache behaving strangely for indexed virtual columns

    XMLWordPrintable

Details

    Description

      When Innodb rows are read from prebuilt cache, sometimes wrong result is returned for table->record[0] (null bits).

      Test Case (for 10.4, 10.5 (with 10.5 debug build it fails more frequently))

      --source include/have_innodb.inc
      CREATE TABLE t1 (id INT, f TEXT UNIQUE, d DATE, PRIMARY KEY (id)) ENGINE=InnoDB;
      INSERT INTO t1 VALUES
          (1,NULL,'2001-11-16'),(2,NULL,'2007-07-01'),(3,NULL,'2020-02-03'),
          (4,NULL,'1971-05-24'),(5,NULL,'1971-05-24'),(6,NULL,'1985-02-07');
      ANALYZE TABLE t1 PERSISTENT FOR ALL;
      # Cleanup
      DROP TABLE t1;
      
      

      In above test case not all table fields are read. Analyze table does not read blob columns
      (Please note we will have 4 fields 4th will be hidden DB_ROW_HASH1 (storing hash for column f))

      Table read_set
      (rr) p/t *args[0]->field->table->read_set->bitmap
      $2 = 1101
      

      Good table record

      (rr) x/26tb args[0]->field->table->record[0]
      0x7f28182205b8: 11111101        00000101        00000000        00000000        00000000        00000000        00000000
       00000000
      0x7f28182205c0: 00000000        00000000        00000000        00000000        00000000        00000000        00000000
       10111000
      0x7f28182205c8: 01100110        00001111        00000000        00000000        00000000        00000000        00000000
       00000000
      0x7f28182205d0: 00000000        00000000
      

      While reading the last column sometime we are given bad result from record[0] null_bits

      (rr) x/26tb args[0]->field->table->record[0]
      0x7f28182205b8: 00101000        00000110        00000000        00000000        00000000        10001111        10001111
       10001111
      0x7f28182205c0: 10001111        10001111        10001111        10001111        10001111        10001111        10001111
       01000111
      0x7f28182205c8: 10000010        00001111        00000000        00000000        00000000        00000000        00000000
       00000000
      0x7f28182205d0: 00000000        00000000
      
      

      Notice the first byte 00101000 , it is wrong

      Attachments

        Activity

          People

            nikitamalyavin Nikita Malyavin
            sachin.setiya.007 Sachin Setiya (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 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.