diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:15:05 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:15:05 +0000 |
commit | 46651ce6fe013220ed397add242004d764fc0153 (patch) | |
tree | 6e5299f990f88e60174a1d3ae6e48eedd2688b2b /src/include/postmaster | |
parent | Initial commit. (diff) | |
download | postgresql-14-upstream.tar.xz postgresql-14-upstream.zip |
Adding upstream version 14.5.upstream/14.5upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | src/include/postmaster/autovacuum.h | 83 | ||||
-rw-r--r-- | src/include/postmaster/bgworker.h | 161 | ||||
-rw-r--r-- | src/include/postmaster/bgworker_internals.h | 64 | ||||
-rw-r--r-- | src/include/postmaster/bgwriter.h | 45 | ||||
-rw-r--r-- | src/include/postmaster/fork_process.h | 17 | ||||
-rw-r--r-- | src/include/postmaster/interrupt.h | 32 | ||||
-rw-r--r-- | src/include/postmaster/pgarch.h | 35 | ||||
-rw-r--r-- | src/include/postmaster/postmaster.h | 78 | ||||
-rw-r--r-- | src/include/postmaster/startup.h | 22 | ||||
-rw-r--r-- | src/include/postmaster/syslogger.h | 98 | ||||
-rw-r--r-- | src/include/postmaster/walwriter.h | 21 |
11 files changed, 656 insertions, 0 deletions
diff --git a/src/include/postmaster/autovacuum.h b/src/include/postmaster/autovacuum.h new file mode 100644 index 0000000..aacdd0f --- /dev/null +++ b/src/include/postmaster/autovacuum.h @@ -0,0 +1,83 @@ +/*------------------------------------------------------------------------- + * + * autovacuum.h + * header file for integrated autovacuum daemon + * + * + * Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/include/postmaster/autovacuum.h + * + *------------------------------------------------------------------------- + */ +#ifndef AUTOVACUUM_H +#define AUTOVACUUM_H + +#include "storage/block.h" + +/* + * Other processes can request specific work from autovacuum, identified by + * AutoVacuumWorkItem elements. + */ +typedef enum +{ + AVW_BRINSummarizeRange +} AutoVacuumWorkItemType; + + +/* GUC variables */ +extern bool autovacuum_start_daemon; +extern int autovacuum_max_workers; +extern int autovacuum_work_mem; +extern int autovacuum_naptime; +extern int autovacuum_vac_thresh; +extern double autovacuum_vac_scale; +extern int autovacuum_vac_ins_thresh; +extern double autovacuum_vac_ins_scale; +extern int autovacuum_anl_thresh; +extern double autovacuum_anl_scale; +extern int autovacuum_freeze_max_age; +extern int autovacuum_multixact_freeze_max_age; +extern double autovacuum_vac_cost_delay; +extern int autovacuum_vac_cost_limit; + +/* autovacuum launcher PID, only valid when worker is shutting down */ +extern int AutovacuumLauncherPid; + +extern int Log_autovacuum_min_duration; + +/* Status inquiry functions */ +extern bool AutoVacuumingActive(void); +extern bool IsAutoVacuumLauncherProcess(void); +extern bool IsAutoVacuumWorkerProcess(void); + +#define IsAnyAutoVacuumProcess() \ + (IsAutoVacuumLauncherProcess() || IsAutoVacuumWorkerProcess()) + +/* Functions to start autovacuum process, called from postmaster */ +extern void autovac_init(void); +extern int StartAutoVacLauncher(void); +extern int StartAutoVacWorker(void); + +/* called from postmaster when a worker could not be forked */ +extern void AutoVacWorkerFailed(void); + +/* autovacuum cost-delay balancer */ +extern void AutoVacuumUpdateDelay(void); + +#ifdef EXEC_BACKEND +extern void AutoVacLauncherMain(int argc, char *argv[]) pg_attribute_noreturn(); +extern void AutoVacWorkerMain(int argc, char *argv[]) pg_attribute_noreturn(); +extern void AutovacuumWorkerIAm(void); +extern void AutovacuumLauncherIAm(void); +#endif + +extern bool AutoVacuumRequestWork(AutoVacuumWorkItemType type, + Oid relationId, BlockNumber blkno); + +/* shared memory stuff */ +extern Size AutoVacuumShmemSize(void); +extern void AutoVacuumShmemInit(void); + +#endif /* AUTOVACUUM_H */ diff --git a/src/include/postmaster/bgworker.h b/src/include/postmaster/bgworker.h new file mode 100644 index 0000000..8e9ef7c --- /dev/null +++ b/src/include/postmaster/bgworker.h @@ -0,0 +1,161 @@ +/*-------------------------------------------------------------------- + * bgworker.h + * POSTGRES pluggable background workers interface + * + * A background worker is a process able to run arbitrary, user-supplied code, + * including normal transactions. + * + * Any external module loaded via shared_preload_libraries can register a + * worker. Workers can also be registered dynamically at runtime. In either + * case, the worker process is forked from the postmaster and runs the + * user-supplied "main" function. This code may connect to a database and + * run transactions. Workers can remain active indefinitely, but will be + * terminated if a shutdown or crash occurs. + * + * If the fork() call fails in the postmaster, it will try again later. Note + * that the failure can only be transient (fork failure due to high load, + * memory pressure, too many processes, etc); more permanent problems, like + * failure to connect to a database, are detected later in the worker and dealt + * with just by having the worker exit normally. A worker which exits with + * a return code of 0 will never be restarted and will be removed from worker + * list. A worker which exits with a return code of 1 will be restarted after + * the configured restart interval (unless that interval is BGW_NEVER_RESTART). + * The TerminateBackgroundWorker() function can be used to terminate a + * dynamically registered background worker; the worker will be sent a SIGTERM + * and will not be restarted after it exits. Whenever the postmaster knows + * that a worker will not be restarted, it unregisters the worker, freeing up + * that worker's slot for use by a new worker. + * + * Note that there might be more than one worker in a database concurrently, + * and the same module may request more than one worker running the same (or + * different) code. + * + * + * Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * IDENTIFICATION + * src/include/postmaster/bgworker.h + *-------------------------------------------------------------------- + */ +#ifndef BGWORKER_H +#define BGWORKER_H + +/*--------------------------------------------------------------------- + * External module API. + *--------------------------------------------------------------------- + */ + +/* + * Pass this flag to have your worker be able to connect to shared memory. + */ +#define BGWORKER_SHMEM_ACCESS 0x0001 + +/* + * This flag means the bgworker requires a database connection. The connection + * is not established automatically; the worker must establish it later. + * It requires that BGWORKER_SHMEM_ACCESS was passed too. + */ +#define BGWORKER_BACKEND_DATABASE_CONNECTION 0x0002 + +/* + * This class is used internally for parallel queries, to keep track of the + * number of active parallel workers and make sure we never launch more than + * max_parallel_workers parallel workers at the same time. Third party + * background workers should not use this class. + */ +#define BGWORKER_CLASS_PARALLEL 0x0010 +/* add additional bgworker classes here */ + + +typedef void (*bgworker_main_type) (Datum main_arg); + +/* + * Points in time at which a bgworker can request to be started + */ +typedef enum +{ + BgWorkerStart_PostmasterStart, + BgWorkerStart_ConsistentState, + BgWorkerStart_RecoveryFinished +} BgWorkerStartTime; + +#define BGW_DEFAULT_RESTART_INTERVAL 60 +#define BGW_NEVER_RESTART -1 +#define BGW_MAXLEN 96 +#define BGW_EXTRALEN 128 + +typedef struct BackgroundWorker +{ + char bgw_name[BGW_MAXLEN]; + char bgw_type[BGW_MAXLEN]; + int bgw_flags; + BgWorkerStartTime bgw_start_time; + int bgw_restart_time; /* in seconds, or BGW_NEVER_RESTART */ + char bgw_library_name[BGW_MAXLEN]; + char bgw_function_name[BGW_MAXLEN]; + Datum bgw_main_arg; + char bgw_extra[BGW_EXTRALEN]; + pid_t bgw_notify_pid; /* SIGUSR1 this backend on start/stop */ +} BackgroundWorker; + +typedef enum BgwHandleStatus +{ + BGWH_STARTED, /* worker is running */ + BGWH_NOT_YET_STARTED, /* worker hasn't been started yet */ + BGWH_STOPPED, /* worker has exited */ + BGWH_POSTMASTER_DIED /* postmaster died; worker status unclear */ +} BgwHandleStatus; + +struct BackgroundWorkerHandle; +typedef struct BackgroundWorkerHandle BackgroundWorkerHandle; + +/* Register a new bgworker during shared_preload_libraries */ +extern void RegisterBackgroundWorker(BackgroundWorker *worker); + +/* Register a new bgworker from a regular backend */ +extern bool RegisterDynamicBackgroundWorker(BackgroundWorker *worker, + BackgroundWorkerHandle **handle); + +/* Query the status of a bgworker */ +extern BgwHandleStatus GetBackgroundWorkerPid(BackgroundWorkerHandle *handle, + pid_t *pidp); +extern BgwHandleStatus WaitForBackgroundWorkerStartup(BackgroundWorkerHandle *handle, pid_t *pid); +extern BgwHandleStatus + WaitForBackgroundWorkerShutdown(BackgroundWorkerHandle *); +extern const char *GetBackgroundWorkerTypeByPid(pid_t pid); + +/* Terminate a bgworker */ +extern void TerminateBackgroundWorker(BackgroundWorkerHandle *handle); + +/* This is valid in a running worker */ +extern PGDLLIMPORT BackgroundWorker *MyBgworkerEntry; + +/* + * Connect to the specified database, as the specified user. Only a worker + * that passed BGWORKER_BACKEND_DATABASE_CONNECTION during registration may + * call this. + * + * If username is NULL, bootstrapping superuser is used. + * If dbname is NULL, connection is made to no specific database; + * only shared catalogs can be accessed. + */ +extern void BackgroundWorkerInitializeConnection(const char *dbname, const char *username, uint32 flags); + +/* Just like the above, but specifying database and user by OID. */ +extern void BackgroundWorkerInitializeConnectionByOid(Oid dboid, Oid useroid, uint32 flags); + +/* + * Flags to BackgroundWorkerInitializeConnection et al + * + * + * Allow bypassing datallowconn restrictions when connecting to database + */ +#define BGWORKER_BYPASS_ALLOWCONN 1 + + +/* Block/unblock signals in a background worker process */ +extern void BackgroundWorkerBlockSignals(void); +extern void BackgroundWorkerUnblockSignals(void); + +#endif /* BGWORKER_H */ diff --git a/src/include/postmaster/bgworker_internals.h b/src/include/postmaster/bgworker_internals.h new file mode 100644 index 0000000..fc77063 --- /dev/null +++ b/src/include/postmaster/bgworker_internals.h @@ -0,0 +1,64 @@ +/*-------------------------------------------------------------------- + * bgworker_internals.h + * POSTGRES pluggable background workers internals + * + * Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * IDENTIFICATION + * src/include/postmaster/bgworker_internals.h + *-------------------------------------------------------------------- + */ +#ifndef BGWORKER_INTERNALS_H +#define BGWORKER_INTERNALS_H + +#include "datatype/timestamp.h" +#include "lib/ilist.h" +#include "postmaster/bgworker.h" + +/* GUC options */ + +/* + * Maximum possible value of parallel workers. + */ +#define MAX_PARALLEL_WORKER_LIMIT 1024 + +/* + * List of background workers, private to postmaster. + * + * A worker that requests a database connection during registration will have + * rw_backend set, and will be present in BackendList. Note: do not rely on + * rw_backend being non-NULL for shmem-connected workers! + */ +typedef struct RegisteredBgWorker +{ + BackgroundWorker rw_worker; /* its registry entry */ + struct bkend *rw_backend; /* its BackendList entry, or NULL */ + pid_t rw_pid; /* 0 if not running */ + int rw_child_slot; + TimestampTz rw_crashed_at; /* if not 0, time it last crashed */ + int rw_shmem_slot; + bool rw_terminate; + slist_node rw_lnode; /* list link */ +} RegisteredBgWorker; + +extern slist_head BackgroundWorkerList; + +extern Size BackgroundWorkerShmemSize(void); +extern void BackgroundWorkerShmemInit(void); +extern void BackgroundWorkerStateChange(bool allow_new_workers); +extern void ForgetBackgroundWorker(slist_mutable_iter *cur); +extern void ReportBackgroundWorkerPID(RegisteredBgWorker *); +extern void ReportBackgroundWorkerExit(slist_mutable_iter *cur); +extern void BackgroundWorkerStopNotifications(pid_t pid); +extern void ForgetUnstartedBackgroundWorkers(void); +extern void ResetBackgroundWorkerCrashTimes(void); + +/* Function to start a background worker, called from postmaster.c */ +extern void StartBackgroundWorker(void) pg_attribute_noreturn(); + +#ifdef EXEC_BACKEND +extern BackgroundWorker *BackgroundWorkerEntry(int slotno); +#endif + +#endif /* BGWORKER_INTERNALS_H */ diff --git a/src/include/postmaster/bgwriter.h b/src/include/postmaster/bgwriter.h new file mode 100644 index 0000000..c430b1b --- /dev/null +++ b/src/include/postmaster/bgwriter.h @@ -0,0 +1,45 @@ +/*------------------------------------------------------------------------- + * + * bgwriter.h + * Exports from postmaster/bgwriter.c and postmaster/checkpointer.c. + * + * The bgwriter process used to handle checkpointing duties too. Now + * there is a separate process, but we did not bother to split this header. + * + * Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group + * + * src/include/postmaster/bgwriter.h + * + *------------------------------------------------------------------------- + */ +#ifndef _BGWRITER_H +#define _BGWRITER_H + +#include "storage/block.h" +#include "storage/relfilenode.h" +#include "storage/smgr.h" +#include "storage/sync.h" + + +/* GUC options */ +extern int BgWriterDelay; +extern int CheckPointTimeout; +extern int CheckPointWarning; +extern double CheckPointCompletionTarget; + +extern void BackgroundWriterMain(void) pg_attribute_noreturn(); +extern void CheckpointerMain(void) pg_attribute_noreturn(); + +extern void RequestCheckpoint(int flags); +extern void CheckpointWriteDelay(int flags, double progress); + +extern bool ForwardSyncRequest(const FileTag *ftag, SyncRequestType type); + +extern void AbsorbSyncRequests(void); + +extern Size CheckpointerShmemSize(void); +extern void CheckpointerShmemInit(void); + +extern bool FirstCallSinceLastCheckpoint(void); + +#endif /* _BGWRITER_H */ diff --git a/src/include/postmaster/fork_process.h b/src/include/postmaster/fork_process.h new file mode 100644 index 0000000..64e0373 --- /dev/null +++ b/src/include/postmaster/fork_process.h @@ -0,0 +1,17 @@ +/*------------------------------------------------------------------------- + * + * fork_process.h + * Exports from postmaster/fork_process.c. + * + * Copyright (c) 1996-2021, PostgreSQL Global Development Group + * + * src/include/postmaster/fork_process.h + * + *------------------------------------------------------------------------- + */ +#ifndef FORK_PROCESS_H +#define FORK_PROCESS_H + +extern pid_t fork_process(void); + +#endif /* FORK_PROCESS_H */ diff --git a/src/include/postmaster/interrupt.h b/src/include/postmaster/interrupt.h new file mode 100644 index 0000000..85a1293 --- /dev/null +++ b/src/include/postmaster/interrupt.h @@ -0,0 +1,32 @@ +/*------------------------------------------------------------------------- + * + * interrupt.h + * Interrupt handling routines. + * + * Responses to interrupts are fairly varied and many types of backends + * have their own implementations, but we provide a few generic things + * here to facilitate code reuse. + * + * Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * IDENTIFICATION + * src/include/postmaster/interrupt.h + * + *------------------------------------------------------------------------- + */ + +#ifndef INTERRUPT_H +#define INTERRUPT_H + +#include <signal.h> + +extern PGDLLIMPORT volatile sig_atomic_t ConfigReloadPending; +extern PGDLLIMPORT volatile sig_atomic_t ShutdownRequestPending; + +extern void HandleMainLoopInterrupts(void); +extern void SignalHandlerForConfigReload(SIGNAL_ARGS); +extern void SignalHandlerForCrashExit(SIGNAL_ARGS); +extern void SignalHandlerForShutdownRequest(SIGNAL_ARGS); + +#endif diff --git a/src/include/postmaster/pgarch.h b/src/include/postmaster/pgarch.h new file mode 100644 index 0000000..1e47a14 --- /dev/null +++ b/src/include/postmaster/pgarch.h @@ -0,0 +1,35 @@ +/*------------------------------------------------------------------------- + * + * pgarch.h + * Exports from postmaster/pgarch.c. + * + * Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/include/postmaster/pgarch.h + * + *------------------------------------------------------------------------- + */ +#ifndef _PGARCH_H +#define _PGARCH_H + +/* ---------- + * Archiver control info. + * + * We expect that archivable files within pg_wal will have names between + * MIN_XFN_CHARS and MAX_XFN_CHARS in length, consisting only of characters + * appearing in VALID_XFN_CHARS. The status files in archive_status have + * corresponding names with ".ready" or ".done" appended. + * ---------- + */ +#define MIN_XFN_CHARS 16 +#define MAX_XFN_CHARS 40 +#define VALID_XFN_CHARS "0123456789ABCDEF.history.backup.partial" + +extern Size PgArchShmemSize(void); +extern void PgArchShmemInit(void); +extern bool PgArchCanRestart(void); +extern void PgArchiverMain(void) pg_attribute_noreturn(); +extern void PgArchWakeup(void); + +#endif /* _PGARCH_H */ diff --git a/src/include/postmaster/postmaster.h b/src/include/postmaster/postmaster.h new file mode 100644 index 0000000..0efdd7c --- /dev/null +++ b/src/include/postmaster/postmaster.h @@ -0,0 +1,78 @@ +/*------------------------------------------------------------------------- + * + * postmaster.h + * Exports from postmaster/postmaster.c. + * + * Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/include/postmaster/postmaster.h + * + *------------------------------------------------------------------------- + */ +#ifndef _POSTMASTER_H +#define _POSTMASTER_H + +/* GUC options */ +extern bool EnableSSL; +extern int ReservedBackends; +extern PGDLLIMPORT int PostPortNumber; +extern int Unix_socket_permissions; +extern char *Unix_socket_group; +extern char *Unix_socket_directories; +extern char *ListenAddresses; +extern bool ClientAuthInProgress; +extern int PreAuthDelay; +extern int AuthenticationTimeout; +extern bool Log_connections; +extern bool log_hostname; +extern bool enable_bonjour; +extern char *bonjour_name; +extern bool restart_after_crash; +extern bool remove_temp_files_after_crash; + +#ifdef WIN32 +extern HANDLE PostmasterHandle; +#else +extern int postmaster_alive_fds[2]; + +/* + * Constants that represent which of postmaster_alive_fds is held by + * postmaster, and which is used in children to check for postmaster death. + */ +#define POSTMASTER_FD_WATCH 0 /* used in children to check for + * postmaster death */ +#define POSTMASTER_FD_OWN 1 /* kept open by postmaster only */ +#endif + +extern PGDLLIMPORT const char *progname; + +extern void PostmasterMain(int argc, char *argv[]) pg_attribute_noreturn(); +extern void ClosePostmasterPorts(bool am_syslogger); +extern void InitProcessGlobals(void); + +extern int MaxLivePostmasterChildren(void); + +extern bool PostmasterMarkPIDForWorkerNotify(int); + +#ifdef EXEC_BACKEND +extern pid_t postmaster_forkexec(int argc, char *argv[]); +extern void SubPostmasterMain(int argc, char *argv[]) pg_attribute_noreturn(); + +extern Size ShmemBackendArraySize(void); +extern void ShmemBackendArrayAllocation(void); +#endif + +/* + * Note: MAX_BACKENDS is limited to 2^18-1 because that's the width reserved + * for buffer references in buf_internals.h. This limitation could be lifted + * by using a 64bit state; but it's unlikely to be worthwhile as 2^18-1 + * backends exceed currently realistic configurations. Even if that limitation + * were removed, we still could not a) exceed 2^23-1 because inval.c stores + * the backend ID as a 3-byte signed integer, b) INT_MAX/4 because some places + * compute 4*MaxBackends without any overflow check. This is rechecked in the + * relevant GUC check hooks and in RegisterBackgroundWorker(). + */ +#define MAX_BACKENDS 0x3FFFF + +#endif /* _POSTMASTER_H */ diff --git a/src/include/postmaster/startup.h b/src/include/postmaster/startup.h new file mode 100644 index 0000000..bf6adf1 --- /dev/null +++ b/src/include/postmaster/startup.h @@ -0,0 +1,22 @@ +/*------------------------------------------------------------------------- + * + * startup.h + * Exports from postmaster/startup.c. + * + * Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group + * + * src/include/postmaster/startup.h + * + *------------------------------------------------------------------------- + */ +#ifndef _STARTUP_H +#define _STARTUP_H + +extern void HandleStartupProcInterrupts(void); +extern void StartupProcessMain(void) pg_attribute_noreturn(); +extern void PreRestoreCommand(void); +extern void PostRestoreCommand(void); +extern bool IsPromoteSignaled(void); +extern void ResetPromoteSignaled(void); + +#endif /* _STARTUP_H */ diff --git a/src/include/postmaster/syslogger.h b/src/include/postmaster/syslogger.h new file mode 100644 index 0000000..1491eec --- /dev/null +++ b/src/include/postmaster/syslogger.h @@ -0,0 +1,98 @@ +/*------------------------------------------------------------------------- + * + * syslogger.h + * Exports from postmaster/syslogger.c. + * + * Copyright (c) 2004-2021, PostgreSQL Global Development Group + * + * src/include/postmaster/syslogger.h + * + *------------------------------------------------------------------------- + */ +#ifndef _SYSLOGGER_H +#define _SYSLOGGER_H + +#include <limits.h> /* for PIPE_BUF */ + + +/* + * Primitive protocol structure for writing to syslogger pipe(s). The idea + * here is to divide long messages into chunks that are not more than + * PIPE_BUF bytes long, which according to POSIX spec must be written into + * the pipe atomically. The pipe reader then uses the protocol headers to + * reassemble the parts of a message into a single string. The reader can + * also cope with non-protocol data coming down the pipe, though we cannot + * guarantee long strings won't get split apart. + * + * We use non-nul bytes in is_last to make the protocol a tiny bit + * more robust against finding a false double nul byte prologue. But + * we still might find it in the len and/or pid bytes unless we're careful. + */ + +#ifdef PIPE_BUF +/* Are there any systems with PIPE_BUF > 64K? Unlikely, but ... */ +#if PIPE_BUF > 65536 +#define PIPE_CHUNK_SIZE 65536 +#else +#define PIPE_CHUNK_SIZE ((int) PIPE_BUF) +#endif +#else /* not defined */ +/* POSIX says the value of PIPE_BUF must be at least 512, so use that */ +#define PIPE_CHUNK_SIZE 512 +#endif + +typedef struct +{ + char nuls[2]; /* always \0\0 */ + uint16 len; /* size of this chunk (counts data only) */ + int32 pid; /* writer's pid */ + char is_last; /* last chunk of message? 't' or 'f' ('T' or + * 'F' for CSV case) */ + char data[FLEXIBLE_ARRAY_MEMBER]; /* data payload starts here */ +} PipeProtoHeader; + +typedef union +{ + PipeProtoHeader proto; + char filler[PIPE_CHUNK_SIZE]; +} PipeProtoChunk; + +#define PIPE_HEADER_SIZE offsetof(PipeProtoHeader, data) +#define PIPE_MAX_PAYLOAD ((int) (PIPE_CHUNK_SIZE - PIPE_HEADER_SIZE)) + + +/* GUC options */ +extern bool Logging_collector; +extern int Log_RotationAge; +extern int Log_RotationSize; +extern PGDLLIMPORT char *Log_directory; +extern PGDLLIMPORT char *Log_filename; +extern bool Log_truncate_on_rotation; +extern int Log_file_mode; + +#ifndef WIN32 +extern int syslogPipe[2]; +#else +extern HANDLE syslogPipe[2]; +#endif + + +extern int SysLogger_Start(void); + +extern void write_syslogger_file(const char *buffer, int count, int dest); + +#ifdef EXEC_BACKEND +extern void SysLoggerMain(int argc, char *argv[]) pg_attribute_noreturn(); +#endif + +extern bool CheckLogrotateSignal(void); +extern void RemoveLogrotateSignalFiles(void); + +/* + * Name of files saving meta-data information about the log + * files currently in use by the syslogger + */ +#define LOG_METAINFO_DATAFILE "current_logfiles" +#define LOG_METAINFO_DATAFILE_TMP LOG_METAINFO_DATAFILE ".tmp" + +#endif /* _SYSLOGGER_H */ diff --git a/src/include/postmaster/walwriter.h b/src/include/postmaster/walwriter.h new file mode 100644 index 0000000..3ccc332 --- /dev/null +++ b/src/include/postmaster/walwriter.h @@ -0,0 +1,21 @@ +/*------------------------------------------------------------------------- + * + * walwriter.h + * Exports from postmaster/walwriter.c. + * + * Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group + * + * src/include/postmaster/walwriter.h + * + *------------------------------------------------------------------------- + */ +#ifndef _WALWRITER_H +#define _WALWRITER_H + +/* GUC options */ +extern int WalWriterDelay; +extern int WalWriterFlushAfter; + +extern void WalWriterMain(void) pg_attribute_noreturn(); + +#endif /* _WALWRITER_H */ |