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 <[email protected]> Author: Manni Wood <[email protected]> Co-authored-by: Andrew Dunstan <[email protected]> Co-authored-by: Euler Taveira <[email protected]> Reviewed-by: Jim Jones <[email protected]> Reviewed-by: Álvaro Herrera <[email protected]> Reviewed-by: Chao Li <[email protected]> Discussion: https://postgr.es/m/CAKWEB6rmnmGKUA87Zmq-s=b3scsnj02c0kobqjnbl2ajfpw...@mail.gmail.com Discussion: https://postgr.es/m/[email protected] 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(-)
