Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc730d65

Browse files
committed
Copy GUCs to threads
1 parentf0584d4 commitc730d65

File tree

2 files changed

+80
-65
lines changed

2 files changed

+80
-65
lines changed

‎src/backend/utils/misc/guc.c

Lines changed: 80 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -3853,6 +3853,20 @@ guc_malloc(int elevel, size_t size)
38533853
returndata;
38543854
}
38553855

3856+
staticvoid*
3857+
guc_clone(intelevel,voidconst*src,size_tsize)
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+
returndst;
3867+
}
3868+
3869+
38563870
staticvoid*
38573871
guc_realloc(intelevel,void*old,size_tsize)
38583872
{
@@ -4067,6 +4081,11 @@ build_guc_variables(void)
40674081
intnum_vars=0;
40684082
structconfig_generic**guc_vars;
40694083
inti;
4084+
structconfig_bool*bconf=ConfigureNamesBool;
4085+
structconfig_int*iconf=ConfigureNamesInt;
4086+
structconfig_real*rconf=ConfigureNamesReal;
4087+
structconfig_string*sconf=ConfigureNamesString;
4088+
structconfig_enum*econf=ConfigureNamesEnum;
40704089

40714090
for (i=0;ConfigureNamesBool[i].gen.name;i++)
40724091
{
@@ -4119,23 +4138,61 @@ build_guc_variables(void)
41194138

41204139
num_vars=0;
41214140

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= (structconfig_bool*)guc_clone(FATAL,ConfigureNamesBool,sizeof(ConfigureNamesBool));
4144+
iconf= (structconfig_int*)guc_clone(FATAL,ConfigureNamesInt,sizeof(ConfigureNamesInt));
4145+
rconf= (structconfig_real*)guc_clone(FATAL,ConfigureNamesReal,sizeof(ConfigureNamesReal));
4146+
sconf= (structconfig_string*)guc_clone(FATAL,ConfigureNamesString,sizeof(ConfigureNamesString));
4147+
econf= (structconfig_enum*)guc_clone(FATAL,ConfigureNamesEnum,sizeof(ConfigureNamesEnum));
4148+
}
41364149

4137-
if (guc_variables)
4138-
free(guc_variables);
4150+
for (i=0;bconf[i].gen.name;i++)
4151+
{
4152+
structconfig_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+
structconfig_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+
structconfig_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+
structconfig_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+
structconfig_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);
41394196
guc_variables=guc_vars;
41404197
num_guc_variables=num_vars;
41414198
size_guc_variables=size_vars;
@@ -4447,26 +4504,22 @@ InitializeOneGUCOption(struct config_generic *gconf)
44474504
casePGC_BOOL:
44484505
{
44494506
structconfig_bool*conf= (structconfig_bool*)gconf;
4450-
boolnewval=IsPostmaster ?conf->boot_val :conf->postmaster_val;
4507+
boolnewval=conf->boot_val;
44514508
void*extra=NULL;
44524509
if (!call_bool_check_hook(conf,&newval,&extra,
44534510
PGC_S_DEFAULT,LOG))
44544511
elog(FATAL,"failed to initialize %s to %d",
44554512
conf->gen.name, (int)newval);
44564513
if (conf->assign_hook)
44574514
conf->assign_hook(newval,extra);
4458-
if (conf->address_hook)
4459-
conf->variable=conf->address_hook();
44604515
*conf->variable=conf->reset_val=newval;
4461-
if (IsPostmaster)
4462-
conf->postmaster_val=newval;
44634516
conf->gen.extra=conf->reset_extra=extra;
44644517
break;
44654518
}
44664519
casePGC_INT:
44674520
{
44684521
structconfig_int*conf= (structconfig_int*)gconf;
4469-
intnewval=IsPostmaster ?conf->boot_val :conf->postmaster_val;
4522+
intnewval=conf->boot_val;
44704523
void*extra=NULL;
44714524

44724525
Assert(newval >=conf->min);
@@ -4477,18 +4530,14 @@ InitializeOneGUCOption(struct config_generic *gconf)
44774530
conf->gen.name,newval);
44784531
if (conf->assign_hook)
44794532
conf->assign_hook(newval,extra);
4480-
if (conf->address_hook)
4481-
conf->variable=conf->address_hook();
44824533
*conf->variable=conf->reset_val=newval;
4483-
if (IsPostmaster)
4484-
conf->postmaster_val=newval;
44854534
conf->gen.extra=conf->reset_extra=extra;
44864535
break;
44874536
}
44884537
casePGC_REAL:
44894538
{
44904539
structconfig_real*conf= (structconfig_real*)gconf;
4491-
doublenewval=IsPostmaster ?conf->boot_val :conf->postmaster_val;
4540+
doublenewval=conf->boot_val;
44924541
void*extra=NULL;
44934542

44944543
Assert(newval >=conf->min);
@@ -4499,11 +4548,7 @@ InitializeOneGUCOption(struct config_generic *gconf)
44994548
conf->gen.name,newval);
45004549
if (conf->assign_hook)
45014550
conf->assign_hook(newval,extra);
4502-
if (conf->address_hook)
4503-
conf->variable=conf->address_hook();
45044551
*conf->variable=conf->reset_val=newval;
4505-
if (IsPostmaster)
4506-
conf->postmaster_val=newval;
45074552
conf->gen.extra=conf->reset_extra=extra;
45084553
break;
45094554
}
@@ -4514,40 +4559,25 @@ InitializeOneGUCOption(struct config_generic *gconf)
45144559
void*extra=NULL;
45154560

