Add application_name to connection authorized msg

Enterprise / PostgreSQL - Stephen Frost [snowman.net] - 28 September 2018 23:04 EDT

The connection authorized message has quite a bit of useful information in it, but didn't include the application_name (when provided), so let's add that as it can be very useful.

Note that at the point where we're emitting the connection authorized message, we haven't processed GUCs, so it's not possible to get this by using log_line_prefix (which pulls from the GUC). There's also something to be said for having this included in the connection authorized message and then not needing to repeat it for every line, as having it in log_line_prefix would do.

The GUC cleans the application name to pure-ascii, so do that here too, but pull out the logic for cleaning up a string into its own function in common and re-use it from those places, and check_cluster_name which was doing the same thing.

Author: Don Seiler Discussion: https://postgr.es/m/CAHJZqBB_Pxv8HRfoh%2BAB4KxSQQuPVvtYCzMg7woNR3r7dfmopw%40mail.gmail.com

8bddc86400 Add application_name to connection authorized msg
src/backend/postmaster/postmaster.c | 16 +++++++++++
src/backend/utils/init/postinit.c | 54 ++++++++++++++++++++++++++-----------
src/backend/utils/misc/guc.c | 17 +++---------
src/common/string.c | 34 +++++++++++++++++++++++
src/include/common/string.h | 1 +
src/include/libpq/libpq-be.h | 7 +++++
6 files changed, 99 insertions(+), 30 deletions(-)

Upstream: git.postgresql.org


  • Share