Re: Introduce "log_connection_stages" setting.

From: Justin Pryzby <pryzby(at)telsasoft(dot)com>
To: Sergey Dudoladov <sergey(dot)dudoladov(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org, Euler Taveira <euler(at)eulerto(dot)com>
Subject: Re: Introduce "log_connection_stages" setting.
Date: 2022-11-17 15:36:29
Message-ID: 20221117153629.GH11463@telsasoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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 been done:

receipt

> + <entry>Logs the original identity that an authentication method employs to identify a user. In most cases, the identity 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2022-11-17 15:39:10 Re: allow segment size to be set to < 1GiB
Previous Message Japin Li 2022-11-17 15:19:26 Re: redundant check of msg in does_not_exist_skipping