diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index bd03965a75..22d43287e3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -8965,7 +8965,14 @@ get_explain_guc_options(int *num) { struct config_string *lconf = (struct config_string *) conf; - modified = (strcmp(lconf->boot_val, *(lconf->variable)) != 0); + if (lconf->boot_val == NULL && + *lconf->variable == NULL) + modified = false; + else if (lconf->boot_val == NULL || + *lconf->variable == NULL) + modified = true; + else + modified = (strcmp(lconf->boot_val, *(lconf->variable)) != 0); } break; @@ -9720,7 +9727,8 @@ write_one_nondefault_variable(FILE *fp, struct config_generic *gconf) { struct config_string *conf = (struct config_string *) gconf; - fprintf(fp, "%s", *conf->variable); + if (*conf->variable) + fprintf(fp, "%s", *conf->variable); } break; diff --git a/src/include/utils/guc_tables.h b/src/include/utils/guc_tables.h index d68976fafa..8b842fca5f 100644 --- a/src/include/utils/guc_tables.h +++ b/src/include/utils/guc_tables.h @@ -223,6 +223,16 @@ struct config_real void *reset_extra; }; +/* + * A note about string GUCs: the boot_val is allowed to be NULL, which leads + * to the reset_val and the actual variable value (*variable) also being NULL. + * However, there is no way to set a NULL value subsequently using + * set_config_option or any other GUC API. Also, GUC APIs such as SHOW will + * display a NULL value as an empty string. Callers that choose to use a NULL + * boot_val should overwrite the setting later in startup, or else be careful + * that NULL doesn't have semantics that are visibly different from an empty + * string. + */ struct config_string { struct config_generic gen;