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

Commitf46f2c0

Browse files
tglsfdcpull[bot]
authored andcommitted
Split up guc.c for better build speed and ease of maintenance.
guc.c has grown to be one of our largest .c files, making ita bottleneck for compilation. It's also acquired a bunch ofknowledge that'd be better kept elsewhere, because of our notvery good habit of putting variable-specific check hooks here.Hence, split it up along these lines:* guc.c itself retains just the core GUC housekeeping mechanisms.* New file guc_funcs.c contains the SET/SHOW interfaces and some SQL-accessible functions for GUC manipulation.* New file guc_tables.c contains the data arrays that define the built-in GUC variables, along with some already-exported constant tables.* GUC check/assign/show hook functions are moved to the variable's home module, whenever that's clearly identifiable. A few hard- to-classify hooks ended up in commands/variable.c, which was already a home for miscellaneous GUC hook functions.To avoid cluttering a lot more header files with #include "guc.h",I also invented a new header file utils/guc_hooks.h and put allthe GUC hook functions' declarations there, regardless of theiroriginating module. That allowed removal of #include "guc.h"from some existing headers. The fallout from that (hopefullyall caught here) demonstrates clearly why such inclusions arebest minimized: there are a lot of files that, for example,were getting array.h at two or more levels of remove, despitenot having any connection at all to GUCs in themselves.There is some very minor code beautification here, such asrenaming a couple of inconsistently-named hook functionsand improving some comments. But mostly this just movescode from point A to point B and deals with the ensuingneeds for #include adjustments and exporting a few functionsthat previously weren't exported.Patch by me, per a suggestion from Andres Freund; thanks alsoto Michael Paquier for the idea to invent guc_funcs.c.Discussion:https://postgr.es/m/587607.1662836699@sss.pgh.pa.us
1 parent6d8ee25 commitf46f2c0

File tree

59 files changed

+12591
-12253
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+12591
-12253
lines changed

‎contrib/amcheck/verify_nbtree.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include"miscadmin.h"
3838
#include"storage/lmgr.h"
3939
#include"storage/smgr.h"
40+
#include"utils/guc.h"
4041
#include"utils/memutils.h"
4142
#include"utils/snapmgr.h"
4243

‎contrib/ltree/_ltree_gist.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include"crc32.h"
1414
#include"ltree.h"
1515
#include"port/pg_bitutils.h"
16+
#include"utils/array.h"
1617

1718
PG_FUNCTION_INFO_V1(_ltree_compress);
1819
PG_FUNCTION_INFO_V1(_ltree_same);

‎contrib/ltree/_ltree_op.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include<ctype.h>
1111

1212
#include"ltree.h"
13+
#include"utils/array.h"
1314

1415
PG_FUNCTION_INFO_V1(_ltree_isparent);
1516
PG_FUNCTION_INFO_V1(_ltree_r_isparent);

‎contrib/ltree/lquery_op.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include"catalog/pg_collation.h"
1111
#include"ltree.h"
1212
#include"miscadmin.h"
13+
#include"utils/array.h"
1314
#include"utils/formatting.h"
1415

1516
PG_FUNCTION_INFO_V1(ltq_regex);

‎contrib/ltree/ltree_gist.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include"access/stratnum.h"
1111
#include"crc32.h"
1212
#include"ltree.h"
13+
#include"utils/array.h"
1314

1415
#defineNEXTVAL(x) ( (lquery*)( (char*)(x) + INTALIGN( VARSIZE(x) ) ) )
1516
#defineISEQ(a,b)( (a)->numlevel == (b)->numlevel && ltree_compare(a,b)==0 )

‎contrib/pg_surgery/heap_surgery.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include"miscadmin.h"
2121
#include"storage/bufmgr.h"
2222
#include"utils/acl.h"
23+
#include"utils/array.h"
2324
#include"utils/rel.h"
2425

2526
PG_MODULE_MAGIC;

‎contrib/pg_trgm/trgm_op.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include"miscadmin.h"
1111
#include"trgm.h"
1212
#include"tsearch/ts_locale.h"
13+
#include"utils/guc.h"
1314
#include"utils/lsyscache.h"
1415
#include"utils/memutils.h"
1516
#include"utils/pg_crc.h"

