summaryrefslogtreecommitdiff
path: root/mysql-test/t/mysqldump.test
diff options
context:
space:
mode:
authorunknown <anozdrin/alik@ibm.>2007-07-27 18:20:17 +0400
committerunknown <anozdrin/alik@ibm.>2007-07-27 18:20:17 +0400
commite030b5dcc030e5777ed6260e4a9bb1c135b32aed (patch)
tree67a0ad62d894ba9e62f87816ac5d66109de254f7 /mysql-test/t/mysqldump.test
parent339ea316b938b9b1c2a166c6580bf84333d80a5f (diff)
downloadmariadb-git-e030b5dcc030e5777ed6260e4a9bb1c135b32aed.tar.gz
Fix for BUG#30027: mysqldump does not dump views properly.
mysqldump generates view defitions in two stages: - dump CREATE TABLE statements for the temporary tables. For each view a temporary table, that has the same structure as the view is created. - dump DROP TABLE statements for the temporary tables and CREATE VIEW statements for the view. This approach is required because views can have dependencies on each other (a view can use other views). So, they should be created in the particular order. mysqldump however is not smart enough, so in order to resolve dependencies it creates temporary tables first of all. The problem was that mysqldump might have generated incorrect dump for the temporary table when a view has non-ASCII column name. That happened when default-character-set is not utf8. The fix is to: 1. Switch character_set_client for the mysqldump's connection to binary before issuing SHOW FIELDS statement in order to avoid conversion. 2. Dump switch character_set_client statements to UTF8 and back for CREATE TABLE statement that is issued to create temporary table. client/mysqldump.c: 1. Switch character_set_results for mysqldump's connection to binary before SHOW FIELDS in order to avoid conversion to client character set. 2. Dump switch character_set_client statements to UTF8 and back for CREATE TABLE statement. mysql-test/r/mysqldump.result: Update result file. mysql-test/t/mysqldump.test: Test case for BUG#30027.
Diffstat (limited to 'mysql-test/t/mysqldump.test')
-rw-r--r--mysql-test/t/mysqldump.test58
1 files changed, 58 insertions, 0 deletions
diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test
index 38d8a07fe48..a0d1195addc 100644
--- a/mysql-test/t/mysqldump.test
+++ b/mysql-test/t/mysqldump.test
@@ -1676,6 +1676,64 @@ drop database mysqldump_test_db;
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug26121.sql
--remove_file $MYSQLTEST_VARDIR/tmp/bug26121.sql
+###########################################################################
+
+--echo #
+--echo # Bug #30027: mysqldump does not dump views properly.
+--echo #
+
+--echo
+--echo # Cleanup.
+
+--disable_warnings
+DROP DATABASE IF EXISTS mysqldump_test_db;
+--enable_warnings
+
+--echo
+--echo # Create objects.
+
+CREATE DATABASE mysqldump_test_db;
+
+set names koi8r;
+
+CREATE VIEW mysqldump_test_db.v2 AS SELECT 1 AS колонка1;
+CREATE VIEW mysqldump_test_db.v1 AS SELECT колонка1 FROM mysqldump_test_db.v2;
+
+set names latin1;
+
+--echo
+--echo # Dump mysqldump_test_db to $MYSQLTEST_VARDIR/tmp/bug30027.sql.
+
+--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --default-character-set=latin1 --databases mysqldump_test_db > $MYSQLTEST_VARDIR/tmp/bug30027.sql
+# --exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --databases mysqldump_test_db > $MYSQLTEST_VARDIR/tmp/bug30027.sql
+
+--echo
+--echo # Drop mysqldump_test_db.
+
+DROP DATABASE mysqldump_test_db;
+
+--echo
+--echo # Restore mysqldump_test_db from $MYSQLTEST_VARDIR/tmp/bug30027.sql.
+
+--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/bug30027.sql
+
+--echo
+--echo # Check the view.
+
+set names utf8;
+
+SHOW CREATE VIEW mysqldump_test_db.v1;
+SHOW CREATE VIEW mysqldump_test_db.v2;
+
+set names latin1;
+
+--echo
+--echo # Cleanup.
+
+DROP DATABASE mysqldump_test_db;
+
+###########################################################################
+
--echo #
--echo # End of 5.1 tests
--echo #