Unix always prompted from /dev/tty, but on Win32 we didn't have that
working until 8.1.4.  It should be that way.

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

Silvio Macedo wrote:
> 
> The following bug has been logged online:
> 
> Bug reference:      2459
> Logged by:          Silvio Macedo
> Email address:      [EMAIL PROTECTED]
> PostgreSQL version: 8.1.4
> Operating system:   Windows XP SP2
> Description:        psql 8.1.4 vs 8.0.x behaves differently with  tty / con
> / stdin recent fixes
> Details: 
> 
> Hi,
> 
> I've been using stdin/stdout of psql on Windows to run a script, without
> messing with "expect".
> 
> Before v8.1.4, one could include the password in the string fed to psql via
> stdin to authenticate the connection.
> 
> With 8.1.4, it doesn't work.
> 
> All of this *seems* to be related to patch introduced by Bruce:
> http://archives.postgresql.org/pgsql-patches/2006-03/msg00051.php
> to avoid relying  on /dev/con on Msys.
> 
> Is this a BUG or a design decision? If it's by design, people should be
> warned about this different behaviour (getting a password on the stdin
> doesn't work in 8.1.4)
> If it's a bug, correction should be on file
> \src\port\sprompt.c:69
> This, together with what is in file port.h, seems to be wrong :
> #ifdef WIN32
>               /* See DEVTTY comment for msys */
>               || (getenv("OSTYPE") && strcmp(getenv("OSTYPE"), "msys") == 0)
> #endif
> 
> 
> Below, reference material with relevant excerpts of different versions of
> \src\include\port.h and \src\port\sprompt.c
> 
> Thanks for any tip or feedback!
> Silvio
> calmetric.pt
> 
> \postgresql-8.0.7\src\include\port.h:81 to 85
> 
> #if defined(WIN32) && !defined(__CYGWIN__)
> #define DEVNULL "nul"
> 
> 
> #else
> #define DEVNULL "/dev/null"
> 
> #endif
> 
> 
> 
> \postgresql-8.1.4\src\include\port.h:85 to 92
> 
> #if defined(WIN32) && !defined(__CYGWIN__)
> #define DEVNULL "nul"
> /* "con" does not work from the Msys 1.0.10 console (part of MinGW). */
> #define DEVTTY        "con"
> #else
> #define DEVNULL "/dev/null"
> #define DEVTTY "/dev/tty"
> #endif
> 
> 
> 
> 
> 
> 
> \postgresql-8.0.7\src\port\sprompt.c:64 to 78
> 
>        * Do not try to collapse these into one "w+" mode file. Doesn't work
>        * on some platforms (eg, HPUX 10.20).
>        */
>       termin = fopen("/dev/tty", "r");
>       termout = fopen("/dev/tty", "w");
>       if (!termin || !termout)
> 
> 
> 
> 
> 
>       {
>               if (termin)
>                       fclose(termin);
>               if (termout)
>                       fclose(termout);
>               termin = stdin;
>               termout = stderr;
>       }
> 
> 
> 
> 
> \postgresql-8.1.4\src\port\sprompt.c:63 to 82
>        * Do not try to collapse these into one "w+" mode file. Doesn't work on
>        * some platforms (eg, HPUX 10.20).
>        */
>       termin = fopen(DEVTTY, "r");
>       termout = fopen(DEVTTY, "w");
>       if (!termin || !termout
> #ifdef WIN32
>               /* See DEVTTY comment for msys */
>               || (getenv("OSTYPE") && strcmp(getenv("OSTYPE"), "msys") == 0)
> #endif
>               )
>       {
>               if (termin)
>                       fclose(termin);
>               if (termout)
>                       fclose(termout);
>               termin = stdin;
>               termout = stderr;
>       }
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
> 

-- 
  Bruce Momjian   http://candle.pha.pa.us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Reply via email to