Index: src/interfaces/libpq/fe-connect.c
===================================================================
RCS file: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v
retrieving revision 1.389
diff -c -c -r1.389 fe-connect.c
*** src/interfaces/libpq/fe-connect.c	3 Mar 2010 20:31:09 -0000	1.389
--- src/interfaces/libpq/fe-connect.c	10 Mar 2010 02:37:20 -0000
***************
*** 652,657 ****
--- 652,659 ----
  										conn->dbName, conn->pguser);
  		if (conn->pgpass == NULL)
  			conn->pgpass = strdup(DefaultPassword);
+ 		else
+ 			conn->used_dot_pgpass = true;
  	}
  
  	/*
***************
*** 1144,1149 ****
--- 1146,1161 ----
  			default:
  				/* Just in case we failed to set it in PQconnectPoll */
  				conn->status = CONNECTION_BAD;
+ 
+ 				/*
+ 				 *	If the connection failed, we should mention that
+ 				 *	we got the password from .pgpass in case that
+ 				 *	password is wrong.
+ 				 */
+ 				if (conn->used_dot_pgpass && conn->password_needed)
+ 					appendPQExpBufferStr(&conn->errorMessage,
+ 						libpq_gettext("(password retrieved from .pgpass)\n"));
+ 
  				return 0;
  		}
  
***************
*** 2191,2196 ****
--- 2203,2209 ----
  	conn->verbosity = PQERRORS_DEFAULT;
  	conn->sock = -1;
  	conn->password_needed = false;
+ 	conn->used_dot_pgpass = false;
  #ifdef USE_SSL
  	conn->allow_ssl_try = true;
  	conn->wait_ssl_try = false;
Index: src/interfaces/libpq/libpq-int.h
===================================================================
RCS file: /cvsroot/pgsql/src/interfaces/libpq/libpq-int.h,v
retrieving revision 1.149
diff -c -c -r1.149 libpq-int.h
*** src/interfaces/libpq/libpq-int.h	26 Feb 2010 02:01:33 -0000	1.149
--- src/interfaces/libpq/libpq-int.h	10 Mar 2010 02:37:20 -0000
***************
*** 343,348 ****
--- 343,349 ----
  	ProtocolVersion pversion;	/* FE/BE protocol version in use */
  	int			sversion;		/* server version, e.g. 70401 for 7.4.1 */
  	bool		password_needed;	/* true if server demanded a password */
+ 	bool		used_dot_pgpass;	/* true if used .pgpass */
  	bool		sigpipe_so;		/* have we masked SIGPIPE via SO_NOSIGPIPE? */
  	bool		sigpipe_flag;	/* can we mask SIGPIPE via MSG_NOSIGNAL? */
  
