Re: Add memory context type to pg_backend_memory_contexts view

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: David Christensen <david+pg(at)pgguru(dot)net>, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Add memory context type to pg_backend_memory_contexts view
Date: 2024-06-01 00:55:25
Message-ID: ZlpxfWV02MmKA3Go@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, May 31, 2024 at 12:35:58PM +1200, David Rowley wrote:
> This follows what we do in other places. If you look at explain.c,
> you'll see lots of "???"s.
>
> I think if you're worried about corrupted memory, then garbled output
> in pg_get_backend_memory_contexts wouldn't be that high on the list of
> concerns.

+ const char *type;
[...]
+ switch (context->type)
+ {
+ case T_AllocSetContext:
+ type = "AllocSet";
+ break;
+ case T_GenerationContext:
+ type = "Generation";
+ break;
+ case T_SlabContext:
+ type = "Slab";
+ break;
+ case T_BumpContext:
+ type = "Bump";
+ break;
+ default:
+ type = "???";
+ break;
+ }

Yeah, it's a common practice to use that as fallback. What you are
doing is OK, and it is not possible to remove the default case as
these are nodetags to generate warnings if a new value needs to be
added.

This patch looks like a good idea, so +1 from here. (PS: catversion
bump).
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message a.kozhemyakin 2024-06-01 04:36:18 pltcl crashes due to a syntax error
Previous Message Alexander Lakhin 2024-05-31 20:00:00 Re: To what extent should tests rely on VACUUM ANALYZE?