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

Wrong error code ER_BAD_DB_ERROR for long filenames

    XMLWordPrintable

Details

    Description

      Tested on 10.7, probably affects lower versions.

      Reproduce

      set names utf8;
      let $save_debug=`select @@debug_dbug`;
      let $MYSQLD_DATADIR= `SELECT @@datadir`;
      # Filename is too long because it is converted to @274e@274e@274e@274e...
      # so each '❎' is 5 bytes in filesystem, 51 x 5 = 255 bytes
      let $t= `select repeat('❎', 51)`;
      --error ER_CANT_CREATE_TABLE
      eval create table $t (x int);
      

      Result

      ER_BAD_DB_ERROR is thrown, misguiding error message Unknown database 'test'

      mysqltest: At line 7: query 'create table $t (x int)' failed: ER_BAD_DB_ERROR (1049): Unknown database 'test'
      

      Expected

      ER_CANT_CREATE_TABLE is thrown on Linux

      ERROR HY000: Can't create table `test`.`❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎ ❎❎❎❎❎❎❎❎❎❎❎❎❎` (errno: 36 "File name too long")
      

      Notes

      The fork for different error codes is here:

      int writefile(const char *path, const char *db, const char *table,
                    bool tmp_table, const uchar *data, size_t len)
      {
      ...
        File file= mysql_file_create(key_file_frm, path,
                                     CREATE_MODE, create_flags, MYF(0));
       
        if (unlikely((error= file < 0)))
        {
          if (my_errno == ENOENT)
            my_error(ER_BAD_DB_ERROR, MYF(0), db);
          else
            my_error(ER_CANT_CREATE_TABLE, MYF(0), db, table, my_errno);
        }
      ...
      

      On Windows it sets my_errno to ENOENT, on Linux it sets my_errno to 36 ("File name too long").

      Attachments

        Activity

          People

            wlad Vladislav Vaintroub
            midenok Aleksey Midenkov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

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