Re: Truncate logs by max_log_size

Fujii Masao <masao.fujii@gmail.com>

From: Fujii Masao <masao.fujii@gmail.com>
To: Jim Jones <jim.jones@uni-muenster.de>
Cc: Kirill Reshke <reshkekirill@gmail.com>, Álvaro Herrera <alvherre@kurilemu.de>, Fujii Masao <masao.fujii@oss.nttdata.com>, Kirill Gavrilov <diphantxm@gmail.com>, "Andrey M. Borodin" <x4mmm@yandex-team.ru>, Euler Taveira <euler@eulerto.com>, pgsql-hackers@lists.postgresql.org
Date: 2026-04-09T18:11:38Z
Lists: pgsql-hackers
On Thu, Apr 9, 2026 at 5:52 AM Jim Jones <jim.jones@uni-muenster.de> wrote:
> Moved tests to:
>  src/test/modules/test_misc/t/012_log_statement_max_length.pl

Thanks for updating the patch! It looks good to me except the
following comments.


+$node->append_conf('postgresql.conf', "log_statement = 'all'\n");

This doesn't seem necessary, since $node->init already sets
log_statement = 'all'.


+$node->append_conf('postgresql.conf', "log_statement_max_length = 20\n");
+$node->reload();
+my $log_offset = -s $node->logfile;
+$node->psql('postgres', "SELECT '123456789ABCDEF'");

Would it be simpler (and cheaper) to use SET instead of reloading the
config? For example:

---------------------------
my $log_offset = -s $node->logfile;
$node->psql(
        'postgres', "
SET log_statement_max_length TO 20;
SELECT '123456789ABCDEF';
");
---------------------------


+char *
+truncate_query_log(const char *query)

In elog.c, truncate_query_log() is currently placed between write_stderr() and
vwrite_stderr(). Since those two functions are related, it might be better to
move truncate_query_log() to a more appropriate location. Thoughts?


I see the patch has been moved to CommitFest PG20-1. Once development for v20
starts, I'd like to commit it.

Regards,

-- 
Fujii Masao



Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Fix log_statement_max_length test with verbose logs

  2. Add log_statement_max_length GUC to limit logged statement text

  3. Improve user control over truncation of logged bind-parameter values.