mirror of
https://github.com/webmin/webmin.git
synced 2026-02-03 14:13:29 +00:00
Add function to get the DB character set
This commit is contained in:
@@ -103,7 +103,8 @@ print &ui_table_row($text{'backup_drop'},
|
|||||||
&ui_yesno_radio("drop", $d ? 1 : 0));
|
&ui_yesno_radio("drop", $d ? 1 : 0));
|
||||||
|
|
||||||
# Show input for character set
|
# 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'},
|
print &ui_table_row($text{'backup_charset'},
|
||||||
&ui_radio("charset_def", $s ? 0 : 1,
|
&ui_radio("charset_def", $s ? 0 : 1,
|
||||||
[ [ 1, $text{'default'} ],
|
[ [ 1, $text{'default'} ],
|
||||||
|
|||||||
@@ -1398,6 +1398,21 @@ else {
|
|||||||
return sort { lc($a->[1]) cmp lc($b->[1]) } @rv;
|
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])
|
# list_collation_orders([db])
|
||||||
# Returns a list of supported collation orders. Each row is an array ref of
|
# Returns a list of supported collation orders. Each row is an array ref of
|
||||||
# a code and character set it can work with.
|
# 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;
|
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)
|
# fix_collation(file)
|
||||||
# Fixes unsupported collations on restore, by replacing
|
# Fixes unsupported collations on restore, by replacing
|
||||||
# unsuported with the closest supported variant
|
# unsuported with the closest supported variant
|
||||||
|
|||||||
Reference in New Issue
Block a user