PostgreSQL Source Code: src/include/tcop/backend_startup.h Source File

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 */
20extern PGDLLIMPORT bool Trace_connection_negotiation;
21extern PGDLLIMPORT uint32 log_connections;
22extern PGDLLIMPORT char *log_connections_string;
23
24/* Other globals */
25extern PGDLLIMPORT struct ConnectionTiming conn_timing;
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 */
33 typedef enum CAC_state
34{
35 CAC_OK,
36 CAC_STARTUP,
37 CAC_SHUTDOWN,
38 CAC_RECOVERY,
39 CAC_NOTHOTSTANDBY,
40 CAC_TOOMANY,
41 } CAC_state;
42
43/* Information passed from postmaster to backend process in 'startup_data' */
44 typedef struct BackendStartupData
45{
46 CAC_state canAcceptConnections;
47
48 /*
49 * Time at which the connection client socket is created. Only used for
50 * client and wal sender connections.
51 */
52 TimestampTz socket_created;
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 */
59 TimestampTz fork_started;
60 } BackendStartupData;
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 */
74 typedef enum LogConnectionOption
75{
76 LOG_CONNECTION_RECEIPT = (1 << 0),
77 LOG_CONNECTION_AUTHENTICATION = (1 << 1),
78 LOG_CONNECTION_AUTHORIZATION = (1 << 2),
79 LOG_CONNECTION_SETUP_DURATIONS = (1 << 3),
80 LOG_CONNECTION_ON =
81 LOG_CONNECTION_RECEIPT |
82 LOG_CONNECTION_AUTHENTICATION |
83 LOG_CONNECTION_AUTHORIZATION,
84 LOG_CONNECTION_ALL =
85 LOG_CONNECTION_RECEIPT |
86 LOG_CONNECTION_AUTHENTICATION |
87 LOG_CONNECTION_AUTHORIZATION |
88 LOG_CONNECTION_SETUP_DURATIONS,
89 } LogConnectionOption;
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 */
97 typedef 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 */
104 TimestampTz socket_create;
105 TimestampTz ready_for_use;
106
107 /* Time at which process creation was initiated */
108 TimestampTz fork_start;
109
110 /* Time at which process creation was completed */
111 TimestampTz fork_end;
112
113 /* Time at which authentication started */
114 TimestampTz auth_start;
115
116 /* Time at which authentication was finished */
117 TimestampTz auth_end;
118 } ConnectionTiming;
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_NOTHOTSTANDBY
@ 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:1319
#define pg_noreturn
Definition: c.h:164
uint32_t uint32
Definition: c.h:538
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

AltStyle によって変換されたページ (->オリジナル) /