On Fri, Mar 28, 2008 at 10:30 AM, Gurjeet Singh <[EMAIL PROTECTED]>
wrote:

>
> I am still looking for comments on the correctness of this script and above
> mentioned procedure for running it on an 8.2.x release.
>

Well, I came across a serious bug in the script. Here's the corrected
version of the perl script for anyone who might have picked up the script
from here:

(Am still looking for any feedback on the correctness of the script;
especially in the light of the recent possible bugs fixed on the server
side, related to recovery)

<script>
my @text = `pg_controldata .`; # here . represents the PGDATA, since the
server is executing here.
my $line;

my $time_line_id;
my $redo_log_id;
my $redo_rec_off;
my $wal_seg_bytes;
my $redo_log_seg;

foreach $line ( @text )
{
    $line = mychomp( $line );

    if( $line =~ m/Latest checkpoint's TimeLineID:\s*(([0-9])+)/ )
    {
        # decimal number
        $time_line_id = 0 + $1;
    }
    if( $line =~ m/Latest checkpoint's REDO
location:\s*(([0-9]|[A-F])+)\/(([0-9]|[A-F])+)/
)
    {
        # hexadecimal numbers
        $redo_log_id = hex( $1 );
        $redo_rec_off = hex( $3 );
    }

    if( $line =~ m/Bytes per WAL segment:\s*([0-9]+)/ )
    {
        # decimal number
        $wal_seg_bytes = $1;
    }
}

$redo_log_seg = sprintf( "%d", $redo_rec_off / $wal_seg_bytes );

print "" . sprintf( "%08X%08X%08X", $time_line_id, $redo_log_id,
$redo_log_seg ) . "\n";

# Wrapper around Perl's chomp function
sub mychomp
{
    my ( $tmp ) = @_;
    chomp( $tmp );
    return $tmp;
}

</script>



-- 
[EMAIL PROTECTED]
[EMAIL PROTECTED] gmail | hotmail | indiatimes | yahoo }.com

EnterpriseDB http://www.enterprisedb.com

Mail sent from my BlackLaptop device

Reply via email to