Align memory context level numbering in pg_log_backend_memory_contexts()

From: torikoshia <torikoshia(at)oss(dot)nttdata(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Align memory context level numbering in pg_log_backend_memory_contexts()
Date: 2025-04-15 13:23:34
Message-ID: 395ea5d4fe190480efa95bf533485c70@oss.nttdata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

With commit 32d3ed81, pg_backend_memory_contexts view will start
numbering memory context levels from 1 instead of 0 in PostgreSQL 18.

For example:

=# select name, level from pg_backend_memory_contexts;
name | level
----------------------------+-------
TopMemoryContext | 1
Record information cache | 2
Btree proof lookup cache | 2

However, pg_log_backend_memory_contexts() still starts its output from
level 0:

=# select pg_log_backend_memory_contexts(pg_backend_pid());

LOG: level: 0; TopMemoryContext: ...
LOG: level: 1; Record information cache: ...
LOG: level: 1; Btree proof lookup cache: ...

I understand that these view and function are intended primarily for
one-off diagnostics and not for direct cross-comparison. So this
discrepancy isn’t critical.
However, for the sake of consistency and to avoid potential confusion,
would it make sense to also start the levels from 1 in
pg_log_backend_memory_contexts() starting in v18?

--
Regards,

--
Atsushi Torikoshi
Seconded from NTT DATA GROUP CORPORATION to SRA OSS K.K.

Attachment Content-Type Size
v1-0001-Increment-level-in-pg_log_backend_memory_contexts.patch text/x-diff 1.2 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Gustafsson 2025-04-15 13:41:22 Re: pg_combinebackup: correct code comment.
Previous Message Robert Haas 2025-04-15 12:41:33 Re: pg_combinebackup: correct code comment.