‎src/backend/access/brin/brin.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include"utils/acl.h"
3737
#include"utils/builtins.h"
3838
#include"utils/datum.h"
39+
#include"utils/guc.h"
3940
#include"utils/index_selfuncs.h"
4041
#include"utils/memutils.h"
4142
#include"utils/rel.h"

‎src/backend/access/table/tableamapi.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include"commands/defrem.h"
2121
#include"miscadmin.h"
2222
#include"utils/fmgroids.h"
23+
#include"utils/guc_hooks.h"
2324
#include"utils/memutils.h"
2425
#include"utils/syscache.h"
2526

‎src/backend/access/transam/xlog.c

Lines changed: 175 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,16 @@
9797
#include"storage/smgr.h"
9898
#include"storage/spin.h"
9999
#include"storage/sync.h"
100-
#include"utils/guc.h"
100+
#include"utils/guc_hooks.h"
101+
#include"utils/guc_tables.h"
101102
#include"utils/memutils.h"
102103
#include"utils/ps_status.h"
103104
#include"utils/relmapper.h"
104105
#include"utils/pg_rusage.h"
105106
#include"utils/snapmgr.h"
106107
#include"utils/timeout.h"
107108
#include"utils/timestamp.h"
109+
#include"utils/varlena.h"
108110

109111
externuint32bootstrap_data_checksum_version;
110112

@@ -160,6 +162,12 @@ intCheckPointSegments;
160162
staticdoubleCheckPointDistanceEstimate=0;
161163
staticdoublePrevCheckPointDistance=0;
162164

165+
/*
166+
* Track whether there were any deferred checks for custom resource managers
167+
* specified in wal_consistency_checking.
168+
*/
169+
staticboolcheck_wal_consistency_checking_deferred= false;
170+
163171
/*
164172
* GUC support
165173
*/
@@ -4304,6 +4312,172 @@ check_wal_buffers(int *newval, void **extra, GucSource source)
43044312
return true;
43054313
}
43064314

