|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* backend_startup.h
|
|
|
|
* prototypes for backend_startup.c.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
|
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
|
|
*
|
|
|
|
* src/include/tcop/backend_startup.h
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#ifndef BACKEND_STARTUP_H
|
|
|
|
#define BACKEND_STARTUP_H
|
|
|
|
|
|
|
|
#include "utils/timestamp.h"
|
|
|
|
|
|
|
|
/* GUCs */
|
|
|
|
extern PGDLLIMPORT bool Trace_connection_negotiation;
|
Modularize log_connections output
Convert the boolean log_connections GUC into a list GUC comprised of the
connection aspects to log.
This gives users more control over the volume and kind of connection
logging.
The current log_connections options are 'receipt', 'authentication', and
'authorization'. The empty string disables all connection logging. 'all'
enables all available connection logging.
For backwards compatibility, the most common values for the
log_connections boolean are still supported (on, off, 1, 0, true, false,
yes, no). Note that previously supported substrings of on, off, true,
false, yes, and no are no longer supported.
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@oss.nttdata.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/flat/CAAKRu_b_smAHK0ZjrnL5GRxnAVWujEXQWpLXYzGbmpcZd3nLYw%40mail.gmail.com
6 months ago
|
|
|
extern PGDLLIMPORT uint32 log_connections;
|
|
|
|
extern PGDLLIMPORT char *log_connections_string;
|
|
|
|
|
|
|
|
/* Other globals */
|
|
|
|
extern PGDLLIMPORT struct ConnectionTiming conn_timing;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* CAC_state is passed from postmaster to the backend process, to indicate
|
|
|
|
* whether the connection should be accepted, or if the process should just
|
|
|
|
* send an error to the client and close the connection. Note that the
|
|
|
|
* connection can fail for various reasons even if postmaster passed CAC_OK.
|
|
|
|
*/
|
|
|
|
typedef enum CAC_state
|
|
|
|
{
|
|
|
|
CAC_OK,
|
|
|
|
CAC_STARTUP,
|
|
|
|
CAC_SHUTDOWN,
|
|
|
|
CAC_RECOVERY,
|
|
|
|
CAC_NOTCONSISTENT,
|
|
|
|
CAC_TOOMANY,
|
|
|
|
} CAC_state;
|
|
|
|
|
|
|
|
/* Information passed from postmaster to backend process in 'startup_data' */
|
|
|
|
typedef struct BackendStartupData
|
|
|
|
{
|
|
|
|
CAC_state canAcceptConnections;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Time at which the connection client socket is created. Only used for
|
|
|
|
* client and wal sender connections.
|
|
|
|
*/
|
|
|
|
TimestampTz socket_created;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Time at which the postmaster initiates process creation -- either
|
|
|
|
* through fork or otherwise. Only used for client and wal sender
|
|
|
|
* connections.
|
|
|
|
*/
|
|
|
|
TimestampTz fork_started;
|
|
|
|
} BackendStartupData;
|
|
|
|
|
Modularize log_connections output
Convert the boolean log_connections GUC into a list GUC comprised of the
connection aspects to log.
This gives users more control over the volume and kind of connection
logging.
The current log_connections options are 'receipt', 'authentication', and
'authorization'. The empty string disables all connection logging. 'all'
enables all available connection logging.
For backwards compatibility, the most common values for the
log_connections boolean are still supported (on, off, 1, 0, true, false,
yes, no). Note that previously supported substrings of on, off, true,
false, yes, and no are no longer supported.
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@oss.nttdata.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/flat/CAAKRu_b_smAHK0ZjrnL5GRxnAVWujEXQWpLXYzGbmpcZd3nLYw%40mail.gmail.com
6 months ago
|
|
|
/*
|
|
|
|
* Granular control over which messages to log for the log_connections GUC.
|
|
|
|
*
|
|
|
|
* RECEIPT, AUTHENTICATION, AUTHORIZATION, and SETUP_DURATIONS are different
|
|
|
|
* aspects of connection establishment and backend setup for which we may emit
|
|
|
|
* a log message.
|
Modularize log_connections output
Convert the boolean log_connections GUC into a list GUC comprised of the
connection aspects to log.
This gives users more control over the volume and kind of connection
logging.
The current log_connections options are 'receipt', 'authentication', and
'authorization'. The empty string disables all connection logging. 'all'
enables all available connection logging.
For backwards compatibility, the most common values for the
log_connections boolean are still supported (on, off, 1, 0, true, false,
yes, no). Note that previously supported substrings of on, off, true,
false, yes, and no are no longer supported.
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@oss.nttdata.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/flat/CAAKRu_b_smAHK0ZjrnL5GRxnAVWujEXQWpLXYzGbmpcZd3nLYw%40mail.gmail.com
6 months ago
|
|
|
*
|
|
|
|
* ALL is a convenience alias equivalent to all of the above aspects.
|
|
|
|
*
|
|
|
|
* ON is backwards compatibility alias for the connection aspects that were
|
|
|
|
* logged in Postgres versions < 18.
|
|
|
|
*/
|
|
|
|
typedef enum LogConnectionOption
|
|
|
|
{
|
|
|
|
LOG_CONNECTION_RECEIPT = (1 << 0),
|
|
|
|
LOG_CONNECTION_AUTHENTICATION = (1 << 1),
|
|
|
|
LOG_CONNECTION_AUTHORIZATION = (1 << 2),
|
|
|
|
LOG_CONNECTION_SETUP_DURATIONS = (1 << 3),
|
Modularize log_connections output
Convert the boolean log_connections GUC into a list GUC comprised of the
connection aspects to log.
This gives users more control over the volume and kind of connection
logging.
The current log_connections options are 'receipt', 'authentication', and
'authorization'. The empty string disables all connection logging. 'all'
enables all available connection logging.
For backwards compatibility, the most common values for the
log_connections boolean are still supported (on, off, 1, 0, true, false,
yes, no). Note that previously supported substrings of on, off, true,
false, yes, and no are no longer supported.
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@oss.nttdata.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/flat/CAAKRu_b_smAHK0ZjrnL5GRxnAVWujEXQWpLXYzGbmpcZd3nLYw%40mail.gmail.com
6 months ago
|
|
|
LOG_CONNECTION_ON =
|
|
|
|
LOG_CONNECTION_RECEIPT |
|
|
|
|
LOG_CONNECTION_AUTHENTICATION |
|
|
|
|
LOG_CONNECTION_AUTHORIZATION,
|
|
|
|
LOG_CONNECTION_ALL =
|
|
|
|
LOG_CONNECTION_RECEIPT |
|
|
|
|
LOG_CONNECTION_AUTHENTICATION |
|
|
|
|
LOG_CONNECTION_AUTHORIZATION |
|
|
|
|
LOG_CONNECTION_SETUP_DURATIONS,
|
Modularize log_connections output
Convert the boolean log_connections GUC into a list GUC comprised of the
connection aspects to log.
This gives users more control over the volume and kind of connection
logging.
The current log_connections options are 'receipt', 'authentication', and
'authorization'. The empty string disables all connection logging. 'all'
enables all available connection logging.
For backwards compatibility, the most common values for the
log_connections boolean are still supported (on, off, 1, 0, true, false,
yes, no). Note that previously supported substrings of on, off, true,
false, yes, and no are no longer supported.
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@oss.nttdata.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/flat/CAAKRu_b_smAHK0ZjrnL5GRxnAVWujEXQWpLXYzGbmpcZd3nLYw%40mail.gmail.com
6 months ago
|
|
|
} LogConnectionOption;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* A collection of timings of various stages of connection establishment and
|
|
|
|
* setup for client backends and WAL senders.
|
|
|
|
*
|
|
|
|
* Used to emit the setup_durations log message for the log_connections GUC.
|
|
|
|
*/
|
|
|
|
typedef struct ConnectionTiming
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* The time at which the client socket is created and the time at which
|
|
|
|
* the connection is fully set up and first ready for query. Together
|
|
|
|
* these represent the total connection establishment and setup time.
|
|
|
|
*/
|
|
|
|
TimestampTz socket_create;
|
|
|
|
TimestampTz ready_for_use;
|
|
|
|
|
|
|
|
/* Time at which process creation was initiated */
|
|
|
|
TimestampTz fork_start;
|
|
|
|
|
|
|
|
/* Time at which process creation was completed */
|
|
|
|
TimestampTz fork_end;
|
|
|
|
|
|
|
|
/* Time at which authentication started */
|
|
|
|
TimestampTz auth_start;
|
|
|
|
|
|
|
|
/* Time at which authentication was finished */
|
|
|
|
TimestampTz auth_end;
|
|
|
|
} ConnectionTiming;
|
|
|
|
|
pg_noreturn to replace pg_attribute_noreturn()
We want to support a "noreturn" decoration on more compilers besides
just GCC-compatible ones, but for that we need to move the decoration
in front of the function declaration instead of either behind it or
wherever, which is the current style afforded by GCC-style attributes.
Also rename the macro to "pg_noreturn" to be similar to the C11
standard "noreturn".
pg_noreturn is now supported on all compilers that support C11 (using
_Noreturn), as well as GCC-compatible ones (using __attribute__, as
before), as well as MSVC (using __declspec). (When PostgreSQL
requires C11, the latter two variants can be dropped.)
Now, all supported compilers effectively support pg_noreturn, so the
extra code for !HAVE_PG_ATTRIBUTE_NORETURN can be dropped.
This also fixes a possible problem if third-party code includes
stdnoreturn.h, because then the current definition of
#define pg_attribute_noreturn() __attribute__((noreturn))
would cause an error.
Note that the C standard does not support a noreturn attribute on
function pointer types. So we have to drop these here. There are
only two instances at this time, so it's not a big loss. In one case,
we can make up for it by adding the pg_noreturn to a wrapper function
and adding a pg_unreachable(), in the other case, the latter was
already done before.
Reviewed-by: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://www.postgresql.org/message-id/flat/pxr5b3z7jmkpenssra5zroxi7qzzp6eswuggokw64axmdixpnk@zbwxuq7gbbcw
6 months ago
|
|
|
pg_noreturn extern void BackendMain(const void *startup_data, size_t startup_data_len);
|
|
|
|
|
|
|
|
#endif /* BACKEND_STARTUP_H */
|