aboutsummaryrefslogtreecommitdiff
path: root/src/bin/pg_dump/dumputils.c
diff options
context:
space:
mode:
authorAndrew Dunstan <andrew@dunslane.net>2011-12-16 19:09:38 -0500
committerAndrew Dunstan <andrew@dunslane.net>2011-12-16 19:09:38 -0500
commita4cd6abcc901c1a8009c62a27f78696717bb8fe1 (patch)
tree5e595245b8e855b27c8b13bbc1e9a36f7fe80da8 /src/bin/pg_dump/dumputils.c
parent4b43b48c9f05d7bfc5d20fdf53c8fb966d704312 (diff)
downloadpostgresql-a4cd6abcc901c1a8009c62a27f78696717bb8fe1.tar.gz
postgresql-a4cd6abcc901c1a8009c62a27f78696717bb8fe1.zip
Add --section option to pg_dump and pg_restore.
Valid values are --pre-data, data and post-data. The option can be given more than once. --schema-only is equivalent to --section=pre-data --section=post-data. --data-only is equivalent to --section=data. Andrew Dunstan, reviewed by Joachim Wieland and Josh Berkus.
Diffstat (limited to 'src/bin/pg_dump/dumputils.c')
-rw-r--r--src/bin/pg_dump/dumputils.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/bin/pg_dump/dumputils.c b/src/bin/pg_dump/dumputils.c
index 5dab9675fc0..659ec06dc79 100644
--- a/src/bin/pg_dump/dumputils.c
+++ b/src/bin/pg_dump/dumputils.c
@@ -17,6 +17,7 @@
#include <ctype.h>
#include "dumputils.h"
+#include "pg_backup.h"
#include "parser/keywords.h"
@@ -1262,3 +1263,32 @@ exit_horribly(const char *modulename, const char *fmt,...)
exit(1);
}
+
+/*
+ * Set the bitmask in dumpSections according to the first argument.
+ * dumpSections is initialised as DUMP_UNSECTIONED by pg_dump and
+ * pg_restore so they can know if this has even been called.
+ */
+
+void
+set_section (const char *arg, int *dumpSections)
+{
+ /* if this is the first, clear all the bits */
+ if (*dumpSections == DUMP_UNSECTIONED)
+ *dumpSections = 0;
+
+ if (strcmp(arg,"pre-data") == 0)
+ *dumpSections |= DUMP_PRE_DATA;
+ else if (strcmp(arg,"data") == 0)
+ *dumpSections |= DUMP_DATA;
+ else if (strcmp(arg,"post-data") == 0)
+ *dumpSections |= DUMP_POST_DATA;
+ else
+ {
+ fprintf(stderr, _("%s: unknown section name \"%s\")\n"),
+ progname, arg);
+ fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
+ progname);
+ exit(1);
+ }
+}