Skip to content

Commit fd62065

Browse files
committed
Fix Win32 pg_dumpall, with help from Claudio.
1 parent 2732932 commit fd62065

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/port/exec.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/port/exec.c,v 1.18 2004/08/08 02:22:55 momjian Exp $
10+
* $PostgreSQL: pgsql/src/port/exec.c,v 1.19 2004/08/08 03:21:39 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -374,15 +374,28 @@ static char *pipe_read_line(char *cmd, char *line, int maxsize)
374374
CloseHandle(childstdoutrddup);
375375
return NULL;
376376
}
377-
378-
377+
379378
/* We try just once */
380379
if (ReadFile(childstdoutrddup, line, maxsize, &bytesread, NULL) &&
381380
bytesread > 0)
382381
{
383382
/* So we read some data */
384383
retval = line;
385384

385+
/*
386+
* Sometime the child returns "\r\n", which doesn't match
387+
* our version string. The backend uses
388+
* setvbuf(stdout, NULL, _IONBF, 0), but pg_dump doesn't
389+
* so we have to fix it here.
390+
*/
391+
if (strlen(line) >= 2 &&
392+
line[strlen(line)-2] == '\r' &&
393+
line[strlen(line)-1] == '\n')
394+
{
395+
line[strlen(line)-2] == '\n';
396+
line[strlen(line)-1] == '\0';
397+
}
398+
386399
/*
387400
* We emulate fgets() behaviour. So if there is no newline
388401
* at the end, we add one...

0 commit comments

Comments
 (0)