From 56a136acd62d4542e07eaea84cfa4cf7ca1c68ae Mon Sep 17 00:00:00 2001 From: Mike Palmiotto Date: Thu, 17 May 2018 12:05:25 +0000 Subject: [PATCH] Fix const warning and log formatting GetConfigOption returns a const char * and it was being handled without casting, since removal of pstrdup in the last version of the patch. Fix this by declaring the variable const char * per other examples in postgres. Additionally account for typical use of whitespace at the end of `log_line_prefix` variables by not adding an extra whitespace character between the old value and the audit tag. --- set_user.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/set_user.c b/set_user.c index c7efa08..94b6c38 100644 --- a/set_user.c +++ b/set_user.c @@ -360,14 +360,11 @@ set_user(PG_FUNCTION_ARGS) if (NewUser_is_superuser && Block_LS) { - char *new_log_prefix = NULL; - char *old_log_prefix = NULL; - - - old_log_prefix = GetConfigOption("log_line_prefix", true, false); + const char *old_log_prefix = GetConfigOption("log_line_prefix", true, false); + char *new_log_prefix = NULL; if (old_log_prefix) - new_log_prefix = psprintf("%s %s: ", old_log_prefix, SU_AuditTag); + new_log_prefix = psprintf("%s%s: ", old_log_prefix, SU_AuditTag); else new_log_prefix = pstrdup(SU_AuditTag);