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

Commit55ef7ab

Browse files
Rename global variable backing DSA area
The global variable backing the DSA area for Memory Context statsreporting had a too generic name, rename to be more descriptive.Independently reported by Peter and Laurenz.Author: Daniel Gustafsson <daniel@yesql.se>Reported-by: Peter Eisentraut <peter@eisentraut.org>Reported-by: Laurenz Albe <laurenz.albe@cybertec.at>Discussion:https://postgr.es/m/d51172bd4e7f4b07a18a0288ca1b1c28a71a5f6a.camel@cybertec.atDiscussion:https://postgr.es/m/25095db5-b595-4b85-9100-d358907c25b5@eisentraut.org
1 parent22cb6d2 commit55ef7ab

File tree

3 files changed

+28
-28
lines changed

3 files changed

+28
-28
lines changed

‎src/backend/utils/adt/mcxtfuncs.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -533,21 +533,21 @@ pg_get_process_memory_contexts(PG_FUNCTION_ARGS)
533533
*/
534534
Assert(memCxtArea->memstats_dsa_handle!=DSA_HANDLE_INVALID);
535535
/* Attach to the dsa area if we have not already done so */
536-
if (area==NULL)
536+
if (MemoryStatsDsaArea==NULL)
537537
{
538538
MemoryContextoldcontext=CurrentMemoryContext;
539539

540540
MemoryContextSwitchTo(TopMemoryContext);
541-
area=dsa_attach(memCxtArea->memstats_dsa_handle);
541+
MemoryStatsDsaArea=dsa_attach(memCxtArea->memstats_dsa_handle);
542542
MemoryContextSwitchTo(oldcontext);
543-
dsa_pin_mapping(area);
543+
dsa_pin_mapping(MemoryStatsDsaArea);
544544
}
545545

546546
/*
547547
* Backend has finished publishing the stats, project them.
548548
*/
549549
memcxt_info= (MemoryStatsEntry*)
550-
dsa_get_address(area,memCxtState[procNumber].memstats_dsa_pointer);
550+
dsa_get_address(MemoryStatsDsaArea,memCxtState[procNumber].memstats_dsa_pointer);
551551

552552
#definePG_GET_PROCESS_MEMORY_CONTEXTS_COLS12
553553
for (inti=0;i<memCxtState[procNumber].total_stats;i++)
@@ -566,15 +566,15 @@ pg_get_process_memory_contexts(PG_FUNCTION_ARGS)
566566

567567
if (DsaPointerIsValid(memcxt_info[i].name))
568568
{
569-
name= (char*)dsa_get_address(area,memcxt_info[i].name);
569+
name= (char*)dsa_get_address(MemoryStatsDsaArea,memcxt_info[i].name);
570570
values[0]=CStringGetTextDatum(name);
571571
}
572572
else
573573
nulls[0]= true;
574574

