[MDEV-8647] mysqldump should exit with an error when used with wrong parameter "-flush-logs" Created: 2015-08-19  Updated: 2015-08-19  Resolved: 2015-08-19

Status: Closed
Project: MariaDB Server
Component/s: Scripts & Clients
Fix Version/s: N/A

Type: Task Priority: Major
Reporter: Stoykov (Inactive) Assignee: Sergei Golubchik
Resolution: Not a Bug Votes: 0
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]$ 
 



 Comments   
Comment by Hartmut Holzgraefe [ 2015-08-19 ]

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?

Comment by Elena Stepanova [ 2015-08-19 ]

hholzgra,
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?

@ ivan.stoykov@skysql.com :
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?

Comment by Stoykov (Inactive) [ 2015-08-19 ]

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

Comment by Elena Stepanova [ 2015-08-19 ]

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.

Comment by Stoykov (Inactive) [ 2015-08-19 ]

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

Comment by Elena Stepanova [ 2015-08-19 ]

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 serg for further consideration (or maybe he can invent a better solution).
Also, maybe hholzgra in his first comment had some alternative solution in mind, and I just couldn't understand it.

Comment by Sergei Golubchik [ 2015-08-19 ]

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

Generated at Thu Feb 08 07:28:44 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.