Commit cc163dcd 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.

tape_gateway_testing_round_001_tradeoffs.sql
  - Added re-compilation in the end to revalidate the procedures and functions disturbed by the schema changes.
  
test_check_nothing_pending.pl
  - Added as a first element of tests automation.
parent 5e92f042
......@@ -810,3 +810,45 @@ BEGIN
END;
/
/*******************************************************************************
********************************************************************************
********************************************************************************
*******************************************************************************/
/* Massage the procedures once for the not-tape gateway related */
BEGIN
FOR obj in (
SELECT *
FROM user_objects
WHERE
object_type IN ('FUNCTION', 'PROCEDURE')
AND status = 'INVALID' AND object_name NOT LIKE 'TG_%') LOOP
EXECUTE IMMEDIATE 'ALTER ' || obj.object_type || ' ' || obj.object_name || ' COMPILE';
END LOOP;
END;
/
/* Massage the TG family */
BEGIN
FOR obj in (
SELECT *
FROM user_objects
WHERE
object_type IN ('FUNCTION', 'PROCEDURE')
AND status = 'INVALID' AND object_name LIKE 'TG_%') LOOP
EXECUTE IMMEDIATE 'ALTER ' || obj.object_type || ' ' || obj.object_name || ' COMPILE';
END LOOP;
END;
/
/* Find the remaining buggers */
SELECT *
FROM user_objects
WHERE
object_type IN ('FUNCTION', 'PROCEDURE')
AND status = 'INVALID';
/*******************************************************************************
********************************************************************************
********************************************************************************
*******************************************************************************/
#!/usr/bin/perl -w
# This perl script that has to be run as root on the stager host will connect to
# the DB and report wether there are any pending mogrations for this stager
# On first version, it will report to both standard output and as an exit value.
# Imports
use strict;
use DBD::Oracle qw(:ora_types);
# Forward declarations
sub open_db();
sub check_leftoevers( $ );
sub print_leftovers ( $ );
sub main();
# Hook for main.
main();
# Main: check for leftovers in DB, print out, return exit code accordingly
sub main ()
{
my $dbh = open_db();
my $ret = 0;
if (check_leftovers ( $dbh )) {
print_leftovers ( $dbh );
$ret = 1;;
}
$dbh->disconnect();
exit $ret;
}
# open_db : find connection parameters and open db connection
sub open_db()
{
my ( $u, $p, $db );
open ORACFG, "< /etc/castor/ORASTAGERCONFIG"
or die "Failed ot open /etc/castor/ORASTAGERCONFIG for reading: $!";
while (<ORACFG>) {
if (/^DbCnvSvc\W+user\W+(\w+)$/) {
$u = $1;
} elsif (/^DbCnvSvc\W+passwd\W+(\w+)$/) {
$p = $1;
} elsif (/^DbCnvSvc\W+dbName\W+(\w+)$/) {
$db = $1;
}
}
my $dbh= DBI->connect('dbi:Oracle',$u.'\@'.$db, $p,
{ RaiseError => 1, AutoCommit => 0})
or die "Failed to connect to DB as ".$u.'\@'.$db;
return $dbh;
}
# check_leftovers : find wether there are any leftover unmigrated data in the stager
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)
UNION ALL
SELECT tc.id from tapecopy tc);");
$sth -> execute ();
my @row = $sth->fetchrow_array();
return $row[0];
}
# print_leftovers
sub print_leftovers ( $ )
{
my $dbh = shift;
# Print by castofile with corresponding tapecopies
my $sth = $dbh -> prepare ("SELECT cf.lastknownfilename, dc.id, dc.status, tc.id, tc.status
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 );");
$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" );
}
# 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 );");
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" );
}
}
\ No newline at end of file
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