Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd68714b

Browse files
committed
Allow pg_basebackup compressed tar output to stdout
1 parent1b6dabc commitd68714b

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

‎doc/src/sgml/ref/pg_basebackup.sgml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,7 @@ PostgreSQL documentation
174174
<listitem>
175175
<para>
176176
Enables gzip compression of tar file output. Compression is only
177-
available when generating tar files, and is not available when sending
178-
output to standard output.
177+
available when using the tar format.
179178
</para>
180179
</listitem>
181180
</varlistentry>

‎src/bin/pg_basebackup/pg_basebackup.c

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,22 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
261261
* Base tablespaces
262262
*/
263263
if (strcmp(basedir,"-")==0)
264-
tarfile=stdout;
264+
{
265+
#ifdefHAVE_LIBZ
266+
if (compresslevel>0)
267+
{
268+
ztarfile=gzdopen(dup(fileno(stdout)),"wb");
269+
if (gzsetparams(ztarfile,compresslevel,Z_DEFAULT_STRATEGY)!=Z_OK)
270+
{
271+
fprintf(stderr,_("%s: could not set compression level %i: %s\n"),
272+
progname,compresslevel,get_gz_error(ztarfile));
273+
disconnect_and_exit(1);
274+
}
275+
}
276+
else
277+
#endif
278+
tarfile=stdout;
279+
}
265280
else
266281
{
267282
#ifdefHAVE_LIBZ
@@ -384,7 +399,14 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
384399
}
385400
}
386401

387-
if (strcmp(basedir,"-")!=0)
402+
if (strcmp(basedir,"-")==0)
403+
{
404+
#ifdefHAVE_LIBZ
405+
if (ztarfile)
406+
gzclose(ztarfile);
407+
#endif
408+
}
409+
else
388410
{
389411
#ifdefHAVE_LIBZ
390412
if (ztarfile!=NULL)
@@ -1076,14 +1098,6 @@ main(int argc, char **argv)
10761098
progname);
10771099
exit(1);
10781100
}
1079-
#else
1080-
if (compresslevel>0&&strcmp(basedir,"-")==0)
1081-
{
1082-
fprintf(stderr,
1083-
_("%s: compression is not supported on standard output\n"),
1084-
progname);
1085-
exit(1);
1086-
}
10871101
#endif
10881102

10891103
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp