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

my_rename() deletes files when it shouldn't

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 5.1.67, 5.2.14, 5.3.12, 5.5.35, 10.0.7
    • 10.0.9
    • None
    • Windows

    Description

      On Windows my_rename() deletes the target file before renaming. But if the source file does not exist, it means that a target file was deleted erroneously.

      It particular, this is a problem for handler::rename_table() that renames all files from handler::bas_ext(). It assumes that the table was renamed successfully if at least some files existed and were renamed. On Windows it would delete all other target files though.

      Possible fixes:

      • verify that the source file exists in my_rename() — unnecessary overhead?
      • verify that the source file exists in handler::rename_table()
      • add a special MYF flag to my_rename() that tells to verify whether the source exists before deleting; use this flag in handler::rename_table()

      Attachments

        Activity

          serg Sergei Golubchik created issue -
          serg Sergei Golubchik made changes -
          Field Original Value New Value
          Description On {{my_rename()}} deletes the target file before renaming. But if the source file does not exist, it means that a target file was deleted erroneously.

          It particular, this is a problem for {{handler::rename_table()}} that renames all files from {{handler::bas_ext()}}}. It assumes the rename was successful if at least some files existed and were renamed. On Windows it would delete all other target files though.

          Possible fixes:
          * verify that the source file exists in {{my_rename()}} — unnecessary overhead?
          * verify that the source file exists in {{handler::rename_table()}}
          * add a special {{MYF}} flag to {{my_rename()}} that tells to verify whether the source exists before deleting; use this flag in {{handler::rename_table()}}
          On Windows {{my_rename()}} deletes the target file before renaming. But if the source file does not exist, it means that a target file was deleted erroneously.

          It particular, this is a problem for {{handler::rename_table()}} that renames all files from {{handler::bas_ext()}}}. It assumes the rename was successful if at least some files existed and were renamed. On Windows it would delete all other target files though.

          Possible fixes:
          * verify that the source file exists in {{my_rename()}} — unnecessary overhead?
          * verify that the source file exists in {{handler::rename_table()}}
          * add a special {{MYF}} flag to {{my_rename()}} that tells to verify whether the source exists before deleting; use this flag in {{handler::rename_table()}}
          serg Sergei Golubchik made changes -
          Environment Windows
          serg Sergei Golubchik made changes -
          Description On Windows {{my_rename()}} deletes the target file before renaming. But if the source file does not exist, it means that a target file was deleted erroneously.

          It particular, this is a problem for {{handler::rename_table()}} that renames all files from {{handler::bas_ext()}}}. It assumes the rename was successful if at least some files existed and were renamed. On Windows it would delete all other target files though.

          Possible fixes:
          * verify that the source file exists in {{my_rename()}} — unnecessary overhead?
          * verify that the source file exists in {{handler::rename_table()}}
          * add a special {{MYF}} flag to {{my_rename()}} that tells to verify whether the source exists before deleting; use this flag in {{handler::rename_table()}}
          On Windows {{my_rename()}} deletes the target file before renaming. But if the source file does not exist, it means that a target file was deleted erroneously.

          It particular, this is a problem for {{handler::rename_table()}} that renames all files from {{handler::bas_ext()}}. It assumes that the table was renamed successfully if at least some files existed and were renamed. On Windows it would delete all other target files though.

          Possible fixes:
          * verify that the source file exists in {{my_rename()}} — unnecessary overhead?
          * verify that the source file exists in {{handler::rename_table()}}
          * add a special {{MYF}} flag to {{my_rename()}} that tells to verify whether the source exists before deleting; use this flag in {{handler::rename_table()}}
          serg Sergei Golubchik made changes -
          Assignee Sergey Vojtovich [ svoj ]

          What's the point for handler::rename_table() not to remove all target files? We'll get a mix of old and new files in this case, which may or may not be desired.
          OTOH I agree that my_rename() should be more consistent.

          svoj Sergey Vojtovich added a comment - What's the point for handler::rename_table() not to remove all target files? We'll get a mix of old and new files in this case, which may or may not be desired. OTOH I agree that my_rename() should be more consistent.
          svoj Sergey Vojtovich made changes -
          Assignee Sergey Vojtovich [ svoj ] Sergei Golubchik [ serg ]

          Sergei, please review fix for this bug.

          svoj Sergey Vojtovich added a comment - Sergei, please review fix for this bug.

          ok to push

          serg Sergei Golubchik added a comment - ok to push
          serg Sergei Golubchik made changes -
          Assignee Sergei Golubchik [ serg ] Sergey Vojtovich [ svoj ]

          Fixed in 10.0.9, revno: 4008, revision-id: svoj@mariadb.org-20140226085528-80vzk8f2c4b4ugxm

          svoj Sergey Vojtovich added a comment - Fixed in 10.0.9, revno: 4008, revision-id: svoj@mariadb.org-20140226085528-80vzk8f2c4b4ugxm
          svoj Sergey Vojtovich made changes -
          Resolution Fixed [ 1 ]
          Status Open [ 1 ] Closed [ 6 ]
          serg Sergei Golubchik made changes -
          Workflow defaullt [ 34106 ] MariaDB v2 [ 42713 ]
          ratzpo Rasmus Johansson (Inactive) made changes -
          Workflow MariaDB v2 [ 42713 ] MariaDB v3 [ 61698 ]
          serg Sergei Golubchik made changes -
          Workflow MariaDB v3 [ 61698 ] MariaDB v4 [ 147463 ]

          People

            svoj Sergey Vojtovich
            serg Sergei Golubchik
            Votes:
            0 Vote for this issue
            Watchers:
            3 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.