]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix handling of escape sequences in postgres_fdw.application_name
authorMichael Paquier <michael@paquier.xyz>
Tue, 21 Feb 2023 11:02:09 +0000 (20:02 +0900)
committerMichael Paquier <michael@paquier.xyz>
Tue, 21 Feb 2023 11:02:09 +0000 (20:02 +0900)
commit5bace41abc317ae8ecf3397e9e92f3b0e5444c69
treeff9abeeed128d14e5af2e913d7cc5ddb19ae6bf4
parent108a22bd14d4deb98340deec422cfec6d3b37840
Fix handling of escape sequences in postgres_fdw.application_name

postgres_fdw.application_name relies on MyProcPort to define the data
that should be added to escape sequences %u (user name) or %d (database
name).  However this code could be run in processes that lack a
MyProcPort, like an autovacuum process, causing crashes.

The code generating the application name is made more flexible with this
commit, so as it now generates no data for %u and %d if MyProcPort is
missing, and a simple "unknown" if MyProcPort exists, but the expected
fields are not set.

Reported-by: Alexander Lakhin
Author: Kyotaro Horiguchi, Michael Paquier
Reviewed-by: Hayato Kuroda, Masahiko Sawada
Discussion: https://postgr.es/m/17789-8b31c5a4672b74d9@postgresql.org
Backpatch-through: 15
contrib/postgres_fdw/option.c