List:Commits« Previous MessageNext Message »
From:Ingo Struewing Date:April 1 2009 3:26pm
Subject:bzr commit into mysql-6.0-backup branch (ingo.struewing:2807) WL#4518
View as plain text  
#At file:///home2/mydev/bzrroot/mysql-6.0-wl4518-2/ based on revid:ingo.struewing@stripped

 2807 Ingo Struewing	2009-04-01
      WL#4518 - Online Backup: Test backupdir variable
      
      Beautified the existing test case.
      Added more tests.
      Added a new test case for symlinks and pipes, not for Windows.
      Added a new test case for synchronization.
     @ mysql-test/suite/backup/r/backup_backupdir.result
        WL#4518 - Online Backup: Test backupdir variable
        Updated test result.
     @ mysql-test/suite/backup/r/backup_backupdir_not_windows.result
        WL#4518 - Online Backup: Test backupdir variable
        New test result.
     @ mysql-test/suite/backup/r/backup_backupdir_sync.result
        WL#4518 - Online Backup: Test backupdir variable
        New test result.
     @ mysql-test/suite/backup/t/backup_backupdir.test
        WL#4518 - Online Backup: Test backupdir variable
        Fixed some echoes.
        Beautified echoes.
        Moved cleanup for files to the tests where they are used.
        Made tests more symmetric. Added file_exists and RESTORE
        at some places.
        Added new tests.
     @ mysql-test/suite/backup/t/backup_backupdir_not_windows.test
        WL#4518 - Online Backup: Test backupdir variable
        New test case.
     @ mysql-test/suite/backup/t/backup_backupdir_sync.test
        WL#4518 - Online Backup: Test backupdir variable
        New test case.
     @ sql/backup/kernel.cc
        WL#4518 - Online Backup: Test backupdir variable
        Added A Debug Sync Point.

    added:
      mysql-test/suite/backup/r/backup_backupdir_not_windows.result
      mysql-test/suite/backup/r/backup_backupdir_sync.result
      mysql-test/suite/backup/t/backup_backupdir_not_windows.test
      mysql-test/suite/backup/t/backup_backupdir_sync.test
    modified:
      mysql-test/suite/backup/r/backup_backupdir.result
      mysql-test/suite/backup/t/backup_backupdir.test
      sql/backup/kernel.cc
=== modified file 'mysql-test/suite/backup/r/backup_backupdir.result'
--- a/mysql-test/suite/backup/r/backup_backupdir.result	2009-03-18 22:01:12 +0000
+++ b/mysql-test/suite/backup/r/backup_backupdir.result	2009-04-01 15:26:41 +0000
@@ -1,82 +1,326 @@
-Reset backupdir 
-SET @@global.backupdir = @@global.datadir;
+# Save backupdir 
+SET @old_backupdir= @@backupdir;
 DROP DATABASE IF EXISTS bup_backupdir;
-Create a database
+#
+# Create a database to be used throughout the test case
+#
 CREATE DATABASE bup_backupdir;
 CREATE TABLE bup_backupdir.t1(a INT);
 INSERT INTO bup_backupdir.t1 VALUES (1), (2), (3);
