99#ifdef USE_INJECTION_POINTS
151#define SizeOfBackendParameters(startup_data_len) (offsetof(BackendParameters, startup_data) + startup_data_len)
180#define PG_PROCTYPE(bktype, bkcategory, description, main_func, shmem_attach) \
181 [bktype] = {description, main_func, shmem_attach},
332 errmsg(
"could not create file \"%s\": %m",
360 argv[0] =
"postgres";
373 (
errmsg(
"could not execute server process \"%s\": %m",
416 sa.nLength =
sizeof(
sa);
427 (
errmsg(
"could not create backend parameter file mapping: error code %lu",
435 (
errmsg(
"could not map backend parameter memory: error code %lu",
452 (
errmsg(
"subprocess command line too long")));
470 (
errmsg(
"CreateProcess() call failed: %m (error code %lu)",
478 pi.hProcess,
pi.dwProcessId,
487 (
errmsg_internal(
"could not terminate unstarted process: error code %lu",
499 (
errmsg(
"could not unmap view of backend parameter file: error code %lu",
503 (
errmsg(
"could not close handle to backend parameter file: error code %lu",
518 (
errmsg_internal(
"could not terminate process that failed to reserve memory: error code %lu",
525 (
errmsg(
"giving up after too many tries to reserve shared memory"),
526 errhint(
"This might be caused by ASLR or antivirus software.")));
540 (
errmsg_internal(
"could not terminate unstartable process: error code %lu",
549 (
errmsg_internal(
"could not resume thread of unstarted process: error code %lu",
561 return pi.dwProcessId;
599 elog(
FATAL,
"invalid subpostmaster invocation");
605 if (
strncmp(argv[1],
"--forkchild=", 12) != 0)
606 elog(
FATAL,
"invalid subpostmaster invocation (--forkchild argument missing)");
690#define write_inheritable_socket(dest, src, childpid) ((*(dest) = (src)), true)
691#define read_inheritable_socket(dest, src) (*(dest) = *(src))
720 param->MyPMChildSlot = child_slot;
728#ifdef USE_INJECTION_POINTS
799 (
errmsg_internal(
"could not duplicate handle to be written to backend parameter file: error code %lu",
818 dest->origsocket = src;
825 (
errmsg(
"could not duplicate socket %d for use in backend: error code %d",
844 *
dest = src->origsocket;
857 write_stderr(
"could not create inherited socket: error code %d\n",
886 write_stderr(
"could not open backend variables file \"%s\": %m\n",
id);
890 if (
fread(¶m,
sizeof(param), 1, fp) != 1)
892 write_stderr(
"could not read from backend variables file \"%s\": %m\n",
id);
898 if (param.startup_data_len > 0)
903 write_stderr(
"could not read startup data from backend variables file \"%s\": %m\n",
931 write_stderr(
"could not map view of backend variables: error code %lu\n",
940 if (param.startup_data_len > 0)
950 write_stderr(
"could not unmap view of backend variables: error code %lu\n",
957 write_stderr(
"could not close handle to backend parameter variables: error code %lu\n",
987#ifdef USE_INJECTION_POINTS
TimestampTz GetCurrentTimestamp(void)
ConnectionTiming conn_timing
#define write_stderr(str)
#define Assert(condition)
#define FLEXIBLE_ARRAY_MEMBER
void dsm_detach_all(void)
int errcode_for_file_access(void)
int errmsg(const char *fmt,...)
int errhint(const char *fmt,...) pg_attribute_printf(1
int int errmsg_internal(const char *fmt,...) pg_attribute_printf(1
#define ereport(elevel,...)
int MakePGDirectory(const char *directoryName)
void ReserveExternalFD(void)
FILE * AllocateFile(const char *name, const char *mode)
#define palloc_object(type)
#define PG_TEMP_FILES_DIR
#define PG_TEMP_FILE_PREFIX
struct ClientSocket * MyClientSocket
char pkglib_path[MAXPGPATH]
bool IsPostmasterEnvironment
char my_exec_path[MAXPGPATH]
void InitializeGUCOptions(void)
static child_process_kind child_process_kinds[]
pid_t postmaster_child_launch(BackendType child_type, int child_slot, void *startup_data, size_t startup_data_len, const ClientSocket *client_sock)
const char * PostmasterChildName(BackendType child_type)
char ** LWLockTrancheNames
int NamedLWLockTrancheRequests
NamedLWLockTrancheRequest * NamedLWLockTrancheRequestArray
LWLockPadded * MainLWLockArray
void * MemoryContextAlloc(MemoryContext context, Size size)
void pfree(void *pointer)
void * palloc0(Size size)
MemoryContext TopMemoryContext
#define IsExternalConnectionBackend(backend_type)
#define BACKEND_NUM_TYPES
void InitPostmasterChild(void)
void process_shared_preload_libraries(void)
BackendType MyBackendType
void SetDataDir(const char *dir)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
NON_EXEC_STATIC int num_pmchild_slots
NON_EXEC_STATIC volatile PMSignalData * PMSignalState
size_t strlcpy(char *dst, const char *src, size_t siz)
CommandDest whereToSendOutput
int postmaster_alive_fds[2]
void ClosePostmasterPorts(bool am_syslogger)
NON_EXEC_STATIC ProcSignalHeader * ProcSignal
void InitShmemAllocator(PGShmemHeader *seghdr)
HANDLE pgwin32_create_signal_listener(pid_t pid)
HANDLE pgwin32_initial_signal_pipe
PGPROC * PreparedXactProcs
NON_EXEC_STATIC PGPROC * AuxiliaryProcs
TimestampTz socket_create
void(* main_fn)(const void *startup_data, size_t startup_data_len)
NON_EXEC_STATIC pg_time_t first_syslogger_file_time
void PGSharedMemoryDetach(void)
unsigned long UsedShmemSegID
void PGSharedMemoryReAttach(void)
void * ShmemProtectiveRegion
int pgwin32_ReserveSharedMemoryRegion(HANDLE hChild)
void PGSharedMemoryNoReAttach(void)
void LocalProcessControlFile(bool reset)