2
# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
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
die "Unknown option format '$option'";
75
my ($name, $value)= @_;
77
return "-".$name."=".$value;
80
return "--".$name."=".$value;
87
# Compare two list of options and return what would need
88
# to be done to get the server running with the new settings
91
my ($from_opts, $to_opts)= @_;
94
foreach my $from (@$from_opts)
96
my ($opt, $value)= _split_option($from);
97
next unless defined($opt);
101
#print "from: ", %from, "\n";
104
foreach my $to (@$to_opts)
106
my ($opt, $value)= _split_option($to);
107
next unless defined($opt);
111
#print "to: ", %to, "\n";
113
# Remove the ones that are in both lists
114
foreach my $name (keys %from){
115
if (exists $to{$name} and $to{$name} eq $from{$name}){
116
#print "removing '$name' from both lists\n";
122
#print "from: ", %from, "\n";
123
#print "to: ", %to, "\n";
125
# Add all keys in "to" to result
127
foreach my $name (keys %to){
128
push(@result, _build_option($name, $to{$name}));
131
# Add all keys in "from" that are not in "to"
132
# to result as "set to default"
133
foreach my $name (keys %from){
134
if (not exists $to{$name}) {
135
push(@result, _build_option($name, "default"));
144
my ($opts, $set_opts)= @_;
146
foreach my $opt (@$opts){
148
my ($opt_name1, $value1)= _split_option($opt);
150
foreach my $set_opt (@$set_opts){
151
my ($opt_name2, $value2)= _split_option($set_opt);
153
if ($opt_name1 eq $opt_name2){
168
foreach my $option (@options) {
169
my ($sql_name, $value)= _split_option($option);
170
#print "name: $sql_name\n";
171
#print "value: $value\n";
173
push(@sql, "SET GLOBAL $sql_name=$value");
175
return join("; ", @sql);
182
"['", join("', '", @_), "']\n";