On 08/25/2011 06:15 PM, Andrew Dunstan wrote:
But we could also add these switches to pg_dump too if people feel
it's worthwhile. I haven't looked but the logic should not be terribly
hard.
Something like the attached, in fact, which seems pretty simple.
cheers
andrew
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index f6cd7eb..e9b4cc6 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -140,6 +140,8 @@ static int column_inserts = 0;
static int no_security_labels = 0;
static int no_unlogged_table_data = 0;
static int serializable_deferrable = 0;
+static int exclude_post_data = 0;
+static int post_data_only = 0;
static void help(const char *progname);
@@ -334,6 +336,8 @@ main(int argc, char **argv)
{"use-set-session-authorization", no_argument, &use_setsessauth, 1},
{"no-security-labels", no_argument, &no_security_labels, 1},
{"no-unlogged-table-data", no_argument, &no_unlogged_table_data, 1},
+ {"no-post-data", no_argument, &exclude_post_data, 1},
+ {"post-data-only", no_argument, &post_data_only, 1},
{NULL, 0, NULL, 0}
};
@@ -790,7 +794,7 @@ main(int argc, char **argv)
dumpStdStrings(g_fout);
/* The database item is always next, unless we don't want it at all */
- if (include_everything && !dataOnly)
+ if (include_everything && !dataOnly && !post_data_only)
dumpDatabase(g_fout);
/* Now the rearrangeable objects. */
@@ -876,6 +880,8 @@ help(const char *progname)
printf(_(" --no-unlogged-table-data do not dump unlogged table data\n"));
printf(_(" --quote-all-identifiers quote all identifiers, even if not key words\n"));
printf(_(" --serializable-deferrable wait until the dump can run without anomalies\n"));
+ printf(_(" --no-post-data do not dump constraints, indexes, rules, triggers\n"));
+ printf(_(" --post-data-only only dump constraints, indexes, rules, triggers\n"));
printf(_(" --use-set-session-authorization\n"
" use SET SESSION AUTHORIZATION commands instead of\n"
" ALTER OWNER commands to set ownership\n"));
@@ -7023,6 +7029,25 @@ collectComments(Archive *fout, CommentItem **items)
static void
dumpDumpableObject(Archive *fout, DumpableObject *dobj)
{
+
+ int skip = 0;
+
+ switch (dobj->objType)
+ {
+ case DO_INDEX:
+ case DO_TRIGGER:
+ case DO_CONSTRAINT:
+ case DO_FK_CONSTRAINT:
+ case DO_RULE:
+ skip = exclude_post_data;
+ break;
+ default:
+ skip = post_data_only;
+ }
+
+ if (skip)
+ return;
+
switch (dobj->objType)
{
case DO_NAMESPACE:
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers