Hi, Peter,
I have two comments for V6 patch:
1. In function describeOneSchemaDetails(), res gets assigned by PSQLexec(),
if res is NULL, code flow goes to error_return label where
termPQExpBuffer(&title) is called.
However, the title is NOT initialized at all in this case.
Suggest to initialize the title right after the initialization of buf.
2. Also in function describeOneSchemaDetails(), res gets assigned by PSQLexec();
res = PSQLexec(buf.data);
If the PQclear() is successful, we will go inside the Footer processing,
if pset.sversion >= 150000 and following PSQLexec() fails,
result = PSQLexec(buf.data);
if (!result)
goto error_return;
code flow goes to error_return label. But there is no PQclear(res), and I think
it may cause memory leak;
Suggest to initialize the res to be NULL and add PQclear(res) in error_return
branch.
Thanks,
Steven
________________________________________
From: Peter Smith <[email protected]>
Sent: Friday, September 11, 2026 15:55
To: Ajin Cherian <[email protected]>
Cc: surya poondla <[email protected]>; PostgreSQL Hackers
<[email protected]>; [email protected]
<[email protected]>; [email protected]
<[email protected]>; [email protected]
<[email protected]>; [email protected] <[email protected]>
Subject: Re: PSQL schema "describe" \dn is not escaping quotes
On Thu, Sep 10, 2026 at 7:52 PM Ajin Cherian <[email protected]> wrote:
>
...
> Thanks for the updated match with the fixes and the new tests. The fix
> works and the new tests are welcome. A few minor comments:
>
> 1.
> + for (int i = 0; i < num_schemas; i++)
> + {
> + const char *nspname = PQgetvalue(res, i, 0);
> +
> + describeOneSchemaDetails(nspname, verbose);
> + }
> + }
>
> The return value (bool) of describeOneSchemaDetails is ignored. Is it
> even required?
>
The return was there to mirror the other describeOneXXX functions, but
I neglected to check it. Now handling the result, similar to other
functions.
> 2.
> The code now allocates memory for title as well but is not freed in
> the error path.
>
> + initPQExpBuffer(&title);
> + printfPQExpBuffer(&title, _("Schema \"%s\""), schemaname);
>
Fixed.
PSA patch v6.
======
Kind Regards,
Peter Smith.
Fujitsu Australia