# 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()");
$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 = <<EOSQL;
+ my $logst2 = q{
- insert into build_status_log
- (sysname, snapshot, branch, log_stage, log_text, stage_duration)
- values (?, ?, ?, ?, ?, ?)
+ insert into build_status_log
+ (sysname, snapshot, branch, log_stage, log_text, stage_duration)
+ values (?, ?, ?, ?, ?, ?)
-EOSQL
- ;
+ };
+
+ $sth = $db->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;