Add pg_get_database_ddl() function to reconstruct CREATE DATABASE statements.#4
Open
akshay-joshi wants to merge 2 commits intomasterfrom
Open
Add pg_get_database_ddl() function to reconstruct CREATE DATABASE statements.#4akshay-joshi wants to merge 2 commits intomasterfrom
akshay-joshi wants to merge 2 commits intomasterfrom
Conversation
25bd4ed to
cfbbcd4
Compare
76b4776 to
8ea45bf
Compare
8ea45bf to
c00e29f
Compare
7042470 to
ece82b3
Compare
42e3705 to
77b9c4d
Compare
…tements.
This adds a new system function, pg_get_database_ddl(database_name/database_oid, ddl_options),
which reconstructs the CREATE DATABASE statement for a given database name or database oid.
Supported ddl_options are 'pretty', '--no-owner', '--no-tablespace' and '--with-defaults'.
Usage:
SELECT pg_get_database_ddl('postgres'); // Non pretty-formatted DDL
SELECT pg_get_database_ddl(16835); // Non pretty-formatted DDL
SELECT pg_get_database_ddl('postgres', 'pretty'); // pretty-formatted DDL
SELECT pg_get_database_ddl('postgres', '--no-owner', '--no-tablespace'); // Omits the Owner and Tablespace clause from the DDL.
SELECT pg_get_database_ddl('postgres', 'pretty', '--with-defaults'); // Includes clauses for parameters that are currently at their default values.
Reference: PG-150
Author: Akshay Joshi <akshay.joshi@enterprisedb.com>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Reviewed-by: Quan Zongliang <quanzongliang@yeah.net>
Reviewed-by: Japin Li <japinli@hotmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Euler Taveira <euler@eulerto.com>
…tements.
This adds a new system function, pg_get_database_ddl(database_name/database_oid, ddl_options),
which reconstructs the CREATE DATABASE statement for a given database name or database oid.
Supported ddl_options are 'pretty', 'owner=no/false/0', 'tablespace=no/false/0' and 'defaults'.
Usage:
SELECT pg_get_database_ddl('postgres'); // Non pretty-formatted DDL
SELECT pg_get_database_ddl(16835); // Non pretty-formatted DDL
SELECT pg_get_database_ddl('postgres', 'pretty'); // pretty-formatted DDL
SELECT pg_get_database_ddl('postgres', 'owner=no', 'tablespace=false'); -- Omits Owner and Tablespace clauses.
SELECT pg_get_database_ddl('postgres', 'pretty', 'defaults=yes'); -- Includes clauses for parameters at their default values.
SELECT pg_get_database_ddl('postgres', 'pretty', 'defaults'); -- Includes clauses for parameters at their default values.
Reference: PG-150
Author: Akshay Joshi <akshay.joshi@enterprisedb.com>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Reviewed-by: Quan Zongliang <quanzongliang@yeah.net>
Reviewed-by: Japin Li <japinli@hotmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Euler Taveira <euler@eulerto.com>
07bf3ed to
97fcd35
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds a new system function, pg_get_database_ddl(database_name/database_oid, pretty), which reconstructs the CREATE DATABASE statement for a given database name or database oid.
Usage:
SELECT pg_get_database_ddl('postgres'); // Non pretty-formatted DDL
SELECT pg_get_database_ddl(16835); // Non pretty-formatted DDL
SELECT pg_get_database_ddl('postgres', true); // pretty-formatted DDL
SELECT pg_get_database_ddl(16835, true); // pretty-formatted DDL
Reference: PG-150
Author: Akshay Joshi akshay.joshi@enterprisedb.com
Reviewed-by: Álvaro Herrera alvherre@kurilemu.de