2
# Copyright (C) 2004-2006 MySQL AB
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; version 2 of the License.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
# Utility functions to work with list of options
30
return compare($l1,$l2) == 0;
41
return -1 if @l1 < @l2;
42
return 1 if @l1 > @l2;
44
while ( @l1 ) # Same length
48
my $cmp= ($e1 cmp $e2);
49
return $cmp if $cmp != 0;
52
return 0; # They are the same
58
if ($option=~ /^--(.*)=(.*)$/){
61
elsif ($option=~ /^--(.*)$/){
64
elsif ($option=~ /^\$(.*)$/){ # $VAR
67
elsif ($option=~ /^(.*)=(.*)$/){
70
elsif ($option=~ /^-O$/){
71
return (undef, undef);
73
die "Unknown option format '$option'";
78
my ($name, $value)= @_;
80
return "-".$name."=".$value;
83
return "--".$name."=".$value;
90
# Compare two list of options and return what would need
91
# to be done to get the server running with the new settings
94
my ($from_opts, $to_opts)= @_;
97
foreach my $from (@$from_opts)
99
my ($opt, $value)= _split_option($from);
100
next unless defined($opt);
104
#print "from: ", %from, "\n";
107
foreach my $to (@$to_opts)
109
my ($opt, $value)= _split_option($to);
110
next unless defined($opt);
114
#print "to: ", %to, "\n";
116
# Remove the ones that are in both lists
117
foreach my $name (keys %from){
118
if (exists $to{$name} and $to{$name} eq $from{$name}){
119
#print "removing '$name' from both lists\n";
125
#print "from: ", %from, "\n";
126
#print "to: ", %to, "\n";
128
# Add all keys in "to" to result
130
foreach my $name (keys %to){
131
push(@result, _build_option($name, $to{$name}));
134
# Add all keys in "from" that are not in "to"
135
# to result as "set to default"
136
foreach my $name (keys %from){
137
if (not exists $to{$name}) {
138
push(@result, _build_option($name, "default"));
147
my ($opts, $set_opts)= @_;
149
foreach my $opt (@$opts){
151
my ($opt_name1, $value1)= _split_option($opt);
153
foreach my $set_opt (@$set_opts){
154
my ($opt_name2, $value2)= _split_option($set_opt);
156
if ($opt_name1 eq $opt_name2){
171
foreach my $option (@options) {
172
my ($name, $value)= _split_option($option);
173
#print "name: $name\n";
174
#print "value: $value\n";
175
if ($name =~ /^O, (.*)/){
176
push(@sql, "SET GLOBAL $1=$value");
178
elsif ($name =~ /^set-variable=(.*)/){
179
push(@sql, "SET GLOBAL $1=$value");
184
push(@sql, "SET GLOBAL $sql_name=$value");
187
return join("; ", @sql);
194
"['", join("', '", @_), "']\n";