summaryrefslogtreecommitdiff
path: root/mysql-test/r/mysql.result
diff options
context:
space:
mode:
authorNirbhay Choubey <nirbhay.choubey@sun.com>2010-11-26 19:27:59 +0530
committerNirbhay Choubey <nirbhay.choubey@sun.com>2010-11-26 19:27:59 +0530
commite1b773cb53bd82f3947704224bee229264c2d120 (patch)
tree28b0c07fd0fed90b389432525c7536412b40f6ca /mysql-test/r/mysql.result
parent01e0be66ddb4e404ab7ae1e218996d57655635ed (diff)
downloadmariadb-git-e1b773cb53bd82f3947704224bee229264c2d120.tar.gz
Bug #54899 : --one-database option cannot handle DROP/CREATE DATABASE commands
After dropping and recreating the database specified along with --one-database option at command line, mysql client keeps filtering the statements even after the execution of a 'USE' command on the same database. --one-database option enables the filtering of statements when the current database is not the one specified at the command line. However, when the same database is dropped and recreated the variable (current_db) that holds the inital database name gets altered. This bug exploits the fact that current_db initially gets set to null value (0) when a 'use db_name' follows the recreation of same database db_name (speficied at the command line) and hence skip_updates gets set to 1, which inturn triggers the further filtering of statements. Fixed by making get_current_db() a no-op function when one_database is set, and hence, under that condition current_db will not get altered. Note, however the value of current_db can change when we execute 'connect' command with a differnet database to reconnect to the server, in which case, the behavior of --one-database will be formulated using this new database. client/mysql.cc: Bug #54899 : --one-database option cannot handle DROP/CREATE DATABASE commands Added an if statement at the beginnning of get_current_db() , which makes it a no-op function if one-database option is specified, and hence current_db remains unchanged. Changed the help message for one-database option to a more appropriate message as specified in mysql documentation. mysql-test/r/mysql.result: Added a test case for bug#54899 and some more test cases to check other one-database option related behaviors. mysql-test/t/mysql.test: Added a test case for bug#54899 and some more test cases to check other one-database option related behaviors.
Diffstat (limited to 'mysql-test/r/mysql.result')
-rw-r--r--mysql-test/r/mysql.result71
1 files changed, 71 insertions, 0 deletions
diff --git a/mysql-test/r/mysql.result b/mysql-test/r/mysql.result
index 68f30ed80f8..cc3f94528f7 100644
--- a/mysql-test/r/mysql.result
+++ b/mysql-test/r/mysql.result
@@ -235,4 +235,75 @@ Bug #47147: mysql client option --skip-column-names does not apply to vertical o
*************************** 1. row ***************************
1
+#
+# Bug #54899: --one-database option cannot handle DROP/CREATE DATABASE
+# commands.
+#
+CREATE DATABASE connected_db;
+USE connected_db;
+SHOW TABLES;
+Tables_in_connected_db
+table_in_connected_db
+DROP DATABASE connected_db;
+
+#
+# Testing --one-database option
+#
+CREATE DATABASE connected_db;
+SHOW TABLES IN connected_db;
+Tables_in_connected_db
+t1
+SHOW TABLES IN test;
+Tables_in_test
+t1
+USE test;
+DROP TABLE t1;
+DROP DATABASE connected_db;
+
+SHOW TABLES IN test;
+Tables_in_test
+SHOW TABLES IN test1;
+Tables_in_test1
+DROP DATABASE test1;
+
+#
+# Checking --one-database option followed by the execution of
+# connect command.
+#
+CREATE DATABASE connected_db;
+SHOW TABLES IN connected_db;
+Tables_in_connected_db
+t1
+t2
+SHOW TABLES IN test;
+Tables_in_test
+t1
+t2
+DROP TABLE test.t1;
+DROP TABLE test.t2;
+DROP DATABASE connected_db;
+
+#
+# Checking --one-database option with no database specified
+# at command-line.
+#
+SHOW TABLES IN test;
+Tables_in_test
+
+#
+# Checking --one-database option with non_existent_db
+# specified with USE command
+#
+SHOW TABLES IN test;
+Tables_in_test
+table_in_test
+DROP DATABASE test;
+
+CREATE DATABASE test;
+SHOW TABLES IN test;
+Tables_in_test
+table_in_test
+DROP DATABASE test;
+CREATE DATABASE test;
+
End of tests