From ae9b665579d43e80539ba9f1c2865293265d99d4 Mon Sep 17 00:00:00 2001 From: tilkow Date: Thu, 29 Jun 2023 15:14:19 +0000 Subject: [PATCH] add NULL test on GetConfigOption() --- pg_query_settings.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pg_query_settings.c b/pg_query_settings.c index af20cb4..b286e1f 100644 --- a/pg_query_settings.c +++ b/pg_query_settings.c @@ -157,6 +157,7 @@ execPlantuner(Query *parse, const char *query_st, int cursorOptions, ParamListIn int64 id; char *guc_value = NULL; char *guc_name = NULL; + const char *oldValue = NULL; parameter *param = NULL; uint64 queryid = 0; @@ -213,7 +214,13 @@ execPlantuner(Query *parse, const char *query_st, int cursorOptions, ParamListIn param->name = pstrdup(guc_name); /* Get and store current value for the parameter. */ - param->oldValue = pstrdup(GetConfigOption(guc_name, true, false)); + oldValue = GetConfigOption(guc_name, true, false); + if (oldValue == NULL) + { + elog(WARNING, "Parameter %s does not exists", guc_name); + continue; + } + param->oldValue = pstrdup(oldValue); slist_push_head(¶mResetList, ¶m->node);