RE: Allow escape in application_name (was: [postgres_fdw] add local pid to fallback_application_name)

From: "kuroda(dot)hayato(at)fujitsu(dot)com" <kuroda(dot)hayato(at)fujitsu(dot)com>
To: 'Fujii Masao' <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
Cc: "'pgsql-hackers(at)lists(dot)postgresql(dot)org'" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, 'Tom Lane' <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: RE: Allow escape in application_name (was: [postgres_fdw] add local pid to fallback_application_name)
Date: 2021-08-26 06:00:27
Message-ID: TYAPR01MB58661635D3884E3B863ED01CF5C79@TYAPR01MB5866.jpnprd01.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Dear Fujii-san,

Thank you for replying! I attached new version.

> Why did you make even %u and %d available in application_name?

Actually no particular reason. I added them because they can easily add...
And I agree what you say, so removed.

> So some people may want to specify their own ID in application_name
> when connecting to the foreign server. For now they can do that by
> setting application_name per foreign server object. But this means that
> every session connecting to the same foreign server basically should
> use the same application_name. If they want to change the setting,
> they need to execute "ALTER SERAVER ... OPTIONS ...". Isn't this inconvenient?

Yeah, currently such users must execute ALTER command for each time.

> If yes, what about allowing us to specify foreign server's application_name
> per session? For example, we can add postgres_fdw.application_name GUC,
> and then if it's set postgres_fdw always uses it instead of the server-level
> option when connecting to the foreign server. Thought?

OK, I added the GUC parameter. My patch Defines new GUC at _PG_init().
The value is used when backends started to connect to remote server.
Normal users can modify the value by SET commands but
that change does not propagate to the established connections.

I'm not sure about the versioning policy about contrib.
Do we have to make new version? Any other objects are not changed.

Finally, I and Fujii-san were now discussing locally whether
this replacement should be in libpq or postgres_fdw layer.
I started to think that it should be postgres_fdw, because:
* previously aplications could distinguish by using current applicaiton_name,
* libpq is used almost all uses so some modifications might affect someone, and
* libpq might be just a tool, and should not be intelligent

I will make and attach another version that new codes move to postgres_fdw.
So could you vote which version is better?

Best Regards,
Hayato Kuroda
FUJITSU LIMITED

Attachment Content-Type Size
v02_0002_add_guc.patch application/octet-stream 3.9 KB
v02_0001_allow_escape_in_application_name.patch application/octet-stream 6.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2021-08-26 06:09:43 Re: Skipping logical replication transactions on subscriber side
Previous Message Andrey Borodin 2021-08-26 05:52:44 Re: Async-unsafe functions in signal handlers