575575
if (DsaPointerIsValid(memcxt_info[i].ident))
576576
{
577-
ident= (char*)dsa_get_address(area,memcxt_info[i].ident);
577+
ident= (char*)dsa_get_address(MemoryStatsDsaArea,memcxt_info[i].ident);
578578
values[1]=CStringGetTextDatum(ident);
579579
}
580580
else
@@ -586,7 +586,7 @@ pg_get_process_memory_contexts(PG_FUNCTION_ARGS)
586586
path_datum= (Datum*)palloc(path_length*sizeof(Datum));
587587
if (DsaPointerIsValid(memcxt_info[i].path))
588588
{
589-
path_int= (int*)dsa_get_address(area,memcxt_info[i].path);
589+
path_int= (int*)dsa_get_address(MemoryStatsDsaArea,memcxt_info[i].path);
590590
for (intj=0;j<path_length;j++)
591591
path_datum[j]=Int32GetDatum(path_int[j]);
592592
path_array=construct_array_builtin(path_datum,path_length,INT4OID);

‎src/backend/utils/mmgr/mcxt.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ MemoryContext CurTransactionContext = NULL;
172172

173173
/* This is a transient link to the active portal's memory context: */
174174
MemoryContextPortalContext=NULL;
175-
dsa_area*area=NULL;
175+
dsa_area*MemoryStatsDsaArea=NULL;
176176

177177
staticvoidMemoryContextDeleteOnly(MemoryContextcontext);
178178
staticvoidMemoryContextCallResetCallbacks(MemoryContextcontext);
@@ -1499,19 +1499,19 @@ ProcessGetMemoryContextInterrupt(void)
14991499

15001500
MemoryContextSwitchTo(TopMemoryContext);
15011501

1502-
area=dsa_create(memCxtArea->lw_lock.tranche);
1502+
MemoryStatsDsaArea=dsa_create(memCxtArea->lw_lock.tranche);
15031503

1504-
handle=dsa_get_handle(area);
1504+
handle=dsa_get_handle(MemoryStatsDsaArea);
15051505
MemoryContextSwitchTo(oldcontext);
15061506

1507-
dsa_pin_mapping(area);
1507+
dsa_pin_mapping(MemoryStatsDsaArea);
15081508

15091509
/*
15101510
* Pin the DSA area, this is to make sure the area remains attachable
15111511
* even if current backend exits. This is done so that the statistics
15121512
* are published even if the process exits while a client is waiting.
15131513
*/
1514-
dsa_pin(area);
1514+
dsa_pin(MemoryStatsDsaArea);
15151515

15161516
/* Set the handle in shared memory */
15171517
memCxtArea->memstats_dsa_handle=handle;
@@ -1521,14 +1521,14 @@ ProcessGetMemoryContextInterrupt(void)
15211521
* If DSA exists, created by another process publishing statistics, attach
15221522
* to it.
15231523
*/
1524-
elseif (area==NULL)
1524+
elseif (MemoryStatsDsaArea==NULL)
15251525
{
15261526
MemoryContextoldcontext=CurrentMemoryContext;
15271527

15281528
MemoryContextSwitchTo(TopMemoryContext);
1529-
area=dsa_attach(memCxtArea->memstats_dsa_handle);
1529+
MemoryStatsDsaArea=dsa_attach(memCxtArea->memstats_dsa_handle);
15301530
MemoryContextSwitchTo(oldcontext);
1531-
dsa_pin_mapping(area);
1531+
dsa_pin_mapping(MemoryStatsDsaArea);
15321532
}
15331533
LWLockRelease(&memCxtArea->lw_lock);
15341534

@@ -1545,7 +1545,7 @@ ProcessGetMemoryContextInterrupt(void)
15451545
* Free any previous allocations, free the name, ident and path
15461546
* pointers before freeing the pointer that contains them.
15471547
*/
1548-
free_memorycontextstate_dsa(area,memCxtState[idx].total_stats,
1548+
free_memorycontextstate_dsa(MemoryStatsDsaArea,memCxtState[idx].total_stats,
15491549
memCxtState[idx].memstats_dsa_pointer);
15501550
}
15511551

@@ -1556,10 +1556,10 @@ ProcessGetMemoryContextInterrupt(void)
15561556
*/
15571557
memCxtState[idx].total_stats=stats_num;
15581558
memCxtState[idx].memstats_dsa_pointer=
1559-
dsa_allocate0(area,stats_num*sizeof(MemoryStatsEntry));
1559+
dsa_allocate0(MemoryStatsDsaArea,stats_num*sizeof(MemoryStatsEntry));
15601560

15611561
meminfo= (MemoryStatsEntry*)
1562-
dsa_get_address(area,memCxtState[idx].memstats_dsa_pointer);
1562+
dsa_get_address(MemoryStatsDsaArea,memCxtState[idx].memstats_dsa_pointer);
15631563

15641564
if (summary)
15651565
{
@@ -1572,7 +1572,7 @@ ProcessGetMemoryContextInterrupt(void)
15721572
&stat, true);
15731573
path=lcons_int(1,path);
15741574
PublishMemoryContext(meminfo,cxt_id,TopMemoryContext,path,stat,
1575-
1,area,100);
1575+
1,MemoryStatsDsaArea,100);
15761576
cxt_id=cxt_id+1;
15771577

