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
This commit is contained in:
linggao 2009-12-17 17:01:08 +00:00
parent 6426ca1e56
commit 6394de13d9

View File

@ -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;
}
}
}
}