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

Commit9d58b96

Browse files
committed
Make pg_dump and pg_restore handle binary archive formats correctly
when using stdout/stdin on Windows.
1 parent889f038 commit9d58b96

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

‎src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.103 2005/01/25 22:44:31 tgl Exp $
18+
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.104 2005/01/26 19:44:43 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -29,6 +29,10 @@
2929
#include<ctype.h>
3030
#include<unistd.h>
3131

32+
#ifdefWIN32
33+
#include<io.h>
34+
#endif
35+
3236
#include"pqexpbuffer.h"
3337
#include"libpq/libpq-fs.h"
3438

@@ -1709,6 +1713,21 @@ _allocAH(const char *FileSpec, const ArchiveFormat fmt,
17091713
AH->gzOut=0;
17101714
AH->OF=stdout;
17111715

1716+
/*
1717+
* On Windows, we need to use binary mode to read/write non-text archive
1718+
* formats. Force stdin/stdout into binary mode in case that is what
1719+
* we are using.
1720+
*/
1721+
#ifdefWIN32
1722+
if (fmt!=archNull)
1723+
{
1724+
if (mode==archModeWrite)
1725+
setmode(fileno(stdout),O_BINARY);
1726+
else
1727+
setmode(fileno(stdin),O_BINARY);
1728+
}
1729+
#endif
1730+
17121731
#if0
17131732
write_msg(modulename,"archive format is %d\n",fmt);
17141733
#endif
@@ -1720,7 +1739,6 @@ _allocAH(const char *FileSpec, const ArchiveFormat fmt,
17201739

17211740
switch (AH->format)
17221741
{
1723-
17241742
casearchCustom:
17251743
InitArchiveFmt_Custom(AH);
17261744
break;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp