mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-10-02 21:56:53 +02:00
Allow pg_basebackup compressed tar output to stdout
This commit is contained in:
parent
1b6dabc452
commit
d68714b29c
@ -174,8 +174,7 @@ PostgreSQL documentation
|
|||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Enables gzip compression of tar file output. Compression is only
|
Enables gzip compression of tar file output. Compression is only
|
||||||
available when generating tar files, and is not available when sending
|
available when using the tar format.
|
||||||
output to standard output.
|
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
@ -261,7 +261,22 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
|
|||||||
* Base tablespaces
|
* Base tablespaces
|
||||||
*/
|
*/
|
||||||
if (strcmp(basedir, "-") == 0)
|
if (strcmp(basedir, "-") == 0)
|
||||||
tarfile = stdout;
|
{
|
||||||
|
#ifdef HAVE_LIBZ
|
||||||
|
if (compresslevel > 0)
|
||||||
|
{
|
||||||
|
ztarfile = gzdopen(dup(fileno(stdout)), "wb");
|
||||||
|
if (gzsetparams(ztarfile, compresslevel, Z_DEFAULT_STRATEGY) != Z_OK)
|
||||||
|
{
|
||||||
|
fprintf(stderr, _("%s: could not set compression level %i: %s\n"),
|
||||||
|
progname, compresslevel, get_gz_error(ztarfile));
|
||||||
|
disconnect_and_exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
tarfile = stdout;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef HAVE_LIBZ
|
#ifdef HAVE_LIBZ
|
||||||
@ -384,7 +399,14 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(basedir, "-") != 0)
|
if (strcmp(basedir, "-") == 0)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_LIBZ
|
||||||
|
if (ztarfile)
|
||||||
|
gzclose(ztarfile);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
#ifdef HAVE_LIBZ
|
#ifdef HAVE_LIBZ
|
||||||
if (ztarfile != NULL)
|
if (ztarfile != NULL)
|
||||||
@ -1076,14 +1098,6 @@ main(int argc, char **argv)
|
|||||||
progname);
|
progname);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
if (compresslevel > 0 && strcmp(basedir, "-") == 0)
|
|
||||||
{
|
|
||||||
fprintf(stderr,
|
|
||||||
_("%s: compression is not supported on standard output\n"),
|
|
||||||
progname);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user