]> granicus.if.org Git - pgbadger/commitdiff
Fix error details in incremental mode in Most Frequent Errors/Events report. Thanks...
authorDarold Gilles <gilles@darold.net>
Tue, 15 Apr 2014 09:29:25 +0000 (11:29 +0200)
committerDarold Gilles <gilles@darold.net>
Tue, 15 Apr 2014 09:29:25 +0000 (11:29 +0200)
pgbadger

index d28cb6b4d672c03b259b8a5cd68513d272f7f325..a5134af10e7432a8f74aa6da576d9abbc65f58c5 100644 (file)
--- a/pgbadger
+++ b/pgbadger
@@ -2426,7 +2426,7 @@ sub set_top_error_sample
 
        # Stop when we have our number of samples
        if (!exists $error_info{$q}{date} || ($#{$error_info{$q}{date}} < $sample)) {
-               if ( ($q =~ /deadlock detected/) || ($real_error && !grep(/\Q$real_error\E/, @{$error_info{$q}{error}})) ) {
+               if ( ($q =~ /deadlock detected/) || ($real_error && !grep(/^\Q$real_error\E$/, @{$error_info{$q}{error}})) ) {
                        push(@{$error_info{$q}{date}},      $date);
                        push(@{$error_info{$q}{detail}},    $detail);
                        push(@{$error_info{$q}{context}},   $context);
@@ -7631,24 +7631,19 @@ sub load_stats
 
        foreach my $q (keys %_error_info) {
                $error_info{$q}{count} += $_error_info{$q}{count};
-               # Keep only the wanted sample number
-               if (!exists $error_info{$q}{date} || ($#{$error_info{$q}{date}} < $sample)) {
-                       push(@{$error_info{$q}{date}},      @{$_error_info{$q}{date}});
-                       push(@{$error_info{$q}{detail}},    @{$_error_info{$q}{detail}});
-                       push(@{$error_info{$q}{context}},   @{$_error_info{$q}{context}});
-                       push(@{$error_info{$q}{statement}}, @{$_error_info{$q}{statement}});
-                       push(@{$error_info{$q}{hint}},      @{$_error_info{$q}{hint}});
-                       push(@{$error_info{$q}{error}},     @{$_error_info{$q}{error}});
-                       push(@{$error_info{$q}{db}},        @{$_error_info{$q}{db}});
-                       foreach my $day (keys %{ $_error_info{$q}{chronos} }) {
-                               foreach my $hour (keys %{$_error_info{$q}{chronos}{$day}}) {
-                                       $error_info{$q}{chronos}{$day}{$hour}{count} += $_error_info{$q}{chronos}{$day}{$hour}{count};
-                                       foreach my $min (keys %{$_error_info{$q}{chronos}{$day}{$hour}{min}}) {
-                                               $error_info{$q}{chronos}{$day}{$hour}{min}{$min} += $_error_info{$q}{chronos}{$day}{$hour}{min}{$min};
-                                       }
+               foreach my $day (keys %{ $_error_info{$q}{chronos} }) {
+                       foreach my $hour (keys %{$_error_info{$q}{chronos}{$day}}) {
+                               $error_info{$q}{chronos}{$day}{$hour}{count} += $_error_info{$q}{chronos}{$day}{$hour}{count};
+                               foreach my $min (keys %{$_error_info{$q}{chronos}{$day}{$hour}{min}}) {
+                                       $error_info{$q}{chronos}{$day}{$hour}{min}{$min} += $_error_info{$q}{chronos}{$day}{$hour}{min}{$min};
                                }
                        }
                }
+               for (my $i = 0; $i <= $#{$_error_info{$q}{date}}; $i++) {
+                       &set_top_error_sample($q, $_error_info{$q}{date}[$i], $_error_info{$q}{error}[$i],
+                               $_error_info{$q}{detail}[$i], $_error_info{$q}{context}[$i], $_error_info{$q}{statement}[$i],
+                               $_error_info{$q}{hint}[$i], $_error_info{$q}{db}[$i]);
+               }
        }
 
        ### per_minute_info ###