PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
backend_startup.h File Reference
#include "utils/timestamp.h"
Include dependency graph for backend_startup.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  BackendStartupData
 
struct  ConnectionTiming
 

Typedefs

typedef enum CAC_state CAC_state
 
typedef struct BackendStartupData BackendStartupData
 
typedef enum LogConnectionOption LogConnectionOption
 
typedef struct ConnectionTiming ConnectionTiming
 

Enumerations

enum  CAC_state {
  CAC_OK , CAC_STARTUP , CAC_SHUTDOWN , CAC_RECOVERY ,
  CAC_NOTHOTSTANDBY , CAC_TOOMANY
}
 
enum  LogConnectionOption {
  LOG_CONNECTION_RECEIPT = (1 << 0) , LOG_CONNECTION_AUTHENTICATION = (1 << 1) , LOG_CONNECTION_AUTHORIZATION = (1 << 2) , LOG_CONNECTION_SETUP_DURATIONS = (1 << 3) ,
  LOG_CONNECTION_ON , LOG_CONNECTION_ALL
}
 

Functions

pg_noreturn void BackendMain (const void *startup_data, size_t startup_data_len)
 

Variables

PGDLLIMPORT bool Trace_connection_negotiation
 
PGDLLIMPORT uint32 log_connections
 
PGDLLIMPORT char * log_connections_string
 
PGDLLIMPORT struct ConnectionTiming conn_timing
 

Typedef Documentation

◆ BackendStartupData

◆ CAC_state

typedef enum CAC_state CAC_state

◆ ConnectionTiming

◆ LogConnectionOption

Enumeration Type Documentation

◆ CAC_state

enum CAC_state
Enumerator
CAC_OK 
CAC_STARTUP 
CAC_SHUTDOWN 
CAC_RECOVERY 
CAC_NOTHOTSTANDBY 
CAC_TOOMANY 

Definition at line 33 of file backend_startup.h.

34{
35 CAC_OK,
41} CAC_state;
CAC_state
@ CAC_TOOMANY
@ CAC_OK
@ CAC_RECOVERY
@ CAC_NOTHOTSTANDBY
@ CAC_STARTUP
@ CAC_SHUTDOWN

◆ LogConnectionOption

Enumerator
LOG_CONNECTION_RECEIPT 
LOG_CONNECTION_AUTHENTICATION 
LOG_CONNECTION_AUTHORIZATION 
LOG_CONNECTION_SETUP_DURATIONS 
LOG_CONNECTION_ON 
LOG_CONNECTION_ALL 

Definition at line 74 of file backend_startup.h.

Function Documentation

◆ BackendMain()

pg_noreturn void BackendMain ( const void *  startup_data,
size_t  startup_data_len 
)

Definition at line 76 of file backend_startup.c.

77{
78 const BackendStartupData *bsdata = startup_data;
79
80 Assert(startup_data_len == sizeof(BackendStartupData));
81 Assert(MyClientSocket != NULL);
82
83#ifdef EXEC_BACKEND
84
85 /*
86 * Need to reinitialize the SSL library in the backend, since the context
87 * structures contain function pointers and cannot be passed through the
88 * parameter file.
89 *
90 * If for some reason reload fails (maybe the user installed broken key
91 * files), soldier on without SSL; that's better than all connections
92 * becoming impossible.
93 *
94 * XXX should we do this in all child processes? For the moment it's
95 * enough to do it in backend children.
96 */
97#ifdef USE_SSL
98 if (EnableSSL)
99 {
100 if (secure_initialize(false) == 0)
101 LoadedSSL = true;
102 else
103 ereport(LOG,
104 (errmsg("SSL configuration could not be loaded in child process")));
105 }
106#endif
107#endif
108
109 /* Perform additional initialization and collect startup packet */
111
112 /*
113 * Create a per-backend PGPROC struct in shared memory. We must do this
114 * before we can use LWLocks or access any shared memory.
115 */
116 InitProcess();
117
118 /*
119 * Make sure we aren't in PostmasterContext anymore. (We can't delete it
120 * just yet, though, because InitPostgres will need the HBA data.)
121 */
123
125}
static void BackendInitialize(ClientSocket *client_sock, CAC_state cac)
int secure_initialize(bool isServerStart)
Definition: be-secure.c:75
int errmsg(const char *fmt,...)
Definition: elog.c:1071
#define LOG
Definition: elog.h:31
#define ereport(elevel,...)
Definition: elog.h:149
struct ClientSocket * MyClientSocket
Definition: globals.c:51
struct Port * MyProcPort
Definition: globals.c:52
Assert(PointerIsAligned(start, uint64))
MemoryContext TopMemoryContext
Definition: mcxt.c:165
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:124
void PostgresMain(const char *dbname, const char *username)
Definition: postgres.c:4189
bool EnableSSL
Definition: postmaster.c:238
PGDLLIMPORT bool LoadedSSL
void InitProcess(void)
Definition: proc.c:391
CAC_state canAcceptConnections
char * user_name
Definition: libpq-be.h:151
char * database_name
Definition: libpq-be.h:150

References Assert(), BackendInitialize(), BackendStartupData::canAcceptConnections, Port::database_name, EnableSSL, ereport, errmsg(), InitProcess(), LoadedSSL, LOG, MemoryContextSwitchTo(), MyClientSocket, MyProcPort, PostgresMain(), secure_initialize(), TopMemoryContext, and Port::user_name.

Variable Documentation

◆ conn_timing

PGDLLIMPORT struct ConnectionTiming conn_timing
extern

Definition at line 58 of file backend_startup.c.

Referenced by PerformAuthentication(), PostgresMain(), and postmaster_child_launch().

◆ log_connections

◆ log_connections_string

PGDLLIMPORT char* log_connections_string
extern

Definition at line 48 of file backend_startup.c.

◆ Trace_connection_negotiation

PGDLLIMPORT bool Trace_connection_negotiation
extern

Definition at line 46 of file backend_startup.c.

Referenced by ProcessSSLStartup(), and ProcessStartupPacket().