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

mysqldump should exit with an error when used with wrong parameter "-flush-logs"

    Details

    • Type: Task
    • Status: Closed
    • Priority: Major
    • Resolution: Not a Bug
    • Fix Version/s: N/A
    • Component/s: Scripts & Clients
    • Labels:
      None

      Description

      When mysqldump is used with flush-logs switch, but with one single dash no error is returned at all:

      root@centos-6-5-tckt-8873:[Wed Aug 19 09:51:24][/etc]$ mysqldump -ignore-table=mysql.user --single-transaction --master-data=2 --flush-logs --delete-master-logs --hex-blob --all-databases 
      mysqldump: unknown option '-g'
      root@centos-6-5-tckt-8873:[Wed Aug 19 09:53:35][/etc]$ echo $?
      2
      root@centos-6-5-tckt-8873:[Wed Aug 19 09:53:40][/etc]$ mysqldump --ignore-table=mysql.user --single-transaction --master-data=2 -flush-logs --delete-master-logs --hex-blob --all-databases 
      -- MySQL dump 10.15  Distrib 10.0.20-MariaDB, for Linux (x86_64)
      --
      -- Host: localhost    Database: 
      -- ------------------------------------------------------
      -- Server version       10.0.20-MariaDB-log
      
      /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
      /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
      /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
      /*!40101 SET NAMES utf8 */;
      /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
      /*!40103 SET TIME_ZONE='+00:00' */;
      /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
      /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
      /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
      /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
      /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
      
      /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
      /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
      /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
      /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
      /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
      /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
      /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
      
      -- Dump completed on 2015-08-19  9:54:09
      root@centos-6-5-tckt-8873:[Wed Aug 19 09:54:09][/etc]$ echo $?
      0
      root@centos-6-5-tckt-8873:[Wed Aug 19 09:54:11][/etc]$ 
      
      

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            hholzgra Hartmut Holzgraefe added a comment -

            in case of "-flush-logs", with a single instead of a double dash, all letters following the dash are interpreted as "short" single letter options, and "f" is the short option for

              -f, --force         Continue even if we get an SQL error.
            

            So the "--force" behavior should maybe be changed to only take effect after option parsing has been completed, not right away as soon as the option is seen?

            Show
            hholzgra Hartmut Holzgraefe added a comment - in case of "-flush-logs", with a single instead of a double dash, all letters following the dash are interpreted as "short" single letter options, and "f" is the short option for -f, --force Continue even if we get an SQL error. So the "--force" behavior should maybe be changed to only take effect after option parsing has been completed, not right away as soon as the option is seen?
            Hide
            elenst Elena Stepanova added a comment - - edited

            Hartmut Holzgraefe,
            Sorry, I don't quite understand – how would postponing the effect of force affect this particular case? Since there is no SQL error, no matter when --force starts working... I must be missing something, could you please expand on it?

            @ Stoykov :
            Ivan,
            Indeed, -flush-logs is interpreted as -f -l -ush-logs, that's normal, nothing new here.
            I don't suppose you have a user sh-logs in your setup, but apparently you have an anonymous one, so I don't see any problem here. What would you consider to be the expected result?

            Show
            elenst Elena Stepanova added a comment - - edited Hartmut Holzgraefe , Sorry, I don't quite understand – how would postponing the effect of force affect this particular case? Since there is no SQL error, no matter when --force starts working... I must be missing something, could you please expand on it? @ Stoykov : Ivan, Indeed, -flush-logs is interpreted as -f -l -ush-logs , that's normal, nothing new here. I don't suppose you have a user sh-logs in your setup, but apparently you have an anonymous one, so I don't see any problem here. What would you consider to be the expected result?
            Hide
            ivan.stoykov@skysql.com Stoykov added a comment - - edited

            I still think this is not proper handling of that argument
            using

            -flush-logs

            should be interpreted in the same way as

            -ignore-table

            - as a non valid mysqldump argument

            Show
            ivan.stoykov@skysql.com Stoykov added a comment - - edited I still think this is not proper handling of that argument using -flush-logs should be interpreted in the same way as -ignore-table - as a non valid mysqldump argument
            Hide
            elenst Elena Stepanova added a comment - - edited

            But it is interpreted exactly the same way as -ignore-table.
            -ignore-table is interpreted as -i -g -n ..., and fails because there is no such option -g (which it says in the error message as you quoted in the description).

            How exactly do you suggest to handle it properly? Prohibit the widely used syntax ps -aux etc., and only allow single-letter options? I doubt the users will appreciate it... Parse the options to search for common words and forbid the command line if we found any? It's kind of weird and not reliable anyway.

            Show
            elenst Elena Stepanova added a comment - - edited But it is interpreted exactly the same way as -ignore-table . -ignore-table is interpreted as -i -g -n ... , and fails because there is no such option -g (which it says in the error message as you quoted in the description). How exactly do you suggest to handle it properly ? Prohibit the widely used syntax ps -aux etc., and only allow single-letter options? I doubt the users will appreciate it... Parse the options to search for common words and forbid the command line if we found any? It's kind of weird and not reliable anyway.
            Hide
            ivan.stoykov@skysql.com Stoykov added a comment -

            like:
            one additional check for the complete string after the single dash , if there is a match within the array of the valid 'double dash' arguments throw an error

            Show
            ivan.stoykov@skysql.com Stoykov added a comment - like: one additional check for the complete string after the single dash , if there is a match within the array of the valid 'double dash' arguments throw an error
            Hide
            elenst Elena Stepanova added a comment - - edited

            Matching the command line to complete option names does not solve the general problem; In order to achieve anything at all with this, we would also have to prohibit prefixes, like ''ord'' for 'order-by-primary' and such, and I doubt users will be happy about that. It's one thing to disapprove using contractions in server options – as server starts rarely, usually with a config file and minimal command line, – and quite another to make users write complete, sometimes very long options for frequently used command-line client tools.

            All in all, I vote against it, but it's not my decision to make, I am converting it to an FR and passing over to Sergei Golubchik for further consideration (or maybe he can invent a better solution).
            Also, maybe Hartmut Holzgraefe in his first comment had some alternative solution in mind, and I just couldn't understand it.

            Show
            elenst Elena Stepanova added a comment - - edited Matching the command line to complete option names does not solve the general problem; In order to achieve anything at all with this, we would also have to prohibit prefixes, like ''ord'' for 'order-by-primary' and such, and I doubt users will be happy about that. It's one thing to disapprove using contractions in server options – as server starts rarely, usually with a config file and minimal command line, – and quite another to make users write complete, sometimes very long options for frequently used command-line client tools. All in all, I vote against it, but it's not my decision to make, I am converting it to an FR and passing over to Sergei Golubchik for further consideration (or maybe he can invent a better solution). Also, maybe Hartmut Holzgraefe in his first comment had some alternative solution in mind, and I just couldn't understand it.
            Hide
            serg Sergei Golubchik added a comment -

            This is not a bug, but expected and documented behavior. See Elena Stepanova explanation above.

            Show
            serg Sergei Golubchik added a comment - This is not a bug, but expected and documented behavior. See Elena Stepanova explanation above.

              People

              • Assignee:
                serg Sergei Golubchik
                Reporter:
                ivan.stoykov@skysql.com Stoykov
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: