From: Gilles Darold Date: Wed, 10 Aug 2016 16:44:53 +0000 (+0200) Subject: Fix multiline statement concatenation after an error. X-Git-Tag: v8.2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8dd76966d100bed7b85fcb3b1fa064b4f29195b9;p=pgbadger Fix multiline statement concatenation after an error. Fix box size for report of queries generatin the most temporary files and the most waiting queries. --- diff --git a/pgbadger b/pgbadger index db6b8cf..2dacc51 100755 --- a/pgbadger +++ b/pgbadger @@ -3076,6 +3076,7 @@ sub parse_orphan_line # Otherwise append the orphan line to the corresponding part of the query } else { + # Append to the error statement if one is defined if (exists $cur_info{$cur_pid}{statement}) { $cur_info{$cur_pid}{statement} .= "\n" . $line if (!$nomultiline); @@ -8918,7 +8919,7 @@ sub print_lock_queries_report $max_time $avg_time -
$query
$md5 +
$query
$md5 $example
@@ -9084,7 +9085,7 @@ sub print_tempfile_report $max_size $avg_size -
$query
$md5 +
$query
$md5 $example
@@ -12192,6 +12193,16 @@ sub parse_query } } + # Stores the error's detail if previous line was an error + if (($prefix_vars{'t_loglevel'} =~ /(DETAIL|STATEMENT|CONTEXT|HINT)/) && ($cur_info{$t_pid}{loglevel} =~ $main_error_regex)) { + if (($prefix_vars{'t_loglevel'} ne 'DETAIL') || ($prefix_vars{'t_query'} !~ /parameters: (.*)/)) { + # Store error details only if this is not a parameter list (never present with errors) + $cur_info{$t_pid}{"\L$prefix_vars{'t_loglevel'}\E"} .= $prefix_vars{'t_query'}; + } + return; + } + + # Special cases when a STATEMENT is parsed if ($prefix_vars{'t_loglevel'} eq 'STATEMENT') { # Stores temporary file statement if a temporary record with the same pid exists @@ -12224,15 +12235,6 @@ sub parse_query } } - # Stores the error's detail if previous line was an error - if (($prefix_vars{'t_loglevel'} =~ /(DETAIL|STATEMENT|CONTEXT|HINT)/) && ($cur_info{$t_pid}{loglevel} =~ $main_error_regex)) { - if (($prefix_vars{'t_loglevel'} ne 'DETAIL') || ($prefix_vars{'t_query'} !~ /parameters: (.*)/)) { - # Store error details only if this is not a parameter list (never present with errors) - $cur_info{$t_pid}{"\L$prefix_vars{'t_loglevel'}\E"} .= $prefix_vars{'t_query'}; - } - return; - } - # set current session workload if ( !$disable_session ) { my $sess_count = scalar keys %current_sessions; @@ -13088,7 +13090,6 @@ sub store_queries # Store the collected information into global statistics if ($cur_info{$t_pid}{loglevel} =~ $main_error_regex) { - # Add log level at beginning of the query and normalize it $cur_info{$t_pid}{query} = $cur_info{$t_pid}{loglevel} . ": " . $cur_info{$t_pid}{query}; my $normalized_error = &normalize_error($cur_info{$t_pid}{query});