Re: pg_get__*_ddl consolidation - Mailing list pgsql-hackers

From Jeff Davis
Subject Re: pg_get__*_ddl consolidation
Date
Msg-id 4efc426cde8eed9734af3a4552c3be29188f3661.camel@j-davis.com
Whole thread Raw
In response to Re: pg_get__*_ddl consolidation  (Andrew Dunstan <andrew@dunslane.net>)
List pgsql-hackers
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)

Also, it looks like the scan key in pg_get_role_ddl_internal() uses
only the second attribute of the index, which might be worth a comment.

Regards,
    Jeff Davis




pgsql-hackers by date:

Previous
From: Antonin Houska
Date:
Subject: Re: Adding REPACK [concurrently]
Next
From: SATYANARAYANA NARLAPURAM
Date:
Subject: Infinite Autovacuum loop caused by failing virtual generated column expression