Commit 2b59f496 authored by unknown's avatar unknown

Folow up on the CS patch:

1. Fix ddl_i18n_koi8r, ddl_i18n_utf8: explicitly specify character-sets
directory for mysqldump;
2. Fix crash in mysqldump if collation is not found;
3. Use proper way to compare character set names.


client/mysqldump.c:
  Prevent crash if collation does not exist.
mysql-test/t/ddl_i18n_koi8r.test:
  Explicitly specify character-sets-directory for mysqldump.
mysql-test/t/ddl_i18n_utf8.test:
  Explicitly specify character-sets-directory for mysqldump.
sql/sql_lex.cc:
  Use my_charset_same() function to check if the charset names are equal.
parent 405f82d3
......@@ -1066,12 +1066,16 @@ static int switch_db_collation(FILE *sql_file,
const char *db_name,
const char *delimiter,
const char *current_db_cl_name,
const char *required_db_cl_name)
const char *required_db_cl_name,
int *db_cl_altered)
{
if (strcmp(current_db_cl_name, required_db_cl_name) != 0)
{
CHARSET_INFO *db_cl= get_charset_by_name(required_db_cl_name, MYF(0));
if (!db_cl)
return 1;
fprintf(sql_file,
"ALTER DATABASE %s CHARACTER SET %s COLLATE %s %s\n",
(const char *) db_name,
......@@ -1079,26 +1083,35 @@ static int switch_db_collation(FILE *sql_file,
(const char *) db_cl->name,
(const char *) delimiter);
return 1;
*db_cl_altered= 1;
return 0;
}
*db_cl_altered= 0;
return 0;
}
static void restore_db_collation(FILE *sql_file,
const char *db_name,
const char *delimiter,
const char *db_cl_name)
static int restore_db_collation(FILE *sql_file,
const char *db_name,
const char *delimiter,
const char *db_cl_name)
{
CHARSET_INFO *db_cl= get_charset_by_name(db_cl_name, MYF(0));
if (!db_cl)
return 1;
fprintf(sql_file,
"ALTER DATABASE %s CHARACTER SET %s COLLATE %s %s\n",
(const char *) db_name,
(const char *) db_cl->csname,
(const char *) db_cl->name,
(const char *) delimiter);
return 0;
}
......@@ -1724,11 +1737,11 @@ static uint dump_events_for_db(char *db)
fprintf(sql_file, "DELIMITER %s\n", delimiter);
db_cl_altered= switch_db_collation(sql_file,
db_name_buff,
delimiter,
db_cl_name,
row[6]);
if (switch_db_collation(sql_file, db_name_buff, delimiter, db_cl_name,
row[6], &db_cl_altered))
{
DBUG_RETURN(1);
}
switch_cs_variables(sql_file, delimiter,
row[4], /* character_set_client */
......@@ -1749,7 +1762,11 @@ static uint dump_events_for_db(char *db)
restore_cs_variables(sql_file, delimiter);
if (db_cl_altered)
restore_db_collation(sql_file, db_name_buff, delimiter, db_cl_name);
{
if (restore_db_collation(sql_file, db_name_buff, delimiter,
db_cl_name))
DBUG_RETURN(1);
}
}
} /* end of event printing */
mysql_free_result(event_res);
......@@ -1935,8 +1952,11 @@ static uint dump_routines_for_db(char *db)
PROCEDURE/FUNCTION otherwise we may need to re-quote routine_name
*/
db_cl_altered= switch_db_collation(sql_file, db_name_buff, ";",
db_cl_name, row[5]);
if (switch_db_collation(sql_file, db_name_buff, ";",
db_cl_name, row[5], &db_cl_altered))
{
DBUG_RETURN(1);
}
switch_cs_variables(sql_file, ";",
row[3], /* character_set_client */
......@@ -1955,7 +1975,10 @@ static uint dump_routines_for_db(char *db)
restore_cs_variables(sql_file, ";");
if (db_cl_altered)
restore_db_collation(sql_file, db_name_buff, ";", db_cl_name);
{
if (restore_db_collation(sql_file, db_name_buff, ";", db_cl_name))
DBUG_RETURN(1);
}
my_free(query_str, MYF(MY_ALLOW_ZERO_PTR));
}
......@@ -2581,8 +2604,9 @@ static void dump_triggers_for_table(char *table, char *db_name)
}
}
db_cl_altered= switch_db_collation(sql_file, db_name, ";",
db_cl_name, row[5]);
if (switch_db_collation(sql_file, db_name, ";",
db_cl_name, row[5], &db_cl_altered))
DBUG_VOID_RETURN;
switch_cs_variables(sql_file, ";",
row[3], /* character_set_client */
......@@ -2601,7 +2625,10 @@ static void dump_triggers_for_table(char *table, char *db_name)
restore_cs_variables(sql_file, ";");
if (db_cl_altered)
restore_db_collation(sql_file, db_name, ";", db_cl_name);
{
if (restore_db_collation(sql_file, db_name, ";", db_cl_name))
DBUG_VOID_RETURN;
}
my_free(query_str, MYF(MY_ALLOW_ZERO_PTR));
}
......
......@@ -139,7 +139,7 @@ set names koi8r|
--echo
--echo ---> Dumping mysqltest1 to ddl_i18n_koi8r.views.mysqltest1.sql
--exec $MYSQL_DUMP --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.views.mysqltest1.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.views.mysqltest1.sql
# - Clean mysqltest1;
......@@ -393,22 +393,22 @@ set names koi8r|
--echo
--echo ---> Dump of mysqltest1
--exec $MYSQL_DUMP --compact --routines --databases mysqltest1
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest1
--echo
--echo ---> Dumping mysqltest1 to ddl_i18n_koi8r.sp.mysqltest1.sql
--exec $MYSQL_DUMP --compact --routines --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.sp.mysqltest1.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.sp.mysqltest1.sql
--echo
--echo ---> Dump of mysqltest2
--exec $MYSQL_DUMP --compact --routines --databases mysqltest2
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest2
--echo
--echo ---> Dumping mysqltest2 to ddl_i18n_koi8r.sp.mysqltest2.sql
--exec $MYSQL_DUMP --compact --routines --databases mysqltest2 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.sp.mysqltest2.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest2 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.sp.mysqltest2.sql
# - Clean mysqltest1, mysqltest2;
......@@ -664,22 +664,22 @@ use mysqltest1|
--echo
--echo ---> Dump of mysqltest1
--exec $MYSQL_DUMP --compact --triggers --databases mysqltest1
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest1
--echo
--echo ---> Dumping mysqltest1 to ddl_i18n_koi8r.triggers.mysqltest1.sql
--exec $MYSQL_DUMP --compact --triggers --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.triggers.mysqltest1.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.triggers.mysqltest1.sql
--echo
--echo ---> Dump of mysqltest2
--exec $MYSQL_DUMP --compact --triggers --databases mysqltest2
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest2
--echo
--echo ---> Dumping mysqltest2 to ddl_i18n_koi8r.triggers.mysqltest2.sql
--exec $MYSQL_DUMP --compact --triggers --databases mysqltest2 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.triggers.mysqltest2.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest2 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.triggers.mysqltest2.sql
# - Clean mysqltest1, mysqltest2;
......@@ -919,22 +919,22 @@ set names koi8r|
--echo
--echo ---> Dump of mysqltest1
--exec $MYSQL_DUMP --compact --events --databases mysqltest1
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest1
--echo
--echo ---> Dumping mysqltest1 to ddl_i18n_koi8r.events.mysqltest1.sql
--exec $MYSQL_DUMP --compact --events --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.events.mysqltest1.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.events.mysqltest1.sql
--echo
--echo ---> Dump of mysqltest2
--exec $MYSQL_DUMP --compact --events --databases mysqltest2
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest2
--echo
--echo ---> Dumping mysqltest2 to ddl_i18n_koi8r.events.mysqltest2.sql
--exec $MYSQL_DUMP --compact --events --databases mysqltest2 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.events.mysqltest2.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest2 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.events.mysqltest2.sql
# - Clean mysqltest1, mysqltest2;
......
......@@ -139,7 +139,7 @@ set names utf8|
--echo
--echo ---> Dumping mysqltest1 to ddl_i18n_utf8views.mysqltest1.sql
--exec $MYSQL_DUMP --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8views.mysqltest1.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8views.mysqltest1.sql
# - Clean mysqltest1;
......@@ -393,22 +393,22 @@ set names utf8|
--echo
--echo ---> Dump of mysqltest1
--exec $MYSQL_DUMP --compact --routines --databases mysqltest1
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest1
--echo
--echo ---> Dumping mysqltest1 to ddl_i18n_utf8sp.mysqltest1.sql
--exec $MYSQL_DUMP --compact --routines --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8sp.mysqltest1.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8sp.mysqltest1.sql
--echo
--echo ---> Dump of mysqltest2
--exec $MYSQL_DUMP --compact --routines --databases mysqltest2
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest2
--echo
--echo ---> Dumping mysqltest2 to ddl_i18n_utf8sp.mysqltest2.sql
--exec $MYSQL_DUMP --compact --routines --databases mysqltest2 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8sp.mysqltest2.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest2 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8sp.mysqltest2.sql
# - Clean mysqltest1, mysqltest2;
......@@ -664,22 +664,22 @@ use mysqltest1|
--echo
--echo ---> Dump of mysqltest1
--exec $MYSQL_DUMP --compact --triggers --databases mysqltest1
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest1
--echo
--echo ---> Dumping mysqltest1 to ddl_i18n_utf8triggers.mysqltest1.sql
--exec $MYSQL_DUMP --compact --triggers --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8triggers.mysqltest1.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8triggers.mysqltest1.sql
--echo
--echo ---> Dump of mysqltest2
--exec $MYSQL_DUMP --compact --triggers --databases mysqltest2
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest2
--echo
--echo ---> Dumping mysqltest2 to ddl_i18n_utf8triggers.mysqltest2.sql
--exec $MYSQL_DUMP --compact --triggers --databases mysqltest2 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8triggers.mysqltest2.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest2 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8triggers.mysqltest2.sql
# - Clean mysqltest1, mysqltest2;
......@@ -919,22 +919,22 @@ set names utf8|
--echo
--echo ---> Dump of mysqltest1
--exec $MYSQL_DUMP --compact --events --databases mysqltest1
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest1
--echo
--echo ---> Dumping mysqltest1 to ddl_i18n_utf8events.mysqltest1.sql
--exec $MYSQL_DUMP --compact --events --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8events.mysqltest1.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8events.mysqltest1.sql
--echo
--echo ---> Dump of mysqltest2
--exec $MYSQL_DUMP --compact --events --databases mysqltest2
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest2
--echo
--echo ---> Dumping mysqltest2 to ddl_i18n_utf8events.mysqltest2.sql
--exec $MYSQL_DUMP --compact --events --databases mysqltest2 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8events.mysqltest2.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest2 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8events.mysqltest2.sql
# - Clean mysqltest1, mysqltest2;
......
......@@ -249,7 +249,7 @@ void Lex_input_stream::body_utf8_append_literal(THD *thd,
LEX_STRING utf_txt;
if (txt_cs->number != my_charset_utf8_general_ci.number)
if (my_charset_same(txt_cs, &my_charset_utf8_general_ci))
{
thd->convert_string(&utf_txt,
&my_charset_utf8_general_ci,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment