Re: show size of DSAs and dshash tables in pg_dsm_registry_allocations - Mailing list pgsql-hackers

From Nathan Bossart
Subject Re: show size of DSAs and dshash tables in pg_dsm_registry_allocations
Date
Msg-id aS4e9z74V-Vn7NEi@nathan
Whole thread Raw
In response to Re: show size of DSAs and dshash tables in pg_dsm_registry_allocations  (Chao Li <li.evan.chao@gmail.com>)
List pgsql-hackers
On Tue, Dec 02, 2025 at 05:35:34AM +0800, Chao Li wrote:
> V2 overall looks good to me. I just got a question and a few nit comments.

Thanks for reviewing.

> Why do you error out instead of reporting 0/NULL usage here?

If attaching to the control segment fails, something has gone horribly
wrong.  I don't think returning 0 for the size is appropriate in that case.
Also note that other functions in this file ERROR when attaching fails
(e.g., dsa_attach()).

> ```
> +        else if (entry->type == DSMR_ENTRY_TYPE_DSH &&
> +                 entry->dsh.dsa_handle !=DSA_HANDLE_INVALID)
> ```
> 
> Missing a white space after !=.

I agree, but for some reason, pgindent insists on removing that space.  I'm
leaving that for another thread.

> ```
> -       Size of the allocation in bytes.  NULL for entries of type
> -       <literal>area</literal> and <literal>hash</literal>.
> +       Size of the allocation in bytes.  NULL for entries that failed
> +       initialization.
> ```
> 
> “Failed initialization”, I guess “to” is needed after “failed”.

IMHO it's fine as-is.  We could say "failed to initialize", but I'm not
sure that's materially better at conveying the information.

> ```
> -SELECT name, type, size IS DISTINCT FROM 0 AS size
> +SELECT name, type, size > 0 AS size
> ```
> 
> As you changed the third column from “size” to “size > 0”, now it’s a
> bool column, so maybe rename the column alias from “size” to something
> indicating a bool type, such as “size_ok”, “has_size”, etc.

It was already a bool column, but your point still stands.  I changed it to
"size_ok".

-- 
nathan

Attachment

pgsql-hackers by date:

Previous
From: Myles Lewis
Date:
Subject: Re: [PATCH] Add native PIVOT syntax for SQL Server/Oracle compatibility
Next
From: Chao Li
Date:
Subject: Re: split tablecmds.c