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

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

BUG #2459: psql 8.1.4 vs 8.0.x behaves differently with tty / con / stdin recent fixes



The following bug has been logged online:

Bug reference:      2459
Logged by:          Silvio Macedo
Email address:      smacedo(at)calmetric(dot)pt
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;
	}



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group