Opening stdin/stdout in binary mode on Windows

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers-win32(at)postgresql(dot)org
Subject: Opening stdin/stdout in binary mode on Windows
Date: 2005-01-25 22:51:47
Message-ID: 7945.1106693507@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers-win32

I wrote:
>> pg_restore: [archiver] unsupported version (1.13) in file header

> Come to think of it, I'll bet that you cannot use "> DBFile" on Windows
> because it ends up opening the archive file in text instead of binary
> mode. SetOutput() in pg_backup_archiver.c tries to work around this by
> doing

> fn = fileno(stdout);
> AH->OF = fdopen(dup(fn), PG_BINARY_W);

> but it wouldn't surprise me in the least to learn that that doesn't work
> on Windows.

We now have confirmation that indeed this is the source of the pg_dump
misbehavior. Can anyone suggest a way that does work to do binary I/O
on stdout? What about reading from stdin?

If we can't fix this it will require some serious uglification of the
pg_dump/pg_restore docs for Windows ...

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2005-01-25 22:58:46 Re: Extended unit
Previous Message David Siebert 2005-01-25 22:49:11 Problem with Postgres V 8 and DBI maybe

Browse pgsql-hackers-win32 by date

  From Date Subject
Next Message Tom Lane 2005-01-26 18:37:16 Re: Opening stdin/stdout in binary mode on Windows
Previous Message Magnus Hagander 2005-01-24 22:47:36 Re: long sql "in" clause crashes server process (8.0 Release)