From 04ca783e8f781b713e622330ce19bb6347696a78 Mon Sep 17 00:00:00 2001 From: ocean-dot-li Date: Thu, 16 Nov 2023 16:40:57 +0800 Subject: [PATCH] [Bug] fix log buffer inital issue In exec_execute_message(), we should initalize the log buffer at outermost layer. If not, crash may happen when trying to pfree its data member. This patch fixes the issue. --- src/backend/tcop/postgres.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 02a5b3992de..ea5c2675f5e 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -2354,13 +2354,15 @@ exec_execute_message(const char *portal_name, long max_rows) pq_putemptymessage('s'); } + /* POLAR: inital buf used by logging info. */ + initStringInfo(&buf); + if (to_log) { /* POLAR: get errmsg params string, we must free it in the last */ // It needs to malloc and free twice, not so efficiency. params_string = polar_get_errmsg_params(portalParams); - initStringInfo(&buf); if (polar_enable_log_search_path) appendStringInfo(&buf, "/*polardb %s polardb*/ ", namespace_search_path);