undefined variables

Bug #530456 reported by dalin
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
mysqltuner
In Progress
High
Sheeri K. Cabral

Bug Description

Here's an excerpt from the output where perl reports some undefined variables. Sorry I know nothing about perl so I can't offer a patch.

table cache size (pre 5.1): 64.00
Use of uninitialized value $num in pattern match (m//) at ./mysqltuner.pl line
        223 (#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.

Use of uninitialized value $compval in concatenation (.) or string at
        ./mysqltuner.pl line 230 (#1)
Use of uninitialized value in string eq at ./mysqltuner.pl line 231 (#1)
table open cache size (5.1+):
table cache size: 64.00

Revision history for this message
Sheeri K. Cabral (awfief) wrote :

This is because the tuner-default.cnf has both:

table_open_cache
table_cache

It looks like from your bug report that you are on MySQL 5.0 or less, because the "table_open_cache" variable could not be found. If you delete the line with "table_open_cache" from the tuner-default.cnf, the problem should go away.

The fix is to have 2 files -- one for 5.1 and one for 5.0 and less...

Changed in mysqltuner:
assignee: nobody → Sheeri K. Cabral (awfief)
Revision history for this message
dalin (dave-hansen-lange) wrote : Re: [Bug 530456] Re: undefined variables

Not knowing anything about Perl, is there some equivalent to:
if (!empty($foo)) {
  // Do something with $foo.
}

On Tue, Mar 2, 2010 at 9:52 PM, Sheeri K. Cabral <email address hidden> wrote:

> This is because the tuner-default.cnf has both:
>
> table_open_cache
> table_cache
>
> It looks like from your bug report that you are on MySQL 5.0 or less,
> because the "table_open_cache" variable could not be found. If you
> delete the line with "table_open_cache" from the tuner-default.cnf, the
> problem should go away.
>
> The fix is to have 2 files -- one for 5.1 and one for 5.0 and less...
>
> ** Changed in: mysqltuner
> Assignee: (unassigned) => Sheeri K. Cabral (awfief)
>
> --
> undefined variables
> https://bugs.launchpad.net/bugs/530456
> You received this bug notification because you are a direct subscriber
> of the bug.
>
> Status in MySQL Tuner: New
>
> Bug description:
> Here's an excerpt from the output where perl reports some undefined
> variables. Sorry I know nothing about perl so I can't offer a patch.
>
> table cache size (pre 5.1): 64.00
> Use of uninitialized value $num in pattern match (m//) at ./mysqltuner.plline
> 223 (#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.
>
> Use of uninitialized value $compval in concatenation (.) or string at
> ./mysqltuner.pl line 230 (#1)
> Use of uninitialized value in string eq at ./mysqltuner.pl line 231 (#1)
> table open cache size (5.1+):
> table cache size: 64.00
>
> To unsubscribe from this bug, go to:
> https://bugs.launchpad.net/mysqltuner/+bug/530456/+subscribe
>

Revision history for this message
Sheeri K. Cabral (awfief) wrote :

dalin -- I'm trying to keep the logic very simple for now.

Certainly I can make the check say "if the version is 5.1, use this, if it's 5.0, use that". But I don't want a lot of one-off exceptions. I *want* people to modify the default config file, because those are simply examples, or a base to start from.

There's an open bug report to make groupings, and I think this goes under that jurisdiction. The calculation is just Perl, though, so your workaround can be done.

Definitely though this will produce your issue on any version, so I should definitely change that.

Revision history for this message
Sheeri K. Cabral (awfief) wrote :

Version 17, now available for download at http://launchpad.net/mysqltuner/2.0/mysqltuner-2.1-rev17/+download/mysqltuner-2.1-rev17.tar.gz has the workaround in place of having different config files (one with table_cache, one with table_open_cache).

I am leaving this bug open because you are correct, there should be a better logic system in place for similar issues (for instance, "if InnoDB is disabled don't bother checking the buffer pool size").

Revision history for this message
Luuk (l-vosslamber) wrote :

I just downloaded your script (rev17) and saw the error in my output, so i wanted to report a bug, but the report was already there ;-)

mysql --version gives:
mysql Ver 14.12 Distrib 5.0.67, for suse-linux-gnu (x86_64) using readline 5.2

commandline:
mysqltuner.pl --config tuner-default_pre_5_1.cnf --recommend
has next line(s) in output:

Total sorts: 0.00
Use of uninitialized value $num in pattern match (m//) at ./mysqltuner.pl line
        223 (#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.

Use of uninitialized value $compval in concatenation (.) or string at
        ./mysqltuner.pl line 230 (#1)
Use of uninitialized value in string eq at ./mysqltuner.pl line 231 (#1)
% sorts that cause temporary tables:
sort_buffer_size: 2.0 Mb
r

Revision history for this message
Sheeri K. Cabral (awfief) wrote :

Luuk -- this looks like a different issue. Can you post the output of:

mysql> SHOW STATUS LIKE 'Sort%';

Revision history for this message
Davide Belloni (dbelloni) wrote :

Another one with mysqltuner-2.1-rev17 and 5.1.40-log MySQL Community Server :

Query cache efficiency (%): 0.00
Use of uninitialized value in pattern match (m//) at mysqltuner.pl line 223 (#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 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.

Use of uninitialized value in concatenation (.) or string at mysqltuner.pl line
        230 (#1)
Use of uninitialized value in string eq at mysqltuner.pl line 231 (#1)
% query cache used:
Query cache low memory prunes: 0.00 per day

Revision history for this message
Sheeri K. Cabral (awfief) wrote :

OK, I've changed this so if the value is undefined, the following prints out:

label: There is a problem. The expression "EXPR" did not evaluate properly. You may need to fix this line in the config file

For example, the variable table_cache was changed to table_open_cache in MySQL 5.1. If I use a config file that uses table_cache against 5.1, here's what I get:

table cache size: There is a problem. The expression "table_cache.>-1" did not evaluate properly. You may need to fix this line in the config file

Will release in version 18, should appear momentarily on the site.

Changed in mysqltuner:
importance: Undecided → High
status: New → In Progress
Revision history for this message
George Tetterton (george-tetterton) wrote :

I just downloaded mysqltuner-2.1-rev18 and I am receiving the following error which is not exactly the same as above but may be related. I am running on Solaris 10 and Mysql 5.0 .

mysqltuner.pl -conf /usr/local/mysqltuner-2.1-rev18/tuner-default_pre_5_1.cnf --recommend

...

MyISAM concurrent inserts: 1.00
Use of uninitialized value in split at /usr/local/bin/mysqltuner.pl line 195 (#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 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.

Use of uninitialized value in pattern match (m//) at
        /usr/local/bin/mysqltuner.pl line 223 (#1)
Use of uninitialized value in concatenation (.) or string at
        /usr/local/bin/mysqltuner.pl line 230 (#1)

Use of uninitialized value in concatenation (.) or string at
        /usr/local/bin/mysqltuner.pl line 231 (#1)
Use of uninitialized value in string eq at /usr/local/bin/mysqltuner.pl line
        231 (#1)
:

:

:

:

RECOMMENDATIONS:
long_query_time is set to 10 seconds or more. This may not be appropriate for y
...

Let me know if you need any details.

Thanks

Revision history for this message
Ike Walker (ike-widgetbox) wrote :

George, you can get those errors to go away by removing the 4 blank lines from the bottom of tuner-default_pre_5_1.cnf.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.