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

Commit12227a1

Browse files
committed
Add context type field to pg_backend_memory_contexts
Since we now (as of v17) have 4 MemoryContext types, the type of contextseems like useful information to include in the pg_backend_memory_contextsview. Here we add that.Reviewed-by: David Christensen, Michael PaquierDiscussion:https://postgr.es/m/CAApHDvrXX1OR09Zjb5TnB0AwCKze9exZN%3D9Nxxg1ZCVV8W-3BA%40mail.gmail.com
1 parente26d313 commit12227a1

File tree

7 files changed

+53
-22
lines changed

7 files changed

+53
-22
lines changed

‎doc/src/sgml/system-views.sgml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,15 @@
490490
</para></entry>
491491
</row>
492492

493+
<row>
494+
<entry role="catalog_table_entry"><para role="column_definition">
495+
<structfield>type</structfield> <type>text</type>
496+
</para>
497+
<para>
498+
Type of the memory context
499+
</para></entry>
500+
</row>
501+
493502
<row>
494503
<entry role="catalog_table_entry"><para role="column_definition">
495504
<structfield>level</structfield> <type>int4</type>

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

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,15 @@ PutMemoryContextsStatsTupleStore(Tuplestorestate *tupstore,
3636
TupleDesctupdesc,MemoryContextcontext,
3737
constchar*parent,intlevel)
3838
{
39-
#definePG_GET_BACKEND_MEMORY_CONTEXTS_COLS9
39+
#definePG_GET_BACKEND_MEMORY_CONTEXTS_COLS10
4040

4141
Datumvalues[PG_GET_BACKEND_MEMORY_CONTEXTS_COLS];
4242
boolnulls[PG_GET_BACKEND_MEMORY_CONTEXTS_COLS];
4343
MemoryContextCountersstat;
4444
MemoryContextchild;
4545
constchar*name;
4646
constchar*ident;
47+
constchar*type;
4748

4849
Assert(MemoryContextIsValid(context));
4950

@@ -96,12 +97,32 @@ PutMemoryContextsStatsTupleStore(Tuplestorestate *tupstore,
9697
else
9798
nulls[2]= true;
9899

99-
values[3]=Int32GetDatum(level);
100-
values[4]=Int64GetDatum(stat.totalspace);
101-
values[5]=Int64GetDatum(stat.nblocks);
102-
values[6]=Int64GetDatum(stat.freespace);
103-
values[7]=Int64GetDatum(stat.freechunks);
104-
values[8]=Int64GetDatum(stat.totalspace-stat.freespace);
100+
switch (context->type)
101+
{
102+
caseT_AllocSetContext:
103+
type="AllocSet";
104+
break;
105+
caseT_GenerationContext:
106+
type="Generation";
107+
break;
108+
caseT_SlabContext:
109+
type="Slab";
110+
break;
111+
caseT_BumpContext:
112+
type="Bump";
113+
break;
114+
default:
115+
type="???";
116+
break;
117+
}
118+
119+
values[3]=CStringGetTextDatum(type);
120+
values[4]=Int32GetDatum(level);
121+
values[5]=Int64GetDatum(stat.totalspace);
122+
values[6]=Int64GetDatum(stat.nblocks);
123+
values[7]=Int64GetDatum(stat.freespace);
124+
values[8]=Int64GetDatum(stat.freechunks);
125+
values[9]=Int64GetDatum(stat.totalspace-stat.freespace);
105126
tuplestore_putvalues(tupstore,tupdesc,values,nulls);
106127

107128
for (child=context->firstchild;child!=NULL;child=child->nextchild)

‎src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@
5757
*/
5858

5959
/*yyyymmddN */
60-
#defineCATALOG_VERSION_NO202406281
60+
#defineCATALOG_VERSION_NO202407011
6161

6262
#endif

‎src/include/catalog/pg_proc.dat

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8279,9 +8279,9 @@
82798279
proname => 'pg_get_backend_memory_contexts', prorows => '100',
82808280
proretset => 't', provolatile => 'v', proparallel => 'r',
82818281
prorettype => 'record', proargtypes => '',
8282-
proallargtypes => '{text,text,text,int4,int8,int8,int8,int8,int8}',
8283-
proargmodes => '{o,o,o,o,o,o,o,o,o}',
8284-
proargnames => '{name, ident, parent, level, total_bytes, total_nblocks, free_bytes, free_chunks, used_bytes}',
8282+
proallargtypes => '{text,text,text,text,int4,int8,int8,int8,int8,int8}',
8283+
proargmodes => '{o,o,o,o,o,o,o,o,o,o}',
8284+
proargnames => '{name, ident, parent,type,level, total_bytes, total_nblocks, free_bytes, free_chunks, used_bytes}',
82858285
prosrc => 'pg_get_backend_memory_contexts' },
82868286

82878287
# logging memory contexts of the specified backend

‎src/test/regress/expected/rules.out

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1306,13 +1306,14 @@ pg_available_extensions| SELECT e.name,
13061306
pg_backend_memory_contexts| SELECT name,
13071307
ident,
13081308
parent,
1309+
type,
13091310
level,
13101311
total_bytes,
13111312
total_nblocks,
13121313
free_bytes,
13131314
free_chunks,
13141315
used_bytes
1315-
FROM pg_get_backend_memory_contexts() pg_get_backend_memory_contexts(name, ident, parent, level, total_bytes, total_nblocks, free_bytes, free_chunks, used_bytes);
1316+
FROM pg_get_backend_memory_contexts() pg_get_backend_memory_contexts(name, ident, parent,type,level, total_bytes, total_nblocks, free_bytes, free_chunks, used_bytes);
13161317
pg_config| SELECT name,
13171318
setting
13181319
FROM pg_config() pg_config(name, setting);

‎src/test/regress/expected/sysviews.out

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ select count(*) >= 0 as ok from pg_available_extensions;
2121

2222
-- The entire output of pg_backend_memory_contexts is not stable,
2323
-- we test only the existence and basic condition of TopMemoryContext.
24-
select name, ident, parent, level, total_bytes >= free_bytes
24+
selecttype,name, ident, parent, level, total_bytes >= free_bytes
2525
from pg_backend_memory_contexts where level = 0;
26-
name | ident | parent | level | ?column?
27-
------------------+-------+--------+-------+----------
28-
TopMemoryContext | | | 0 | t
26+
type | name | ident | parent | level | ?column?
27+
----------+------------------+-------+--------+-------+----------
28+
AllocSet |TopMemoryContext | | | 0 | t
2929
(1 row)
3030

3131
-- We can exercise some MemoryContext type stats functions. Most of the
@@ -43,11 +43,11 @@ fetch 1 from cur;
4343
bbbbbbbbbb | 2
4444
(1 row)
4545

46-
select name, parent, total_bytes > 0, total_nblocks, free_bytes > 0, free_chunks
46+
selecttype,name, parent, total_bytes > 0, total_nblocks, free_bytes > 0, free_chunks
4747
from pg_backend_memory_contexts where name = 'Caller tuples';
48-
name | parent | ?column? | total_nblocks | ?column? | free_chunks
49-
---------------+----------------+----------+---------------+----------+-------------
50-
Caller tuples | TupleSort sort | t | 2 | t | 0
48+
type | name | parent | ?column? | total_nblocks | ?column? | free_chunks
49+
------+---------------+----------------+----------+---------------+----------+-------------
50+
Bump |Caller tuples | TupleSort sort | t | 2 | t | 0
5151
(1 row)
5252

5353
rollback;

‎src/test/regress/sql/sysviews.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ select count(*) >= 0 as ok from pg_available_extensions;
1414

1515
-- The entire output of pg_backend_memory_contexts is not stable,
1616
-- we test only the existence and basic condition of TopMemoryContext.
17-
select name, ident, parent, level, total_bytes>= free_bytes
17+
selecttype,name, ident, parent, level, total_bytes>= free_bytes
1818
from pg_backend_memory_contextswhere level=0;
1919

2020
-- We can exercise some MemoryContext type stats functions. Most of the
@@ -28,7 +28,7 @@ declare cur cursor for select left(a,10), b
2828
from (values(repeat('a',512*1024),1),(repeat('b',512),2)) v(a,b)
2929
order byv.adesc;
3030
fetch1from cur;
31-
select name, parent, total_bytes>0, total_nblocks, free_bytes>0, free_chunks
31+
selecttype,name, parent, total_bytes>0, total_nblocks, free_bytes>0, free_chunks
3232
from pg_backend_memory_contextswhere name='Caller tuples';
3333
rollback;
3434

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp