Re: Add memory context type to pg_backend_memory_contexts view - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Add memory context type to pg_backend_memory_contexts view
Date
Msg-id ZlpxfWV02MmKA3Go@paquier.xyz
Whole thread Raw
In response to Re: Add memory context type to pg_backend_memory_contexts view  (David Rowley <dgrowleyml@gmail.com>)
List 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

Attachment

pgsql-hackers by date:

Previous
From: Alexander Lakhin
Date:
Subject: Re: To what extent should tests rely on VACUUM ANALYZE?
Next
From: "a.kozhemyakin"
Date:
Subject: pltcl crashes due to a syntax error