From 724ca82e4949450d800edd31f3bf9bfe310ef9d9 Mon Sep 17 00:00:00 2001 From: linggao Date: Wed, 28 Oct 2009 19:28:00 +0000 Subject: [PATCH] prevent calling table.commit for the tables that has not been changed in nodech nodeadd and noderm command git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@4460 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/tabutils.pm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/tabutils.pm b/xCAT-server/lib/xcat/plugins/tabutils.pm index 5667e27fe..59e6099ca 100644 --- a/xCAT-server/lib/xcat/plugins/tabutils.pm +++ b/xCAT-server/lib/xcat/plugins/tabutils.pm @@ -879,6 +879,7 @@ sub nodech my $tabhdl = xCAT::Table->new($tab, -create => 1, -autocommit => 0); if ($tabhdl) { + my $changed=0; my @entities; if ($groupmode) { @entities = @groups; @@ -889,6 +890,7 @@ sub nodech foreach $entity (@entities) { if ($deletemode) { $tabhdl->delEntries({'node' => $entity}); + $changed=1; } else { #$tabhdl->setNodeAttribs($_,$tables{$tab}); my %uhsh; @@ -983,11 +985,14 @@ sub nodech $clrhash{$_}=""; } $tabhdl->setAttribs({node=>$entity},\%uhsh); + $changed=1; $nodes = [noderange($entity)]; unless (scalar @$nodes) { next; } $tabhdl->setNodesAttribs($nodes,\%clrhash); + $changed=1; } else { my @rc = $tabhdl->setNodeAttribs($entity, \%uhsh); + $changed=1; if (not defined($rc[0])) { $callback->({error => "DB error " . $rc[1],errorcode=>1}); } @@ -995,7 +1000,9 @@ sub nodech } } } - $tabhdl->commit; + if ($changed) { + $tabhdl->commit; + } } else {