Re: Re : Win32 binaries test / pg_dump problem

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: pgsql-hackers-win32(at)postgresql(dot)org, PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Re : Win32 binaries test / pg_dump problem
Date: 2004-07-11 00:58:00
Message-ID: 200407110058.i6B0w0v25179@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers-win32 pgsql-patches


OK, the attached applied patch opens text files in binary mode in psql.
As you said, it already handles CRLF OK, and we need this to read
control-Z in copy files.

I assume we can write control-Z in text mode just fine, right?

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

Andrew Dunstan wrote:
> Bruce Momjian wrote:
>
> >Andrew Dunstan wrote:
> >
> >
> >>Cyril VELTER said:
> >>
> >>
> >>>From: "Andrew Dunstan" <andrew(at)dunslane(dot)net>
> >>>
> >>>
> >>>
> >>>>Cyril VELTER wrote:
> >>>>
> >>>>
> >>>>
> >>>>> if you psql -f test.sql basetest from the windows shell to a
> >>>>> windows
> >>>>>
> >>>>>
> >>>or
> >>>
> >>>
> >>>>>linux database, you'll get a missing data error :
> >>>>>
> >>>>>psql:test.sql:9: ERROR: missing data for column "b"
> >>>>>CONTEXT: COPY test, line 1: "a"
> >>>>>
> >>>>> if you psql -f test.sql basetest from a linux shell to a windows
> >>>>> or
> >>>>>linux database, you won't get an error
> >>>>>
> >>>>>
> >>>>Sounds like we should have psql open the file in binary mode on
> >>>>Windows. Would that cause problems? I doubt it, but I wonder.
> >>>>
> >>>>
> >>>>
> >>> you might be right, I just found some information on msdn that fseek
> >>> for
> >>>example is influenced by ctrl-z when the file is opened in text mode.
> >>>
> >>> I'm not sure that this is the cause of the second problem (backend
> >>> crash
> >>>on copy to) though.
> >>>
> >>> do you known where this modification needs to be done ?
> >>>
> >>> cyril
> >>>
> >>>
> >>>
> >>probably in src/bin/psql/command.c::process_file()
> >>
> >>instead of mode "r" we should probably use the predefined constant
> >>PG_BINARY_R
> >>
> >>
> >
> >Uh, but it isn't a binary file, it is SQL commands.
> >
> >
> >
>
> If it can have an embedded ^Z it is not a legal Windows text file.
>
> Adding the binary flag will have exactly 2 effects:
> 1. It will inhibit the behaviour of the driver in translating CRLF to
> plain LF
> 2. It will not see ^Z as EOF.
>
> We don't care about the first - we handle CRLF just fine. But we do care
> about the second, and we don't want the library to interpret ^Z as EOF.
>
> cheers
>
> andrew
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>

--
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 3.0 KB

In response to

Responses

Browse pgsql-hackers-win32 by date

  From Date Subject
Next Message Bruce Momjian 2004-07-11 02:57:35 Re: Data directory with trailing [back]slash
Previous Message Tom Lane 2004-07-10 23:53:06 Re: [HACKERS] Weird new time zone

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2004-07-11 01:51:57 Re: Updated ALTER TABLE ... SET TABLESPACE patch
Previous Message Bruce Momjian 2004-07-11 00:21:39 Re: nested xacts and phantom Xids