-Create a directory for backup images
-Reset backupdir 
-SET @@global.backupdir = '../../tmp/backup';
-Perform backup
-BACKUP DATABASE bup_backupdir TO 'bup_backupdir1.bak';
-backup_id
-#
-Ensure backup image file went to the correct location
-/backup/bup_backupdir.bak
-Perform restore
-RESTORE FROM 'bup_backupdir1.bak' OVERWRITE;
-backup_id
-#
-Now do the backup and restore by specifying a path.
-Perform backup
-BACKUP DATABASE bup_backupdir TO '../bup_backupdir2.bak';
-backup_id
-#
-Ensure backup image file went to the correct location
-Perform restore
-RESTORE FROM '../bup_backupdir2.bak' OVERWRITE;
-backup_id
-#
-Perform backup
-BACKUP DATABASE bup_backupdir TO '../../bup_backupdir3.bak';
-backup_id
-#
-Ensure backup image file went to the correct location
-Reset backupdir with ending /
-SET @@global.backupdir = '../../tmp/backup/';
-Perform backup
-BACKUP DATABASE bup_backupdir TO '../../bup_backupdir4.bak';
-backup_id
-#
-Ensure backup image file went to the correct location
-Try a backup to an invalid relative path.
-BACKUP DATABASE bup_backupdir TO '../not/there/bup_backupdir5.bak';
-ERROR HY000: Can't create/write to file 'MYSQLTEST_VARDIR/tmp/not/there/bup_backupdir5.bak' (Errcode: #)
-
-Try a backup to an invalid hard path.
-*Actual BACKUP DATABASE command not printed due to non-deterministic path.
-*Performing: 
-*BACKUP DATABASE bup_backupdir TO '$MYSQLTEST_VARDIR/not/there/either/bup_backupdir6.bak';
-ERROR HY000: Can't create/write to file 'MYSQLTEST_VARDIR/not/there/either/bup_backupdir6.bak' (Errcode: #)
-
-Attempt to set the backupdir to a really long string.
-set global max_allowed_packet=1024*100;
-
-Now attempt to set the backupdir to 512 characters.
-
-SET @@global.backupdir = repeat('a',####);
+#
+# Create a backup directory to be used throughout the test case
+#
+#
+# The following tests the backupdir variable by changing it to redirect
+# the output of the backup command/input of the restore command.
+#
+# Set backupdir 
+SET @@global.backupdir = '../../tmp/bup_backupdir';
+# Perform backup
+BACKUP DATABASE bup_backupdir TO 'bup_backupdir_1.bak';
+backup_id
+#
+# Ensure backup image file went to the correct location
+# Perform restore
+RESTORE FROM 'bup_backupdir_1.bak' OVERWRITE;
+backup_id
+#
+#
+# Do the backup and restore by specifying a path.
+#
+# Perform backup
+BACKUP DATABASE bup_backupdir TO '../bup_backupdir_2.bak';
+backup_id
+#
+# Ensure backup image file went to the correct location
+# Perform restore
+RESTORE FROM '../bup_backupdir_2.bak' OVERWRITE;
+backup_id
+#
+#
+# Use yet another path.
+#
+# Perform backup
+BACKUP DATABASE bup_backupdir TO '../../bup_backupdir_3.bak';
+backup_id
+#
+# Ensure backup image file went to the correct location
+# Perform restore
+RESTORE FROM '../../bup_backupdir_3.bak' OVERWRITE;
+backup_id
+#
+#
+# Set backupdir with ending /
+#
+SET @@global.backupdir = '../../tmp/bup_backupdir/';
+# Perform backup
+BACKUP DATABASE bup_backupdir TO '../../bup_backupdir_4.bak';
+backup_id
+#
+# Ensure backup image file went to the correct location
+# Perform restore
+RESTORE FROM '../../bup_backupdir_4.bak' OVERWRITE;
+backup_id
+#
+#
+# Attempt backup/restore to/from an invalid relative path.
+#
+BACKUP DATABASE bup_backupdir TO '../not/there/bup_backupdir_x.bak';
+ERROR HY000: Can't create/write to file 'MYSQLTEST_VARDIR/tmp/not/there/bup_backupdir_x.bak' (Errcode: #)
+RESTORE FROM '../not/there/bup_backupdir_x.bak' OVERWRITE;
+ERROR HY000: File 'MYSQLTEST_VARDIR/tmp/not/there/bup_backupdir_x.bak' not found (Errcode: #)
+# 
+# Attempt backup/restore to/from an invalid hard path.
+#
+# *Actual BACKUP DATABASE command not printed due to
+#  non-deterministic path.
+# *Performing: 
+# *BACKUP DATABASE bup_backupdir TO
+#  '$MYSQLTEST_VARDIR/not/there/either/bup_backupdir_x.bak';
+ERROR HY000: Can't create/write to file 'MYSQLTEST_VARDIR/not/there/either/bup_backupdir_x.bak' (Errcode: #)
+# *Actual RESTORE command not printed due to
+#  non-deterministic path.
+# *Performing: 
+# *RESTORE FROM
+#  '$MYSQLTEST_VARDIR/not/there/either/bup_backupdir_x.bak';
+ERROR HY000: File 'MYSQLTEST_VARDIR/not/there/either/bup_backupdir_x.bak' not found (Errcode: #)
+#
+# Set backupdir to 512 characters.
+#
+SET @@global.backupdir= REPEAT('a',####);
 Warnings:
 Warning	####	The path specified for the system variable backupdir cannot be accessed or is invalid. ref: 
-
-Now attempt to set the backupdir to 513 characters.
-
-SET @@global.backupdir = repeat('a',513);
+#
+# Attempt to set the backupdir to 513 characters.
+#
+SET @@global.backupdir= REPEAT('a', 513);
 ERROR HY000: The path specified for backupdir is too long.
-
-Now attempt to set the backupdir to a really long string.
-
-SET @@global.backupdir = repeat('a',99*1024);
+#
+# Attempt to set the backupdir to a really long string.
+#
+SET GLOBAL max_allowed_packet= 100 * 1024;
+SET @@global.backupdir= REPEAT('a', 99 * 1024);
 ERROR HY000: The path specified for backupdir is too long.
-
-Attempt to set the backupdir to something invalid.
-
-SET @@global.backupdir = 'This_is_really_stupid/not/there/at/all';
+SET GLOBAL max_allowed_packet= DEFAULT;
+#
+# Set backupdir to something invalid.
+#
+SET @@global.backupdir= 'This_is_really_stupid/not/there/at/all';
 Warnings:
 Warning	####	The path specified for the system variable backupdir cannot be accessed or is invalid. ref: This_is_really_stupid/not/there/at/all
 Warning	####	The path specified for the system variable backupdir cannot be accessed or is invalid. ref: This_is_really_stupid/not/there/at/all
-set global max_allowed_packet=DEFAULT;
-Cleanup
-Reset backupdir 
-SET @@global.backupdir = @@global.datadir;
+# Attempt backup to a pure file name in invalid backupdir.
+BACKUP DATABASE bup_backupdir TO 'bup_backupdir_x.bak';
+ERROR HY000: The path specified for the system variable backupdir cannot be accessed or is invalid. ref: This_is_really_stupid/not/there/at/all
+# Attempt restore from a pure file name in invalid backupdir.
+RESTORE FROM 'bup_backupdir_x.bak' OVERWRITE;
+ERROR HY000: The path specified for the system variable backupdir cannot be accessed or is invalid. ref: This_is_really_stupid/not/there/at/all
+# Attempt backup to a relative path name in invalid backupdir.
+# Try 'test' in case current directory is used instead of backupdir.
+BACKUP DATABASE bup_backupdir TO 'test/bup_backupdir_x.bak';
+ERROR HY000: The path specified for the system variable backupdir cannot be accessed or is invalid. ref: This_is_really_stupid/not/there/at/all
+# Attempt restore from a relative path name in invalid backupdir.
+# Try 'test' in case current directory is used instead of backupdir.
+RESTORE FROM 'test/bup_backupdir_x.bak' OVERWRITE;
+ERROR HY000: The path specified for the system variable backupdir cannot be accessed or is invalid. ref: This_is_really_stupid/not/there/at/all
+# Attempt backup to a backref path in invalid backupdir.
+BACKUP DATABASE bup_backupdir TO '../../../../../bup_backupdir_x.bak';
+ERROR HY000: The path specified for the system variable backupdir cannot be accessed or is invalid. ref: This_is_really_stupid/not/there/at/all
+# Attempt restore from a backref path in invalid backupdir.
+RESTORE FROM '../../../../../bup_backupdir_x.bak' OVERWRITE;
+ERROR HY000: The path specified for the system variable backupdir cannot be accessed or is invalid. ref: This_is_really_stupid/not/there/at/all
+# Attempt backup to an absolute path.
+# *Actual BACKUP DATABASE command not printed due to
+#  non-deterministic path.
+# *Attempting: 
+# *BACKUP DATABASE bup_backupdir TO
+#  '$MYSQLTEST_VARDIR/bup_backupdir_5.bak';
+ERROR HY000: The path specified for the system variable backupdir cannot be accessed or is invalid. ref: This_is_really_stupid/not/there/at/all
+# Attempt restore from an absolute path.
+# *Actual RESTORE command not printed due to
+#  non-deterministic path.
+# *Attempting: 
+# *RESTORE FROM
+#  '$MYSQLTEST_VARDIR/bup_backupdir_5.bak';
+ERROR HY000: The path specified for the system variable backupdir cannot be accessed or is invalid. ref: This_is_really_stupid/not/there/at/all
+#
+# Set backupdir to an absolute path outside of datadir.
+#
+# SET @@global.backupdir = '$MYSQLTEST_VARDIR/tmp';
+# Perform backup to a pure file name.
+BACKUP DATABASE bup_backupdir TO 'bup_backupdir_6.bak';
+backup_id
+#
+# Ensure backup image file went to the correct location
+# Perform restore from a pure file name.
+RESTORE FROM 'bup_backupdir_6.bak' OVERWRITE;
+backup_id
+#
+# Perform backup to a relative path name.
+BACKUP DATABASE bup_backupdir TO 'bup_backupdir/bup_backupdir_6.bak';
+backup_id
+#
+# Ensure backup image file went to the correct location
+# Perform restore from a relative path name.
+RESTORE FROM 'bup_backupdir/bup_backupdir_6.bak' OVERWRITE;
+backup_id
+#
+# Perform backup to a backref path name.
+BACKUP DATABASE bup_backupdir TO '../bup_backupdir_6.bak';
+backup_id
+#
+# Ensure backup image file went to the correct location
+# Perform restore from a backref path name.
+RESTORE FROM '../bup_backupdir_6.bak' OVERWRITE;
+backup_id
+#
+# Perform backup to an absolute path name.
+# *Actual BACKUP DATABASE command not printed due to
+#  non-deterministic path.
+# *Performing: 
+# *BACKUP DATABASE bup_backupdir TO
+#  '$MYSQLTEST_VARDIR/bup_backupdir_6.bak';
+backup_id
+#
+# Ensure backup image file went to the correct location
+# Perform restore from an absolute path name.
+# *Actual RESTORE command not printed due to
+#  non-deterministic path.
+# *Performing: 
+# *RESTORE FROM
+#  '$MYSQLTEST_VARDIR/bup_backupdir_6.bak';
+backup_id
+#
+#
+# Set backupdir to an absolute path outside of datadir
+# with a trailing slash.
+#
+# SET @@global.backupdir = '$MYSQLTEST_VARDIR/tmp/';
+# Perform backup to a pure file name.
+BACKUP DATABASE bup_backupdir TO 'bup_backupdir_6.bak';
+backup_id
+#
+# Ensure backup image file went to the correct location
+# Perform restore from a pure file name.
+RESTORE FROM 'bup_backupdir_6.bak' OVERWRITE;
+backup_id
+#
+# Perform backup to a relative path name.
+BACKUP DATABASE bup_backupdir TO 'bup_backupdir/bup_backupdir_6.bak';
+backup_id
+#
+# Ensure backup image file went to the correct location
+# Perform restore from a relative path name.
+RESTORE FROM 'bup_backupdir/bup_backupdir_6.bak' OVERWRITE;
+backup_id
+#
+# Perform backup to a backref path name.
+BACKUP DATABASE bup_backupdir TO '../bup_backupdir_6.bak';
+backup_id
+#
+# Ensure backup image file went to the correct location
+# Perform restore from a backref path name.
+RESTORE FROM '../bup_backupdir_6.bak' OVERWRITE;
+backup_id
+#
+# Perform backup to an absolute path name.
+# *Actual BACKUP DATABASE command not printed due to
+#  non-deterministic path.
+# *Performing: 
+# *BACKUP DATABASE bup_backupdir TO
+#  '$MYSQLTEST_VARDIR/bup_backupdir_6.bak';
+backup_id
+#
+# Ensure backup image file went to the correct location
+# Perform restore from an absolute path name.
+# *Actual RESTORE command not printed due to
+#  non-deterministic path.
+# *Performing: 
+# *RESTORE FROM
+#  '$MYSQLTEST_VARDIR/bup_backupdir_6.bak';
+backup_id
+#
+#
+# Set backupdir to an existent file.
+#
+# Create file.
+# Set backupdir.
+SET @@global.backupdir = '../../tmp/bup_backupdir_file.txt';
+# Attempt backup to a pure file name in invalid backupdir.
+BACKUP DATABASE bup_backupdir TO 'bup_backupdir_x.bak';
+ERROR HY000: Can't create/write to file 'MYSQLTEST_VARDIR/tmp/bup_backupdir_file.txt/bup_backupdir_x.bak' (Errcode: 20)
+# Attempt restore from a pure file name in invalid backupdir.
+RESTORE FROM 'bup_backupdir_x.bak' OVERWRITE;
+ERROR HY000: File 'MYSQLTEST_VARDIR/tmp/bup_backupdir_file.txt/bup_backupdir_x.bak' not found (Errcode: 20)
+# Attempt backup to a relative path name in invalid backupdir.
+# Try 'test' in case current directory is used instead of backupdir.
+BACKUP DATABASE bup_backupdir TO 'test/bup_backupdir_x.bak';
+ERROR HY000: Can't create/write to file 'MYSQLTEST_VARDIR/tmp/bup_backupdir_file.txt/test/bup_backupdir_x.bak' (Errcode: 20)
+# Attempt restore from a relative path name in invalid backupdir.
+# Try 'test' in case current directory is used instead of backupdir.
+RESTORE FROM 'test/bup_backupdir_x.bak' OVERWRITE;
+ERROR HY000: File 'MYSQLTEST_VARDIR/tmp/bup_backupdir_file.txt/test/bup_backupdir_x.bak' not found (Errcode: 20)
+# Attempt backup to a backref path in invalid backupdir.
+###
+### WARNING! This should fail, not work! See Bug#43747.
+### WARNING! This should fail, not work! See Bug#43747.
+### WARNING! This should fail, not work! See Bug#43747.
+### Remove this comment and the next three lines and uncomment
+### the error line when Bug#43747 is fixed.
+###
+BACKUP DATABASE bup_backupdir TO '../bup_backupdir_x.bak';
+backup_id
+#
+# Attempt restore from a backref path in invalid backupdir.
+###
+### WARNING! This should fail, not work! See Bug#43747.
+### WARNING! This should fail, not work! See Bug#43747.
+### WARNING! This should fail, not work! See Bug#43747.
+### Remove this comment, the next line, and uncomment
+### the error line when Bug#43747 is fixed.
+###
+RESTORE FROM '../bup_backupdir_x.bak' OVERWRITE;
+backup_id
+#
+###
+### Remove this comment and the next line when Bug#43747 is fixed.
+###
+# Attempt backup to an absolute path.
+# *Actual BACKUP DATABASE command not printed due to
+#  non-deterministic path.
+# *Attempting: 
+# *BACKUP DATABASE bup_backupdir TO
+#  '$MYSQLTEST_VARDIR/bup_backupdir_x.bak';
+###
+### WARNING! This should fail, not work! See Bug#43747.
+### WARNING! This should fail, not work! See Bug#43747.
+### WARNING! This should fail, not work! See Bug#43747.
+### Remove this comment and the next three lines and uncomment
+### the error line when Bug#43747 is fixed.
+###
+backup_id
+#
+# Attempt restore from an absolute path.
+# *Actual RESTORE command not printed due to
+#  non-deterministic path.
+# *Attempting: 
+# *RESTORE FROM
+#  '$MYSQLTEST_VARDIR/bup_backupdir_x.bak';
+###
+### WARNING! This should fail, not work! See Bug#43747.
+### WARNING! This should fail, not work! See Bug#43747.
+### WARNING! This should fail, not work! See Bug#43747.
+### Remove this comment and the next line and uncomment
+### the error line when Bug#43747 is fixed.
+###
+backup_id
+#
+###
+### Remove this comment and the next line when Bug#43747 is fixed.
+###
+#
+# Cleanup
+#
 DROP DATABASE bup_backupdir;
+# Reset backupdir 
+SET @@global.backupdir= @old_backupdir;

=== added file 'mysql-test/suite/backup/r/backup_backupdir_not_windows.result'
--- a/mysql-test/suite/backup/r/backup_backupdir_not_windows.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/r/backup_backupdir_not_windows.result	2009-04-01 15:26:41 +0000
@@ -0,0 +1,451 @@
+# Save backupdir 
+SET @old_backupdir= @@backupdir;
+DROP DATABASE IF EXISTS bup_backupdir_nw;
+#
+# Create a database to be used throughout the test case
+#
+CREATE DATABASE bup_backupdir_nw;
+CREATE TABLE bup_backupdir_nw.t1(a INT);
+INSERT INTO bup_backupdir_nw.t1 VALUES (1), (2), (3);
+#
+# Dangling symlink.
+#
+# Ensure that the backup directory does not exist.
+# Create a symlink.
+#   VARDIR/tmp/bup_backupdir_nw_symlink -> VARDIR/tmp/bup_backupdir_nw/symdir
+# Set backupdir to the dangling symlink
+SET @@global.backupdir = '../../tmp/bup_backupdir_nw_symlink';
+Warnings:
+Warning	####	The path specified for the system variable backupdir cannot be accessed or is invalid. ref: ../../tmp/bup_backupdir_nw_symlink
+# Attempt backup to a pure file name in invalid backupdir.
+BACKUP DATABASE bup_backupdir_nw TO 'bup_backupdir_nw_x.bak';
+ERROR HY000: The path specified for the system variable backupdir cannot be accessed or is invalid. ref: ../../tmp/bup_backupdir_nw_symlink
+# Attempt restore from a pure file name in invalid backupdir.
+RESTORE FROM 'bup_backupdir_nw_x.bak' OVERWRITE;
+ERROR HY000: The path specified for the system variable backupdir cannot be accessed or is invalid. ref: ../../tmp/bup_backupdir_nw_symlink
+# Attempt backup to a relative path name in invalid backupdir.
+# Try 'test' in case current directory is used instead of backupdir.
+BACKUP DATABASE bup_backupdir_nw TO 'test/bup_backupdir_nw_x.bak';
+ERROR HY000: The path specified for the system variable backupdir cannot be accessed or is invalid. ref: ../../tmp/bup_backupdir_nw_symlink
+# Attempt restore from a relative path name in invalid backupdir.
+# Try 'test' in case current directory is used instead of backupdir.
+RESTORE FROM 'test/bup_backupdir_nw_x.bak' OVERWRITE;
+ERROR HY000: The path specified for the system variable backupdir cannot be accessed or is invalid. ref: ../../tmp/bup_backupdir_nw_symlink
+# Attempt backup to a backref path in invalid backupdir.
+BACKUP DATABASE bup_backupdir_nw TO '../bup_backupdir_nw_x.bak';
+ERROR HY000: The path specified for the system variable backupdir cannot be accessed or is invalid. ref: ../../tmp/bup_backupdir_nw_symlink
+# Attempt restore from a backref path in invalid backupdir.
+RESTORE FROM '../bup_backupdir_nw_x.bak' OVERWRITE;
+ERROR HY000: The path specified for the system variable backupdir cannot be accessed or is invalid. ref: ../../tmp/bup_backupdir_nw_symlink
+# Attempt backup to an absolute path.
+# *Actual BACKUP DATABASE command not printed due to
+#  non-deterministic path.
+# *Attempting: 
+# *BACKUP DATABASE bup_backupdir_nw TO
+#  '$MYSQLTEST_VARDIR/bup_backupdir_nw_x.bak';
+ERROR HY000: The path specified for the system variable backupdir cannot be accessed or is invalid. ref: ../../tmp/bup_backupdir_nw_symlink
+# Attempt restore from an absolute path.
+# *Actual RESTORE command not printed due to
+#  non-deterministic path.
+# *Attempting: 
+# *RESTORE FROM
+#  '$MYSQLTEST_VARDIR/bup_backupdir_nw_x.bak';
+ERROR HY000: The path specified for the system variable backupdir cannot be accessed or is invalid. ref: ../../tmp/bup_backupdir_nw_symlink
+#
+# Symlink to existent directory.
+#
+# Create directories for symlink tests
+#   MYSQLTEST_VARDIR/tmp/bup_backupdir_nw
+#   MYSQLTEST_VARDIR/tmp/bup_backupdir_nw/symdir
+#   MYSQLTEST_VARDIR/tmp/bup_backupdir_nw/symdir/subdir
+# Set backupdir to symlink
+#   VARDIR/tmp/bup_backupdir_nw_symlink -> VARDIR/tmp/bup_backupdir_nw/symdir
+SET @@global.backupdir = '../../tmp/bup_backupdir_nw_symlink';
+# Perform backup to a pure file name.
+BACKUP DATABASE bup_backupdir_nw TO 'bup_backupdir_nw_1.bak';
+backup_id
+#
+# Ensure backup image file went to the correct location
+# Perform restore from a pure file name.
+RESTORE FROM 'bup_backupdir_nw_1.bak' OVERWRITE;
+backup_id
+#
+# Perform backup to a relative path name.
+BACKUP DATABASE bup_backupdir_nw TO 'subdir/bup_backupdir_nw_1.bak';
+backup_id
+#
+# Ensure backup image file went to the correct location
+# Perform restore from a relative path name.
+RESTORE FROM 'subdir/bup_backupdir_nw_1.bak' OVERWRITE;
+backup_id
+#
+# Perform backup to a backref path name.
+BACKUP DATABASE bup_backupdir_nw TO '../bup_backupdir_nw_1.bak';
+backup_id
+#
+# Ensure backup image file went to the correct location
+###
+### WARNING! The file should go relative to the symlink target,
+### not relative to the symlink! See Bug#43767.
+### Remove this comment and the next line and uncomment
+### the file_exists line when Bug#43767 is fixed.
+###
+# Perform restore from a backref path name.
+RESTORE FROM '../bup_backupdir_nw_1.bak' OVERWRITE;
+backup_id
+#
+###
+### WARNING! The file should go relative to the symlink target,
+### not relative to the symlink! See Bug#43767.
+### Remove this comment and the next line and uncomment
+### the remove_file line when Bug#43767 is fixed.
+###
+# Perform backup to an absolute path name.
+# *Actual BACKUP DATABASE command not printed due to
+#  non-deterministic path.
+# *Performing: 
+# *BACKUP DATABASE bup_backupdir_nw TO
+#  '$MYSQLTEST_VARDIR/bup_backupdir_nw_1.bak';
+backup_id
+#
+# Ensure backup image file went to the correct location
+# Perform restore from an absolute path name.
+# *Actual RESTORE command not printed due to
+#  non-deterministic path.
+# *Performing: 
+# *RESTORE FROM
+#  '$MYSQLTEST_VARDIR/bup_backupdir_nw_1.bak';
+backup_id
+#
+# Remove subdirectory
+# Remove backup directory
+#
+# Symlink to existent plain file.
+#
+# Create a file at the target path of the symlink.
+# Set backupdir to symlink
+SET @@global.backupdir = '../../tmp/bup_backupdir_nw_symlink';
+# Attempt backup to a pure file name in invalid backupdir.
+BACKUP DATABASE bup_backupdir_nw TO 'bup_backupdir_nw_x.bak';
+ERROR HY000: Can't create/write to file 'MYSQLTEST_VARDIR/tmp/bup_backupdir_nw_symlink/bup_backupdir_nw_x.bak' (Errcode: 20)
+# Attempt restore from a pure file name in invalid backupdir.
+RESTORE FROM 'bup_backupdir_nw_x.bak' OVERWRITE;
+ERROR HY000: File 'MYSQLTEST_VARDIR/tmp/bup_backupdir_nw_symlink/bup_backupdir_nw_x.bak' not found (Errcode: 20)
+# Attempt backup to a relative path name in invalid backupdir.
+# Try 'test' in case current directory is used instead of backupdir.
+BACKUP DATABASE bup_backupdir_nw TO 'test/bup_backupdir_nw_x.bak';
+ERROR HY000: Can't create/write to file 'MYSQLTEST_VARDIR/tmp/bup_backupdir_nw_symlink/test/bup_backupdir_nw_x.bak' (Errcode: 20)
+# Attempt restore from a relative path name in invalid backupdir.
+# Try 'test' in case current directory is used instead of backupdir.
+RESTORE FROM 'test/bup_backupdir_nw_x.bak' OVERWRITE;
+ERROR HY000: File 'MYSQLTEST_VARDIR/tmp/bup_backupdir_nw_symlink/test/bup_backupdir_nw_x.bak' not found (Errcode: 20)
+###
+### Remove this comment and the next two lines when Bug#43747 is fixed.
+###
+# Attempt backup to a backref path in invalid backupdir.
+###
+### WARNING! This should fail, not work! See Bug#43747.
+### WARNING! This should fail, not work! See Bug#43747.
+### WARNING! This should fail, not work! See Bug#43747.
+### Remove this comment and the next three lines and uncomment
+### the error line when Bug#43747 is fixed.
+###
+BACKUP DATABASE bup_backupdir_nw TO '../bup_backupdir_nw_x.bak';
+backup_id
+#
+# Attempt restore from a backref path in invalid backupdir.
+###
+### WARNING! This should fail, not work! See Bug#43747.
+### WARNING! This should fail, not work! See Bug#43747.
+### WARNING! This should fail, not work! See Bug#43747.
+### Remove this comment, the next line, and uncomment
+### the error line when Bug#43747 is fixed.
+###
+RESTORE FROM '../bup_backupdir_nw_x.bak' OVERWRITE;
+backup_id
+#
+###
+### Remove this comment and the next line when Bug#43747 is fixed.
+###
+# Attempt backup to an absolute path.
+# *Actual BACKUP DATABASE command not printed due to
+#  non-deterministic path.
+# *Attempting: 
+# *BACKUP DATABASE bup_backupdir_nw TO
+#  '$MYSQLTEST_VARDIR/bup_backupdir_nw_1.bak';
+###
+### WARNING! This should fail, not work! See Bug#43747.
+### WARNING! This should fail, not work! See Bug#43747.
+### WARNING! This should fail, not work! See Bug#43747.
+### Remove this comment and the next three lines and uncomment
+### the error line when Bug#43747 is fixed.
+###
+backup_id
+#
+# Attempt restore from an absolute path.
+# *Actual RESTORE command not printed due to
+#  non-deterministic path.
+# *Attempting: 
+# *RESTORE FROM
+#  '$MYSQLTEST_VARDIR/bup_backupdir_nw_x.bak';
+###
+### WARNING! This should fail, not work! See Bug#43747.
+### WARNING! This should fail, not work! See Bug#43747.
+### WARNING! This should fail, not work! See Bug#43747.
+### Remove this comment and the next line and uncomment
+### the error line when Bug#43747 is fixed.
+###
+backup_id
+#
+###
+### Remove this comment and the next line when Bug#43747 is fixed.
+###
+# Remove file
+# Remove symlink
+#
+# Pipe.
+#
+###
+### Creating a pipe in the same test that sets the backupdir variable
+### lets mysql-test-run hang if the pipe is not deleted before the
+### test ends. See Bug#43570.
+### We do proper cleanup at test end. But if the test ends due to
+### an unexpected error/success, there is no chance to remove the pipe.
+### --disable_abort_on_error avoids termination before cleanup.
+### Remove this comment and the next line when Bug#43570 is fixed.
+###
+# Create a named pipe
+# Set backupdir to the pipe
+SET @@global.backupdir = '../../tmp/bup_backupdir_nw_fifo';
+# Attempt backup to a pure file name in invalid backupdir.
+BACKUP DATABASE bup_backupdir_nw TO 'bup_backupdir_nw_x.bak';
+ERROR HY000: Can't create/write to file 'MYSQLTEST_VARDIR/tmp/bup_backupdir_nw_fifo/bup_backupdir_nw_x.bak' (Errcode: 20)
+# Attempt restore from a pure file name in invalid backupdir.
+RESTORE FROM 'bup_backupdir_nw_x.bak' OVERWRITE;
+ERROR HY000: File 'MYSQLTEST_VARDIR/tmp/bup_backupdir_nw_fifo/bup_backupdir_nw_x.bak' not found (Errcode: 20)
+# Attempt backup to a relative path name in invalid backupdir.
+# Try 'test' in case current directory is used instead of backupdir.
+BACKUP DATABASE bup_backupdir_nw TO 'test/bup_backupdir_nw_x.bak';
+ERROR HY000: Can't create/write to file 'MYSQLTEST_VARDIR/tmp/bup_backupdir_nw_fifo/test/bup_backupdir_nw_x.bak' (Errcode: 20)
+# Attempt restore from a relative path name in invalid backupdir.
+# Try 'test' in case current directory is used instead of backupdir.
+RESTORE FROM 'test/bup_backupdir_nw_x.bak' OVERWRITE;
+ERROR HY000: File 'MYSQLTEST_VARDIR/tmp/bup_backupdir_nw_fifo/test/bup_backupdir_nw_x.bak' not found (Errcode: 20)
+# Attempt backup to a backref path in invalid backupdir.
+###
+### WARNING! This should fail, not work! See Bug#43747.
+### WARNING! This should fail, not work! See Bug#43747.
+### WARNING! This should fail, not work! See Bug#43747.
+### Remove this comment, uncomment the error line, remove "send",
+### and remove everything after the BACKUP statement
+### until and including "reap", when Bug#43747 is fixed.
+###
+BACKUP DATABASE bup_backupdir_nw TO '../bup_backupdir_nw_fifo';
+# connection con1
+###
+### Normally, the 'connect' command is not logged. But due to
+### the 'disable_abort_on_error' command it is. See Bug#43588.
+### Remove this comment and the next line when Bug#43588 is fixed.
+###
+###
+### Re-enabling query log. See above for an explanation.
+### Remove this comment and the next line when Bug#43588 is fixed.
+###
+# Cat the backup image from the pipe to a file.
+# connection default
+# Receive status from BACKUP
+backup_id
+#
+# Attempt restore from a backref path in invalid backupdir.
+###
+### WARNING! This should fail, not work! See Bug#43747.
+### WARNING! This should fail, not work! See Bug#43747.
+### WARNING! This should fail, not work! See Bug#43747.
+### Remove this comment, uncomment the error line, remove "send",
+### and remove everything after the RESTORE statement
+### until and including "reap", when Bug#43747 is fixed.
+###
+RESTORE FROM '../bup_backupdir_nw_fifo' OVERWRITE;
+# connection con1
+###
+### Normally, the 'connect' command is not logged. But due to
+### the 'disable_abort_on_error' command it is. See Bug#43588.
+### Remove this comment and the next line when Bug#43588 is fixed.
+###
+###
+### Re-enabling query log. See above for an explanation.
+### Remove this comment and the next line when Bug#43588 is fixed.
+###
+# Cat the backup image from a file to the pipe.
+# connection default
+# Receive status from RESTORE
+backup_id
+#
+###
+### WARNING! This file should not extist.
+### Remove this comment and the next line when Bug#43747 is fixed.
+###
+# Attempt backup to an absolute path.
+# *Actual BACKUP DATABASE command not printed due to
+#  non-deterministic path.
+# *Attempting: 
+# *BACKUP DATABASE bup_backupdir_nw TO
+#  '$MYSQLTEST_VARDIR/bup_backupdir_nw_x.bak';
+###
+### WARNING! This should fail, not work! See Bug#43747.
+### WARNING! This should fail, not work! See Bug#43747.
+### WARNING! This should fail, not work! See Bug#43747.
+### Remove this comment and the next three lines and uncomment
+### the error line when Bug#43747 is fixed.
+###
+backup_id
+#
+# Attempt restore from an absolute path.
+# *Actual RESTORE command not printed due to
+#  non-deterministic path.
+# *Attempting: 
+# *RESTORE FROM
+#  '$MYSQLTEST_VARDIR/bup_backupdir_nw_x.bak';
+###
+### WARNING! This should fail, not work! See Bug#43747.
+### WARNING! This should fail, not work! See Bug#43747.
+### WARNING! This should fail, not work! See Bug#43747.
+### Remove this comment and the next line and uncomment
+### the error line when Bug#43747 is fixed.
+###
+backup_id
+#
+###
+### Remove this comment and the next line when Bug#43747 is fixed.
+###
+# Attempt backup into the pipe by using empty file name.
+BACKUP DATABASE bup_backupdir_nw TO '';
+ERROR HY000: Malformed file path ''
+# Attempt restore from the pipe by using empty file name.
+RESTORE FROM '' OVERWRITE;
+ERROR HY000: Malformed file path ''
+#
+# Symlink to existent pipe.
+#
+# Create a symlink to the existent pipe.
+# Set backupdir to symlink
+SET @@global.backupdir = '../../tmp/bup_backupdir_nw_symlink';
+# Attempt backup to a pure file name in invalid backupdir.
+BACKUP DATABASE bup_backupdir_nw TO 'bup_backupdir_nw_x.bak';
+ERROR HY000: Can't create/write to file 'MYSQLTEST_VARDIR/tmp/bup_backupdir_nw_symlink/bup_backupdir_nw_x.bak' (Errcode: 20)
+# Attempt restore from a pure file name in invalid backupdir.
+RESTORE FROM 'bup_backupdir_nw_x.bak' OVERWRITE;
+ERROR HY000: File 'MYSQLTEST_VARDIR/tmp/bup_backupdir_nw_symlink/bup_backupdir_nw_x.bak' not found (Errcode: 20)
+# Attempt backup to a relative path name in invalid backupdir.
+# Try 'test' in case current directory is used instead of backupdir.
+BACKUP DATABASE bup_backupdir_nw TO 'test/bup_backupdir_nw_x.bak';
+ERROR HY000: Can't create/write to file 'MYSQLTEST_VARDIR/tmp/bup_backupdir_nw_symlink/test/bup_backupdir_nw_x.bak' (Errcode: 20)
+# Attempt restore from a relative path name in invalid backupdir.
+# Try 'test' in case current directory is used instead of backupdir.
+RESTORE FROM 'test/bup_backupdir_nw_x.bak' OVERWRITE;
+ERROR HY000: File 'MYSQLTEST_VARDIR/tmp/bup_backupdir_nw_symlink/test/bup_backupdir_nw_x.bak' not found (Errcode: 20)
+# Attempt backup to a backref path in invalid backupdir.
+###
+### WARNING! This should fail, not work! See Bug#43747.
+### WARNING! This should fail, not work! See Bug#43747.
+### WARNING! This should fail, not work! See Bug#43747.
+### Remove this comment, uncomment the error line, remove "send",
+### and remove everything after the BACKUP statement
+### until and including "reap", when Bug#43747 is fixed.
+###
+BACKUP DATABASE bup_backupdir_nw TO '../bup_backupdir_nw_fifo';
+# connection con1
+###
+### Normally, the 'connect' command is not logged. But due to
+### the 'disable_abort_on_error' command it is. See Bug#43588.
+### Remove this comment and the next line when Bug#43588 is fixed.
+###
+###
+### Re-enabling query log. See above for an explanation.
+### Remove this comment and the next line when Bug#43588 is fixed.
+###
+# Cat the backup image from the pipe to a file.
+# connection default
+# Receive status from BACKUP
+backup_id
+#
+# Attempt restore from a backref path in invalid backupdir.
+###
+### WARNING! This should fail, not work! See Bug#43747.
+### WARNING! This should fail, not work! See Bug#43747.
+### WARNING! This should fail, not work! See Bug#43747.
+### Remove this comment, uncomment the error line, remove "send",
+### and remove everything after the RESTORE statement
+### until and including "reap", when Bug#43747 is fixed.
+###
+RESTORE FROM '../bup_backupdir_nw_fifo' OVERWRITE;
+# connection con1
+###
+### Normally, the 'connect' command is not logged. But due to
+### the 'disable_abort_on_error' command it is. See Bug#43588.
+### Remove this comment and the next line when Bug#43588 is fixed.
+###
+###
+### Re-enabling query log. See above for an explanation.
+### Remove this comment and the next line when Bug#43588 is fixed.
+###
+# Cat the backup image from a file to the pipe.
+# connection default
+# Receive status from RESTORE
+backup_id
+#
+###
+### WARNING! This file should not extist.
+### Remove this comment and the next line when Bug#43747 is fixed.
+###
+# Attempt backup to an absolute path.
+# *Actual BACKUP DATABASE command not printed due to
+#  non-deterministic path.
+# *Attempting: 
+# *BACKUP DATABASE bup_backupdir_nw TO
+#  '$MYSQLTEST_VARDIR/bup_backupdir_nw_x.bak';
+###
+### WARNING! This should fail, not work! See Bug#43747.
+### WARNING! This should fail, not work! See Bug#43747.
+### WARNING! This should fail, not work! See Bug#43747.
+### Remove this comment and the next three lines and uncomment
+### the error line when Bug#43747 is fixed.
+###
+backup_id
+#
+# Attempt restore from an absolute path.
+# *Actual RESTORE command not printed due to
+#  non-deterministic path.
+# *Attempting: 
+# *RESTORE FROM
+#  '$MYSQLTEST_VARDIR/bup_backupdir_nw_x.bak';
+###
+### WARNING! This should fail, not work! See Bug#43747.
+### WARNING! This should fail, not work! See Bug#43747.
+### WARNING! This should fail, not work! See Bug#43747.
+### Remove this comment and the next line and uncomment
+### the error line when Bug#43747 is fixed.
+###
+backup_id
+#
+###
+### Remove this comment and the next line when Bug#43747 is fixed.
+###
+# Attempt backup into the pipe by using empty file name.
+BACKUP DATABASE bup_backupdir_nw TO '';
+ERROR HY000: Malformed file path ''
+# Attempt restore from the pipe by using empty file name.
+RESTORE FROM '' OVERWRITE;
+ERROR HY000: Malformed file path ''
+# Remove symlink
+# Remove pipe
+###
+### Re-enabling abort on error. See above for an explanation.
+### Remove this comment and the next line when Bug#43570 is fixed.
+###
+#
+# Cleanup
+#
+DROP DATABASE bup_backupdir_nw;
+# Reset backupdir 
+SET @@global.backupdir= @old_backupdir;

=== added file 'mysql-test/suite/backup/r/backup_backupdir_sync.result'
--- a/mysql-test/suite/backup/r/backup_backupdir_sync.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/r/backup_backupdir_sync.result	2009-04-01 15:26:41 +0000
@@ -0,0 +1,100 @@
+# Save backupdir 
+SET @old_backupdir= @@backupdir;
+SET DEBUG_SYNC= 'RESET';
+DROP DATABASE IF EXISTS bup_backupdir;
+#
+# Create a database to be used throughout the test case
+#
+CREATE DATABASE bup_backupdir;
+CREATE TABLE bup_backupdir.t1(a INT);
+INSERT INTO bup_backupdir.t1 VALUES (1), (2), (3);
+# Create directories.
+#   MYSQLTEST_VARDIR/tmp/bup_backupdir_s
+#   MYSQLTEST_VARDIR/tmp/bup_backupdir_s_1
+#   MYSQLTEST_VARDIR/tmp/bup_backupdir_s_2
+#
+# Blackbox test. Set backupdir differently in two connections
+# one after the other.
+# This test does not require DEBUG_SYNC. But it profits from the
+# setup of directories done for the other tests.
+#
+# Set backupdir.
+SET @@global.backupdir = '../../tmp/bup_backupdir_s_1';
+# connection con1
+# Set backupdir.
+SET @@global.backupdir = '../../tmp/bup_backupdir_s_2';
+# connection default
+# Run BACKUP.
+BACKUP DATABASE bup_backupdir TO 'bup_backupdir_s_1.bak';
+backup_id
+#
+# Ensure backup image file went to the correct location
+# connection con1
+# Run BACKUP.
+BACKUP DATABASE bup_backupdir TO 'bup_backupdir_s_2.bak';
+backup_id
+#
+# Ensure backup image file went to the correct location
+# connection default
+# Run RESTORE.
+RESTORE FROM 'bup_backupdir_s_1.bak' OVERWRITE;
+backup_id
+#
+# connection con1
+# Run RESTORE.
+RESTORE FROM 'bup_backupdir_s_2.bak' OVERWRITE;
+backup_id
+#
+# connection default
+#
+# Whitebox test. Have a synchronization point after checking backupdir.
+# While waiting there, remove the backup directory.
+#
+# Set backupdir.
+SET @@global.backupdir = '../../tmp/bup_backupdir_s';
+# Activate sync point and start BACKUP.
+SET DEBUG_SYNC= 'after_backup_checked_backupdir SIGNAL checked WAIT_FOR go';
+BACKUP DATABASE bup_backupdir TO 'bup_backupdir_s_3.bak';
+# connection con1
+# Wait for BACKUP to reach the sync point.
+SET DEBUG_SYNC= 'now WAIT_FOR checked';
+# Remove backup directory.
+# Signal BACKUP to continue.
+SET DEBUG_SYNC= 'now SIGNAL go';
+# connection default
+# Retrieve result from BACKUP.
+ERROR HY000: Can't create/write to file 'MYSQLTEST_VARDIR/tmp/bup_backupdir_s/bup_backupdir_s_3.bak' (Errcode: 2)
+#
+# Whitebox test. Set backupdir to a symlink,
+# which references an existent directory.
+# Have a synchronization point after checking backupdir.
+# While waiting there, change the symlink to reference an existent file.
+#
+# Create a directory.
+#   VARDIR/tmp/bup_backupdir_s
+# Create a symlink.
+#   VARDIR/tmp/bup_backupdir_s_symlink -> VARDIR/tmp/bup_backupdir_s
+# Set backupdir.
+SET @@global.backupdir = '../../tmp/bup_backupdir_s_symlink';
+# Activate sync point and start BACKUP.
+SET DEBUG_SYNC= 'after_backup_checked_backupdir SIGNAL checked WAIT_FOR go';
+BACKUP DATABASE bup_backupdir TO 'bup_backupdir_s_4.bak';
+# connection con1
+# Wait for BACKUP to reach the sync point.
+SET DEBUG_SYNC= 'now WAIT_FOR checked';
+# Create file.
+#   VARDIR/tmp/bup_backupdir_s_file
+# Re-create symlink.
+#   VARDIR/tmp/bup_backupdir_s_symlink -> VARDIR/tmp/bup_backupdir_s_file
+# Signal BACKUP to continue.
+SET DEBUG_SYNC= 'now SIGNAL go';
+# connection default
+# Retrieve result from BACKUP.
+ERROR HY000: Can't create/write to file 'MYSQLTEST_VARDIR/tmp/bup_backupdir_s_symlink/bup_backupdir_s_4.bak' (Errcode: 2)
+#
+# Cleanup
+#
+SET DEBUG_SYNC= 'RESET';
+DROP DATABASE bup_backupdir;
+# Reset backupdir 
+SET @@global.backupdir= @old_backupdir;

=== modified file 'mysql-test/suite/backup/t/backup_backupdir.test'
--- a/mysql-test/suite/backup/t/backup_backupdir.test	2009-02-26 22:19:09 +0000
+++ b/mysql-test/suite/backup/t/backup_backupdir.test	2009-04-01 15:26:41 +0000
@@ -1,151 +1,528 @@
 #
 # This test is designed to test the new backupdir variable.
+# BUG#35230 Backup: no backupdir
+# Chuck Bell, 2008-08-08
+# Ingo Struewing, 2009-03-12, WL#4518 - Online Backup: Test backupdir variable
 #
 
 --source include/not_embedded.inc
 
 # Suppress warning about expected backup/restore errors
-disable_query_log;
+--disable_query_log
 call mtr.add_suppression("Backup:");
 call mtr.add_suppression("Restore:");
-enable_query_log;
-
-let $MYSQLD_DATADIR= `select @@datadir`;
+--enable_query_log
 
---echo Reset backupdir 
-SET @@global.backupdir = @@global.datadir;
+--echo # Save backupdir 
+SET @old_backupdir= @@backupdir;
 
 --disable_warnings
 DROP DATABASE IF EXISTS bup_backupdir;
 --enable_warnings
 
---echo Create a database
+--echo #
+--echo # Create a database to be used throughout the test case
+--echo #
 CREATE DATABASE bup_backupdir;
 CREATE TABLE bup_backupdir.t1(a INT);
 INSERT INTO bup_backupdir.t1 VALUES (1), (2), (3);
 
-#
-# The following tests the backupdir variable by changing it to
-# redirect the output of the backup command/input of the restore
-# command.
-#
-
+--echo #
+--echo # Create a backup directory to be used throughout the test case
+--echo #
 --error 0,1,2
-rmdir $MYSQLTEST_VARDIR/tmp/backup;
+--rmdir $MYSQLTEST_VARDIR/tmp/bup_backupdir
+--mkdir $MYSQLTEST_VARDIR/tmp/bup_backupdir
+
+--echo #
+--echo # The following tests the backupdir variable by changing it to redirect
+--echo # the output of the backup command/input of the restore command.
+--echo #
 
---echo Create a directory for backup images
-mkdir $MYSQLTEST_VARDIR/tmp/backup;
+--echo # Set backupdir 
+SET @@global.backupdir = '../../tmp/bup_backupdir';
 
---echo Reset backupdir 
-SET @@global.backupdir = '../../tmp/backup';
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir/bup_backupdir_1.bak
 
---echo Perform backup
+--echo # Perform backup
 --replace_column 1 #
-BACKUP DATABASE bup_backupdir TO 'bup_backupdir1.bak';
+BACKUP DATABASE bup_backupdir TO 'bup_backupdir_1.bak';
 
---echo Ensure backup image file went to the correct location
---echo $MYSQLTEST_DIR/backup/bup_backupdir.bak
---file_exists $MYSQLTEST_VARDIR/tmp/backup/bup_backupdir1.bak
+--echo # Ensure backup image file went to the correct location
+--file_exists $MYSQLTEST_VARDIR/tmp/bup_backupdir/bup_backupdir_1.bak
 
---echo Perform restore
+--echo # Perform restore
 --replace_column 1 #
-RESTORE FROM 'bup_backupdir1.bak' OVERWRITE;
+RESTORE FROM 'bup_backupdir_1.bak' OVERWRITE;
+--remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir/bup_backupdir_1.bak
 
---echo Now do the backup and restore by specifying a path.
+--echo #
+--echo # Do the backup and restore by specifying a path.
+--echo #
 
---echo Perform backup
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir_2.bak
+
+--echo # Perform backup
+--replace_column 1 #
+BACKUP DATABASE bup_backupdir TO '../bup_backupdir_2.bak';
+
+--echo # Ensure backup image file went to the correct location
+--file_exists $MYSQLTEST_VARDIR/tmp/bup_backupdir_2.bak
+
+--echo # Perform restore
 --replace_column 1 #
-BACKUP DATABASE bup_backupdir TO '../bup_backupdir2.bak';
+RESTORE FROM '../bup_backupdir_2.bak' OVERWRITE;
+--remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir_2.bak
 
---echo Ensure backup image file went to the correct location
---file_exists $MYSQLTEST_VARDIR/tmp/bup_backupdir2.bak
+--echo #
+--echo # Use yet another path.
+--echo #
 
---echo Perform restore
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/bup_backupdir_3.bak
+
+--echo # Perform backup
 --replace_column 1 #
-RESTORE FROM '../bup_backupdir2.bak' OVERWRITE;
+BACKUP DATABASE bup_backupdir TO '../../bup_backupdir_3.bak';
 
---echo Perform backup
+--echo # Ensure backup image file went to the correct location
+--file_exists $MYSQLTEST_VARDIR/bup_backupdir_3.bak
+
+--echo # Perform restore
 --replace_column 1 #
-BACKUP DATABASE bup_backupdir TO '../../bup_backupdir3.bak';
+RESTORE FROM '../../bup_backupdir_3.bak' OVERWRITE;
+--remove_file $MYSQLTEST_VARDIR/bup_backupdir_3.bak
 
---echo Ensure backup image file went to the correct location
---file_exists $MYSQLTEST_VARDIR/bup_backupdir3.bak
+--echo #
+--echo # Set backupdir with ending /
+--echo #
 
---echo Reset backupdir with ending /
-SET @@global.backupdir = '../../tmp/backup/';
+SET @@global.backupdir = '../../tmp/bup_backupdir/';
 
---echo Perform backup
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/bup_backupdir_4.bak
+
+--echo # Perform backup
+--replace_column 1 #
+BACKUP DATABASE bup_backupdir TO '../../bup_backupdir_4.bak';
+
+--echo # Ensure backup image file went to the correct location
+--file_exists $MYSQLTEST_VARDIR/bup_backupdir_4.bak
+
+--echo # Perform restore
 --replace_column 1 #
-BACKUP DATABASE bup_backupdir TO '../../bup_backupdir4.bak';
+RESTORE FROM '../../bup_backupdir_4.bak' OVERWRITE;
+--remove_file $MYSQLTEST_VARDIR/bup_backupdir_4.bak
 
---echo Ensure backup image file went to the correct location
---file_exists $MYSQLTEST_VARDIR/bup_backupdir4.bak
+--echo #
+--echo # Attempt backup/restore to/from an invalid relative path.
+--echo #
 
---echo Try a backup to an invalid relative path.
 --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 --replace_regex /Errcode: [0-9]+/Errcode: #/
 --error 1
-BACKUP DATABASE bup_backupdir TO '../not/there/bup_backupdir5.bak';
+BACKUP DATABASE bup_backupdir TO '../not/there/bup_backupdir_x.bak';
 
---echo 
---echo Try a backup to an invalid hard path.
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--replace_regex /Errcode: [0-9]+/Errcode: #/
+--error 29
+RESTORE FROM '../not/there/bup_backupdir_x.bak' OVERWRITE;
 
---echo *Actual BACKUP DATABASE command not printed due to non-deterministic path.
---echo *Performing: 
---echo *BACKUP DATABASE bup_backupdir TO '\$MYSQLTEST_VARDIR/not/there/either/bup_backupdir6.bak';
-# Do not print the SQL command to result file because dir is not deterministic across hosts
+--echo # 
+--echo # Attempt backup/restore to/from an invalid hard path.
+--echo #
+
+--echo # *Actual BACKUP DATABASE command not printed due to
+--echo #  non-deterministic path.
+--echo # *Performing: 
+--echo # *BACKUP DATABASE bup_backupdir TO
+--echo #  '\$MYSQLTEST_VARDIR/not/there/either/bup_backupdir_x.bak';
 --disable_query_log
-# Replace actual dir in error message because $MYSQLTEST_VARDIR is not deterministic
+# Replace actual dir in error message because $MYSQLTEST_VARDIR
+# is not deterministic
 --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 --replace_regex /Errcode: [0-9]+/Errcode: #/
 --error 1
---eval BACKUP DATABASE bup_backupdir TO '$MYSQLTEST_VARDIR/not/there/either/bup_backupdir6.bak';
+eval BACKUP DATABASE bup_backupdir TO
+  '$MYSQLTEST_VARDIR/not/there/either/bup_backupdir_x.bak';
 --enable_query_log
 
---echo
---echo Attempt to set the backupdir to a really long string.
-
-set global max_allowed_packet=1024*100;
+--echo # *Actual RESTORE command not printed due to
+--echo #  non-deterministic path.
+--echo # *Performing: 
+--echo # *RESTORE FROM
+--echo #  '\$MYSQLTEST_VARDIR/not/there/either/bup_backupdir_x.bak';
+--disable_query_log
+# Replace actual dir in error message because $MYSQLTEST_VARDIR
+# is not deterministic
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--replace_regex /Errcode: [0-9]+/Errcode: #/
+--error 29
+eval RESTORE FROM
+  '$MYSQLTEST_VARDIR/not/there/either/bup_backupdir_x.bak' OVERWRITE;
+--enable_query_log
 
---echo
---echo Now attempt to set the backupdir to 512 characters.
---echo
+--echo #
+--echo # Set backupdir to 512 characters.
+--echo #
 # Mask out the error value on the warning.
 --replace_regex /[0000-9999]+/####/
-SET @@global.backupdir = repeat('a',512);
+SET @@global.backupdir= REPEAT('a',512);
 
---echo
---echo Now attempt to set the backupdir to 513 characters.
---echo
+--echo #
+--echo # Attempt to set the backupdir to 513 characters.
+--echo #
 --error ER_PATH_LENGTH
-SET @@global.backupdir = repeat('a',513);
+SET @@global.backupdir= REPEAT('a', 513);
 
---echo
---echo Now attempt to set the backupdir to a really long string.
---echo
+--echo #
+--echo # Attempt to set the backupdir to a really long string.
+--echo #
+SET GLOBAL max_allowed_packet= 100 * 1024;
 --error ER_PATH_LENGTH
-SET @@global.backupdir = repeat('a',99*1024);
+SET @@global.backupdir= REPEAT('a', 99 * 1024);
+SET GLOBAL max_allowed_packet= DEFAULT;
+
 
---echo
---echo Attempt to set the backupdir to something invalid.
---echo
+--echo #
+--echo # Set backupdir to something invalid.
+--echo #
 # Mask out the error value on the warning.
 --replace_regex /[0000-9999]+/####/
-SET @@global.backupdir = 'This_is_really_stupid/not/there/at/all';
+SET @@global.backupdir= 'This_is_really_stupid/not/there/at/all';
 
-set global max_allowed_packet=DEFAULT;
+--echo # Attempt backup to a pure file name in invalid backupdir.
+--error ER_BACKUP_BACKUPDIR
+BACKUP DATABASE bup_backupdir TO 'bup_backupdir_x.bak';
+
+--echo # Attempt restore from a pure file name in invalid backupdir.
+--error ER_BACKUP_BACKUPDIR
+RESTORE FROM 'bup_backupdir_x.bak' OVERWRITE;
+
+--echo # Attempt backup to a relative path name in invalid backupdir.
+--echo # Try 'test' in case current directory is used instead of backupdir.
+--error ER_BACKUP_BACKUPDIR
+BACKUP DATABASE bup_backupdir TO 'test/bup_backupdir_x.bak';
+
+--echo # Attempt restore from a relative path name in invalid backupdir.
+--echo # Try 'test' in case current directory is used instead of backupdir.
+--error ER_BACKUP_BACKUPDIR
+RESTORE FROM 'test/bup_backupdir_x.bak' OVERWRITE;
+
+--echo # Attempt backup to a backref path in invalid backupdir.
+--error ER_BACKUP_BACKUPDIR
+BACKUP DATABASE bup_backupdir TO '../../../../../bup_backupdir_x.bak';
+
+--echo # Attempt restore from a backref path in invalid backupdir.
+--error ER_BACKUP_BACKUPDIR
+RESTORE FROM '../../../../../bup_backupdir_x.bak' OVERWRITE;
+
+--echo # Attempt backup to an absolute path.
+--echo # *Actual BACKUP DATABASE command not printed due to
+--echo #  non-deterministic path.
+--echo # *Attempting: 
+--echo # *BACKUP DATABASE bup_backupdir TO
+--echo #  '\$MYSQLTEST_VARDIR/bup_backupdir_5.bak';
+--disable_query_log
+--error ER_BACKUP_BACKUPDIR
+eval BACKUP DATABASE bup_backupdir TO '$MYSQLTEST_VARDIR/bup_backupdir_5.bak';
+--enable_query_log
 
---echo Cleanup
+--echo # Attempt restore from an absolute path.
+--echo # *Actual RESTORE command not printed due to
+--echo #  non-deterministic path.
+--echo # *Attempting: 
+--echo # *RESTORE FROM
+--echo #  '\$MYSQLTEST_VARDIR/bup_backupdir_5.bak';
+--disable_query_log
+--error ER_BACKUP_BACKUPDIR
+eval RESTORE FROM '$MYSQLTEST_VARDIR/bup_backupdir_5.bak' OVERWRITE;
+--enable_query_log
 
---echo Reset backupdir 
-SET @@global.backupdir = @@global.datadir;
+--echo #
+--echo # Set backupdir to an absolute path outside of datadir.
+--echo #
 
-DROP DATABASE bup_backupdir;
+--echo # SET @@global.backupdir = '\$MYSQLTEST_VARDIR/tmp';
+--disable_query_log
+eval SET @@global.backupdir = '$MYSQLTEST_VARDIR/tmp';
+--enable_query_log
+
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir_6.bak
+
+--echo # Perform backup to a pure file name.
+--replace_column 1 #
+BACKUP DATABASE bup_backupdir TO 'bup_backupdir_6.bak';
+
+--echo # Ensure backup image file went to the correct location
+--file_exists $MYSQLTEST_VARDIR/tmp/bup_backupdir_6.bak
+
+--echo # Perform restore from a pure file name.
+--replace_column 1 #
+RESTORE FROM 'bup_backupdir_6.bak' OVERWRITE;
+--remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir_6.bak
+
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir/bup_backupdir_6.bak
+
+--echo # Perform backup to a relative path name.
+--replace_column 1 #
+BACKUP DATABASE bup_backupdir TO 'bup_backupdir/bup_backupdir_6.bak';
+
+--echo # Ensure backup image file went to the correct location
+--file_exists $MYSQLTEST_VARDIR/tmp/bup_backupdir/bup_backupdir_6.bak
+
+--echo # Perform restore from a relative path name.
+--replace_column 1 #
+RESTORE FROM 'bup_backupdir/bup_backupdir_6.bak' OVERWRITE;
+--remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir/bup_backupdir_6.bak
+
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/bup_backupdir_6.bak
+
+--echo # Perform backup to a backref path name.
+--replace_column 1 #
+BACKUP DATABASE bup_backupdir TO '../bup_backupdir_6.bak';
+
+--echo # Ensure backup image file went to the correct location
+--file_exists $MYSQLTEST_VARDIR/bup_backupdir_6.bak
 
-remove_file $MYSQLTEST_VARDIR/tmp/backup/bup_backupdir1.bak;
-remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir2.bak;
-remove_file $MYSQLTEST_VARDIR/bup_backupdir3.bak;
-remove_file $MYSQLTEST_VARDIR/bup_backupdir4.bak;
+--echo # Perform restore from a backref path name.
+--replace_column 1 #
+RESTORE FROM '../bup_backupdir_6.bak' OVERWRITE;
+--remove_file $MYSQLTEST_VARDIR/bup_backupdir_6.bak
 
 --error 0,1
-rmdir $MYSQLTEST_VARDIR/tmp/backup;
+--remove_file $MYSQLTEST_VARDIR/bup_backupdir_6.bak
+
+--echo # Perform backup to an absolute path name.
+--echo # *Actual BACKUP DATABASE command not printed due to
+--echo #  non-deterministic path.
+--echo # *Performing: 
+--echo # *BACKUP DATABASE bup_backupdir TO
+--echo #  '\$MYSQLTEST_VARDIR/bup_backupdir_6.bak';
+--disable_query_log
+--replace_column 1 #
+eval BACKUP DATABASE bup_backupdir TO '$MYSQLTEST_VARDIR/bup_backupdir_6.bak';
+--enable_query_log
+
+--echo # Ensure backup image file went to the correct location
+--file_exists $MYSQLTEST_VARDIR/bup_backupdir_6.bak
+
+--echo # Perform restore from an absolute path name.
+--echo # *Actual RESTORE command not printed due to
+--echo #  non-deterministic path.
+--echo # *Performing: 
+--echo # *RESTORE FROM
+--echo #  '\$MYSQLTEST_VARDIR/bup_backupdir_6.bak';
+--disable_query_log
+--replace_column 1 #
+eval RESTORE FROM '$MYSQLTEST_VARDIR/bup_backupdir_6.bak' OVERWRITE;
+--enable_query_log
+--remove_file $MYSQLTEST_VARDIR/bup_backupdir_6.bak
+
+--echo #
+--echo # Set backupdir to an absolute path outside of datadir
+--echo # with a trailing slash.
+--echo #
+
+--echo # SET @@global.backupdir = '\$MYSQLTEST_VARDIR/tmp/';
+--disable_query_log
+eval SET @@global.backupdir = '$MYSQLTEST_VARDIR/tmp/';
+--enable_query_log
+
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/bup_backupdir_6.bak
+
+--echo # Perform backup to a pure file name.
+--replace_column 1 #
+BACKUP DATABASE bup_backupdir TO 'bup_backupdir_6.bak';
+
+--echo # Ensure backup image file went to the correct location
+--file_exists $MYSQLTEST_VARDIR/tmp/bup_backupdir_6.bak
+
+--echo # Perform restore from a pure file name.
+--replace_column 1 #
+RESTORE FROM 'bup_backupdir_6.bak' OVERWRITE;
+--remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir_6.bak
+
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir/bup_backupdir_6.bak
+
+--echo # Perform backup to a relative path name.
+--replace_column 1 #
+BACKUP DATABASE bup_backupdir TO 'bup_backupdir/bup_backupdir_6.bak';
+
+--echo # Ensure backup image file went to the correct location
+--file_exists $MYSQLTEST_VARDIR/tmp/bup_backupdir/bup_backupdir_6.bak
+
+--echo # Perform restore from a relative path name.
+--replace_column 1 #
+RESTORE FROM 'bup_backupdir/bup_backupdir_6.bak' OVERWRITE;
+--remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir/bup_backupdir_6.bak
+
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/bup_backupdir_6.bak
+
+--echo # Perform backup to a backref path name.
+--replace_column 1 #
+BACKUP DATABASE bup_backupdir TO '../bup_backupdir_6.bak';
+
+--echo # Ensure backup image file went to the correct location
+--file_exists $MYSQLTEST_VARDIR/bup_backupdir_6.bak
+
+--echo # Perform restore from a backref path name.
+--replace_column 1 #
+RESTORE FROM '../bup_backupdir_6.bak' OVERWRITE;
+--remove_file $MYSQLTEST_VARDIR/bup_backupdir_6.bak
+
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/bup_backupdir_6.bak
+
+--echo # Perform backup to an absolute path name.
+--echo # *Actual BACKUP DATABASE command not printed due to
+--echo #  non-deterministic path.
+--echo # *Performing: 
+--echo # *BACKUP DATABASE bup_backupdir TO
+--echo #  '\$MYSQLTEST_VARDIR/bup_backupdir_6.bak';
+--disable_query_log
+--replace_column 1 #
+eval BACKUP DATABASE bup_backupdir TO '$MYSQLTEST_VARDIR/bup_backupdir_6.bak';
+--enable_query_log
+
+--echo # Ensure backup image file went to the correct location
+--file_exists $MYSQLTEST_VARDIR/bup_backupdir_6.bak
+
+--echo # Perform restore from an absolute path name.
+--echo # *Actual RESTORE command not printed due to
+--echo #  non-deterministic path.
+--echo # *Performing: 
+--echo # *RESTORE FROM
+--echo #  '\$MYSQLTEST_VARDIR/bup_backupdir_6.bak';
+--disable_query_log
+--replace_column 1 #
+eval RESTORE FROM '$MYSQLTEST_VARDIR/bup_backupdir_6.bak' OVERWRITE;
+--enable_query_log
+--remove_file $MYSQLTEST_VARDIR/bup_backupdir_6.bak
+
+--echo #
+--echo # Set backupdir to an existent file.
+--echo #
+
+--echo # Create file.
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir_file.txt
+--write_file $MYSQLTEST_VARDIR/tmp/bup_backupdir_file.txt EOF
+blabla
+EOF
+--echo # Set backupdir.
+SET @@global.backupdir = '../../tmp/bup_backupdir_file.txt';
+
+--echo # Attempt backup to a pure file name in invalid backupdir.
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--error 1
+BACKUP DATABASE bup_backupdir TO 'bup_backupdir_x.bak';
+
+--echo # Attempt restore from a pure file name in invalid backupdir.
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--error 29
+RESTORE FROM 'bup_backupdir_x.bak' OVERWRITE;
+
+--echo # Attempt backup to a relative path name in invalid backupdir.
+--echo # Try 'test' in case current directory is used instead of backupdir.
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--error 1
+BACKUP DATABASE bup_backupdir TO 'test/bup_backupdir_x.bak';
+
+--echo # Attempt restore from a relative path name in invalid backupdir.
+--echo # Try 'test' in case current directory is used instead of backupdir.
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--error 29
+RESTORE FROM 'test/bup_backupdir_x.bak' OVERWRITE;
+
+--echo # Attempt backup to a backref path in invalid backupdir.
+--echo ###
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### Remove this comment and the next three lines and uncomment
+--echo ### the error line when Bug#43747 is fixed.
+--echo ###
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir_x.bak
+--replace_column 1 #
+#--error ER_BACKUP_BACKUPDIR
+BACKUP DATABASE bup_backupdir TO '../bup_backupdir_x.bak';
+
+--echo # Attempt restore from a backref path in invalid backupdir.
+--echo ###
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### Remove this comment, the next line, and uncomment
+--echo ### the error line when Bug#43747 is fixed.
+--echo ###
+--replace_column 1 #
+#--error ER_BACKUP_BACKUPDIR
+RESTORE FROM '../bup_backupdir_x.bak' OVERWRITE;
+--echo ###
+--echo ### Remove this comment and the next line when Bug#43747 is fixed.
+--echo ###
+--remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir_x.bak
+
+--echo # Attempt backup to an absolute path.
+--echo # *Actual BACKUP DATABASE command not printed due to
+--echo #  non-deterministic path.
+--echo # *Attempting: 
+--echo # *BACKUP DATABASE bup_backupdir TO
+--echo #  '\$MYSQLTEST_VARDIR/bup_backupdir_x.bak';
+--disable_query_log
+--echo ###
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### Remove this comment and the next three lines and uncomment
+--echo ### the error line when Bug#43747 is fixed.
+--echo ###
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir_x.bak
+--replace_column 1 #
+#--error ER_BACKUP_BACKUPDIR
+eval BACKUP DATABASE bup_backupdir TO '$MYSQLTEST_VARDIR/bup_backupdir_x.bak';
+--enable_query_log
+
+--echo # Attempt restore from an absolute path.
+--echo # *Actual RESTORE command not printed due to
+--echo #  non-deterministic path.
+--echo # *Attempting: 
+--echo # *RESTORE FROM
+--echo #  '\$MYSQLTEST_VARDIR/bup_backupdir_x.bak';
+--disable_query_log
+--echo ###
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### Remove this comment and the next line and uncomment
+--echo ### the error line when Bug#43747 is fixed.
+--echo ###
+--replace_column 1 #
+#--error ER_BACKUP_BACKUPDIR
+eval RESTORE FROM '$MYSQLTEST_VARDIR/bup_backupdir_x.bak' OVERWRITE;
+--enable_query_log
+--echo ###
+--echo ### Remove this comment and the next line when Bug#43747 is fixed.
+--echo ###
+--remove_file $MYSQLTEST_VARDIR/bup_backupdir_x.bak
+--remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir_file.txt
+
+--echo #
+--echo # Cleanup
+--echo #
+DROP DATABASE bup_backupdir;
+--rmdir $MYSQLTEST_VARDIR/tmp/bup_backupdir
+--echo # Reset backupdir 
+SET @@global.backupdir= @old_backupdir;
+

=== added file 'mysql-test/suite/backup/t/backup_backupdir_not_windows.test'
--- a/mysql-test/suite/backup/t/backup_backupdir_not_windows.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/t/backup_backupdir_not_windows.test	2009-04-01 15:26:41 +0000
@@ -0,0 +1,674 @@
+#
+# This test is designed to test the new backupdir variable
+# with symbolic links, named pipes, or other stuff that
+# does not work in this way on Windows.
+# WL#4518 - Online Backup: Test backupdir variable
+# Ingo Struewing, 2009-03-12
+#
+
+--source include/not_embedded.inc
+--source include/not_windows.inc
+
+# Suppress warning about expected backup/restore errors
+--disable_query_log
+call mtr.add_suppression("Backup:");
+call mtr.add_suppression("Restore:");
+--enable_query_log
+
+--echo # Save backupdir 
+SET @old_backupdir= @@backupdir;
+
+--disable_warnings
+DROP DATABASE IF EXISTS bup_backupdir_nw;
+--enable_warnings
+
+--echo #
+--echo # Create a database to be used throughout the test case
+--echo #
+CREATE DATABASE bup_backupdir_nw;
+CREATE TABLE bup_backupdir_nw.t1(a INT);
+INSERT INTO bup_backupdir_nw.t1 VALUES (1), (2), (3);
+
+--echo #
+--echo # Dangling symlink.
+--echo #
+
+--echo # Ensure that the backup directory does not exist.
+--error 0,1,2
+--rmdir $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw/symdir/subdir
+--error 0,1,2
+--rmdir $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw/symdir
+--error 0,1,2
+--rmdir $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw
+
+--echo # Create a symlink.
+--echo #   VARDIR/tmp/bup_backupdir_nw_symlink -> VARDIR/tmp/bup_backupdir_nw/symdir
+--exec ln -s bup_backupdir_nw/symdir $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw_symlink
+
+--echo # Set backupdir to the dangling symlink
+# Mask out the error value on the warning.
+--replace_regex /[0000-9999]+/####/
+SET @@global.backupdir = '../../tmp/bup_backupdir_nw_symlink';
+
+--echo # Attempt backup to a pure file name in invalid backupdir.
+--error ER_BACKUP_BACKUPDIR
+BACKUP DATABASE bup_backupdir_nw TO 'bup_backupdir_nw_x.bak';
+
+--echo # Attempt restore from a pure file name in invalid backupdir.
+--error ER_BACKUP_BACKUPDIR
+RESTORE FROM 'bup_backupdir_nw_x.bak' OVERWRITE;
+
+--echo # Attempt backup to a relative path name in invalid backupdir.
+--echo # Try 'test' in case current directory is used instead of backupdir.
+--error ER_BACKUP_BACKUPDIR
+BACKUP DATABASE bup_backupdir_nw TO 'test/bup_backupdir_nw_x.bak';
+
+--echo # Attempt restore from a relative path name in invalid backupdir.
+--echo # Try 'test' in case current directory is used instead of backupdir.
+--error ER_BACKUP_BACKUPDIR
+RESTORE FROM 'test/bup_backupdir_nw_x.bak' OVERWRITE;
+
+--echo # Attempt backup to a backref path in invalid backupdir.
+--error ER_BACKUP_BACKUPDIR
+BACKUP DATABASE bup_backupdir_nw TO '../bup_backupdir_nw_x.bak';
+
+--echo # Attempt restore from a backref path in invalid backupdir.
+--error ER_BACKUP_BACKUPDIR
+RESTORE FROM '../bup_backupdir_nw_x.bak' OVERWRITE;
+
+--echo # Attempt backup to an absolute path.
+--echo # *Actual BACKUP DATABASE command not printed due to
+--echo #  non-deterministic path.
+--echo # *Attempting: 
+--echo # *BACKUP DATABASE bup_backupdir_nw TO
+--echo #  '\$MYSQLTEST_VARDIR/bup_backupdir_nw_x.bak';
+--disable_query_log
+--error ER_BACKUP_BACKUPDIR
+eval BACKUP DATABASE bup_backupdir_nw TO '$MYSQLTEST_VARDIR/bup_backupdir_nw_x.bak';
+--enable_query_log
+
+--echo # Attempt restore from an absolute path.
+--echo # *Actual RESTORE command not printed due to
+--echo #  non-deterministic path.
+--echo # *Attempting: 
+--echo # *RESTORE FROM
+--echo #  '\$MYSQLTEST_VARDIR/bup_backupdir_nw_x.bak';
+--disable_query_log
+--error ER_BACKUP_BACKUPDIR
+eval RESTORE FROM '$MYSQLTEST_VARDIR/bup_backupdir_nw_x.bak' OVERWRITE;
+--enable_query_log
+
+--echo #
+--echo # Symlink to existent directory.
+--echo #
+
+--echo # Create directories for symlink tests
+--echo #   MYSQLTEST_VARDIR/tmp/bup_backupdir_nw
+--echo #   MYSQLTEST_VARDIR/tmp/bup_backupdir_nw/symdir
+--echo #   MYSQLTEST_VARDIR/tmp/bup_backupdir_nw/symdir/subdir
+--mkdir $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw
+--mkdir $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw/symdir
+--mkdir $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw/symdir/subdir
+
+--echo # Set backupdir to symlink
+--echo #   VARDIR/tmp/bup_backupdir_nw_symlink -> VARDIR/tmp/bup_backupdir_nw/symdir
+SET @@global.backupdir = '../../tmp/bup_backupdir_nw_symlink';
+
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw/symdir/bup_backupdir_nw_1.bak
+
+--echo # Perform backup to a pure file name.
+--replace_column 1 #
+BACKUP DATABASE bup_backupdir_nw TO 'bup_backupdir_nw_1.bak';
+
+--echo # Ensure backup image file went to the correct location
+--file_exists $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw/symdir/bup_backupdir_nw_1.bak
+
+--echo # Perform restore from a pure file name.
+--replace_column 1 #
+RESTORE FROM 'bup_backupdir_nw_1.bak' OVERWRITE;
+--remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw/symdir/bup_backupdir_nw_1.bak
+
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw/symdir/subdir/bup_backupdir_nw_1.bak
+
+--echo # Perform backup to a relative path name.
+--replace_column 1 #
+BACKUP DATABASE bup_backupdir_nw TO 'subdir/bup_backupdir_nw_1.bak';
+
+--echo # Ensure backup image file went to the correct location
+--file_exists $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw/symdir/subdir/bup_backupdir_nw_1.bak
+
+--echo # Perform restore from a relative path name.
+--replace_column 1 #
+RESTORE FROM 'subdir/bup_backupdir_nw_1.bak' OVERWRITE;
+--remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw/symdir/subdir/bup_backupdir_nw_1.bak
+
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw/bup_backupdir_nw_1.bak
+
+--echo # Perform backup to a backref path name.
+--replace_column 1 #
+BACKUP DATABASE bup_backupdir_nw TO '../bup_backupdir_nw_1.bak';
+
+--echo # Ensure backup image file went to the correct location
+--echo ###
+--echo ### WARNING! The file should go relative to the symlink target,
+--echo ### not relative to the symlink! See Bug#43767.
+--echo ### Remove this comment and the next line and uncomment
+--echo ### the file_exists line when Bug#43767 is fixed.
+--echo ###
+--file_exists $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw_1.bak
+#--file_exists $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw/bup_backupdir_nw_1.bak
+
+--echo # Perform restore from a backref path name.
+--replace_column 1 #
+RESTORE FROM '../bup_backupdir_nw_1.bak' OVERWRITE;
+--echo ###
+--echo ### WARNING! The file should go relative to the symlink target,
+--echo ### not relative to the symlink! See Bug#43767.
+--echo ### Remove this comment and the next line and uncomment
+--echo ### the remove_file line when Bug#43767 is fixed.
+--echo ###
+--remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw_1.bak
+#--remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw/bup_backupdir_nw_1.bak
+
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/bup_backupdir_nw_1.bak
+
+--echo # Perform backup to an absolute path name.
+--echo # *Actual BACKUP DATABASE command not printed due to
+--echo #  non-deterministic path.
+--echo # *Performing: 
+--echo # *BACKUP DATABASE bup_backupdir_nw TO
+--echo #  '\$MYSQLTEST_VARDIR/bup_backupdir_nw_1.bak';
+--disable_query_log
+--replace_column 1 #
+eval BACKUP DATABASE bup_backupdir_nw TO '$MYSQLTEST_VARDIR/bup_backupdir_nw_1.bak';
+--enable_query_log
+
+--echo # Ensure backup image file went to the correct location
+--file_exists $MYSQLTEST_VARDIR/bup_backupdir_nw_1.bak
+
+--echo # Perform restore from an absolute path name.
+--echo # *Actual RESTORE command not printed due to
+--echo #  non-deterministic path.
+--echo # *Performing: 
+--echo # *RESTORE FROM
+--echo #  '\$MYSQLTEST_VARDIR/bup_backupdir_nw_1.bak';
+--disable_query_log
+--replace_column 1 #
+eval RESTORE FROM '$MYSQLTEST_VARDIR/bup_backupdir_nw_1.bak' OVERWRITE;
+--enable_query_log
+--remove_file $MYSQLTEST_VARDIR/bup_backupdir_nw_1.bak
+
+--echo # Remove subdirectory
+--rmdir $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw/symdir/subdir
+
+--echo # Remove backup directory
+--rmdir $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw/symdir
+
+--echo #
+--echo # Symlink to existent plain file.
+--echo #
+
+--echo # Create a file at the target path of the symlink.
+--write_file $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw/symdir EOF
+blabla
+EOF
+
+--echo # Set backupdir to symlink
+SET @@global.backupdir = '../../tmp/bup_backupdir_nw_symlink';
+
+--echo # Attempt backup to a pure file name in invalid backupdir.
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--error 1
+BACKUP DATABASE bup_backupdir_nw TO 'bup_backupdir_nw_x.bak';
+
+--echo # Attempt restore from a pure file name in invalid backupdir.
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--error 29
+RESTORE FROM 'bup_backupdir_nw_x.bak' OVERWRITE;
+
+--echo # Attempt backup to a relative path name in invalid backupdir.
+--echo # Try 'test' in case current directory is used instead of backupdir.
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--error 1
+BACKUP DATABASE bup_backupdir_nw TO 'test/bup_backupdir_nw_x.bak';
+
+--echo # Attempt restore from a relative path name in invalid backupdir.
+--echo # Try 'test' in case current directory is used instead of backupdir.
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--error 29
+RESTORE FROM 'test/bup_backupdir_nw_x.bak' OVERWRITE;
+
+--echo ###
+--echo ### Remove this comment and the next two lines when Bug#43747 is fixed.
+--echo ###
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw_x.bak
+
+--echo # Attempt backup to a backref path in invalid backupdir.
+--echo ###
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### Remove this comment and the next three lines and uncomment
+--echo ### the error line when Bug#43747 is fixed.
+--echo ###
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw_x.bak
+--replace_column 1 #
+#--error ER_BACKUP_BACKUPDIR
+BACKUP DATABASE bup_backupdir_nw TO '../bup_backupdir_nw_x.bak';
+
+--echo # Attempt restore from a backref path in invalid backupdir.
+--echo ###
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### Remove this comment, the next line, and uncomment
+--echo ### the error line when Bug#43747 is fixed.
+--echo ###
+--replace_column 1 #
+#--error ER_BACKUP_BACKUPDIR
+RESTORE FROM '../bup_backupdir_nw_x.bak' OVERWRITE;
+--echo ###
+--echo ### Remove this comment and the next line when Bug#43747 is fixed.
+--echo ###
+--remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw_x.bak
+
+--echo # Attempt backup to an absolute path.
+--echo # *Actual BACKUP DATABASE command not printed due to
+--echo #  non-deterministic path.
+--echo # *Attempting: 
+--echo # *BACKUP DATABASE bup_backupdir_nw TO
+--echo #  '\$MYSQLTEST_VARDIR/bup_backupdir_nw_1.bak';
+--disable_query_log
+--echo ###
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### Remove this comment and the next three lines and uncomment
+--echo ### the error line when Bug#43747 is fixed.
+--echo ###
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw_x.bak
+--replace_column 1 #
+#--error ER_BACKUP_BACKUPDIR
+eval BACKUP DATABASE bup_backupdir_nw TO '$MYSQLTEST_VARDIR/bup_backupdir_nw_x.bak';
+--enable_query_log
+
+--echo # Attempt restore from an absolute path.
+--echo # *Actual RESTORE command not printed due to
+--echo #  non-deterministic path.
+--echo # *Attempting: 
+--echo # *RESTORE FROM
+--echo #  '\$MYSQLTEST_VARDIR/bup_backupdir_nw_x.bak';
+--disable_query_log
+--echo ###
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### Remove this comment and the next line and uncomment
+--echo ### the error line when Bug#43747 is fixed.
+--echo ###
+--replace_column 1 #
+#--error ER_BACKUP_BACKUPDIR
+eval RESTORE FROM '$MYSQLTEST_VARDIR/bup_backupdir_nw_x.bak' OVERWRITE;
+--enable_query_log
+--echo ###
+--echo ### Remove this comment and the next line when Bug#43747 is fixed.
+--echo ###
+--remove_file $MYSQLTEST_VARDIR/bup_backupdir_nw_x.bak
+
+--echo # Remove file
+--remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw/symdir
+
+--echo # Remove symlink
+--remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw_symlink
+
+--echo #
+--echo # Pipe.
+--echo #
+
+--echo ###
+--echo ### Creating a pipe in the same test that sets the backupdir variable
+--echo ### lets mysql-test-run hang if the pipe is not deleted before the
+--echo ### test ends. See Bug#43570.
+--echo ### We do proper cleanup at test end. But if the test ends due to
+--echo ### an unexpected error/success, there is no chance to remove the pipe.
+--echo ### --disable_abort_on_error avoids termination before cleanup.
+--echo ### Remove this comment and the next line when Bug#43570 is fixed.
+--echo ###
+--disable_abort_on_error
+
+--echo # Create a named pipe
+--exec mkfifo $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw_fifo
+
+--echo # Set backupdir to the pipe
+# Mask out the error value on the warning.
+--replace_regex /[0000-9999]+/####/
+SET @@global.backupdir = '../../tmp/bup_backupdir_nw_fifo';
+
+--echo # Attempt backup to a pure file name in invalid backupdir.
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--error 1
+BACKUP DATABASE bup_backupdir_nw TO 'bup_backupdir_nw_x.bak';
+
+--echo # Attempt restore from a pure file name in invalid backupdir.
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--error 29
+RESTORE FROM 'bup_backupdir_nw_x.bak' OVERWRITE;
+
+--echo # Attempt backup to a relative path name in invalid backupdir.
+--echo # Try 'test' in case current directory is used instead of backupdir.
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--error 1
+BACKUP DATABASE bup_backupdir_nw TO 'test/bup_backupdir_nw_x.bak';
+
+--echo # Attempt restore from a relative path name in invalid backupdir.
+--echo # Try 'test' in case current directory is used instead of backupdir.
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--error 29
+RESTORE FROM 'test/bup_backupdir_nw_x.bak' OVERWRITE;
+
+--echo # Attempt backup to a backref path in invalid backupdir.
+--echo ###
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### Remove this comment, uncomment the error line, remove "send",
+--echo ### and remove everything after the BACKUP statement
+--echo ### until and including "reap", when Bug#43747 is fixed.
+--echo ###
+#--error ER_BAD_PATH
+send BACKUP DATABASE bup_backupdir_nw TO '../bup_backupdir_nw_fifo';
+    --echo # connection con1
+    --echo ###
+    --echo ### Normally, the 'connect' command is not logged. But due to
+    --echo ### the 'disable_abort_on_error' command it is. See Bug#43588.
+    --echo ### Remove this comment and the next line when Bug#43588 is fixed.
+    --echo ###
+    --disable_query_log
+    --connect (con1,localhost,root,,)
+    --echo ###
+    --echo ### Re-enabling query log. See above for an explanation.
+    --echo ### Remove this comment and the next line when Bug#43588 is fixed.
+    --echo ###
+    --enable_query_log
+    --echo # Cat the backup image from the pipe to a file.
+    --exec cat $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw_fifo > $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw_file
+    --disconnect con1
+--echo # connection default
+--connection default
+--echo # Receive status from BACKUP
+--replace_column 1 #
+reap;
+
+--echo # Attempt restore from a backref path in invalid backupdir.
+--echo ###
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### Remove this comment, uncomment the error line, remove "send",
+--echo ### and remove everything after the RESTORE statement
+--echo ### until and including "reap", when Bug#43747 is fixed.
+--echo ###
+#--error ER_BAD_PATH
+send RESTORE FROM '../bup_backupdir_nw_fifo' OVERWRITE;
+    --echo # connection con1
+    --echo ###
+    --echo ### Normally, the 'connect' command is not logged. But due to
+    --echo ### the 'disable_abort_on_error' command it is. See Bug#43588.
+    --echo ### Remove this comment and the next line when Bug#43588 is fixed.
+    --echo ###
+    --disable_query_log
+    --connect (con1,localhost,root,,)
+    --echo ###
+    --echo ### Re-enabling query log. See above for an explanation.
+    --echo ### Remove this comment and the next line when Bug#43588 is fixed.
+    --echo ###
+    --enable_query_log
+    --echo # Cat the backup image from a file to the pipe.
+    --exec cat $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw_file > $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw_fifo
+    --disconnect con1
+--echo # connection default
+--connection default
+--echo # Receive status from RESTORE
+--replace_column 1 #
+reap;
+
+--echo ###
+--echo ### WARNING! This file should not extist.
+--echo ### Remove this comment and the next line when Bug#43747 is fixed.
+--echo ###
+--remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw_file
+
+--echo # Attempt backup to an absolute path.
+--echo # *Actual BACKUP DATABASE command not printed due to
+--echo #  non-deterministic path.
+--echo # *Attempting: 
+--echo # *BACKUP DATABASE bup_backupdir_nw TO
+--echo #  '\$MYSQLTEST_VARDIR/bup_backupdir_nw_x.bak';
+--disable_query_log
+--echo ###
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### Remove this comment and the next three lines and uncomment
+--echo ### the error line when Bug#43747 is fixed.
+--echo ###
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw_x.bak
+--replace_column 1 #
+#--error ER_BACKUP_BACKUPDIR
+eval BACKUP DATABASE bup_backupdir_nw TO '$MYSQLTEST_VARDIR/bup_backupdir_nw_x.bak';
+--enable_query_log
+
+--echo # Attempt restore from an absolute path.
+--echo # *Actual RESTORE command not printed due to
+--echo #  non-deterministic path.
+--echo # *Attempting: 
+--echo # *RESTORE FROM
+--echo #  '\$MYSQLTEST_VARDIR/bup_backupdir_nw_x.bak';
+--disable_query_log
+--echo ###
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### Remove this comment and the next line and uncomment
+--echo ### the error line when Bug#43747 is fixed.
+--echo ###
+--replace_column 1 #
+#--error ER_BACKUP_BACKUPDIR
+eval RESTORE FROM '$MYSQLTEST_VARDIR/bup_backupdir_nw_x.bak' OVERWRITE;
+--enable_query_log
+--echo ###
+--echo ### Remove this comment and the next line when Bug#43747 is fixed.
+--echo ###
+--remove_file $MYSQLTEST_VARDIR/bup_backupdir_nw_x.bak
+
+--echo # Attempt backup into the pipe by using empty file name.
+--error ER_BAD_PATH
+BACKUP DATABASE bup_backupdir_nw TO '';
+
+--echo # Attempt restore from the pipe by using empty file name.
+--error ER_BAD_PATH
+RESTORE FROM '' OVERWRITE;
+
+--echo #
+--echo # Symlink to existent pipe.
+--echo #
+
+--echo # Create a symlink to the existent pipe.
+--exec ln -s bup_backupdir_nw_fifo $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw_symlink
+
+--echo # Set backupdir to symlink
+SET @@global.backupdir = '../../tmp/bup_backupdir_nw_symlink';
+
+--echo # Attempt backup to a pure file name in invalid backupdir.
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--error 1
+BACKUP DATABASE bup_backupdir_nw TO 'bup_backupdir_nw_x.bak';
+
+--echo # Attempt restore from a pure file name in invalid backupdir.
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--error 29
+RESTORE FROM 'bup_backupdir_nw_x.bak' OVERWRITE;
+
+--echo # Attempt backup to a relative path name in invalid backupdir.
+--echo # Try 'test' in case current directory is used instead of backupdir.
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--error 1
+BACKUP DATABASE bup_backupdir_nw TO 'test/bup_backupdir_nw_x.bak';
+
+--echo # Attempt restore from a relative path name in invalid backupdir.
+--echo # Try 'test' in case current directory is used instead of backupdir.
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--error 29
+RESTORE FROM 'test/bup_backupdir_nw_x.bak' OVERWRITE;
+
+--echo # Attempt backup to a backref path in invalid backupdir.
+--echo ###
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### Remove this comment, uncomment the error line, remove "send",
+--echo ### and remove everything after the BACKUP statement
+--echo ### until and including "reap", when Bug#43747 is fixed.
+--echo ###
+#--error ER_BAD_PATH
+send BACKUP DATABASE bup_backupdir_nw TO '../bup_backupdir_nw_fifo';
+    --echo # connection con1
+    --echo ###
+    --echo ### Normally, the 'connect' command is not logged. But due to
+    --echo ### the 'disable_abort_on_error' command it is. See Bug#43588.
+    --echo ### Remove this comment and the next line when Bug#43588 is fixed.
+    --echo ###
+    --disable_query_log
+    --connect (con1,localhost,root,,)
+    --echo ###
+    --echo ### Re-enabling query log. See above for an explanation.
+    --echo ### Remove this comment and the next line when Bug#43588 is fixed.
+    --echo ###
+    --enable_query_log
+    --echo # Cat the backup image from the pipe to a file.
+    --exec cat $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw_fifo > $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw_file
+    --disconnect con1
+--echo # connection default
+--connection default
+--echo # Receive status from BACKUP
+--replace_column 1 #
+reap;
+
+--echo # Attempt restore from a backref path in invalid backupdir.
+--echo ###
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### Remove this comment, uncomment the error line, remove "send",
+--echo ### and remove everything after the RESTORE statement
+--echo ### until and including "reap", when Bug#43747 is fixed.
+--echo ###
+#--error ER_BAD_PATH
+send RESTORE FROM '../bup_backupdir_nw_fifo' OVERWRITE;
+    --echo # connection con1
+    --echo ###
+    --echo ### Normally, the 'connect' command is not logged. But due to
+    --echo ### the 'disable_abort_on_error' command it is. See Bug#43588.
+    --echo ### Remove this comment and the next line when Bug#43588 is fixed.
+    --echo ###
+    --disable_query_log
+    --connect (con1,localhost,root,,)
+    --echo ###
+    --echo ### Re-enabling query log. See above for an explanation.
+    --echo ### Remove this comment and the next line when Bug#43588 is fixed.
+    --echo ###
+    --enable_query_log
+    --echo # Cat the backup image from a file to the pipe.
+    --exec cat $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw_file > $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw_fifo
+    --disconnect con1
+--echo # connection default
+--connection default
+--echo # Receive status from RESTORE
+--replace_column 1 #
+reap;
+
+--echo ###
+--echo ### WARNING! This file should not extist.
+--echo ### Remove this comment and the next line when Bug#43747 is fixed.
+--echo ###
+--remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw_file
+
+--echo # Attempt backup to an absolute path.
+--echo # *Actual BACKUP DATABASE command not printed due to
+--echo #  non-deterministic path.
+--echo # *Attempting: 
+--echo # *BACKUP DATABASE bup_backupdir_nw TO
+--echo #  '\$MYSQLTEST_VARDIR/bup_backupdir_nw_x.bak';
+--disable_query_log
+--echo ###
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### Remove this comment and the next three lines and uncomment
+--echo ### the error line when Bug#43747 is fixed.
+--echo ###
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw_x.bak
+--replace_column 1 #
+#--error ER_BACKUP_BACKUPDIR
+eval BACKUP DATABASE bup_backupdir_nw TO '$MYSQLTEST_VARDIR/bup_backupdir_nw_x.bak';
+--enable_query_log
+
+--echo # Attempt restore from an absolute path.
+--echo # *Actual RESTORE command not printed due to
+--echo #  non-deterministic path.
+--echo # *Attempting: 
+--echo # *RESTORE FROM
+--echo #  '\$MYSQLTEST_VARDIR/bup_backupdir_nw_x.bak';
+--disable_query_log
+--echo ###
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### WARNING! This should fail, not work! See Bug#43747.
+--echo ### Remove this comment and the next line and uncomment
+--echo ### the error line when Bug#43747 is fixed.
+--echo ###
+--replace_column 1 #
+#--error ER_BACKUP_BACKUPDIR
+eval RESTORE FROM '$MYSQLTEST_VARDIR/bup_backupdir_nw_x.bak' OVERWRITE;
+--enable_query_log
+--echo ###
+--echo ### Remove this comment and the next line when Bug#43747 is fixed.
+--echo ###
+--remove_file $MYSQLTEST_VARDIR/bup_backupdir_nw_x.bak
+
+--echo # Attempt backup into the pipe by using empty file name.
+--error ER_BAD_PATH
+BACKUP DATABASE bup_backupdir_nw TO '';
+
+--echo # Attempt restore from the pipe by using empty file name.
+--error ER_BAD_PATH
+RESTORE FROM '' OVERWRITE;
+
+--echo # Remove symlink
+--remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw_symlink
+
+--echo # Remove pipe
+--remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir_nw_fifo
+
+--echo ###
+--echo ### Re-enabling abort on error. See above for an explanation.
+--echo ### Remove this comment and the next line when Bug#43570 is fixed.
+--echo ###
+--enable_abort_on_error
+
+--echo #
+--echo # Cleanup
+--echo #
+DROP DATABASE bup_backupdir_nw;
+--echo # Reset backupdir 
+SET @@global.backupdir= @old_backupdir;
+

=== added file 'mysql-test/suite/backup/t/backup_backupdir_sync.test'
--- a/mysql-test/suite/backup/t/backup_backupdir_sync.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/t/backup_backupdir_sync.test	2009-04-01 15:26:41 +0000
@@ -0,0 +1,202 @@
+#
+# This test is designed to test the new backupdir variable
+# with multiple sessions changing it in parallel.
+# WL#4518 - Online Backup: Test backupdir variable
+# Ingo Struewing, 2009-03-12
+#
+
+--source include/not_embedded.inc
+--source include/have_debug_sync.inc
+
+# Suppress warning about expected backup/restore errors
+--disable_query_log
+call mtr.add_suppression("Backup:");
+call mtr.add_suppression("Restore:");
+--enable_query_log
+
+--echo # Save backupdir 
+SET @old_backupdir= @@backupdir;
+
+--disable_warnings
+SET DEBUG_SYNC= 'RESET';
+DROP DATABASE IF EXISTS bup_backupdir;
+--enable_warnings
+
+--echo #
+--echo # Create a database to be used throughout the test case
+--echo #
+CREATE DATABASE bup_backupdir;
+CREATE TABLE bup_backupdir.t1(a INT);
+INSERT INTO bup_backupdir.t1 VALUES (1), (2), (3);
+
+--echo # Create directories.
+--echo #   MYSQLTEST_VARDIR/tmp/bup_backupdir_s
+--echo #   MYSQLTEST_VARDIR/tmp/bup_backupdir_s_1
+--echo #   MYSQLTEST_VARDIR/tmp/bup_backupdir_s_2
+#
+--error 0,1,2
+--rmdir $MYSQLTEST_VARDIR/tmp/bup_backupdir_s
+--error 0,1,2
+--rmdir $MYSQLTEST_VARDIR/tmp/bup_backupdir_s_1
+--error 0,1,2
+--rmdir $MYSQLTEST_VARDIR/tmp/bup_backupdir_s_2
+#
+--mkdir $MYSQLTEST_VARDIR/tmp/bup_backupdir_s
+--mkdir $MYSQLTEST_VARDIR/tmp/bup_backupdir_s_1
+--mkdir $MYSQLTEST_VARDIR/tmp/bup_backupdir_s_2
+
+--echo #
+--echo # Blackbox test. Set backupdir differently in two connections
+--echo # one after the other.
+--echo # This test does not require DEBUG_SYNC. But it profits from the
+--echo # setup of directories done for the other tests.
+--echo #
+
+--echo # Set backupdir.
+SET @@global.backupdir = '../../tmp/bup_backupdir_s_1';
+
+    --echo # connection con1
+    --connect (con1,localhost,root,,)
+
+    --echo # Set backupdir.
+    SET @@global.backupdir = '../../tmp/bup_backupdir_s_2';
+
+--echo # connection default
+--connection default
+
+--echo # Run BACKUP.
+--replace_column 1 #
+BACKUP DATABASE bup_backupdir TO 'bup_backupdir_s_1.bak';
+
+--echo # Ensure backup image file went to the correct location
+--file_exists $MYSQLTEST_VARDIR/tmp/bup_backupdir_s_2/bup_backupdir_s_1.bak
+
+    --echo # connection con1
+    --connection con1
+
+    --echo # Run BACKUP.
+    --replace_column 1 #
+    BACKUP DATABASE bup_backupdir TO 'bup_backupdir_s_2.bak';
+
+    --echo # Ensure backup image file went to the correct location
+    --file_exists $MYSQLTEST_VARDIR/tmp/bup_backupdir_s_2/bup_backupdir_s_2.bak
+
+--echo # connection default
+--connection default
+
+--echo # Run RESTORE.
+--replace_column 1 #
+RESTORE FROM 'bup_backupdir_s_1.bak' OVERWRITE;
+--remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir_s_2/bup_backupdir_s_1.bak
+
+    --echo # connection con1
+    --connection con1
+
+    --echo # Run RESTORE.
+    --replace_column 1 #
+    RESTORE FROM 'bup_backupdir_s_2.bak' OVERWRITE;
+    --remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir_s_2/bup_backupdir_s_2.bak
+    --disconnect con1
+
+--echo # connection default
+--connection default
+
+--echo #
+--echo # Whitebox test. Have a synchronization point after checking backupdir.
+--echo # While waiting there, remove the backup directory.
+--echo #
+
+--echo # Set backupdir.
+SET @@global.backupdir = '../../tmp/bup_backupdir_s';
+
+--echo # Activate sync point and start BACKUP.
+SET DEBUG_SYNC= 'after_backup_checked_backupdir SIGNAL checked WAIT_FOR go';
+send BACKUP DATABASE bup_backupdir TO 'bup_backupdir_s_3.bak';
+
+    --echo # connection con1
+    --connect (con1,localhost,root,,)
+
+    --echo # Wait for BACKUP to reach the sync point.
+    SET DEBUG_SYNC= 'now WAIT_FOR checked';
+
+    --echo # Remove backup directory.
+    --rmdir $MYSQLTEST_VARDIR/tmp/bup_backupdir_s
+
+    --echo # Signal BACKUP to continue.
+    SET DEBUG_SYNC= 'now SIGNAL go';
+    --disconnect con1
+
+--echo # connection default
+--connection default
+
+--echo # Retrieve result from BACKUP.
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--error 1
+reap;
+
+--echo #
+--echo # Whitebox test. Set backupdir to a symlink,
+--echo # which references an existent directory.
+--echo # Have a synchronization point after checking backupdir.
+--echo # While waiting there, change the symlink to reference an existent file.
+--echo #
+
+--echo # Create a directory.
+--echo #   VARDIR/tmp/bup_backupdir_s
+--mkdir $MYSQLTEST_VARDIR/tmp/bup_backupdir_s
+
+--echo # Create a symlink.
+--echo #   VARDIR/tmp/bup_backupdir_s_symlink -> VARDIR/tmp/bup_backupdir_s
+--exec ln -s bup_backupdir_s $MYSQLTEST_VARDIR/tmp/bup_backupdir_s_symlink
+
+--echo # Set backupdir.
+SET @@global.backupdir = '../../tmp/bup_backupdir_s_symlink';
+
+--echo # Activate sync point and start BACKUP.
+SET DEBUG_SYNC= 'after_backup_checked_backupdir SIGNAL checked WAIT_FOR go';
+send BACKUP DATABASE bup_backupdir TO 'bup_backupdir_s_4.bak';
+
+    --echo # connection con1
+    --connect (con1,localhost,root,,)
+
+    --echo # Wait for BACKUP to reach the sync point.
+    SET DEBUG_SYNC= 'now WAIT_FOR checked';
+
+    --echo # Create file.
+    --echo #   VARDIR/tmp/bup_backupdir_s_file
+    --error 0,1
+    --remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir_s_file
+    --write_file $MYSQLTEST_VARDIR/tmp/bup_backupdir_s_file EOF
+blabla
+EOF
+
+    --echo # Re-create symlink.
+    --echo #   VARDIR/tmp/bup_backupdir_s_symlink -> VARDIR/tmp/bup_backupdir_s_file
+    --remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir_s_symlink
+    --exec ln -s backup_file $MYSQLTEST_VARDIR/tmp/bup_backupdir_s_symlink
+
+    --echo # Signal BACKUP to continue.
+    SET DEBUG_SYNC= 'now SIGNAL go';
+    --disconnect con1
+
+--echo # connection default
+--connection default
+
+--echo # Retrieve result from BACKUP.
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--error 1
+reap;
+--remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir_s_symlink
+--remove_file $MYSQLTEST_VARDIR/tmp/bup_backupdir_s_file
+
+--echo #
+--echo # Cleanup
+--echo #
+SET DEBUG_SYNC= 'RESET';
+DROP DATABASE bup_backupdir;
+--rmdir $MYSQLTEST_VARDIR/tmp/bup_backupdir_s
+--rmdir $MYSQLTEST_VARDIR/tmp/bup_backupdir_s_1
+--rmdir $MYSQLTEST_VARDIR/tmp/bup_backupdir_s_2
+--echo # Reset backupdir 
+SET @@global.backupdir= @old_backupdir;
+

=== modified file 'sql/backup/kernel.cc'
--- a/sql/backup/kernel.cc	2009-03-16 14:38:05 +0000
+++ b/sql/backup/kernel.cc	2009-04-01 15:26:41 +0000
@@ -163,7 +163,8 @@ execute_backup_command(THD *thd, 
   */
   if (backupdir->length() && my_access(backupdir->c_ptr(), (F_OK|W_OK)))
     DBUG_RETURN(send_error(context, ER_BACKUP_BACKUPDIR, backupdir->c_ptr()));
- 
+  DEBUG_SYNC(thd, "after_backup_checked_backupdir");
+
   switch (lex->sql_command) {
 
   case SQLCOM_BACKUP:


Attachment: [text/bzr-bundle] bzr/ingo.struewing@sun.com-20090401152641-gtan62hkopnpandl.bundle
Thread
bzr commit into mysql-6.0-backup branch (ingo.struewing:2807) WL#4518Ingo Struewing1 Apr
  • WL#4518 code available for reviewIngo Strüwing1 Apr
Re: WL#4518 code available for reviewIngo Strüwing7 Apr
  • Re: WL#4518 code available for reviewIngo Strüwing8 Apr