]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Remove obsolete restriction on the range of log_rotation_size.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 31 Jan 2025 19:36:56 +0000 (14:36 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 31 Jan 2025 19:36:56 +0000 (14:36 -0500)
When syslogger.c was first written, we didn't want to assume that
all platforms have 64-bit ftello.  But we've been assuming that
since v13 (cf commit 799d22461), so let's use that in syslogger.c
and allow log_rotation_size to range up to INT_MAX kilobytes.

The old code effectively limited log_rotation_size to 2GB regardless
of platform.  While nobody's complained, that doesn't seem too far
away from what might be thought reasonable these days.

I noticed this while searching for instances of "1024L" in connection
with commit 041e8b95b.  These were the last such instances.
(We still have instances of L-suffixed literals, but most of them
are associated with wait intervals for pg_usleep or similar functions.
I don't see any urgent reason to change that.)

src/backend/postmaster/syslogger.c
src/backend/utils/misc/guc_tables.c

index a71810d55e523924000f45361774621009b5798a..7e9b3f2a0fd670b4d83be31029d3c74b66ddb77f 100644 (file)
@@ -444,19 +444,19 @@ SysLoggerMain(char *startup_data, size_t startup_data_len)
                if (!rotation_requested && Log_RotationSize > 0 && !rotation_disabled)
                {
                        /* Do a rotation if file is too big */
-                       if (ftell(syslogFile) >= Log_RotationSize * 1024L)
+                       if (ftello(syslogFile) >= Log_RotationSize * (pgoff_t) 1024)
                        {
                                rotation_requested = true;
                                size_rotation_for |= LOG_DESTINATION_STDERR;
                        }
                        if (csvlogFile != NULL &&
-                               ftell(csvlogFile) >= Log_RotationSize * 1024L)
+                               ftello(csvlogFile) >= Log_RotationSize * (pgoff_t) 1024)
                        {
                                rotation_requested = true;
                                size_rotation_for |= LOG_DESTINATION_CSVLOG;
                        }
                        if (jsonlogFile != NULL &&
-                               ftell(jsonlogFile) >= Log_RotationSize * 1024L)
+                               ftello(jsonlogFile) >= Log_RotationSize * (pgoff_t) 1024)
                        {
                                rotation_requested = true;
                                size_rotation_for |= LOG_DESTINATION_JSONLOG;
@@ -1183,9 +1183,11 @@ pipeThread(void *arg)
                 */
                if (Log_RotationSize > 0)
                {
-                       if (ftell(syslogFile) >= Log_RotationSize * 1024L ||
-                               (csvlogFile != NULL && ftell(csvlogFile) >= Log_RotationSize * 1024L) ||
-                               (jsonlogFile != NULL && ftell(jsonlogFile) >= Log_RotationSize * 1024L))
+                       if (ftello(syslogFile) >= Log_RotationSize * (pgoff_t) 1024 ||
+                               (csvlogFile != NULL &&
+                                ftello(csvlogFile) >= Log_RotationSize * (pgoff_t) 1024) ||
+                               (jsonlogFile != NULL &&
+                                ftello(jsonlogFile) >= Log_RotationSize * (pgoff_t) 1024))
                                SetLatch(MyLatch);
                }
                LeaveCriticalSection(&sysloggerSection);
index 38cb9e970d5b0a31010ddb98cfab4263278f2ff2..0bdfc839078ba22586bde4de505193bc6e2d1256 100644 (file)
@@ -3299,7 +3299,7 @@ struct config_int ConfigureNamesInt[] =
                        GUC_UNIT_KB
                },
                &Log_RotationSize,
-               10 * 1024, 0, INT_MAX / 1024,
+               10 * 1024, 0, INT_MAX,
                NULL, NULL, NULL
        },