45164561
/* 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);
45244564
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;
45324566

45334567
if (!call_string_check_hook(conf,&newval,&extra,
45344568
PGC_S_DEFAULT,LOG))
45354569
elog(FATAL,"failed to initialize %s to \"%s\"",
45364570
conf->gen.name,newval ?newval :"");
45374571
if (conf->assign_hook)
45384572
conf->assign_hook(newval,extra);
4539-
if (conf->address_hook)
4540-
conf->variable=conf->address_hook();
45414573
*conf->variable=conf->reset_val=newval;
4542-
if (IsPostmaster)
4543-
conf->postmaster_val=newval;
45444574
conf->gen.extra=conf->reset_extra=extra;
45454575
break;
45464576
}
45474577
casePGC_ENUM:
45484578
{
45494579
structconfig_enum*conf= (structconfig_enum*)gconf;
4550-
intnewval=IsPostmaster ?conf->boot_val :conf->postmaster_val;
4580+
intnewval=conf->boot_val;
45514581
void*extra=NULL;
45524582

45534583
if (!call_enum_check_hook(conf,&newval,&extra,
@@ -4556,11 +4586,7 @@ InitializeOneGUCOption(struct config_generic *gconf)
45564586
conf->gen.name,newval);
45574587
if (conf->assign_hook)
45584588
conf->assign_hook(newval,extra);
4559-
if (conf->address_hook)
4560-
conf->variable=conf->address_hook();
45614589
*conf->variable=conf->reset_val=newval;
4562-
if (IsPostmaster)
4563-
conf->postmaster_val=newval;
45644590
conf->gen.extra=conf->reset_extra=extra;
45654591
break;
45664592
}
@@ -6096,8 +6122,6 @@ set_config_option(const char *name, const char *value,
60966122
if (conf->assign_hook)
60976123
conf->assign_hook(newval,newextra);
60986124
*conf->variable=newval;
6099-
if (IsPostmaster)
6100-
conf->postmaster_val=newval;
61016125
set_extra_field(&conf->gen,&conf->gen.extra,
61026126
newextra);
61036127
conf->gen.source=source;
@@ -6188,8 +6212,6 @@ set_config_option(const char *name, const char *value,
61886212
if (conf->assign_hook)
61896213
conf->assign_hook(newval,newextra);
61906214
*conf->variable=newval;
6191-
if (IsPostmaster)
6192-
conf->postmaster_val=newval;
61936215
set_extra_field(&conf->gen,&conf->gen.extra,
61946216
newextra);
61956217
conf->gen.source=source;
@@ -6280,8 +6302,6 @@ set_config_option(const char *name, const char *value,
62806302
if (conf->assign_hook)
62816303
conf->assign_hook(newval,newextra);
62826304
*conf->variable=newval;
6283-
if (IsPostmaster)
6284-
conf->postmaster_val=newval;
62856305
set_extra_field(&conf->gen,&conf->gen.extra,
62866306
newextra);
62876307
conf->gen.source=source;
@@ -6390,8 +6410,6 @@ set_config_option(const char *name, const char *value,
63906410
if (conf->assign_hook)
63916411
conf->assign_hook(newval,newextra);
63926412
set_string_field(conf,conf->variable,newval);
6393-
if (IsPostmaster)
6394-
conf->postmaster_val=*conf->variable;
63956413
set_extra_field(&conf->gen,&conf->gen.extra,
63966414
newextra);
63976415
conf->gen.source=source;
@@ -6487,8 +6505,6 @@ set_config_option(const char *name, const char *value,
64876505
if (conf->assign_hook)
64886506
conf->assign_hook(newval,newextra);
64896507
*conf->variable=newval;
6490-
if (IsPostmaster)
6491-
conf->postmaster_val=newval;
64926508
set_extra_field(&conf->gen,&conf->gen.extra,
64936509
newextra);
64946510
conf->gen.source=source;

‎src/include/utils/guc_tables.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ struct config_bool
187187
/* variable fields, initialized at runtime: */
188188
boolreset_val;
189189
void*reset_extra;
190-
boolpostmaster_val;
191190
};
192191

193192
structconfig_int

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp