pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Dunstan <andrew@dunslane.net>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Add pg_get_tablespace_ddl() function
Date: Sun, 05 Apr 2026 15:02:21 +0000
Message-ID: <E1w9OzU-0035r8-1L@gemulon.postgresql.org> (raw)

Add pg_get_tablespace_ddl() function

Add a new SQL-callable function that returns the DDL statements needed
to recreate a tablespace. It takes a tablespace name or OID and an
optional VARIADIC text argument for options that are specified as
alternating name/value pairs. The following options are supported: pretty
(boolean) for formatted output and owner (boolean) to include OWNER.
(It includes two variants because there is no regtablespace pseudotype.)
The return is one or multiple rows where the first row is a CREATE
TABLESPACE statement and subsequent rows are ALTER TABLESPACE statements
to set some tablespace properties.

The caller must have SELECT privilege on pg_tablespace.

get_reloptions() in ruleutils.c is made non-static so it can be called
from the new ddlutils.c file.

Author: Nishant Sharma <nishant.sharma@enterprisedb.com>
Author: Manni Wood <manni.wood@enterprisedb.com>
Co-authored-by: Andrew Dunstan <andrew@dunslane.net>
Co-authored-by: Euler Taveira <euler@eulerto.com>
Reviewed-by: Jim Jones <jim.jones@uni-muenster.de>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CAKWEB6rmnmGKUA87Zmq-s=b3Scsnj02C0kObQjnbL2ajfPWGEw@mail.gmail.com
Discussion: https://postgr.es/m/e247c261-e3fb-4810-81e0-a65893170e94@dunslane.net

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/b99fd9fd7f363c6363f4c8a95c699b9134b0357f

Modified Files
--------------
doc/src/sgml/func/func-info.sgml             |  28 ++++
src/backend/utils/adt/ddlutils.c             | 206 ++++++++++++++++++++++++++-
src/backend/utils/adt/ruleutils.c            |   4 +-
src/include/catalog/pg_proc.dat              |  16 +++
src/include/utils/ruleutils.h                |   1 +
src/test/regress/expected/tablespace_ddl.out |  84 +++++++++++
src/test/regress/parallel_schedule           |   2 +-
src/test/regress/sql/tablespace_ddl.sql      |  58 ++++++++
8 files changed, 395 insertions(+), 4 deletions(-)



Message-ID: <E1w9OzU-0035r8-1L@gemulon.postgresql.org>
Permalink:  ../E1w9OzU-0035r8-1L@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1w9OzU-0035r8-1L@gemulon.postgresql.org

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: andrew@dunslane.net, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Add pg_get_tablespace_ddl() function
  In-Reply-To: <E1w9OzU-0035r8-1L@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox