Skip to content

Commit 32d6db3

Browse files
author
Shishir Jaiswal
committed
Bug#19920049 - MYSQLD_MULTI MISLEADING WHEN MY_PRINT_DEFAULTS
IS NOT FOUND DESCRIPTION =========== If script mysqld_multi and utility my_print_defaults are in the same folder (not included in $PATH) and the former is made to run, it complaints that the mysqld binary is absent eventhough the binary exists. ANALYSIS ======== We've a subroutine my_which() mimicking the behaviour of POSIX "which" command. Its current behaviour is to check for a given argument as follows: - Step 1: Assume the argument to be a command having full fledged absolute path. If it exists "as-is", return the argument (which will be pathname), else proceed to Step 2. - Step 2: Assume the argument to be a plain command with no aboslute path. Try locating it in all of the paths (mentioned in $PATH) one by one. If found return the pathname. If found nowhere, return NULL. Currently when my_which(my_print_defaults) is called, it returns from Step 1 (since utlity exists in current folder) and doesn't proceed to Step 2. This is wrong since the returned value is same as the argument i.e. 'my_print_default' which defies the purpose of this subroutine whose job is to return a pathname either in Step 1 or Step 2. Later when the utility is executed in subroutine defaults_for_group(), it evaluates to NULL and returns the same. This is because the plain command 'my_print_defaults {options} ...' would execute properly only if my_print_defaults exists in one of the paths (in $PATH). In such a case, in the course of the flow it looks onto the variable $mysqld_found which comes out to be NULL and hence ethe error. In this case, call to my_which should fail resulting in script being aborted and thus avoiding this mess. FIX === This utility my_print_defaults should be tested only in Step 2 since it does not have an absolute path. Thus added a condition in Step 1 so that is gets executed iff not called for my_print_defaults thus bypassing it to proceed to Step 2 where the check is made for various paths (in $PATH)
1 parent 8361151 commit 32d6db3

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

scripts/mysqld_multi.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/perl
22

3-
# Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
3+
# Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
44
#
55
# This program is free software; you can redistribute it and/or
66
# modify it under the terms of the GNU Library General Public
@@ -596,7 +596,11 @@ sub my_which
596596
my ($command) = @_;
597597
my (@paths, $path);
598598

599-
return $command if (-f $command && -x $command);
599+
# If the argument is not 'my_print_defaults' then it would be of the format
600+
# <absolute_path>/<program>
601+
return $command if ($command ne 'my_print_defaults' && -f $command &&
602+
-x $command);
603+
600604
@paths = split(':', $ENV{'PATH'});
601605
foreach $path (@paths)
602606
{

0 commit comments

Comments
 (0)