Re: Truncate logs by max_log_size - Mailing list pgsql-hackers

From Fujii Masao
Subject Re: Truncate logs by max_log_size
Date
Msg-id CAHGQGwHJHCi=4zEyMc4GJWPC9-oQZHj+9kncxS2442V9PXGgoQ@mail.gmail.com
Whole thread
In response to Re: Truncate logs by max_log_size  (Álvaro Herrera <alvherre@kurilemu.de>)
Responses Re: Truncate logs by max_log_size
List pgsql-hackers
On Fri, May 15, 2026 at 7:48 PM Jim Jones <jim.jones@uni-muenster.de> wrote:
>
> rebase due to recent changes in src/test/modules/test_misc/meson.build

I reviewed the patch again and made a few additional changes. The updated
patch is attached. Barring any objections, I'm thinking to commit it.

         If greater than zero, each statement logged by
-        <xref linkend="guc-log-statement"/> or
-        <xref linkend="guc-log-min-duration-statement"/> is truncated to
-        at most this many bytes.
+        <xref linkend="guc-log-statement"/>,
+        <xref linkend="guc-log-min-duration-statement"/>,
+        <xref linkend="guc-log-min-duration-sample"/>, or
+        <xref linkend="guc-log-transaction-sample-rate"/>
+        is truncated to at most this many bytes.

Since this parameter also affects statements logged by
log_min_duration_sample and log_transaction_sample_rate, I added
those parameters to the description.


+        This setting does not affect statements logged because of
+        <xref linkend="guc-log-min-error-statement"/>.

I also clarified that this parameter does not affect statements logged
by log_min_error_statement.


+static char *
+truncate_query_log(const char *query)

Since truncate_query_log() is only used in postgres.c, I moved it
from elog.c and made it a static function.


-ok( $node->log_contains(
- qr/statement: SELECT '123456789ABC(?!D)/, $log_offset),
+ok($node->log_contains(qr/statement: SELECT '123456789ABC$/m, $log_offset),

I tightened the test to verify that the truncated statement ends exactly
at the 20th byte.


-# character (the 🐘 emoji is 4 bytes; with limit=12 it must be kept whole
-# and the following 't' must not appear).
-note "Multibyte truncation respects character boundaries";
+# character when the byte limit falls in the middle of it.
+SKIP:

Using an emoji directly in the test seems fragile and the behavior
may depend on the test platform. To make the test more robust, I changed
it to construct the multibyte character with pack() and run the test
only when the server encoding is UTF-8.

Regards,

--
Fujii Masao

Attachment

pgsql-hackers by date:

Previous
From: jian he
Date:
Subject: Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions
Next
From: Robert Haas
Date:
Subject: json/jsonb cleanup + FmgrInfo caching