Bug #34770 Backup: Special charcters or space could be file name in the backup location.
Submitted: 23 Feb 2008 1:56 Modified: 3 Nov 2008 9:06
Reporter: Hema Sridharan Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server: Backup Severity:S3 (Non-critical)
Version:mysql-6.0-backup OS:Linux
Assigned to: Jørgen Løland CPU Architecture:Any

[23 Feb 2008 1:56] Hema Sridharan
Description:
1) I create a database and few tables in the database.
2) I backup the database to a local file by giving  some special characters and blank space in destination location.
3) The backup command gets executed successfully.

Backup should be done to the filename and the file name cannot be blank space or special characters.

How to repeat:
1) I create database err 
2) I create some tables in the database.
3)I backup database err to local file by giving blank space as destination location,

backup database err to '/data2/hema/backup_dmp/   ';

+-----------+
| backup_id |
+-----------+
| 56        |
+-----------+
1 row in set (0.08 sec)

The operation is successful even if we don't give file name and just give blank space.

4) Now while doing backup I give all the special characters in destination location.

mysql> backup database err to '/data2/hema/backup_dmp/__**))!@#$%^&*';
+-----------+
| backup_id |
+-----------+
| 34        |
+-----------+
1 row in set (0.08 sec)

The backup operation is successful for special characters.
[26 Mar 2008 0:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[27 Mar 2008 18:59] Hema Sridharan
MTR Test for this Bug:

--error 0,1
--remove_file $MYSQLTEST_VARDIR/master-data/try.bak

#Create Database

--disable_warnings
DROP DATABASE IF EXISTS try;
--enable_warnings

CREATE DATABASE try;
USE try;

#Create table and load with data.

--echo Creating table
CREATE TABLE t1(name char(10), id int)ENGINE=MYISAM;

CREATE TABLE t2(city varchar(20), state char(10))ENGINE=MYISAM;

--echo loading data
INSERT INTO t1 VALUES('aa',1),('bb',2);

INSERT INTO t2 VALUES('austin','TX'),('sfo','CA');

#selecting data

SELECT * FROM t1;

SELECT * FROM t2;

#Backup and restore data.
--echo backup data

BACKUP DATABASE try TO 'try.bak';

#In doing BACKUP even if we give blank space as destination, the BACKUP command is successful.
#Bug#34770 Backup: Special characters or space could be file name in the backup location.

BACKUP DATABASE try TO ' ';

#While doing BACKUP even special characters can be a file name(destination location)

BACKUP DATABASE try TO '#$%^&*()@';

and the BACKUP DATABASE is successful
[1 Apr 2008 12:07] Susanne Ebrecht
Verified as described.
[30 Oct 2008 9:47] Jørgen Løland
What is supposed to work here? I extended the test with drop database,restore,verify content for all these cases:

--echo Case 1
--echo Whitespace before string
BACKUP DATABASE try TO ' afile.bak';
drop database try;
restore from ' afile.bak';
select * from t1;
select * from t2;
# Works, filename on disk is ' afile.bak'

--echo Case 2
--echo Whitespace after string
BACKUP DATABASE try TO 'afile.bak ';
drop database try;
restore from 'afile.bak ';
select * from t1;
select * from t2;
# Works, filename on disk is 'afile.bak', i.e., whitespace removed

--echo Case 3
--echo Special characters
BACKUP DATABASE try TO '__**))!@#$%^&*';
drop database try;
restore from '__**))!@#$%^&*';
select * from t1;
select * from t2;
# Works, filename on disk exactly as written in command

--echo Case 4
--echo Only whitespace, full path
BACKUP DATABASE try TO '<path>/ ';
drop database try;
restore from '<path>/ ';
select * from t1;
select * from t2;
# Works, filename on disk is ' '

--echo Case 5
--echo Only whitespace, no path
BACKUP DATABASE try TO ' ';
drop database try;
restore from ' ';
select * from t1;
select * from t2;
# Fails with error "1632: Can't write to backup location ' ' (file already exists?)"

Which of these are supposed to work, and which are supposed to fail? Note that "select ... into outfile" command works like this when run instead of backup/restore in the above cases:

Case 1: Works, filename starts with space
Case 2: Works, filename does not contain space at end
Case 3: Works, filename exactly as written in command
Case 4: Fails with error 1086: File '<path>/ ' already exists
Case 5: Fails with error 1086: File '<path>/ ' already exists

Only case 4 differs between "select into outfile" and backup/restore
[30 Oct 2008 9:51] Jørgen Løland
Typo - Case 5 for "select into outfile" should be like this:

Case 5: Fails with error 1086: File ' ' already exists
[3 Nov 2008 8:05] Jørgen Løland
Whitespace filename is no longer possible in the backup team branch.