@@ -3853,6 +3853,20 @@ guc_malloc(int elevel, size_t size)
3853
3853
return data ;
3854
3854
}
3855
3855
3856
+ static void *
3857
+ guc_clone (int elevel ,void const * src ,size_t size )
3858
+ {
3859
+ void * dst ;
3860
+ dst = malloc (size );
3861
+ if (dst == NULL )
3862
+ ereport (elevel ,
3863
+ (errcode (ERRCODE_OUT_OF_MEMORY ),
3864
+ errmsg ("out of memory" )));
3865
+ memcpy (dst ,src ,size );
3866
+ return dst ;
3867
+ }
3868
+
3869
+
3856
3870
static void *
3857
3871
guc_realloc (int elevel ,void * old ,size_t size )
3858
3872
{
@@ -4067,6 +4081,11 @@ build_guc_variables(void)
4067
4081
int num_vars = 0 ;
4068
4082
struct config_generic * * guc_vars ;
4069
4083
int i ;
4084
+ struct config_bool * bconf = ConfigureNamesBool ;
4085
+ struct config_int * iconf = ConfigureNamesInt ;
4086
+ struct config_real * rconf = ConfigureNamesReal ;
4087
+ struct config_string * sconf = ConfigureNamesString ;
4088
+ struct config_enum * econf = ConfigureNamesEnum ;
4070
4089
4071
4090
for (i = 0 ;ConfigureNamesBool [i ].gen .name ;i ++ )
4072
4091
{
@@ -4119,23 +4138,61 @@ build_guc_variables(void)
4119
4138
4120
4139
num_vars = 0 ;
4121
4140
4122
- for (i = 0 ;ConfigureNamesBool [i ].gen .name ;i ++ )
4123
- guc_vars [num_vars ++ ]= & ConfigureNamesBool [i ].gen ;
4124
-
4125
- for (i = 0 ;ConfigureNamesInt [i ].gen .name ;i ++ )
4126
- guc_vars [num_vars ++ ]= & ConfigureNamesInt [i ].gen ;
4127
-
4128
- for (i = 0 ;ConfigureNamesReal [i ].gen .name ;i ++ )
4129
- guc_vars [num_vars ++ ]= & ConfigureNamesReal [i ].gen ;
4130
-
4131
- for (i = 0 ;ConfigureNamesString [i ].gen .name ;i ++ )
4132
- guc_vars [num_vars ++ ]= & ConfigureNamesString [i ].gen ;
4133
-
4134
- for (i = 0 ;ConfigureNamesEnum [i ].gen .name ;i ++ )
4135
- guc_vars [num_vars ++ ]= & ConfigureNamesEnum [i ].gen ;
4141
+ if (!IsPostmaster )
4142
+ {
4143
+ bconf = (struct config_bool * )guc_clone (FATAL ,ConfigureNamesBool ,sizeof (ConfigureNamesBool ));
4144
+ iconf = (struct config_int * )guc_clone (FATAL ,ConfigureNamesInt ,sizeof (ConfigureNamesInt ));
4145
+ rconf = (struct config_real * )guc_clone (FATAL ,ConfigureNamesReal ,sizeof (ConfigureNamesReal ));
4146
+ sconf = (struct config_string * )guc_clone (FATAL ,ConfigureNamesString ,sizeof (ConfigureNamesString ));
4147
+ econf = (struct config_enum * )guc_clone (FATAL ,ConfigureNamesEnum ,sizeof (ConfigureNamesEnum ));
4148
+ }
4136
4149
4137
- if (guc_variables )
4138
- free (guc_variables );
4150
+ for (i = 0 ;bconf [i ].gen .name ;i ++ )
4151
+ {
4152
+ struct config_bool * conf = & bconf [i ];
4153
+ if (conf -> address_hook )
4154
+ conf -> variable = conf -> address_hook ();
4155
+ if (conf -> variable && !IsPostmaster )
4156
+ conf -> boot_val = * ConfigureNamesBool [i ].variable ;
4157
+ guc_vars [num_vars ++ ]= & conf -> gen ;
4158
+ }
4159
+ for (i = 0 ;iconf [i ].gen .name ;i ++ )
4160
+ {
4161
+ struct config_int * conf = & iconf [i ];
4162
+ if (conf -> address_hook )
4163
+ conf -> variable = conf -> address_hook ();
4164
+ if (conf -> variable && !IsPostmaster )
4165
+ conf -> boot_val = * ConfigureNamesInt [i ].variable ;
4166
+ guc_vars [num_vars ++ ]= & conf -> gen ;
4167
+ }
4168
+ for (i = 0 ;rconf [i ].gen .name ;i ++ )
4169
+ {
4170
+ struct config_real * conf = & rconf [i ];
4171
+ if (conf -> address_hook )
4172
+ conf -> variable = conf -> address_hook ();
4173
+ if (conf -> variable && !IsPostmaster )
4174
+ conf -> boot_val = * ConfigureNamesReal [i ].variable ;
4175
+ guc_vars [num_vars ++ ]= & conf -> gen ;
4176
+ }
4177
+ for (i = 0 ;sconf [i ].gen .name ;i ++ )
4178
+ {
4179
+ struct config_string * conf = & sconf [i ];
4180
+ if (conf -> address_hook )
4181
+ conf -> variable = conf -> address_hook ();
4182
+ if (conf -> variable && !IsPostmaster )
4183
+ conf -> boot_val = * ConfigureNamesString [i ].variable ;
4184
+ guc_vars [num_vars ++ ]= & conf -> gen ;
4185
+ }
4186
+ for (i = 0 ;econf [i ].gen .name ;i ++ )
4187
+ {
4188
+ struct config_enum * conf = & econf [i ];
4189
+ if (conf -> address_hook )
4190
+ conf -> variable = conf -> address_hook ();
4191
+ if (conf -> variable && !IsPostmaster )
4192
+ conf -> boot_val = * ConfigureNamesEnum [i ].variable ;
4193
+ guc_vars [num_vars ++ ]= & conf -> gen ;
4194
+ }
4195
+ free (guc_variables );
4139
4196
guc_variables = guc_vars ;
4140
4197
num_guc_variables = num_vars ;
4141
4198
size_guc_variables = size_vars ;
@@ -4447,26 +4504,22 @@ InitializeOneGUCOption(struct config_generic *gconf)
4447
4504
case PGC_BOOL :
4448
4505
{
4449
4506
struct config_bool * conf = (struct config_bool * )gconf ;
4450
- bool newval = IsPostmaster ? conf -> boot_val : conf -> postmaster_val ;
4507
+ bool newval = conf -> boot_val ;
4451
4508
void * extra = NULL ;
4452
4509
if (!call_bool_check_hook (conf ,& newval ,& extra ,
4453
4510
PGC_S_DEFAULT ,LOG ))
4454
4511
elog (FATAL ,"failed to initialize %s to %d" ,
4455
4512
conf -> gen .name , (int )newval );
4456
4513
if (conf -> assign_hook )
4457
4514
conf -> assign_hook (newval ,extra );
4458
- if (conf -> address_hook )
4459
- conf -> variable = conf -> address_hook ();
4460
4515
* conf -> variable = conf -> reset_val = newval ;
4461
- if (IsPostmaster )
4462
- conf -> postmaster_val = newval ;
4463
4516
conf -> gen .extra = conf -> reset_extra = extra ;
4464
4517
break ;
4465
4518
}
4466
4519
case PGC_INT :
4467
4520
{
4468
4521
struct config_int * conf = (struct config_int * )gconf ;
4469
- int newval = IsPostmaster ? conf -> boot_val : conf -> postmaster_val ;
4522
+ int newval = conf -> boot_val ;
4470
4523
void * extra = NULL ;
4471
4524
4472
4525
Assert (newval >=conf -> min );
@@ -4477,18 +4530,14 @@ InitializeOneGUCOption(struct config_generic *gconf)
4477
4530
conf -> gen .name ,newval );
4478
4531
if (conf -> assign_hook )
4479
4532
conf -> assign_hook (newval ,extra );
4480
- if (conf -> address_hook )
4481
- conf -> variable = conf -> address_hook ();
4482
4533
* conf -> variable = conf -> reset_val = newval ;
4483
- if (IsPostmaster )
4484
- conf -> postmaster_val = newval ;
4485
4534
conf -> gen .extra = conf -> reset_extra = extra ;
4486
4535
break ;
4487
4536
}
4488
4537
case PGC_REAL :
4489
4538
{
4490
4539
struct config_real * conf = (struct config_real * )gconf ;
4491
- double newval = IsPostmaster ? conf -> boot_val : conf -> postmaster_val ;
4540
+ double newval = conf -> boot_val ;
4492
4541
void * extra = NULL ;
4493
4542
4494
4543
Assert (newval >=conf -> min );
@@ -4499,11 +4548,7 @@ InitializeOneGUCOption(struct config_generic *gconf)
4499
4548
conf -> gen .name ,newval );
4500
4549
if (conf -> assign_hook )
4501
4550
conf -> assign_hook (newval ,extra );
4502
- if (conf -> address_hook )
4503
- conf -> variable = conf -> address_hook ();
4504
4551
* conf -> variable = conf -> reset_val = newval ;
4505
- if (IsPostmaster )
4506
- conf -> postmaster_val = newval ;
4507
4552
conf -> gen .extra = conf -> reset_extra = extra ;
4508
4553
break ;
4509
4554
}
@@ -4514,40 +4559,25 @@ InitializeOneGUCOption(struct config_generic *gconf)
4514
4559
void * extra = NULL ;
4515
4560
4516
4561
/* non-NULL boot_val must always get strdup'd */
4517
- if (IsPostmaster )
4518
- {
4519
- if (conf -> boot_val != NULL )
4520
- newval = guc_strdup (FATAL ,conf -> boot_val );
4521
- else
4522
- newval = NULL ;
4523
- }
4562
+ if (conf -> boot_val != NULL )
4563
+ newval = guc_strdup (FATAL ,conf -> boot_val );
4524
4564
else
4525
- {
4526
- if (conf -> postmaster_val != NULL )
4527
- newval = guc_strdup (FATAL ,conf -> postmaster_val );
4528
- else
4529
- newval = NULL ;
4530
- }
4531
-
4565
+ newval = NULL ;
4532
4566
4533
4567
if (!call_string_check_hook (conf ,& newval ,& extra ,
4534
4568
PGC_S_DEFAULT ,LOG ))
4535
4569
elog (FATAL ,"failed to initialize %s to \"%s\"" ,
4536
4570
conf -> gen .name ,newval ?newval :"" );
4537
4571
if (conf -> assign_hook )
4538
4572
conf -> assign_hook (newval ,extra );
4539
- if (conf -> address_hook )
4540
- conf -> variable = conf -> address_hook ();
4541
4573
* conf -> variable = conf -> reset_val = newval ;
4542
- if (IsPostmaster )
4543
- conf -> postmaster_val = newval ;
4544
4574
conf -> gen .extra = conf -> reset_extra = extra ;
4545
4575
break ;
4546
4576
}
4547
4577
case PGC_ENUM :
4548
4578
{
4549
4579
struct config_enum * conf = (struct config_enum * )gconf ;
4550
- int newval = IsPostmaster ? conf -> boot_val : conf -> postmaster_val ;
4580
+ int newval = conf -> boot_val ;
4551
4581
void * extra = NULL ;
4552
4582
4553
4583
if (!call_enum_check_hook (conf ,& newval ,& extra ,
@@ -4556,11 +4586,7 @@ InitializeOneGUCOption(struct config_generic *gconf)
4556
4586
conf -> gen .name ,newval );
4557
4587
if (conf -> assign_hook )
4558
4588
conf -> assign_hook (newval ,extra );
4559
- if (conf -> address_hook )
4560
- conf -> variable = conf -> address_hook ();
4561
4589
* conf -> variable = conf -> reset_val = newval ;
4562
- if (IsPostmaster )
4563
- conf -> postmaster_val = newval ;
4564
4590
conf -> gen .extra = conf -> reset_extra = extra ;
4565
4591
break ;
4566
4592
}
@@ -6096,8 +6122,6 @@ set_config_option(const char *name, const char *value,
6096
6122
if (conf -> assign_hook )
6097
6123
conf -> assign_hook (newval ,newextra );
6098
6124
* conf -> variable = newval ;
6099
- if (IsPostmaster )
6100
- conf -> postmaster_val = newval ;
6101
6125
set_extra_field (& conf -> gen ,& conf -> gen .extra ,
6102
6126
newextra );
6103
6127
conf -> gen .source = source ;
@@ -6188,8 +6212,6 @@ set_config_option(const char *name, const char *value,
6188
6212
if (conf -> assign_hook )
6189
6213
conf -> assign_hook (newval ,newextra );
6190
6214
* conf -> variable = newval ;
6191
- if (IsPostmaster )
6192
- conf -> postmaster_val = newval ;
6193
6215
set_extra_field (& conf -> gen ,& conf -> gen .extra ,
6194
6216
newextra );
6195
6217
conf -> gen .source = source ;
@@ -6280,8 +6302,6 @@ set_config_option(const char *name, const char *value,
6280
6302
if (conf -> assign_hook )
6281
6303
conf -> assign_hook (newval ,newextra );
6282
6304
* conf -> variable = newval ;
6283
- if (IsPostmaster )
6284
- conf -> postmaster_val = newval ;
6285
6305
set_extra_field (& conf -> gen ,& conf -> gen .extra ,
6286
6306
newextra );
6287
6307
conf -> gen .source = source ;
@@ -6390,8 +6410,6 @@ set_config_option(const char *name, const char *value,
6390
6410
if (conf -> assign_hook )
6391
6411
conf -> assign_hook (newval ,newextra );
6392
6412
set_string_field (conf ,conf -> variable ,newval );
6393
- if (IsPostmaster )
6394
- conf -> postmaster_val = * conf -> variable ;
6395
6413
set_extra_field (& conf -> gen ,& conf -> gen .extra ,
6396
6414
newextra );
6397
6415
conf -> gen .source = source ;
@@ -6487,8 +6505,6 @@ set_config_option(const char *name, const char *value,
6487
6505
if (conf -> assign_hook )
6488
6506
conf -> assign_hook (newval ,newextra );
6489
6507
* conf -> variable = newval ;
6490
- if (IsPostmaster )
6491
- conf -> postmaster_val = newval ;
6492
6508
set_extra_field (& conf -> gen ,& conf -> gen .extra ,
6493
6509
newextra );
6494
6510
conf -> gen .source = source ;