Skip to content

Commit 9dc1225

Browse files
committed
Silence compiler warning
My original coding was questionable anyway. Reported-by: Sergei Kornilov Discussion: https://postgr.es/m/9645101543575886@myt6-27270b78ac4f.qloud-c.yandex.net
1 parent dcfdf56 commit 9dc1225

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/backend/tcop/postgres.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2244,12 +2244,13 @@ check_log_duration(char *msec_str, bool was_logged)
22442244
/*
22452245
* Do not log if log_statement_sample_rate = 0. Log a sample if
22462246
* log_statement_sample_rate <= 1 and avoid unecessary random() call
2247-
* if log_statement_sample_rate = 1.
2247+
* if log_statement_sample_rate = 1. But don't compute any of this
2248+
* unless needed.
22482249
*/
2249-
if (exceeded)
2250-
in_sample = log_statement_sample_rate != 0 &&
2251-
(log_statement_sample_rate == 1 ||
2252-
random() <= log_statement_sample_rate * MAX_RANDOM_VALUE);
2250+
in_sample = exceeded &&
2251+
log_statement_sample_rate != 0 &&
2252+
(log_statement_sample_rate == 1 ||
2253+
random() <= log_statement_sample_rate * MAX_RANDOM_VALUE);
22532254

22542255
if ((exceeded && in_sample) || log_duration)
22552256
{

0 commit comments

Comments
 (0)