2016-11-07 7:06 GMT+01:00 amul sul <sula...@gmail.com>:

> On Mon, Nov 7, 2016 at 2:03 AM, Guillaume Lelarge
> <guilla...@lelarge.info> wrote:
> >>
> >> Agreed. I was afraid of that, but for some reason, didn't find that.
> I'll
> >> fix this.
> >
> >
> > Fixed in v4.
> >
>
> This fix is broken.
>
>  70  -   if (dopt.include_everything && !dopt.schemaOnly)
>  71 +   if (dopt.include_everything && !dopt.schemaOnly &&
> !dopt.outputBlobs)
>  72         dopt.outputBlobs = true;
>
> dopt.outputBlobs set to FALSE when option -B is specified and this IF
> condition reverts to TRUE which force to dump blobs.
>
>
I don't see what you mean. It forces dump of Blobs if we didn't use -B and
if we include everything in the dump, which seems good to me. What did you
try that didn't work as expected?

>>
> >>
> >>>
> >>> #2 :
> >>> We should add note for default behaviour if --no-blobs & --blobs both
> >>> are specified.
> >>>
> >>
> >> Right. I don't know how I will handle this, but you're right that the
> >> behaviour should be specified. I'll also fix this.
> >>
> >
> > I checked other options, such as --format, and there's nothing noted as a
> > default behaviour. Last one wins, which is what this patch does.
> >
>
> Such note exists for --table & --exclude-table option, see following
> lines in pg_dump.sgml
>
>  569        <para>
>  570         When both <option>-t</> and <option>-T</> are given, the
> behavior
>  571         is to dump just the tables that match at least one
> <option>-t</>
>  572         switch but no <option>-T</> switches.  If <option>-T</>
> appears
>  573         without <option>-t</>, then tables matching <option>-T</> are
>  574         excluded from what is otherwise a normal dump.
>  575        </para>
>  576       </listitem>
>
>
You're right on this. v5 fixes this.


-- 
Guillaume.
  http://blog.guillaume.lelarge.info
  http://www.dalibo.com
diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml
index 371a614..fb69d6d 100644
--- a/doc/src/sgml/ref/pg_dump.sgml
+++ b/doc/src/sgml/ref/pg_dump.sgml
@@ -145,6 +145,21 @@ PostgreSQL documentation
      </varlistentry>
 
      <varlistentry>
+      <term><option>-B</></term>
+      <term><option>--no-blobs</></term>
+      <listitem>
+       <para>
+        Exclude large objects in the dump.
+       </para>
+
+       <para>
+        When both <option>-b</> and <option>-B</> are given, the behavior
+        is dependent on which option is last on the command line.
+       </para>
+      </listitem>
+     </varlistentry>
+
+     <varlistentry>
       <term><option>-c</option></term>
       <term><option>--clean</option></term>
       <listitem>
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index 0e20985..f90c074 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -137,6 +137,7 @@ InitDumpOptions(DumpOptions *opts)
 {
 	memset(opts, 0, sizeof(DumpOptions));
 	/* set any fields that shouldn't default to zeroes */
+	opts->outputBlobs = true;
 	opts->include_everything = true;
 	opts->dumpSections = DUMP_UNSECTIONED;
 }
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 4da297f..4d3e245 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -291,6 +291,7 @@ main(int argc, char **argv)
 	static struct option long_options[] = {
 		{"data-only", no_argument, NULL, 'a'},
 		{"blobs", no_argument, NULL, 'b'},
+		{"no-blobs", no_argument, NULL, 'B'},
 		{"clean", no_argument, NULL, 'c'},
 		{"create", no_argument, NULL, 'C'},
 		{"dbname", required_argument, NULL, 'd'},
@@ -379,7 +380,7 @@ main(int argc, char **argv)
 
 	InitDumpOptions(&dopt);
 
-	while ((c = getopt_long(argc, argv, "abcCd:E:f:F:h:j:n:N:oOp:RsS:t:T:U:vwWxZ:",
+	while ((c = getopt_long(argc, argv, "abBcCd:E:f:F:h:j:n:N:oOp:RsS:t:T:U:vwWxZ:",
 							long_options, &optindex)) != -1)
 	{
 		switch (c)
@@ -392,6 +393,10 @@ main(int argc, char **argv)
 				dopt.outputBlobs = true;
 				break;
 
+			case 'B':			/* Don't dump blobs */
+				dopt.outputBlobs = false;
+				break;
+
 			case 'c':			/* clean (i.e., drop) schema prior to create */
 				dopt.outputClean = 1;
 				break;
@@ -708,7 +713,7 @@ main(int argc, char **argv)
 	 * Dumping blobs is now default unless we saw an inclusion switch or -s
 	 * ... but even if we did see one of these, -b turns it back on.
 	 */
-	if (dopt.include_everything && !dopt.schemaOnly)
+	if (dopt.include_everything && !dopt.schemaOnly && !dopt.outputBlobs)
 		dopt.outputBlobs = true;
 
 	/*
@@ -864,6 +869,7 @@ help(const char *progname)
 	printf(_("\nOptions controlling the output content:\n"));
 	printf(_("  -a, --data-only              dump only the data, not the schema\n"));
 	printf(_("  -b, --blobs                  include large objects in dump\n"));
+	printf(_("  -B, --no-blobs               exclude large objects in dump\n"));
 	printf(_("  -c, --clean                  clean (drop) database objects before recreating\n"));
 	printf(_("  -C, --create                 include commands to create database in dump\n"));
 	printf(_("  -E, --encoding=ENCODING      dump the data in encoding ENCODING\n"));
-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to