4315+
/*
4316+
* GUC check_hook for wal_consistency_checking
4317+
*/
4318+
bool
4319+
check_wal_consistency_checking(char**newval,void**extra,GucSourcesource)
4320+
{
4321+
char*rawstring;
4322+
List*elemlist;
4323+
ListCell*l;
4324+
boolnewwalconsistency[RM_MAX_ID+1];
4325+
4326+
/* Initialize the array */
4327+
MemSet(newwalconsistency,0, (RM_MAX_ID+1)*sizeof(bool));
4328+
4329+
/* Need a modifiable copy of string */
4330+
rawstring=pstrdup(*newval);
4331+
4332+
/* Parse string into list of identifiers */
4333+
if (!SplitIdentifierString(rawstring,',',&elemlist))
4334+
{
4335+
/* syntax error in list */
4336+
GUC_check_errdetail("List syntax is invalid.");
4337+
pfree(rawstring);
4338+
list_free(elemlist);
4339+
return false;
4340+
}
4341+
4342+
foreach(l,elemlist)
4343+
{
4344+
char*tok= (char*)lfirst(l);
4345+
intrmid;
4346+
4347+
/* Check for 'all'. */
4348+
if (pg_strcasecmp(tok,"all")==0)
4349+
{
4350+
for (rmid=0;rmid <=RM_MAX_ID;rmid++)
4351+
if (RmgrIdExists(rmid)&&GetRmgr(rmid).rm_mask!=NULL)
4352+
newwalconsistency[rmid]= true;
4353+
}
4354+
else
4355+
{
4356+
/* Check if the token matches any known resource manager. */
4357+
boolfound= false;
4358+
4359+
for (rmid=0;rmid <=RM_MAX_ID;rmid++)
4360+
{
4361+
if (RmgrIdExists(rmid)&&GetRmgr(rmid).rm_mask!=NULL&&
4362+
pg_strcasecmp(tok,GetRmgr(rmid).rm_name)==0)
4363+
{
4364+
newwalconsistency[rmid]= true;
4365+
found= true;
4366+
break;
4367+
}
4368+
}
4369+
if (!found)
4370+
{
4371+
/*
4372+
* During startup, it might be a not-yet-loaded custom
4373+
* resource manager. Defer checking until
4374+
* InitializeWalConsistencyChecking().
4375+
*/
4376+
if (!process_shared_preload_libraries_done)
4377+
{
4378+
check_wal_consistency_checking_deferred= true;
4379+
}
4380+
else
4381+
{
4382+
GUC_check_errdetail("Unrecognized key word: \"%s\".",tok);
4383+
pfree(rawstring);
4384+
list_free(elemlist);
4385+
return false;
4386+
}
4387+
}
4388+
}
4389+
}
4390+
4391+
pfree(rawstring);
4392+
list_free(elemlist);
4393+
4394+
/* assign new value */
4395+
*extra=guc_malloc(ERROR, (RM_MAX_ID+1)*sizeof(bool));
4396+
memcpy(*extra,newwalconsistency, (RM_MAX_ID+1)*sizeof(bool));
4397+
return true;
4398+
}
4399+
4400+
/*
4401+
* GUC assign_hook for wal_consistency_checking
4402+
*/
4403+
void
4404+
assign_wal_consistency_checking(constchar*newval,void*extra)
4405+
{
4406+
/*
4407+
* If some checks were deferred, it's possible that the checks will fail
4408+
* later during InitializeWalConsistencyChecking(). But in that case, the
4409+
* postmaster will exit anyway, so it's safe to proceed with the
4410+
* assignment.
4411+
*
4412+
* Any built-in resource managers specified are assigned immediately,
4413+
* which affects WAL created before shared_preload_libraries are
4414+
* processed. Any custom resource managers specified won't be assigned
4415+
* until after shared_preload_libraries are processed, but that's OK
4416+
* because WAL for a custom resource manager can't be written before the
4417+
* module is loaded anyway.
4418+
*/
4419+
wal_consistency_checking=extra;
4420+
}
4421+
4422+
/*
4423+
* InitializeWalConsistencyChecking: run after loading custom resource managers
4424+
*
4425+
* If any unknown resource managers were specified in the
4426+
* wal_consistency_checking GUC, processing was deferred. Now that
4427+
* shared_preload_libraries have been loaded, process wal_consistency_checking
4428+
* again.
4429+
*/
4430+
void
4431+
InitializeWalConsistencyChecking(void)
4432+
{
4433+
Assert(process_shared_preload_libraries_done);
4434+
4435+
if (check_wal_consistency_checking_deferred)
4436+
{
4437+
structconfig_generic*guc;
4438+
4439+
guc=find_option("wal_consistency_checking", false, false,ERROR);
4440+
4441+
check_wal_consistency_checking_deferred= false;
4442+
4443+
set_config_option_ext("wal_consistency_checking",
4444+
wal_consistency_checking_string,
4445+
guc->scontext,guc->source,guc->srole,
4446+
GUC_ACTION_SET, true,ERROR, false);
4447+
4448+
/* checking should not be deferred again */
4449+
Assert(!check_wal_consistency_checking_deferred);
4450+
}
4451+
}
4452+
4453+
/*
4454+
* GUC show_hook for archive_command
4455+
*/
4456+
constchar*
4457+
show_archive_command(void)
4458+
{
4459+
if (XLogArchivingActive())
4460+
returnXLogArchiveCommand;
4461+
else
4462+
return"(disabled)";
4463+
}
4464+
4465+
/*
4466+
* GUC show_hook for in_hot_standby
4467+
*/
4468+
constchar*
4469+
show_in_hot_standby(void)
4470+
{
4471+
/*
4472+
* We display the actual state based on shared memory, so that this GUC
4473+
* reports up-to-date state if examined intra-query. The underlying
4474+
* variable (in_hot_standby_guc) changes only when we transmit a new value
4475+
* to the client.
4476+
*/
4477+
returnRecoveryInProgress() ?"on" :"off";
4478+
}
4479+
4480+
43074481
/*
43084482
* Read the control file, set respective GUCs.
43094483
*

‎src/backend/access/transam/xlogprefetcher.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
#include"storage/bufmgr.h"
4545
#include"storage/shmem.h"
4646
#include"storage/smgr.h"
47-
#include"utils/guc.h"
47+
#include"utils/guc_hooks.h"
4848
#include"utils/hsearch.h"
4949

5050
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp