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

myisamchk is broken for collation IDs >255

    XMLWordPrintable

Details

    Description

      MyISAM uses only one byte to store the ID of the table-level default collation:

      myisamdef.h:    uchar language;    /* Language for indexes */
      

      This member is used in myisamchk.c.

      If I create a table with a collation whose ID is greater than 255 (for example, latin1_nopad_bin, collation ID=1071)

      CREATE OR REPLCE TABLE t1 (a TEXT) CHARACTER SET latin1 COLLATE latin1_nopad_bin;
      FLUSH TABLES;
      

      myisamchk erroneously thinks the ID equals to (1071 mod 256), which gives 47:

      $ ../../bin/myisamchk -d t1.MYI
       
      MyISAM file:         t1.MYI
      Record format:       Packed
      Character set:       latin1_bin (47)
      Data records:                    0  Deleted blocks:                 0
      Recordlength:                   12
      

      table description:
      Key Start Len Index Type

       

      This makes myisamchk broken for collations > 255. It seems that it can corrupt the table that way. Or at least it can keep repairing it, thinking that collation changes every time.

      MyISAM should be fixed to store collation IDs using 2 bytes.

      Aria should be checked for the same problem.

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              2 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.