Skip to content

If/Else uses uninitialized value when InnoDB not enabled. #42

Description

@bswopes

On a system with InnoDB disabled...

[--] Status: +ARCHIVE +BLACKHOLE +CSV -FEDERATED -InnoDB +MRG_MYISAM 

MySQLTuner throws an error attempting to print the uninitialized value Innodb_log_waits at line 969.

Use of uninitialized value $mystat{"Innodb_log_waits"} in concatenation (.) or
    string at ./MySQLTuner/mysqltuner.pl line 969 (#1)
    (W uninitialized) An undefined value was used as if it were already
    defined.  It was interpreted as a "" or a 0, but maybe it was a mistake.
    To suppress this warning assign a defined value to your variables.

    To help you figure out what was undefined, perl will try to tell you the
    name of the variable (if any) that was undefined. In some cases it cannot
    do this, so it also tells you what operation you used the undefined value
    in.  Note, however, that perl optimizes your program and the operation
    displayed in the warning may not necessarily appear literally in your
    program.  For example, "that $foo" is usually optimized into "that "
    . $foo, and the warning will refer to the concatenation (.) operator,
    even though there is no . in your program.

[OK] InnoDB log waits: 

This is because the if/else block beginning at line 965 will execute even when have_innodb is undefined or set to NO and Innodb_log_waits being undefined triggers the else block which attempts to print Innodb_log_waits.

        if (defined $mystat{'Innodb_log_waits'} && $mystat{'Innodb_log_waits'} > 0) {
                badprint "InnoDB log waits: ".$mystat{'Innodb_log_waits'};
                push(@adjvars,"innodb_log_buffer_size (>= ".hr_bytes_rnd($myvar{'innodb_log_buffer_size'}).")");
        } else {
                goodprint "InnoDB log waits: ".$mystat{'Innodb_log_waits'};
        }

The solution seems to be shifting this if/else block up into the if block beginning at line 957 or adding a new else if to ensure that Innodb_log_waits is defined.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions