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

From Jim Jones
Subject Re: Truncate logs by max_log_size
Date
Msg-id 35096a36-04d4-480b-a7cd-a2d8151fb737@uni-muenster.de
Whole thread Raw
In response to Re: Truncate logs by max_log_size  ("Euler Taveira" <euler@eulerto.com>)
List pgsql-hackers

On 01.10.24 17:46, Kirill Gavrilov wrote:
>  My apologies, attached patch should work on master branch.

Nice.

I tested the feature and it does what it is intended to.

postgres=# SHOW max_log_size;
 max_log_size
--------------
 10
(1 row)

postgres=# INSERT INTO t VALUES (1,2,3,4,5,6,7,8,9,0);
ERROR:  relation "t" does not exist
LINE 1: INSERT INTO t VALUES (1,2,3,4,5,6,7,8,9,0);

Log file:

2024-10-02 00:57:13.618 CEST [1975926] ERROR:  relation "t" does not
exist at character 13
2024-10-02 00:57:13.618 CEST [1975926] STATEMENT:  INSERT INT

A few observations:

1) You missed a const qualifier in elog.c:

elog.c: In function ‘EmitErrorReport’:
elog.c:1699:29: warning: initialization discards ‘const’ qualifier from
pointer target type [-Wdiscarded-qualifiers]
 1699 |                 char* str = debug_query_string;
      |                             ^~~~~~~~~~~~~~~~~~

2) The new parameter cannot be set within a session with SET. Is it
supposed to be like this? IMHO it would be nice to able to temporarily
set this parameter without having to reload the postgresql.conf

postgres=# SET max_log_size TO 100;
ERROR:  parameter "max_log_size" cannot be changed now

3) I personally find -1 more intuitive than 0 to disable a parameter,
but I have no strong opinion about it.

4) It still lacks documentation.

-- 
Jim




pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Fixing backslash dot for COPY FROM...CSV
Next
From: Masahiko Sawada
Date:
Subject: Re: Add on_error and log_verbosity options to file_fdw