@@ -46,11 +46,13 @@ static bool pg_include_config(const char *configFilePath,
4646static bool ensure_default_settings_file_exists (const char * configFilePath ,
4747 GUC * settings ,
4848 PostgresSetup * pgSetup ,
49+ const char * hostname ,
4950 bool includeTuning );
5051static bool prepare_guc_settings_from_pgsetup (const char * configFilePath ,
5152 PQExpBuffer config ,
5253 GUC * settings ,
5354 PostgresSetup * pgSetup ,
55+ const char * hostname ,
5456 bool includeTuning );
5557static void log_program_output (Program prog , int outLogLevel , int errorLogLevel );
5658
@@ -731,7 +733,8 @@ find_extension_control_file(const char *pg_ctl, const char *extName)
731733 */
732734bool
733735pg_add_auto_failover_default_settings (PostgresSetup * pgSetup ,
734- char * configFilePath ,
736+ const char * hostname ,
737+ const char * configFilePath ,
735738 GUC * settings )
736739{
737740 bool includeTuning = true;
@@ -750,6 +753,7 @@ pg_add_auto_failover_default_settings(PostgresSetup *pgSetup,
750753 if (!ensure_default_settings_file_exists (pgAutoFailoverDefaultsConfigPath ,
751754 settings ,
752755 pgSetup ,
756+ hostname ,
753757 includeTuning ))
754758 {
755759 return false;
@@ -870,6 +874,7 @@ static bool
870874ensure_default_settings_file_exists (const char * configFilePath ,
871875 GUC * settings ,
872876 PostgresSetup * pgSetup ,
877+ const char * hostname ,
873878 bool includeTuning )
874879{
875880 PQExpBuffer defaultConfContents = createPQExpBuffer ();
@@ -884,6 +889,7 @@ ensure_default_settings_file_exists(const char *configFilePath,
884889 defaultConfContents ,
885890 settings ,
886891 pgSetup ,
892+ hostname ,
887893 includeTuning ))
888894 {
889895 /* errors have already been logged */
@@ -957,6 +963,7 @@ prepare_guc_settings_from_pgsetup(const char *configFilePath,
957963 PQExpBuffer config ,
958964 GUC * settings ,
959965 PostgresSetup * pgSetup ,
966+ const char * hostname ,
960967 bool includeTuning )
961968{
962969 char tuning [BUFSIZE ] = { 0 };
@@ -1101,14 +1108,23 @@ prepare_guc_settings_from_pgsetup(const char *configFilePath,
11011108 setting -> name , pgSetup -> citusClusterName );
11021109 }
11031110 }
1111+ else if (streq (setting -> name , "citus.local_hostname" ))
1112+ {
1113+ if (hostname != NULL && !IS_EMPTY_STRING_BUFFER (hostname ))
1114+ {
1115+ appendPQExpBuffer (config , "%s = '%s'\n" ,
1116+ setting -> name , hostname );
1117+ }
1118+ }
11041119 else if (setting -> value != NULL &&
11051120 !IS_EMPTY_STRING_BUFFER (setting -> value ))
11061121 {
11071122 appendPQExpBuffer (config , "%s = %s\n" ,
11081123 setting -> name ,
11091124 setting -> value );
11101125 }
1111- else
1126+ else if (setting -> value == NULL ||
1127+ IS_EMPTY_STRING_BUFFER (setting -> value ))
11121128 {
11131129 /*
11141130 * Our GUC entry has a NULL (or empty) value. Skip the setting.
@@ -1122,6 +1138,13 @@ prepare_guc_settings_from_pgsetup(const char *configFilePath,
11221138 */
11231139 log_debug ("GUC setting \"%s\" has a NULL value" , setting -> name );
11241140 }
1141+ else
1142+ {
1143+ /* the GUC setting in the array has not been processed */
1144+ log_error ("BUG: GUC settings \"%s\" has not been processed" ,
1145+ setting -> name );
1146+ return false;
1147+ }
11251148 }
11261149
11271150 if (includeTuning )
@@ -2004,6 +2027,7 @@ pg_write_recovery_conf(const char *pgdata, ReplicationSource *replicationSource)
20042027 return ensure_default_settings_file_exists (recoveryConfPath ,
20052028 recoverySettings ,
20062029 NULL ,
2030+ NULL ,
20072031 includeTuning );
20082032}
20092033
@@ -2103,6 +2127,7 @@ pg_write_standby_signal(const char *pgdata,
21032127 if (!ensure_default_settings_file_exists (standbyConfigFilePath ,
21042128 recoverySettings ,
21052129 NULL ,
2130+ NULL ,
21062131 includeTuning ))
21072132 {
21082133 return false;
0 commit comments