15781578
/*
@@ -1602,7 +1602,7 @@ ProcessGetMemoryContextInterrupt(void)
16021602
*/
16031603
memCxtState[idx].total_stats=cxt_id++;
16041604
PublishMemoryContext(meminfo,cxt_id,c,path,
1605-
grand_totals,num_contexts,area,100);
1605+
grand_totals,num_contexts,MemoryStatsDsaArea,100);
16061606
}
16071607
memCxtState[idx].total_stats=cxt_id;
16081608

@@ -1632,7 +1632,7 @@ ProcessGetMemoryContextInterrupt(void)
16321632
if (context_id< (max_stats-1)||stats_count <=max_stats)
16331633
{
16341634
/* Copy statistics to DSA memory */
1635-
PublishMemoryContext(meminfo,context_id,cur,path,stat,1,area,100);
1635+
PublishMemoryContext(meminfo,context_id,cur,path,stat,1,MemoryStatsDsaArea,100);
16361636
}
16371637
else
16381638
{
@@ -1657,8 +1657,8 @@ ProcessGetMemoryContextInterrupt(void)
16571657
intnamelen=strlen("Remaining Totals");
16581658

16591659
num_individual_stats=context_id+1;
1660-
meminfo[max_stats-1].name=dsa_allocate(area,namelen+1);
1661-
nameptr=dsa_get_address(area,meminfo[max_stats-1].name);
1660+
meminfo[max_stats-1].name=dsa_allocate(MemoryStatsDsaArea,namelen+1);
1661+
nameptr=dsa_get_address(MemoryStatsDsaArea,meminfo[max_stats-1].name);
16621662
strncpy(nameptr,"Remaining Totals",namelen);
16631663
meminfo[max_stats-1].ident=InvalidDsaPointer;
16641664
meminfo[max_stats-1].path=InvalidDsaPointer;
@@ -1921,18 +1921,18 @@ AtProcExit_memstats_cleanup(int code, Datum arg)
19211921
}
19221922

19231923
/* If the dsa mapping could not be found, attach to the area */
1924-
if (area==NULL)
1925-
area=dsa_attach(memCxtArea->memstats_dsa_handle);
1924+
if (MemoryStatsDsaArea==NULL)
1925+
MemoryStatsDsaArea=dsa_attach(memCxtArea->memstats_dsa_handle);
19261926

19271927
/*
19281928
* Free the memory context statistics, free the name, ident and path
19291929
* pointers before freeing the pointer that contains these pointers and
19301930
* integer statistics.
19311931
*/
1932-
free_memorycontextstate_dsa(area,memCxtState[idx].total_stats,
1932+
free_memorycontextstate_dsa(MemoryStatsDsaArea,memCxtState[idx].total_stats,
19331933
memCxtState[idx].memstats_dsa_pointer);
19341934

1935-
dsa_detach(area);
1935+
dsa_detach(MemoryStatsDsaArea);
19361936
LWLockRelease(&memCxtState[idx].lw_lock);
19371937
}
19381938

‎src/include/utils/memutils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,11 +394,11 @@ typedef struct MemoryStatsContextId
394394

395395
externPGDLLIMPORTMemoryStatsBackendState*memCxtState;
396396
externPGDLLIMPORTMemoryStatsCtl*memCxtArea;
397+
externPGDLLIMPORTdsa_area*MemoryStatsDsaArea;
397398
externvoidProcessGetMemoryContextInterrupt(void);
398399
externconstchar*ContextTypeToString(NodeTagtype);
399400
externvoidHandleGetMemoryContextInterrupt(void);
400401
externSizeMemoryContextReportingShmemSize(void);
401402
externvoidMemoryContextReportingShmemInit(void);
402403
externvoidAtProcExit_memstats_cleanup(intcode,Datumarg);
403-
externdsa_area*area;
404404
#endif/* MEMUTILS_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp