2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-12-10 19:19:56 +00:00

Merge pull request #5711 from robin2008/tabch-d

Handle the wrong table name when using tabch
This commit is contained in:
zet809
2018-10-22 13:11:54 +08:00
committed by GitHub
2 changed files with 27 additions and 4 deletions

View File

@@ -2297,6 +2297,7 @@ sub tabch {
my %rsp;
$rsp{data}->[0] = "Incorrect argument \"$_\".\n";
$rsp{data}->[1] = "Check man tabch or tabch -h\n";
$rsp{errorcode}->[0] = 1;
$callback->(\%rsp);
return 1;
}
@@ -2318,14 +2319,23 @@ sub tabch {
my %rsp;
$rsp{data}->[0] = "Missing table name.\n";
$rsp{data}->[1] = "Check man tabch or tabch -h\n";
$rsp{errorcode}->[0] = 1;
$callback->(\%rsp);
return 1;
}
for (@tables_to_del)
{
$tables{$_} = xCAT::Table->new($_, -create => 1, -autocommit => 0);
$tables{$_}->delEntries(\%keyhash);
$tables{$_}->commit;
my $tab = xCAT::Table->new($_, -create => 1, -autocommit => 0);
unless ($tab) {
my %rsp;
$rsp{data}->[0] = "Table $_ does not exist.";
$rsp{errorcode}->[0] = 1;
$callback->(\%rsp);
next;
}
$tab->delEntries(\%keyhash);
$tab->commit;
}
}
else {
@@ -2347,6 +2357,7 @@ sub tabch {
} else {
my %rsp;
$rsp{data}->[0] = "Table $table does not exist.\n";
$rsp{errorcode}->[0] = 1;
$callback->(\%rsp);
return 1;
@@ -2386,7 +2397,7 @@ sub tabch {
}
unless (grep /$column/, @{ $xCAT::Schema::tabspec{$table}->{cols} }) {
$callback->({ error => "$table.$column not a valid table.column description", errorcode => [1] });
return;
return 1;
}
$tableupdates{$table}{$column} = $value;
}

View File

@@ -62,6 +62,18 @@ check:output=~Usage
end
start:chtab_nonexist_table
description:chtab with nonexisting table name
label:mn_only,db
cmd:tabch -d key=abc123 nonexist_table1 nonexist_table2
check:rc!=0
check:output=~Table nonexist_table1 does not exist
check:output=~Table nonexist_table2 does not exist
cmd:tabch key=abc123 nonexist_table1.comments="mg"
check:rc!=0
check:output=~Table nonexist_table1 does not exist
end
start:chtab_err_table
description:chtab with error table
label:mn_only,db