Commit da5ffc73 authored by unknown's avatar unknown

WL#2779 ndb_size.pl

Bug reported by Adam Dixon - table name needs quoting.


ndb/tools/ndb_size.pl:
  Always quote the table and database names when sending to cluster.
parent f28e81d0
...@@ -68,8 +68,9 @@ foreach(@{$tables}) ...@@ -68,8 +68,9 @@ foreach(@{$tables})
{ {
my $table= @{$_}[0]; my $table= @{$_}[0];
my @columns; my @columns;
my $info= $dbh->selectall_hashref("describe $table","Field"); my $info= $dbh->selectall_hashref("describe ".$dbh->quote($table),"Field");
my @count = $dbh->selectrow_array("select count(*) from $table"); my @count = $dbh->selectrow_array("select count(*) from "
.$dbh->quote($table));
my %columnsize; # used for index calculations my %columnsize; # used for index calculations
# We now work out the DataMemory usage # We now work out the DataMemory usage
...@@ -129,7 +130,9 @@ foreach(@{$tables}) ...@@ -129,7 +130,9 @@ foreach(@{$tables})
elsif($type =~ /varchar/ || $type =~ /varbinary/) elsif($type =~ /varchar/ || $type =~ /varbinary/)
{ {
my $fixed= 1+$size; my $fixed= 1+$size;
my @dynamic=$dbh->selectrow_array("select avg(length($name)) from $table"); my @dynamic=$dbh->selectrow_array("select avg(length("
.$dbh->quote($name)
.")) from ".$dbh->quote($table));
$dynamic[0]=0 if !$dynamic[0]; $dynamic[0]=0 if !$dynamic[0];
@realsize= ($fixed,$fixed,ceil($dynamic[0])); @realsize= ($fixed,$fixed,ceil($dynamic[0]));
} }
...@@ -163,7 +166,7 @@ foreach(@{$tables}) ...@@ -163,7 +166,7 @@ foreach(@{$tables})
# we can still connect to pre-5.0 mysqlds. # we can still connect to pre-5.0 mysqlds.
my %indexes; my %indexes;
{ {
my $sth= $dbh->prepare("show index from $table"); my $sth= $dbh->prepare("show index from "$dbh->quote($table));
$sth->execute; $sth->execute;
while(my $i = $sth->fetchrow_hashref) while(my $i = $sth->fetchrow_hashref)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment