Add pg_get_tablespace_ddl() function
Andrew Dunstan <andrew@dunslane.net>
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
Files
| Path | Change | +/− |
|---|---|---|
| doc/src/sgml/func/func-info.sgml | modified | +28 −0 |
| src/backend/utils/adt/ddlutils.c | modified | +205 −1 |
| src/backend/utils/adt/ruleutils.c | modified | +2 −2 |
| src/include/catalog/pg_proc.dat | modified | +16 −0 |
| src/include/utils/ruleutils.h | modified | +1 −0 |
| src/test/regress/expected/tablespace_ddl.out | added | +84 −0 |
| src/test/regress/parallel_schedule | modified | +1 −1 |
| src/test/regress/sql/tablespace_ddl.sql | added | +58 −0 |
Discussion
- pg_get__*_ddl consolidation 36 messages · 2026-03-19 → 2026-06-28
- [PATCH] Add pg_get_tablespace_ddl() function to reconstruct CREATE TABLESPACE statement 36 messages · 2025-10-29 → 2025-11-26