From 8216a254ad42ea1f5eb843ce5edef8f3c52826c1 Mon Sep 17 00:00:00 2001 From: lissav Date: Tue, 31 Aug 2010 19:18:47 +0000 Subject: [PATCH] for db2 add logic to move to larger tablespace on add columns in updateschema git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@7325 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/Table.pm | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/perl-xCAT/xCAT/Table.pm b/perl-xCAT/xCAT/Table.pm index 13d66ea50..f97c09ff7 100644 --- a/perl-xCAT/xCAT/Table.pm +++ b/perl-xCAT/xCAT/Table.pm @@ -999,9 +999,40 @@ sub updateschema $tmpcol="\`$dcol\`"; } } + my $tablespace; my $stmt = "ALTER TABLE " . $self->{tabname} . " ADD $tmpcol $datatype"; $self->{dbh}->do($stmt); + if ($self->{dbh}->errstr) { + xCAT::MsgUtils->message("S", "Error adding columns for table " . $self->{tabname} .":" . $self->{dbh}->errstr); + if ($xcatcfg =~ /^DB2:/){ # see if table space error + my $error = $self->{dbh}->errstr; + if ($error =~ /54010/) { + # move the table to the next tablespace + if ($error =~ /USERSPACE1/) { + $tablespace="XCATTBS16K"; + } else { + $tablespace="XCATTBS32K"; + } + my $tablename=$self->{tabname}; + $tablename=~ tr/a-z/A-Z/; # convert to upper + my $msg="Moving table $self->{tabname} to $tablespace"; + xCAT::MsgUtils->message("S", $msg); + my $stmt2="Call sysproc.admin_move_table('XCATDB',\'$tablename\',\'$tablespace\',\'$tablespace\',\'$tablespace\','','','','','','MOVE')"; + $self->{dbh}->do($stmt2); + if ($self->{dbh}->errstr) { + xCAT::MsgUtils->message("S", "Error on tablespace move for table " . $self->{tabname} .":" . $self->{dbh}->errstr); + } else { # tablespace move try column add again + if (!$self->{dbh}->{AutoCommit}) { # commit tbsp move + $self->{dbh}->commit; + } + $self->{dbh}->do($stmt); + } + + } # if tablespace error + + } # if db2 + } # error on add column } }