-Rest of fix for bug 1965012. gettab now checks for valid column names, Table.pm properly formats the SQL statement so SQLite won't blow up in the prepare phase when searching for NULL entries.

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@1428 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
jbjohnso 2008-05-16 18:47:32 +00:00
parent 13d6232518
commit 853a9093a2
2 changed files with 14 additions and 2 deletions

View File

@ -1478,7 +1478,6 @@ sub getAttribs
my @exeargs;
foreach (keys %keypairs)
{
if ($keypairs{$_})
{
$statement .= "\"".$_ . "\" = ? and ";
@ -1493,7 +1492,7 @@ sub getAttribs
}
else
{
$statement .= "$_ is NULL and ";
$statement .= "\"$_\" is NULL and ";
}
}
$statement .= "(\"disable\" is NULL or \"disable\" in ('0','no','NO','No','nO'))";

View File

@ -153,6 +153,10 @@ sub gettab
foreach (@keypairs)
{
(my $key, my $value) = split /=/, $_;
unless (defined $key) {
gettab_usage(1);
return;
}
$keyhash{$key} = $value;
}
@ -164,6 +168,15 @@ sub gettab
$tabhash{$table}->{$column} = 1;
}
#Sanity check the key against all tables in question
foreach my $tabn (keys %tabhash) {
foreach my $kcheck (keys %keyhash) {
unless (grep /^$kcheck$/, @{$xCAT::Schema::tabspec{$tabn}->{cols}}) {
$callback->({error => ["Unkown key $kcheck to $tabn"],errorcode=>[1]});
return;
}
}
}
# Get the requested columns from each table
foreach my $tabn (keys %tabhash)
{