Bug #36635 Backup: errors should be warnings
Submitted: 9 May 2008 21:32 Modified: 11 May 2008 2:37
Reporter: Peter Gulutzan
Status: Verified
Category:Server: Backup Severity:S3 (Non-critical)
Version:6.0.6-alpha-debug OS:Linux (SUSE 10 | 32-bit)
Assigned to: Rafal Somla Target Version:
Triage: Triaged: D4 (Minor)

[9 May 2008 21:32] Peter Gulutzan
Description:
Currently backup of a nonexistent database causes ER_BAD_DB_ERROR:
  mysql> backup database no_such_database to '112';
  ERROR 1049 (42000): Unknown database 'no_such_database'

It should be a warning, not an error, for these reasons:
* BACKUP is comparable to utilities like zip and tar, which
generate warnings for missing files rather than errors
* BACKUP is comparable to some MySQL 'maintenance' statements
which generate warnings rather than errors,
* users tend to look at results carefully the first time when
they're making a script but could miss an error in an
unattended backup
* in general MySQL tries to do what it can
and that is a distinguishing product feature.

Therefore change this so that it causes a (new) warning instead.
So if there are multiple databases, then backup continues even
if some databases are not found.

For example, if database a exists, database b does not exist,
and database c exists, then:
BACKUP DATABASE a, b, c TO '1';
causes a warning, but database a and database c are backed up.

* In the mysql.online_backup table there is a relevant column:
backup_state. It will contain 'warning' instead of 'complete'
or 'error'. It would be possible to concatenate all warnings
about 'not found' into this column, but that isn't requested.
The error_num column is not affected because it's not an error.

* In the mysql.online_backup_progress table there is no
relevant column. The 'error_num' and 'notes' columns are
not affected.

* This change applies only for "database not found" errors.
All other error situations continue to cause error returns.
If later there is a need to consider "tablespace not found",
"table not found", etc., we'll worry about that later.

* In later MySQL-6,x versions it will be possible to say
CREATE PROCEDURE p ()
BEGIN
  DECLARE EXIT HANDLER FOR SQLWARNING
  SIGNAL SQLSTATE '55555' SET MESSAGE_TEXT = 'Error!';
  BACKUP DATABASE no_such_database TO '1';
  END
Thus users can themselves change any warnings to errors.

How to repeat:
mysql> backup database no_such_database to '112';
ERROR 1049 (42000): Unknown database 'no_such_database'
[11 May 2008 2:37] Miguel Solorzano
Thank you for the bug report.