]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Add pg_get_tablespace_ddl() function
authorAndrew Dunstan <andrew@dunslane.net>
Thu, 19 Mar 2026 13:55:16 +0000 (09:55 -0400)
committerAndrew Dunstan <andrew@dunslane.net>
Sun, 5 Apr 2026 14:54:54 +0000 (10:54 -0400)
commitb99fd9fd7f363c6363f4c8a95c699b9134b0357f
treef8fa17b5ffc97101c6a02c893550df0c66604c4e
parent76e514ebb4b55f95b844e3e94e61fa64ab16fd0b
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
doc/src/sgml/func/func-info.sgml
src/backend/utils/adt/ddlutils.c
src/backend/utils/adt/ruleutils.c
src/include/catalog/pg_proc.dat
src/include/utils/ruleutils.h
src/test/regress/expected/tablespace_ddl.out [new file with mode: 0644]
src/test/regress/parallel_schedule
src/test/regress/sql/tablespace_ddl.sql [new file with mode: 0644]