Bug #104769 CLI options deprecation warnings of mysqldump are printed to stdout
Submitted: 30 Aug 2021 14:58 Modified: 27 Apr 2022 15:17
Reporter: Alexander Baran Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: mysqldump Command-line Client Severity:S2 (Serious)
Version:8.0.26 OS:Debian
Assigned to: CPU Architecture:x86

[30 Aug 2021 14:58] Alexander Baran
Description:
mysqldump --version
mysqldump  Ver 8.0.26 for Linux on x86_64 (MySQL Community Server - GPL)

Warnings about using deprecated command-line options are printed to stdout, which breaks the dump files in some cases.

How to repeat:
1) create a backup using a deprecated arg:
mysqldump --all-databases --master-data=2 -p > /tmp/backup.sql

2) head -2 /tmp/backup.sql
WARNING: --master-data is deprecated and will be removed in a future version. Use --source-data instead.
-- MySQL dump 10.13  Distrib 8.0.26, for Linux (x86_64)

3) try to restore this backup:
mysql -p < /tmp/backup.sql 
Enter password: 
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WARNING: --master-data is deprecated and will be removed in a future version. Us' at line 1
[30 Aug 2021 15:15] Alexander Baran
Wouldn't it be better to print these warnings to stderr instead?
[31 Aug 2021 13:25] MySQL Verification Team
Hi,

We have to analyse this problem further .......
[31 Aug 2021 13:47] MySQL Verification Team
Hi,

As a workaround, please do NOT use stdout, use the result file and you will not get that warning in the dump !!!!!
[31 Aug 2021 13:50] Alexander Baran
Hello, I totally get the renaming and the importance of these warning, my only concern is that these warning are printed to stdout and hence interfering with the actual mysqldump output.
[31 Aug 2021 13:51] Alexander Baran
> As a workaround, please do NOT use stdout, use the result file and you will not get that warning in the dump !!!!!

That's exactly what the problem is, the warning gets into the dump file.
[31 Aug 2021 14:10] Alexander Baran
And I think it could be fixed by printing these warnings to stderr instead of stdout.
[31 Aug 2021 14:28] Alexander Baran
right, if I use --result-file=name it works fine, but I can't use pipes or redirection this way (eg. I don't want a backup stored locally in the file, I want to pipe it to some other tool)
[1 Sep 2021 12:07] MySQL Verification Team
Hi,

We fully understand your wishes and we agree with them, but the decision on any changes in this regard are not yet made.

Use the result file and you can pipe it to any other program, since it will not contain any uncommented WARNINGs.
[1 Sep 2021 15:31] Tsubasa Tanaka
I strongly wish to change this behavior.
No one wants to get "Syntax error" message when they going to restore their database!

p.s. 
mysqldump document uses redirect ">" and pipe "|" sometimes.
There are many users who uses mysqldump --all-databases .. > /path/to/backup as described by document.

https://dev.mysql.com/doc/refman/8.0/en/mysqldump.html
[2 Sep 2021 11:53] MySQL Verification Team
Hi,

We already noted that decision is not made yet on what to be done with this warnings dilemma. There are a number of operating systems on which a behaviour is different ....

Hence, you will have to wait for a decision to be made internally.
[7 Jan 2022 11:48] MySQL Verification Team
Thank you for the feedback.

Sincerely,
Umesh
[10 Jan 2022 14:20] MySQL Verification Team
Hi Mr. Baran,

We hope that you were able to see that your report was accepted as a valuable one.

Thank you.
[13 Jan 2022 13:48] David Harper
I have just been made aware of this bug by a member of the MySQL user community at my Institute, whose MySQL dump/load pipeline stopped working suddenly after a client tools upgrade.  I agree with Alexander Baran and Tsubasa Tanaka that it is unacceptable for the MySQL developers to deliberately introduce behaviour that breaks a key MySQL client tool so badly.  If I had adopted this attitude when I was a software developer, I'd expect to be demoted or fired.

The correct solution is to output the deprecation warning to STDERR, not to STDOUT where it breaks the dump file.
[13 Jan 2022 13:56] MySQL Verification Team
Hi,

This bug will be fixed, but in a different manner.

Directing to stderr instead of stdout will not work on all operating systems that we support. In any case, this bug will be fixed properly.
[27 Apr 2022 15:17] Margaret Fisher
Posted by developer:
 
Changelog entry added for MySQL 8.0.30:

Deprecation warnings returned to client programs were sent to stdout rather than stderr, which in the case of mysqldump could mean that the dump file no longer worked because the warnings were included in it. The issue has now been fixed and the warnings are sent to stderr.