diff --git a/mysql/backup_form.cgi b/mysql/backup_form.cgi index 7ca520a02..4e9cac733 100755 --- a/mysql/backup_form.cgi +++ b/mysql/backup_form.cgi @@ -103,7 +103,8 @@ print &ui_table_row($text{'backup_drop'}, &ui_yesno_radio("drop", $d ? 1 : 0)); # Show input for character set -$s = $c{'backup_charset_'.$in{'db'}} || $c{'charset'}; +$dbc = $in{'db'} ? &get_character_set($in{'db'}) : ""; +$s = $c{'backup_charset_'.$in{'db'}} || $c{'charset'} || $dbc; print &ui_table_row($text{'backup_charset'}, &ui_radio("charset_def", $s ? 0 : 1, [ [ 1, $text{'default'} ], diff --git a/mysql/mysql-lib.pl b/mysql/mysql-lib.pl index 722ad88ec..985fc2654 100755 --- a/mysql/mysql-lib.pl +++ b/mysql/mysql-lib.pl @@ -1398,6 +1398,21 @@ else { return sort { lc($a->[1]) cmp lc($b->[1]) } @rv; } +# get_character_set(db) +# Returns the character set for a database +sub get_character_set +{ +my ($db) = @_; +my $d; +eval { + local $main::error_must_die = 1; + $d = &execute_sql($db, 'select @@character_set_database'); + }; +return undef if ($@); +return undef if (!@{$d->{'data'}}); +return $d->{'data'}->[0]->[0]; +} + # list_collation_orders([db]) # Returns a list of supported collation orders. Each row is an array ref of # a code and character set it can work with. @@ -1412,6 +1427,21 @@ if (&compare_version_numbers(&get_remote_mysql_version(), "5") >= 0) { return sort { lc($a->[0]) cmp lc($b->[0]) } @rv; } +# get_collation_order(db) +# Returns the collation order for a database +sub get_collation_order +{ +my ($db) = @_; +my $d; +eval { + local $main::error_must_die = 1; + $d = &execute_sql($db, 'select @@collation_database'); + }; +return undef if ($@); +return undef if (!@{$d->{'data'}}); +return $d->{'data'}->[0]->[0]; +} + # fix_collation(file) # Fixes unsupported collations on restore, by replacing # unsuported with the closest supported variant