On Tue, Nov 08, 2022 at 07:30:38PM +0100, Sergey Dudoladov wrote:
> + <entry>Logs reception of a connection. At this point a connection has been received, but no further work has
beendone:
receipt
> + <entry>Logs the original identity that an authentication method employs to identify a user. In most cases,
theidentity string equals the PostgreSQL username,
s/equals/matches
> +/* check_hook: validate new log_connection_messages value */
> +bool
> +check_log_connection_messages(char **newval, void **extra, GucSource source)
> +{
> + char *rawname;
> + List *namelist;
> + ListCell *l;
> + char *log_connection_messages = *newval;
> + bool *myextra;
> +
> + /*
> + * Set up the "extra" struct actually used by assign_log_connection_messages.
> + */
> + myextra = (bool *) guc_malloc(LOG, 4 * sizeof(bool));
This function hardcodes each of the 4 connections:
> + if (pg_strcasecmp(stage, "received") == 0)
> + myextra[0] = true;
It'd be better to use #defines or enums for these.
> --- a/src/backend/tcop/postgres.c
> +++ b/src/backend/tcop/postgres.c
> @@ -84,8 +84,11 @@ const char *debug_query_string; /* client-supplied query string */
> /* Note: whereToSendOutput is initialized for the bootstrap/standalone case */
> CommandDest whereToSendOutput = DestDebug;
>
> -/* flag for logging end of session */
> -bool Log_disconnections = false;
> +/* flags for logging information about session state */
> +bool Log_disconnected = false;
> +bool Log_authenticated = false;
> +bool Log_authorized = false;
> +bool Log_received = false;
I think this ought to be an integer with flag bits, rather than 4
booleans (I don't know, but there might be more later?). Then, the
implementation follows the user-facing GUC and also follows
log_destination.
--
Justin