PostgreSQL Source Code git master
backend_startup.h
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * backend_startup.h
4 * prototypes for backend_startup.c.
5 *
6 *
7 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
9 *
10 * src/include/tcop/backend_startup.h
11 *
12 *-------------------------------------------------------------------------
13 */
14#ifndef BACKEND_STARTUP_H
15#define BACKEND_STARTUP_H
16
17#include "utils/timestamp.h"
18
19/* GUCs */
23
24/* Other globals */
26
27/*
28 * CAC_state is passed from postmaster to the backend process, to indicate
29 * whether the connection should be accepted, or if the process should just
30 * send an error to the client and close the connection. Note that the
31 * connection can fail for various reasons even if postmaster passed CAC_OK.
32 */
33typedef enum CAC_state
34{
42
43/* Information passed from postmaster to backend process in 'startup_data' */
44typedef struct BackendStartupData
45{
47
48 /*
49 * Time at which the connection client socket is created. Only used for
50 * client and wal sender connections.
51 */
53
54 /*
55 * Time at which the postmaster initiates process creation -- either
56 * through fork or otherwise. Only used for client and wal sender
57 * connections.
58 */
61
62/*
63 * Granular control over which messages to log for the log_connections GUC.
64 *
65 * RECEIPT, AUTHENTICATION, AUTHORIZATION, and SETUP_DURATIONS are different
66 * aspects of connection establishment and backend setup for which we may emit
67 * a log message.
68 *
69 * ALL is a convenience alias equivalent to all of the above aspects.
70 *
71 * ON is backwards compatibility alias for the connection aspects that were
72 * logged in Postgres versions < 18.
73 */
75{
90
91/*
92 * A collection of timings of various stages of connection establishment and
93 * setup for client backends and WAL senders.
94 *
95 * Used to emit the setup_durations log message for the log_connections GUC.
96 */
97typedef struct ConnectionTiming
98{
99 /*
100 * The time at which the client socket is created and the time at which
101 * the connection is fully set up and first ready for query. Together
102 * these represent the total connection establishment and setup time.
103 */
106
107 /* Time at which process creation was initiated */
109
110 /* Time at which process creation was completed */
112
113 /* Time at which authentication started */
115
116 /* Time at which authentication was finished */
119
120pg_noreturn extern void BackendMain(const void *startup_data, size_t startup_data_len);
121
122#endif /* BACKEND_STARTUP_H */
struct BackendStartupData BackendStartupData
CAC_state
@ CAC_TOOMANY
@ CAC_OK
@ CAC_RECOVERY
@ CAC_NOTCONSISTENT
@ CAC_STARTUP
@ CAC_SHUTDOWN
PGDLLIMPORT struct ConnectionTiming conn_timing
pg_noreturn void BackendMain(const void *startup_data, size_t startup_data_len)
PGDLLIMPORT uint32 log_connections
LogConnectionOption
@ LOG_CONNECTION_AUTHORIZATION
@ LOG_CONNECTION_ON
@ LOG_CONNECTION_SETUP_DURATIONS
@ LOG_CONNECTION_ALL
@ LOG_CONNECTION_RECEIPT
@ LOG_CONNECTION_AUTHENTICATION
PGDLLIMPORT bool Trace_connection_negotiation
struct ConnectionTiming ConnectionTiming
PGDLLIMPORT char * log_connections_string
#define PGDLLIMPORT
Definition: c.h:1291
#define pg_noreturn
Definition: c.h:165
uint32_t uint32
Definition: c.h:502
int64 TimestampTz
Definition: timestamp.h:39
CAC_state canAcceptConnections
TimestampTz fork_started
TimestampTz socket_created
TimestampTz ready_for_use
TimestampTz auth_start
TimestampTz socket_create
TimestampTz fork_start
TimestampTz auth_end
TimestampTz fork_end