Win32 fix for pg_dumpall - Mailing list pgsql-patches

From Bruce Momjian
Subject Win32 fix for pg_dumpall
Date
Msg-id 200408080321.i783LKm13857@candle.pha.pa.us
Whole thread Raw
Responses Re: Win32 fix for pg_dumpall
List pgsql-patches
Here is fix for Win32 pg_dumpall that Claudio helped with.

Attached and applied.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
Index: src/port/exec.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/port/exec.c,v
retrieving revision 1.18
diff -c -c -r1.18 exec.c
*** src/port/exec.c    8 Aug 2004 02:22:55 -0000    1.18
--- src/port/exec.c    8 Aug 2004 03:16:52 -0000
***************
*** 374,381 ****
              CloseHandle(childstdoutrddup);
              return NULL;
          }
!
!
          /* We try just once */
          if (ReadFile(childstdoutrddup, line, maxsize, &bytesread, NULL) &&
              bytesread > 0)
--- 374,380 ----
              CloseHandle(childstdoutrddup);
              return NULL;
          }
!
          /* We try just once */
          if (ReadFile(childstdoutrddup, line, maxsize, &bytesread, NULL) &&
              bytesread > 0)
***************
*** 384,389 ****
--- 383,402 ----
              retval = line;

              /*
+              *    Sometime the child returns "\r\n", which doesn't match
+              *    our version string.  The backend uses
+              *    setvbuf(stdout, NULL, _IONBF, 0), but pg_dump doesn't
+              *    so we have to fix it here.
+              */
+             if (strlen(line) >= 2 &&
+                 line[strlen(line)-2] == '\r' &&
+                 line[strlen(line)-1] == '\n')
+             {
+                 line[strlen(line)-2] == '\n';
+                 line[strlen(line)-1] == '\0';
+             }
+
+             /*
               *    We emulate fgets() behaviour. So if there is no newline
               *    at the end, we add one...
               */

pgsql-patches by date:

Previous
From: "John Hansen"
Date:
Subject: Re: [HACKERS] UNICODE characters above 0x10000
Next
From: markir@coretech.co.nz
Date:
Subject: Re: Win32 tablespace