Re: [PATCH] psql: tab completion for ALTER ROLE ... IN DATABASE ...

From: VASUKI M <vasukianand0119(at)gmail(dot)com>
To: zengman <zengman(at)halodbtech(dot)com>
Cc: Ian Lawrence Barwick <barwick(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, surya poondla <suryapoondla4(at)gmail(dot)com>
Subject: Re: [PATCH] psql: tab completion for ALTER ROLE ... IN DATABASE ...
Date: 2025-12-22 15:40:50
Message-ID: CAE2r8H7h0gknvZHBcYJSzqC=DL3yZXfjfH3BvfnNbBxwh6dexg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi zeng,

Thanks for pointing this out. You’re absolutely right — PQescapeLiteral()
allocates memory using libpq’s allocator, so the returned buffers must be
released with PQfreemem() rather than pfree(). Using pfree() here would be
incorrect, since it expects memory allocated via PostgreSQL’s memory
context APIs (palloc/psprintf).

I’ll update the patch to replace pfree() with PQfreemem() for the buffers
returned by PQescapeLiteral(),while continuing to use pfree() for memory
allocated via psprintf().

Thanks again for catching this.

Best regards,
Vasuki M
C-DAC,Chennai

On Mon, 22 Dec 2025, 8:18 pm zengman, <zengman(at)halodbtech(dot)com> wrote:

> Hi
>
> I noticed that in the code, the variables `q_role` and `q_dbname` are
> processed with the `PQescapeLiteral` function,
> so `PQfreemem` – instead of `pfree` – should be used here to free the
> memory.
>
> --
> Regards,
> Man Zeng
> www.openhalo.org

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Dilip Kumar 2025-12-22 15:41:03 Re: Proposal: Conflict log history table for Logical Replication
Previous Message Yugo Nagata 2025-12-22 15:37:05 Re: psql: tab-completion support for COPY ... TO/FROM STDIN, STDOUT, and PROGRAM