Re: Allow escape in application_name

Fujii Masao <masao.fujii@oss.nttdata.com>

From: Fujii Masao <masao.fujii@oss.nttdata.com>
To: "kuroda.hayato@fujitsu.com" <kuroda.hayato@fujitsu.com>, 'Kyotaro Horiguchi' <horikyota.ntt@gmail.com>
Cc: "ikedamsh@oss.nttdata.com" <ikedamsh@oss.nttdata.com>, "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>, "tgl@sss.pgh.pa.us" <tgl@sss.pgh.pa.us>
Date: 2021-09-10T00:23:45Z
Lists: pgsql-hackers

On 2021/09/09 21:36, kuroda.hayato@fujitsu.com wrote:
> In this case, I expected to use fallback_application_name instead of appname,
> but I missed the case where appname was set as a server option.
> Maybe we should do continue when buf.data is \0.

Yes.

+				/*
+				 * If the input format is wrong and the string becomes '\0',
+				 * this parameter is no longer used.
+				 * We conitnue searching application_name.
+				 */
+				if (values[i] == '\0')
+					continue;
+				else
+					break;

We can simplify the code as follows.

     if (values[i] != '\0')
         break;

> Yeah, and I found that "%+5p" is another example.
> Our padding function does not understand plus sign
> (and maybe this is the specification of printf()), but strtol() reads.
> 
> I did not fix here because I lost my way. Do we treats these cases
> and continue to use strtol(), or use process_padding()?

IMO it's better to use process_padding() to process log_line_prefix and
postgres_fdw.application in the same way as possible.
Which would be less confusing.

Regards,

-- 
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION



Commits

  1. postgres_fdw: Add regression test for postgres_fdw.application_name GUC.

  2. postgres_fdw: Allow postgres_fdw.application_name to include escape sequences.

  3. doc: Add note about postgres_fdw.application_name.

  4. postgres_fdw: Revert unstable tests for postgres_fdw.application_name.

  5. postgres_fdw: Allow application_name of remote connection to be set via GUC.