#At file:///Users/cbell/source/bzr/MS10/ based on revid:charles.bell@strippedpj8a085nwjhf
3114 Chuck Bell 2010-02-23
BUG#33354 - revert changes to preserving current database.
This patch changes the code to save the current database before restore
are resetting it after. This forces many tests to change because the
current database is not changed to one of the databases in the restore.
modified:
mysql-test/suite/backup/r/backup_blob.result
mysql-test/suite/backup/r/backup_default.result
mysql-test/suite/backup/r/backup_errors.result
mysql-test/suite/backup/r/backup_errors_compression.result
mysql-test/suite/backup/r/backup_functions.result
mysql-test/suite/backup/r/backup_multi_blocks.result
mysql-test/suite/backup/r/backup_myisam_sync.result
mysql-test/suite/backup/r/backup_online_testing.result
mysql-test/suite/backup/r/backup_procedures.result
mysql-test/suite/backup/r/backup_restore_locking.result
mysql-test/suite/backup/r/backup_table_grants.result
mysql-test/suite/backup/r/backup_views.result
mysql-test/suite/backup/t/backup_blob.test
mysql-test/suite/backup/t/backup_default.test
mysql-test/suite/backup/t/backup_errors.test
mysql-test/suite/backup/t/backup_functions.test
mysql-test/suite/backup/t/backup_multi_blocks.test
mysql-test/suite/backup/t/backup_myisam_sync.test
mysql-test/suite/backup/t/backup_online_testing.test
mysql-test/suite/backup/t/backup_procedures.test
mysql-test/suite/backup/t/backup_restore_locking.test
mysql-test/suite/backup/t/backup_table_grants.test
mysql-test/suite/backup_engines/r/backup_partitioning.result
mysql-test/suite/backup_engines/r/backup_triggers.result
mysql-test/suite/backup_engines/t/backup_partitioning.test
mysql-test/suite/backup_engines/t/backup_triggers.test
sql/backup/backup_kernel.h
sql/backup/kernel.cc
sql/si_objects.cc
=== modified file 'mysql-test/suite/backup/r/backup_blob.result'
--- a/mysql-test/suite/backup/r/backup_blob.result 2010-01-06 15:03:50 +0000
+++ b/mysql-test/suite/backup/r/backup_blob.result 2010-02-23 22:36:19 +0000
@@ -36,6 +36,7 @@ backup_id
#
Check tables after restore
+USE mysqltest;
SELECT * FROM t1 ORDER BY id;
id txt
1 short text
=== modified file 'mysql-test/suite/backup/r/backup_default.result'
--- a/mysql-test/suite/backup/r/backup_default.result 2010-01-06 15:03:50 +0000
+++ b/mysql-test/suite/backup/r/backup_default.result 2010-02-23 22:36:19 +0000
@@ -20,6 +20,7 @@ restore on csv only
RESTORE FROM 'bup_csv.bak';
backup_id
#
+USE db1;
testing content in restored tables
SELECT * FROM csv_table ORDER BY id;
id name city
@@ -62,6 +63,7 @@ restore on mixed table database
RESTORE FROM 'bup_mixed.bak';
backup_id
#
+USE db1;
testing content in restored tables
SELECT * FROM partition_table ORDER BY int_column;
int_column char_column
=== modified file 'mysql-test/suite/backup/r/backup_errors.result'
--- a/mysql-test/suite/backup/r/backup_errors.result 2010-01-26 21:31:41 +0000
+++ b/mysql-test/suite/backup/r/backup_errors.result 2010-02-23 22:36:19 +0000
@@ -419,6 +419,7 @@ Restore after deleting db; will succeed
RESTORE FROM 'overwrite.bak';
backup_id
#
+USE db1;
Show that inserted value 2 is not there
SELECT * FROM table1;
=== modified file 'mysql-test/suite/backup/r/backup_errors_compression.result'
--- a/mysql-test/suite/backup/r/backup_errors_compression.result 2010-01-26 21:31:41 +0000
+++ b/mysql-test/suite/backup/r/backup_errors_compression.result 2010-02-23 22:36:19 +0000
@@ -419,6 +419,7 @@ Restore after deleting db; will succeed
RESTORE FROM 'overwrite.bak';
backup_id
#
+USE db1;
Show that inserted value 2 is not there
SELECT * FROM table1;
=== modified file 'mysql-test/suite/backup/r/backup_functions.result'
--- a/mysql-test/suite/backup/r/backup_functions.result 2010-01-14 17:26:34 +0000
+++ b/mysql-test/suite/backup/r/backup_functions.result 2010-02-23 22:36:19 +0000
@@ -213,6 +213,7 @@ Note # This function 'y' has the same na
SELECT @@SQL_MODE;
@@SQL_MODE
STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
+USE bup_sfs;
showing objects and create statements
SHOW CREATE DATABASE bup_sfs;;
Database bup_sfs
@@ -338,6 +339,7 @@ backup_id
#
Warnings:
Note # This function 'y' has the same name as a native function
+USE bup_sfs;
SELECT @@SQL_MODE;
@@SQL_MODE
REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI
@@ -442,6 +444,7 @@ backup_id
#
Warnings:
Note # This function 'y' has the same name as a native function
+USE bup_sfs;
SELECT @@SQL_MODE;
@@SQL_MODE
PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,MAXDB,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS,NO_AUTO_CREATE_USER
@@ -553,6 +556,7 @@ backup_id
#
Warnings:
Note # This function 'y' has the same name as a native function
+USE bup_sfs;
SELECT @@SQL_MODE;
@@SQL_MODE
=== modified file 'mysql-test/suite/backup/r/backup_multi_blocks.result'
--- a/mysql-test/suite/backup/r/backup_multi_blocks.result 2010-01-06 15:03:50 +0000
+++ b/mysql-test/suite/backup/r/backup_multi_blocks.result 2010-02-23 22:36:19 +0000
@@ -31,6 +31,7 @@ Performing restore ...
RESTORE FROM 'test.ba';
backup_id
#;
+USE mysqltest;
Checking contents of restore ...
SELECT LENGTH(a) FROM t1;
LENGTH(a)
=== modified file 'mysql-test/suite/backup/r/backup_myisam_sync.result'
--- a/mysql-test/suite/backup/r/backup_myisam_sync.result 2010-02-16 15:40:17 +0000
+++ b/mysql-test/suite/backup/r/backup_myisam_sync.result 2010-02-23 22:36:19 +0000
@@ -55,6 +55,7 @@ DROP DATABASE mysqltest;
RESTORE FROM 'bup_myisam_sync.bak';
backup_id
#
+USE mysqltest;
SELECT LENGTH(c1) FROM t1;
LENGTH(c1)
262144
=== modified file 'mysql-test/suite/backup/r/backup_online_testing.result'
--- a/mysql-test/suite/backup/r/backup_online_testing.result 2010-01-06 15:03:50 +0000
+++ b/mysql-test/suite/backup/r/backup_online_testing.result 2010-02-23 22:36:19 +0000
@@ -108,6 +108,7 @@ backup_id
*** RESULT AFTER RESTORE ***
+USE bup_online;
SELECT * FROM t1;
id details
1 testing1
@@ -215,6 +216,7 @@ backup_id
*** RESULT AFTER RESTORE ***
+USE bup_online;
SELECT * FROM t1;
id details
1 testing1
@@ -334,6 +336,7 @@ backup_id
*** RESULT AFTER RESTORE ***
+USE bup_online;
SELECT * FROM t1;
id details
1 testing1
@@ -455,6 +458,7 @@ backup_id
*** RESULT AFTER RESTORE ***
+USE bup_online;
SELECT * FROM t1;
id details
1 testing1
@@ -578,6 +582,7 @@ backup_id
*** RESULT AFTER RESTORE ***
+USE bup_online;
SELECT * FROM t1;
id details
1 testing1
@@ -709,6 +714,7 @@ backup_id
*** RESULT AFTER RESTORE ***
+USE bup_online;
SELECT * FROM t1;
id details
1 testing1
@@ -840,6 +846,7 @@ backup_id
*** RESULT AFTER RESTORE ***
+USE bup_online;
SELECT * FROM t1;
id details
1 testing1
@@ -966,6 +973,7 @@ backup_id
*** RESULT AFTER RESTORE ***
+USE bup_online;
SELECT * FROM t1;
id details
1 testing1
@@ -1092,6 +1100,7 @@ backup_id
*** RESULT AFTER RESTORE ***
+USE bup_online;
SELECT * FROM t1;
id details
1 testing1
=== modified file 'mysql-test/suite/backup/r/backup_procedures.result'
--- a/mysql-test/suite/backup/r/backup_procedures.result 2010-01-06 15:03:50 +0000
+++ b/mysql-test/suite/backup/r/backup_procedures.result 2010-02-23 22:36:19 +0000
@@ -96,6 +96,7 @@ DROP DATABASE bup_sp;
RESTORE FROM 'bup_sp.bak';
backup_id
#
+USE bup_sp;
showing objects and create statements
SHOW CREATE PROCEDURE countryinfo;;
Procedure countryinfo
@@ -198,6 +199,7 @@ DROP DATABASE bup_proc;
RESTORE FROM 'bup_proc.bak';
backup_id
#
+USE bup_proc;
Check that procedures are there after the restore
CALL p1();
=== modified file 'mysql-test/suite/backup/r/backup_restore_locking.result'
--- a/mysql-test/suite/backup/r/backup_restore_locking.result 2010-02-16 15:40:17 +0000
+++ b/mysql-test/suite/backup/r/backup_restore_locking.result 2010-02-23 22:36:19 +0000
@@ -30,6 +30,7 @@ SET DEBUG_SYNC= 'now SIGNAL restore_fini
backup_id
###
SET DEBUG_SYNC= 'RESET';
+USE bup_reslock_db1;
SELECT * FROM t1;
c1 c2
1 abc
@@ -101,6 +102,7 @@ SET DEBUG_SYNC= 'RESET';
# connection con4, retrieve INSERT result.
#
# connection default
+USE bup_reslock_db1;
SELECT * FROM t1 ORDER BY c1;
c1 c2
0 backup
=== modified file 'mysql-test/suite/backup/r/backup_table_grants.result'
--- a/mysql-test/suite/backup/r/backup_table_grants.result 2010-01-06 15:03:50 +0000
+++ b/mysql-test/suite/backup/r/backup_table_grants.result 2010-02-23 22:36:19 +0000
@@ -75,6 +75,7 @@ GRANT INSERT ON `mysqltest1`.`t2` TO 'my
GRANT SELECT (col1), UPDATE (col2) ON `mysqltest1`.`t1` TO 'mysqluser1'@'%'
SHOW GRANTS FOR 'mysqluser2';
ERROR 42000: There is no such grant defined for user 'mysqluser2' on host '%'
+USE mysqltest1;
SELECT * FROM t1;
col1
SELECT * FROM t2;
=== modified file 'mysql-test/suite/backup/r/backup_views.result'
--- a/mysql-test/suite/backup/r/backup_views.result 2010-01-06 15:03:50 +0000
+++ b/mysql-test/suite/backup/r/backup_views.result 2010-02-23 22:36:19 +0000
@@ -317,12 +317,12 @@ Tables_in_bup_db2 vv
Table_type VIEW
SHOW CREATE VIEW bup_db1.v1;;
View v1
-Create View CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`id` AS `id`,`t1`.`name` AS `name`,`t1`.`city` AS `city` from `t1`
+Create View CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `bup_db1`.`v1` AS select `bup_db1`.`t1`.`id` AS `id`,`bup_db1`.`t1`.`name` AS `name`,`bup_db1`.`t1`.`city` AS `city` from `bup_db1`.`t1`
character_set_client latin1
collation_connection latin1_swedish_ci
SHOW CREATE VIEW bup_db1.vcomb;;
View vcomb
-Create View CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vcomb` AS select `t1`.`name` AS `name`,`t1`.`city` AS `city`,`t3`.`ccode` AS `ccode` from (`t1` join `t3`) where (`t1`.`id` = `t3`.`scode`)
+Create View CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `bup_db1`.`vcomb` AS select `bup_db1`.`t1`.`name` AS `name`,`bup_db1`.`t1`.`city` AS `city`,`bup_db1`.`t3`.`ccode` AS `ccode` from (`bup_db1`.`t1` join `bup_db1`.`t3`) where (`bup_db1`.`t1`.`id` = `bup_db1`.`t3`.`scode`)
character_set_client latin1
collation_connection latin1_swedish_ci
SHOW CREATE VIEW bup_db2.v3;;
=== modified file 'mysql-test/suite/backup/t/backup_blob.test'
--- a/mysql-test/suite/backup/t/backup_blob.test 2010-01-06 15:03:50 +0000
+++ b/mysql-test/suite/backup/t/backup_blob.test 2010-02-23 22:36:19 +0000
@@ -53,6 +53,8 @@ RESTORE FROM 'blob.bak';
--echo
--echo Check tables after restore
+USE mysqltest;
+
SELECT * FROM t1 ORDER BY id;
CHECKSUM TABLE t2;
CHECKSUM TABLE t3;
=== modified file 'mysql-test/suite/backup/t/backup_default.test'
--- a/mysql-test/suite/backup/t/backup_default.test 2010-01-06 15:03:50 +0000
+++ b/mysql-test/suite/backup/t/backup_default.test 2010-02-23 22:36:19 +0000
@@ -37,6 +37,8 @@ DROP DATABASE db1;
--replace_column 1 #
RESTORE FROM 'bup_csv.bak';
+USE db1;
+
--echo testing content in restored tables
SELECT * FROM csv_table ORDER BY id;
@@ -89,6 +91,8 @@ DROP DATABASE db1;
--replace_column 1 #
RESTORE FROM 'bup_mixed.bak';
+USE db1;
+
--echo testing content in restored tables
SELECT * FROM partition_table ORDER BY int_column;
SELECT * FROM csv_table ORDER BY id;
=== modified file 'mysql-test/suite/backup/t/backup_errors.test'
--- a/mysql-test/suite/backup/t/backup_errors.test 2010-01-26 21:31:41 +0000
+++ b/mysql-test/suite/backup/t/backup_errors.test 2010-02-23 22:36:19 +0000
@@ -482,6 +482,9 @@ DROP DATABASE db1;
--echo Restore after deleting db; will succeed
--replace_column 1 #
RESTORE FROM 'overwrite.bak';
+
+USE db1;
+
--echo
--echo Show that inserted value 2 is not there
SELECT * FROM table1;
=== modified file 'mysql-test/suite/backup/t/backup_functions.test'
--- a/mysql-test/suite/backup/t/backup_functions.test 2010-01-06 15:03:50 +0000
+++ b/mysql-test/suite/backup/t/backup_functions.test 2010-02-23 22:36:19 +0000
@@ -177,6 +177,8 @@ DROP DATABASE bup_sfs;
RESTORE FROM 'bup_sfs.bak';
SELECT @@SQL_MODE;
+USE bup_sfs;
+
#show data and create statements
--echo showing objects and create statements
--query_vertical SHOW CREATE DATABASE bup_sfs;
@@ -213,6 +215,8 @@ SET SQL_MODE=ANSI;
--replace_regex /[0-9]+/#/
RESTORE FROM 'bup_sfs.bak';
+USE bup_sfs;
+
SELECT @@SQL_MODE;
#show data and create statements
@@ -241,6 +245,8 @@ SET SQL_MODE=MAXDB;
--replace_regex /[0-9]+/#/
RESTORE FROM 'bup_sfs.bak';
+USE bup_sfs;
+
SELECT @@SQL_MODE;
#show data and create statements
@@ -269,6 +275,8 @@ SET SQL_MODE=' ';
--replace_regex /[0-9]+/#/
RESTORE FROM 'bup_sfs.bak';
+USE bup_sfs;
+
SELECT @@SQL_MODE;
#show data and create statements
--echo showing objects and create statements
=== modified file 'mysql-test/suite/backup/t/backup_multi_blocks.test'
--- a/mysql-test/suite/backup/t/backup_multi_blocks.test 2010-01-06 15:03:50 +0000
+++ b/mysql-test/suite/backup/t/backup_multi_blocks.test 2010-02-23 22:36:19 +0000
@@ -35,6 +35,8 @@ DROP DATABASE mysqltest;
--replace_column 1 #;
RESTORE FROM 'test.ba';
+USE mysqltest;
+
--echo Checking contents of restore ...
SELECT LENGTH(a) FROM t1;
CHECKSUM TABLE t1;
=== modified file 'mysql-test/suite/backup/t/backup_myisam_sync.test'
--- a/mysql-test/suite/backup/t/backup_myisam_sync.test 2010-02-16 15:40:17 +0000
+++ b/mysql-test/suite/backup/t/backup_myisam_sync.test 2010-02-23 22:36:19 +0000
@@ -84,6 +84,8 @@ SET DEBUG_SYNC= 'now SIGNAL bup_finish';
--replace_column 1 #
RESTORE FROM 'bup_myisam_sync.bak';
+ USE mysqltest;
+
SELECT LENGTH(c1) FROM t1;
CHECKSUM TABLE t1;
CHECK TABLE t1 EXTENDED;
=== modified file 'mysql-test/suite/backup/t/backup_online_testing.test'
--- a/mysql-test/suite/backup/t/backup_online_testing.test 2010-01-06 15:03:50 +0000
+++ b/mysql-test/suite/backup/t/backup_online_testing.test 2010-02-23 22:36:19 +0000
@@ -216,6 +216,8 @@ RESTORE FROM 'bup_online.bak';
--echo *** RESULT AFTER RESTORE ***
--echo
+USE bup_online;
+
SELECT * FROM t1;
SELECT COUNT(*) FROM t1;
SELECT * FROM t2;
@@ -324,6 +326,8 @@ RESTORE FROM 'bup_online1.bak';
--echo *** RESULT AFTER RESTORE ***
--echo
+USE bup_online;
+
SELECT * FROM t1;
SELECT COUNT(*) FROM t1;
SELECT * FROM t2;
@@ -434,6 +438,8 @@ RESTORE FROM 'bup_online.bak';
--echo *** RESULT AFTER RESTORE ***
--echo
+USE bup_online;
+
SELECT * FROM t1;
SELECT COUNT(*) FROM t1;
SELECT * FROM t2;
@@ -544,6 +550,8 @@ RESTORE FROM 'bup_online.bak';
--echo *** RESULT AFTER RESTORE ***
--echo
+USE bup_online;
+
SELECT * FROM t1;
SELECT COUNT(*) FROM t1;
SELECT * FROM t2;
@@ -654,6 +662,8 @@ RESTORE FROM 'bup_online.bak';
--echo *** RESULT AFTER RESTORE ***
--echo
+USE bup_online;
+
SELECT * FROM t1;
SELECT COUNT(*) FROM t1;
SELECT * FROM t2;
@@ -786,6 +796,8 @@ RESTORE FROM 'bup_online.bak';
--echo *** RESULT AFTER RESTORE ***
--echo
+USE bup_online;
+
SELECT * FROM t1;
SELECT COUNT(*) FROM t1;
SELECT * FROM t2;
@@ -918,6 +930,8 @@ RESTORE FROM 'bup_online.bak';
--echo *** RESULT AFTER RESTORE ***
--echo
+USE bup_online;
+
SELECT * FROM t1;
SELECT COUNT(*) FROM t1;
SELECT * FROM t2;
@@ -1029,6 +1043,8 @@ RESTORE FROM 'bup_online.bak';
--echo *** RESULT AFTER RESTORE ***
--echo
+USE bup_online;
+
SELECT * FROM t1;
SELECT COUNT(*) FROM t1;
SELECT * FROM t2;
@@ -1139,6 +1155,8 @@ RESTORE FROM 'bup_online.bak';
--echo *** RESULT AFTER RESTORE ***
--echo
+USE bup_online;
+
SELECT * FROM t1;
SELECT COUNT(*) FROM t1;
SELECT * FROM t2;
=== modified file 'mysql-test/suite/backup/t/backup_procedures.test'
--- a/mysql-test/suite/backup/t/backup_procedures.test 2010-01-06 15:03:50 +0000
+++ b/mysql-test/suite/backup/t/backup_procedures.test 2010-02-23 22:36:19 +0000
@@ -90,6 +90,8 @@ DROP DATABASE bup_sp;
--replace_column 1 #
RESTORE FROM 'bup_sp.bak';
+USE bup_sp;
+
#show data and create statements
--echo showing objects and create statements
--query_vertical SHOW CREATE PROCEDURE countryinfo;
@@ -162,6 +164,7 @@ DROP DATABASE bup_proc;
--replace_column 1 #
RESTORE FROM 'bup_proc.bak';
+USE bup_proc;
--echo
--echo Check that procedures are there after the restore
=== modified file 'mysql-test/suite/backup/t/backup_restore_locking.test'
--- a/mysql-test/suite/backup/t/backup_restore_locking.test 2010-02-16 15:40:17 +0000
+++ b/mysql-test/suite/backup/t/backup_restore_locking.test 2010-02-23 22:36:19 +0000
@@ -56,6 +56,7 @@ send RESTORE FROM 'bup_reslock_db1.bak';
reap;
SET DEBUG_SYNC= 'RESET';
#
+USE bup_reslock_db1;
SELECT * FROM t1;
FLUSH TABLE t1;
SELECT * FROM t1;
@@ -164,6 +165,7 @@ SET DEBUG_SYNC= 'RESET';
--echo #
--echo # connection default
--connection default
+USE bup_reslock_db1;
SELECT * FROM t1 ORDER BY c1;
FLUSH TABLE t1;
SELECT * FROM t1 ORDER BY c1;
=== modified file 'mysql-test/suite/backup/t/backup_table_grants.test'
--- a/mysql-test/suite/backup/t/backup_table_grants.test 2010-01-08 22:09:19 +0000
+++ b/mysql-test/suite/backup/t/backup_table_grants.test 2010-02-23 22:36:19 +0000
@@ -72,6 +72,9 @@ SHOW WARNINGS;
SHOW GRANTS FOR 'mysqluser1';
--error ER_NONEXISTING_GRANT
SHOW GRANTS FOR 'mysqluser2';
+
+USE mysqltest1;
+
SELECT * FROM t1;
--error ER_NO_SUCH_TABLE
SELECT * FROM t2;
=== modified file 'mysql-test/suite/backup_engines/r/backup_partitioning.result'
--- a/mysql-test/suite/backup_engines/r/backup_partitioning.result 2010-02-11 14:04:43 +0000
+++ b/mysql-test/suite/backup_engines/r/backup_partitioning.result 2010-02-23 22:36:19 +0000
@@ -176,6 +176,7 @@ backup_id
** RESULTS AFTER RESTORE **
+USE `¥`;
Obtaining Information about Partitions
SHOW FULL TABLES;;
Tables_in_¥ µ
@@ -314,6 +315,7 @@ DROP DATABASE `¥`;
RESTORE FROM 'partitions.bak';
backup_id
#
+USE `¥`;
showing objects and create statements
EXPLAIN PARTITIONS SELECT * FROM `ê`;;
id #
@@ -433,6 +435,7 @@ DROP DATABASE `¥`;
RESTORE FROM 'partitions.bak';
backup_id
#
+USE `¥`;
SHOW FULL TABLES;
Tables_in_¥ Table_type
µ BASE TABLE
=== modified file 'mysql-test/suite/backup_engines/r/backup_triggers.result'
--- a/mysql-test/suite/backup_engines/r/backup_triggers.result 2010-01-06 15:03:50 +0000
+++ b/mysql-test/suite/backup_engines/r/backup_triggers.result 2010-02-23 22:36:19 +0000
@@ -290,6 +290,7 @@ perform restore
RESTORE FROM 'bup_ts.bak';
backup_id
#
+USE bup_ts;
show data and create statements after Restore
showing objects and create statements
SHOW CREATE DATABASE bup_ts;;
@@ -490,6 +491,7 @@ SET SQL_MODE=TRADITIONAL;
RESTORE FROM 'bup_ts.bak';
backup_id
#
+USE bup_ts;
SHOW TRIGGERS;;
Trigger cap_tri
Event INSERT
@@ -638,6 +640,7 @@ SET SQL_MODE=MAXDB;
RESTORE FROM 'bup_ts.bak';
backup_id
#
+USE bup_ts;
Check contents after Restore and change of SQL mode
INSERT INTO bup_ts.cap VALUES(11,'UK','Edenburg',-36637782899,'london');
SELECT * FROM bup_ts.cap ORDER BY city;
=== modified file 'mysql-test/suite/backup_engines/t/backup_partitioning.test'
--- a/mysql-test/suite/backup_engines/t/backup_partitioning.test 2010-02-11 18:28:07 +0000
+++ b/mysql-test/suite/backup_engines/t/backup_partitioning.test 2010-02-23 22:36:19 +0000
@@ -172,6 +172,8 @@ RESTORE FROM 'partitions.bak';
--echo ** RESULTS AFTER RESTORE **
--echo
+USE `¥`;
+
#show data and create statements
--echo Obtaining Information about Partitions
--query_vertical SHOW FULL TABLES;
@@ -237,6 +239,8 @@ DROP DATABASE `¥`;
RESTORE FROM 'partitions.bak';
--remove_file $bdir/partitions.bak
+USE `¥`;
+
#show data and create statements
--echo showing objects and create statements
--replace_column 1 # 10 #
@@ -282,6 +286,8 @@ DROP DATABASE `¥`;
--replace_column 1 #
RESTORE FROM 'partitions.bak';
+USE `¥`;
+
SHOW FULL TABLES;
SELECT * FROM `фы`;
--replace_column 1 # 10 #
=== modified file 'mysql-test/suite/backup_engines/t/backup_triggers.test'
--- a/mysql-test/suite/backup_engines/t/backup_triggers.test 2010-02-11 18:28:07 +0000
+++ b/mysql-test/suite/backup_engines/t/backup_triggers.test 2010-02-23 22:36:19 +0000
@@ -203,6 +203,8 @@ DROP DATABASE bup_ts;
RESTORE FROM 'bup_ts.bak';
+USE bup_ts;
+
--echo show data and create statements after Restore
--echo showing objects and create statements
--query_vertical SHOW CREATE DATABASE bup_ts;
@@ -238,6 +240,8 @@ SET SQL_MODE=TRADITIONAL;
--replace_column 1 #
RESTORE FROM 'bup_ts.bak';
+USE bup_ts;
+
--query_vertical SHOW TRIGGERS;
--replace_result $ENGINE ENGINE
--query_vertical SHOW CREATE TABLE t2;
@@ -262,6 +266,8 @@ SET SQL_MODE=MAXDB;
--replace_column 1 #
RESTORE FROM 'bup_ts.bak';
+USE bup_ts;
+
--echo Check contents after Restore and change of SQL mode
INSERT INTO bup_ts.cap VALUES(11,'UK','Edenburg',-36637782899,'london');
=== modified file 'sql/backup/backup_kernel.h'
--- a/sql/backup/backup_kernel.h 2010-02-11 14:04:43 +0000
+++ b/sql/backup/backup_kernel.h 2010-02-23 22:36:19 +0000
@@ -163,6 +163,13 @@ private:
int m_error;
int fatal_error(int);
+ /*
+ Default database of the thread. This will be used to set thread's
+ default database after backup/restore operation is over and context
+ is being destroyed.
+ */
+ ::String m_default_db;
+
::String m_path; ///< Path to where the backup image file is located.
backup::Stream *m_stream; ///< Pointer to the backup stream object, if opened.
=== modified file 'sql/backup/kernel.cc'
--- a/sql/backup/kernel.cc 2010-02-19 21:35:32 +0000
+++ b/sql/backup/kernel.cc 2010-02-23 22:36:19 +0000
@@ -484,6 +484,12 @@ Backup_restore_ctx::Backup_restore_ctx(T
m_error= ER_QUERY_INTERRUPTED;
else if (log_handler->check_backup_logs(thd))
m_error= ER_BACKUP_PROGRESS_TABLES;
+ /*
+ Need to store default database event in case of error
+ as destructor won't know if the default database is null
+ because of the error or it was null to begin with.
+ */
+ m_default_db.copy(m_thd->db, m_thd->db_length, m_thd->db_charset);
}
@@ -495,6 +501,13 @@ Backup_restore_ctx::~Backup_restore_ctx(
delete mem_alloc;
delete m_catalog;
delete m_stream;
+ /*
+ Set threads default database.
+ */
+ if (m_default_db.length() == 0)
+ m_thd->set_db(NULL, 0);
+ else
+ m_thd->set_db(m_default_db.ptr(), m_default_db.length());
}
=== modified file 'sql/si_objects.cc'
--- a/sql/si_objects.cc 2010-02-11 14:04:43 +0000
+++ b/sql/si_objects.cc 2010-02-23 22:36:19 +0000
@@ -76,7 +76,6 @@ private:
Time_zone *m_tz_saved;
TABLE *m_tmp_tables_saved;
bool m_engage_general_log;
- String m_db_saved_string;
private:
Si_session_context(const Si_session_context &);
@@ -107,19 +106,6 @@ void Si_session_context::save_si_ctx(THD
m_tmp_tables_saved= thd->temporary_tables;
m_old_db_collation= thd->variables.collation_database;
- /* Saving the default database */
- if (thd->db)
- m_db_saved_string.copy(thd->db, thd->db_length, thd->db_charset);
- /*
- Clear up and old data in the saved database since there is no default
- database set.
- */
- else
- if (!m_db_saved_string.is_empty())
- m_db_saved_string= 0;
- /* clean up database info from thd context */
- thd->set_db(NULL,0);
-
DBUG_VOID_RETURN;
}
@@ -170,23 +156,8 @@ void Si_session_context::reset_si_ctx(TH
void Si_session_context::restore_si_ctx(THD *thd)
{
-
- String query ("USE `",m_db_saved_string.charset());
- Ed_connection ed_connection(thd);
- LEX_STRING lex_query;
-
-
DBUG_ENTER("Si_session_context::restore_si_ctx");
-
- /* Restoring the default database */
- if (m_db_saved_string != 0)
- {
- query.append(m_db_saved_string);
- query.append("`");
- lex_query= query.lex_string();
- ed_connection.execute_direct(lex_query);
- }
thd->variables.sql_mode= m_sql_mode_saved;
thd->variables.time_zone= m_tz_saved;
Attachment: [text/bzr-bundle] bzr/charles.bell@sun.com-20100223223619-s11y3bzs7v9sxb4j.bundle
| Thread |
|---|
| • bzr commit into mysql-backup-backport branch (charles.bell:3114)Bug#33354 | Chuck Bell | 23 Feb |