Re: [PATCH] Add pg_get_tablespace_ddl() function to reconstruct CREATE TABLESPACE statement

Jim Jones <jim.jones@uni-muenster.de>

From: Jim Jones <jim.jones@uni-muenster.de>
To: Manni Wood <manni.wood@enterprisedb.com>, Nishant Sharma <nishant.sharma@enterprisedb.com>
Cc: Álvaro Herrera <alvherre@kurilemu.de>, pgsql-hackers@postgresql.org
Date: 2025-11-07T16:16:38Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Add infrastructure for pg_get_*_ddl functions

  2. Add pg_get_tablespace_ddl() function

  3. Split out innards of pg_tablespace_location()

  4. Remove spclocation field from pg_tablespace


On 07/11/2025 02:27, Manni Wood wrote:
> Attached v7 fixes problems in tests due to whitespace.


Since get_tablespace_loc_string returns a palloc'd string, I guess you
could pfree it after the if block. The same applies for spcowner, since
you're calling GetUserNameFromId() with noerr = false.

For reference, see pg_get_indexdef_worker():

...
/*
 * If it has options, append "WITH (options)"
 */
str = flatten_reloptions(indexrelid);
if (str)
{
  appendStringInfo(&buf, " WITH (%s)", str);
  pfree(str);
}
...


Thanks

Best, Jim