Commit 0c677825 authored by Eric Cano's avatar Eric Cano
Browse files

bug #72215: Remove the TAPEGATEWAYREQUEST table from the schema, and drop the...

bug #72215: Remove the TAPEGATEWAYREQUEST table from the schema, and drop the triggers that populate it.

Fixed various technicalities in perl script.
parent cc163dcd
......@@ -12,6 +12,7 @@ use DBD::Oracle qw(:ora_types);
sub open_db();
sub check_leftoevers( $ );
sub print_leftovers ( $ );
sub nullize_arrays_undefs ( $ );
sub main();
# Hook for main.
......@@ -45,7 +46,7 @@ sub open_db()
$db = $1;
}
}
my $dbh= DBI->connect('dbi:Oracle',$u.'\@'.$db, $p,
my $dbh= DBI->connect('dbi:Oracle:'.$db ,$u, $p,
{ RaiseError => 1, AutoCommit => 0})
or die "Failed to connect to DB as ".$u.'\@'.$db;
return $dbh;
......@@ -57,9 +58,9 @@ sub check_leftovers ( $ )
my $dbh = shift;
my $sth = $dbh -> prepare("SELECT count (*) from (
SELECT dc.id from diskcopy dc where
dc.status NOT IN (0)
dc.status NOT IN ( 0 )
UNION ALL
SELECT tc.id from tapecopy tc);");
SELECT tc.id from tapecopy tc)");
$sth -> execute ();
my @row = $sth->fetchrow_array();
return $row[0];
......@@ -74,20 +75,35 @@ sub print_leftovers ( $ )
FROM castorfile cf
LEFT OUTER JOIN diskcopy dc ON dc.castorfile = cf.id
LEFT OUTER JOIN tapecopy tc ON tc.castorfile = cf.id
WHERE dc.status NOT IN ( 0 );");
WHERE dc.status NOT IN ( 0 )");
$sth -> execute();
while ( my @row = $sth->fetchrow_array() ) {
print ( "Remaining catorfile for $row[0] with diskcopy (id=$row[1], ".
"status=$row[2]) and tapecopy (id=$row[3], status=$row[4])\n" );
nullize_arrays_undefs ( \@row );
print( "Remaining catorfile for $row[0]\n\twith diskcopy (id=$row[1], ".
"status=$row[2]) and tapecopy (id=$row[3], status=$row[4])\n" );
}
# print any other tapecopy not covered previously
$sth = $dbh -> prepare ("SELECT cf.lastknownfilename, dc.id, dc.status, tc.id, tc.status
FROM castorfile cf
RIGHT OUTER JOIN diskcopy dc ON dc.castorfile = cf.id
RIGHT OUTER JOIN tapecopy tc ON tc.castorfile = cf.id
WHERE dc.status IS NULL OR dc.status IN ( 0 );");
WHERE dc.status IS NULL OR dc.status IN ( 0 )");
$sth -> execute();
while ( my @row = $sth->fetchrow_array() ) {
print ( "Remaining tapecopy for $row[0] with diskcopy (id=$row[1], ".
"status=$row[2]) and tapecopy (id=$row[3], status=$row[4])\n" );
nullize_arrays_undefs ( \@row );
print( "Remaining tapecopy for $row[0]\n\twith diskcopy (id=$row[1], ".
"status=$row[2]) and tapecopy (id=$row[3], status=$row[4])\n" );
}
}
\ No newline at end of file
}
# Replace undef members of an array by the string NULL
sub nullize_arrays_undefs ( $ )
{
my $row=shift;
for my $i ( 0 .. ( scalar(@{$row}) -1) ) {
if ( ! defined ($row->[$i]) ) {
$row->[$i] = 'NULL';
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment