Skip site navigation (1) Skip section navigation (2)

Re: Re : Win32 binaries test / pg_dump problem

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: pgsql-hackers-win32(at)postgresql(dot)org
Subject: Re: Re : Win32 binaries test / pg_dump problem
Date: 2004-05-28 18:52:04
Message-ID: 40B78A54.50309@dunslane.net (view raw or flat)
Thread:
Lists: pgsql-hackers-win32pgsql-patches
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

In response to

Responses

pgsql-patches by date

Next:From: Andreas PflugDate: 2004-05-28 18:52:15
Subject: Re: thread safety testing fix
Previous:From: Thomas HallgrenDate: 2004-05-28 18:44:05
Subject: Re: Link errors on win32

pgsql-hackers-win32 by date

Next:From: Bruce MomjianDate: 2004-05-28 19:20:17
Subject: Re: Compiling libpq with VisualC
Previous:From: Bruce MomjianDate: 2004-05-28 18:34:51
Subject: Re: Re : Win32 binaries test / pg_dump problem

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group