Re: Allow escape in application_name

From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: "kuroda(dot)hayato(at)fujitsu(dot)com" <kuroda(dot)hayato(at)fujitsu(dot)com>
Cc: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, "houzj(dot)fnst(at)fujitsu(dot)com" <houzj(dot)fnst(at)fujitsu(dot)com>, "ikedamsh(at)oss(dot)nttdata(dot)com" <ikedamsh(at)oss(dot)nttdata(dot)com>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, "tgl(at)sss(dot)pgh(dot)pa(dot)us" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: Allow escape in application_name
Date: 2021-12-28 00:32:13
Message-ID: CAD21AoAcnynacMVr7U2TC=eMtxSdxRZLG6RS7uEunoSfdyux-g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Dec 28, 2021 at 8:57 AM kuroda(dot)hayato(at)fujitsu(dot)com
<kuroda(dot)hayato(at)fujitsu(dot)com> wrote:
>
> Dear Sawada-san,
>
> > If so, we need to do substring(... for
> > 63) instead.

Just to be clear, I meant substring(... for NAMEDATALEN - 1).

>
> Yeah, the parameter will be truncated as one less than NAMEDATALEN:
>
> ```
> max_identifier_length (integer)
> Reports the maximum identifier length. It is determined as one less than the value of NAMEDATALEN when building the server.
> The default value of NAMEDATALEN is 64; therefore the default max_identifier_length is 63 bytes,
> which can be less than 63 characters when using multibyte encodings.
> ```

I think this is the description of the max_identifier_length GUC parameter.

>
> But in Fujii-san's patch length is picked up by the following SQL, so I think it works well.
>
> ```
> SELECT max_identifier_length FROM pg_control_init()
> ```

Doesn't this query return 64? So the expression "substring(str for
(SELECT max_identifier_length FROM pg_control_init()))" returns the
first 64 characters of the given string while the application_name is
truncated to be 63 (NAMEDATALEN - 1) characters. It also seems to be
fine to use current_setting('max_identifier_length') instead of
max_identifier_length of pg_control_init().

Regards,

--
Masahiko Sawada
EDB: https://www.enterprisedb.com/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message SATYANARAYANA NARLAPURAM 2021-12-28 00:40:28 Re: Throttling WAL inserts when the standby falls behind more than the configured replica_lag_in_bytes
Previous Message Imseih (AWS), Sami 2021-12-28 00:13:16 Re: Add index scan progress to pg_stat_progress_vacuum