From: Andrew Dunstan Date: Fri, 17 Feb 2012 18:35:17 +0000 (-0800) Subject: Truncate 64bit int status, error on db failure. X-Git-Url: https://git.exim.org/buildfarm-server.git/commitdiff_plain/dae28f34bafb3f4b5892e7870b249bbac8103bb5 Truncate 64bit int status, error on db failure. Problems noted by Tom Lane, diagnosed and fixed by me. --- diff --git a/cgi-bin/pgstatus.pl b/cgi-bin/pgstatus.pl index 57a60ed..bfe50ce 100755 --- a/cgi-bin/pgstatus.pl +++ b/cgi-bin/pgstatus.pl @@ -317,6 +317,8 @@ EOSQL # just for the duration of the transaction. That turns off logging the # bind params, so all the logs don't get stuffed on the postgres logs + +my $sqlres; $db->begin_work; $db->do("select set_local_error_terse()"); @@ -341,42 +343,59 @@ $sth->bind_param(14,$scmurl); $sth->bind_param(15,$githeadref); $sth->bind_param(16,$frozen_sconf,{ pg_type => DBD::Pg::PG_BYTEA }); -$sth->execute; -$sth->finish; +$sqlres = $sth->execute; +if ($sqlres) +{ + $sth->finish; -my $logst2 = <prepare($logst2); + + $/=undef; + + my $stage_start = $ts; -$sth = $db->prepare($logst2); + foreach my $log_file( @log_file_names ) + { + next if $log_file =~ /^githead/; + my $handle; + open($handle,"$dirname/$log_file"); + my $mtime = (stat $handle)[9]; + my $stage_interval = $mtime - $stage_start; + $stage_start = $mtime; + my $ltext = <$handle>; + close($handle); + $ltext =~ s/\x00/\\0/g; + $sqlres = $sth->execute($animal,$dbdate,$branch,$log_file,$ltext, + "$stage_interval seconds"); + last unless $sqlres; + } -$/=undef; + $sth->finish unless $sqlres; -my $stage_start = $ts; +} -foreach my $log_file( @log_file_names ) +if (! $sqlres) { - next if $log_file =~ /^githead/; - my $handle; - open($handle,"$dirname/$log_file"); - my $mtime = (stat $handle)[9]; - my $stage_interval = $mtime - $stage_start; - $stage_start = $mtime; - my $ltext = <$handle>; - close($handle); - $ltext =~ s/\x00/\\0/g; - $sth->execute($animal,$dbdate,$branch,$log_file,$ltext, - "$stage_interval seconds"); + + print "Status: 462 database failure\nContent-Type: text/plain\n\n"; + print "Your report generated a database failure:\n", + $db->errstr, + "\n"; + $db->rollback; + $db->disconnect; + exit; } -$sth->finish; $db->commit;