1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-18 02:02:55 +03:00

Create a separate file listing backend types

Use our established coding pattern to reduce maintenance pain when
adding other per-process-type characteristics.

Like PG_KEYWORD, PG_CMDTAG, PG_RMGR.

To keep the strings translatable, the relevant makefile now also scans
src/include for this specific file.  I didn't want to have it scan all
.h files, as then gettext would have to scan all header files.  I didn't
find any way to affect the meson behavior in this respect though.

Author: Álvaro Herrera <alvherre@kurilemu.de>
Co-authored-by: Jonathan Gonzalez V. <jonathan.abdiel@gmail.com>
Discussion: https://postgr.es/m/202507151830.dwgz5nmmqtdy@alvherre.pgsql
This commit is contained in:
Álvaro Herrera
2025-09-26 15:21:49 +02:00
parent 8bb174295e
commit dbf8cfb4f0
5 changed files with 65 additions and 88 deletions

View File

@@ -28,7 +28,7 @@ GETTEXT_FLAGS = $(BACKEND_COMMON_GETTEXT_FLAGS) \
error_cb:2:c-format
gettext-files: generated-parser-sources generated-headers
find $(srcdir) $(srcdir)/../common $(srcdir)/../port -name '*.c' -print | LC_ALL=C sort >$@
find $(srcdir) $(srcdir)/../common $(srcdir)/../port $(srcdir)/../include/ \( -name '*.c' -o -name "proctypelist.h" \) -print | LC_ALL=C sort >$@
my-clean:
rm -f gettext-files

View File

@@ -179,34 +179,10 @@ typedef struct
} child_process_kind;
static child_process_kind child_process_kinds[] = {
[B_INVALID] = {"invalid", NULL, false},
[B_BACKEND] = {"backend", BackendMain, true},
[B_DEAD_END_BACKEND] = {"dead-end backend", BackendMain, true},
[B_AUTOVAC_LAUNCHER] = {"autovacuum launcher", AutoVacLauncherMain, true},
[B_AUTOVAC_WORKER] = {"autovacuum worker", AutoVacWorkerMain, true},
[B_BG_WORKER] = {"bgworker", BackgroundWorkerMain, true},
/*
* WAL senders start their life as regular backend processes, and change
* their type after authenticating the client for replication. We list it
* here for PostmasterChildName() but cannot launch them directly.
*/
[B_WAL_SENDER] = {"wal sender", NULL, true},
[B_SLOTSYNC_WORKER] = {"slot sync worker", ReplSlotSyncWorkerMain, true},
[B_STANDALONE_BACKEND] = {"standalone backend", NULL, false},
[B_ARCHIVER] = {"archiver", PgArchiverMain, true},
[B_BG_WRITER] = {"bgwriter", BackgroundWriterMain, true},
[B_CHECKPOINTER] = {"checkpointer", CheckpointerMain, true},
[B_IO_WORKER] = {"io_worker", IoWorkerMain, true},
[B_STARTUP] = {"startup", StartupProcessMain, true},
[B_WAL_RECEIVER] = {"wal_receiver", WalReceiverMain, true},
[B_WAL_SUMMARIZER] = {"wal_summarizer", WalSummarizerMain, true},
[B_WAL_WRITER] = {"wal_writer", WalWriterMain, true},
[B_LOGGER] = {"syslogger", SysLoggerMain, false},
#define PG_PROCTYPE(bktype, description, main_func, shmem_attach) \
[bktype] = {description, main_func, shmem_attach},
#include "postmaster/proctypelist.h"
#undef PG_PROCTYPE
};
const char *

View File

@@ -266,62 +266,11 @@ GetBackendTypeDesc(BackendType backendType)
switch (backendType)
{
case B_INVALID:
backendDesc = gettext_noop("not initialized");
break;
case B_ARCHIVER:
backendDesc = gettext_noop("archiver");
break;
case B_AUTOVAC_LAUNCHER:
backendDesc = gettext_noop("autovacuum launcher");
break;
case B_AUTOVAC_WORKER:
backendDesc = gettext_noop("autovacuum worker");
break;
case B_BACKEND:
backendDesc = gettext_noop("client backend");
break;
case B_DEAD_END_BACKEND:
backendDesc = gettext_noop("dead-end client backend");
break;
case B_BG_WORKER:
backendDesc = gettext_noop("background worker");
break;
case B_BG_WRITER:
backendDesc = gettext_noop("background writer");
break;
case B_CHECKPOINTER:
backendDesc = gettext_noop("checkpointer");
break;
case B_IO_WORKER:
backendDesc = gettext_noop("io worker");
break;
case B_LOGGER:
backendDesc = gettext_noop("logger");
break;
case B_SLOTSYNC_WORKER:
backendDesc = gettext_noop("slotsync worker");
break;
case B_STANDALONE_BACKEND:
backendDesc = gettext_noop("standalone backend");
break;
case B_STARTUP:
backendDesc = gettext_noop("startup");
break;
case B_WAL_RECEIVER:
backendDesc = gettext_noop("walreceiver");
break;
case B_WAL_SENDER:
backendDesc = gettext_noop("walsender");
break;
case B_WAL_SUMMARIZER:
backendDesc = gettext_noop("walsummarizer");
break;
case B_WAL_WRITER:
backendDesc = gettext_noop("walwriter");
break;
#define PG_PROCTYPE(bktype, description, main_func, shmem_attach) \
case bktype: backendDesc = description; break;
#include "postmaster/proctypelist.h"
#undef PG_PROCTYPE
}
return backendDesc;
}