From 6394de13d972a10f5e8c0610fcffcf571a5d28fb Mon Sep 17 00:00:00 2001 From: linggao Date: Thu, 17 Dec 2009 17:01:08 +0000 Subject: [PATCH] fixed problem for PostgreSQL when changing primary keys for a table git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@4819 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/Table.pm | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/perl-xCAT/xCAT/Table.pm b/perl-xCAT/xCAT/Table.pm index 012faece2..bd907735e 100644 --- a/perl-xCAT/xCAT/Table.pm +++ b/perl-xCAT/xCAT/Table.pm @@ -864,15 +864,15 @@ sub updateschema xCAT::MsgUtils->message("S", "Error changing the keys for table " . $self->{tabname} .":" . $self->{dbh}->errstr); } } else { #for the rest, recreate the table - print "need to change keys\n"; + #print "need to change keys\n"; my $btn=$tn . "_xcatbackup"; #remove the backup table just in case; - my $str="DROP TABLE $btn"; - $self->{dbh}->do($str); + #my $str="DROP TABLE $btn"; + #$self->{dbh}->do($str); #rename the table name to name_xcatbackup - $str = "ALTER TABLE $tn RENAME TO $btn"; + my $str = "ALTER TABLE $tn RENAME TO $btn"; $self->{dbh}->do($str); if ($self->{dbh}->errstr) { xCAT::MsgUtils->message("S", "Error renaming the table from $tn to $btn:" . $self->{dbh}->errstr); @@ -898,6 +898,11 @@ sub updateschema $str = "DROP TABLE $btn"; $self->{dbh}->do($str); } + + if (!$self->{dbh}->{AutoCommit}) { + $self->{dbh}->commit; + } + } } }