Thread

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

    VASUKI M <vasukianand0119@gmail.com> — 2025-12-22T15:40:50Z

    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@halodbtech.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