Re: Win32 fix for pg_dumpall

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Win32 fix for pg_dumpall
Date: 2004-08-16 01:26:20
Message-ID: 200408160126.i7G1QKX09226@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches


OK, I have cleaned up this code and clarified the comment. Attached and
applied.

---------------------------------------------------------------------------

Andrew Dunstan wrote:
>
>
> Bruce Momjian wrote:
>
> >
> > /*
> >+ * 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';
> >+ }
> >+
> >+ /*
> >
> >
> >
>
> I do not see how the comment relates at all to the code following it -
> buffer mode and line end mode are two different things. Also, the
> repeated calls to strlen(line) are horribly inefficient - it should be
> called once and stashed in an int (I once made an order of magnitude
> speedup in a program by correcting a piece of someone else's code that
> looked like this: for (i = 0; i <= strlen(s); i++) where s was an
> invariant very long string)
>
> cheers
>
> andrew
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

Attachment Content-Type Size
unknown_filename text/plain 1.7 KB

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2004-08-16 01:28:37 Re: 8.0: Absolute path required for INITDB?
Previous Message Philip Warner 2004-08-16 01:10:18 Re: pg_dump 'die_on_errors'