pgsql/logger: close json array if params truncated

Pgsql logger would only open a ParameterStatus message array and only
close it when a different type of message was seen (following an
expected pgsql transaction style). However, if no different type of
message followed the ParameterStatus message, the array remained open,
leading to an unbalanced `}` count, and poisoning the whole JSON log,
from that point on.

Now, if we finish the responses logging loop without reaching another
type of response, close the array, regardless.

Ticket: #9012
(cherry picked from commit 85168b8036)
pull/16211/head
Juliana Fajardini 2 months ago committed by Jason Ish
parent 566861b97c
commit d38c2cc5e7

@ -172,6 +172,10 @@ fn log_response_object(tx: &PgsqlTransaction) -> Result<JsonBuilder, JsonError>
log_response(response, &mut jb)?;
}
}
if array_open {
// the last stored response was a ParameterStatus so we still have an array open
jb.close()?;
}
jb.close()?;
Ok(jb)
}
@ -341,7 +345,6 @@ fn log_startup_parameters(params: &PgsqlStartupParameters) -> Result<JsonBuilder
}
jb.close()?;
}
jb.close()?;
Ok(jb)
}

Loading…
Cancel
Save