Re: pg_get__*_ddl consolidation

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: SATYANARAYANA NARLAPURAM <satyanarlapuram(at)gmail(dot)com>, Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Japin Li <japinli(at)hotmail(dot)com>, Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>, Euler Taveira <euler(at)eulerto(dot)com>, Álvaro Herrera <alvherre(at)kurilemu(dot)de>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pg_get__*_ddl consolidation
Date: 2026-04-14 22:52:04
Message-ID: 786bceca-84c4-4a83-9c30-3ce49d81b274@dunslane.net
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 2026-04-13 Mo 3:41 PM, SATYANARAYANA NARLAPURAM wrote:
> Hi,
>
> On Fri, Apr 10, 2026 at 1:03 PM Jeff Davis <pgsql(at)j-davis(dot)com> wrote:
>
> On Sun, 2026-04-05 at 11:06 -0400, Andrew Dunstan wrote:
> > Pushed. I have moved the remaining get_*_ddl items to PG20-1
>
> The line:
>
>   role_settings = DatumGetArrayTypeP(datum);
>
> should be DatumGetArrayTypePCopy(), because it's being pfree()d later.
> The existing code will sometimes make a copy and sometimes not, e.g.:
>
>   -- settings are contrived to make the datum inline
>   CREATE USER u1;
>   ALTER ROLE u1 SET search_path = 'public, pg_catalog, pg_temp';
>   ALTER ROLE u1 SET work_mem='64MB';
>   ALTER ROLE u1 SET statement_timeout='30s';
>   ALTER ROLE u1 SET lock_timeout='10s';
>   ALTER ROLE u1 SET idle_in_transaction_session_timeout = '60s';
>   SELECT pg_get_role_ddl('u1');
>   ERROR:  pfree called with invalid pointer 0x7986dd0c7cc8 (header
> 0x0000400600000000)
>
>
> Yes, it appears to be a bug. Attached a patch to fix this. Tested with
> the
> attached patch and don't see server crashing after that.
>
>

Thanks, pushed.

cheers

andrew

--
Andrew Dunstan
EDB:https://www.enterprisedb.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Smith 2026-04-14 23:23:45 Re: Add missing period to HINT messages
Previous Message David Rowley 2026-04-14 22:41:28 Re: [PATCH] Miscellaneous little fixes