33 *
44 * Copyright (c) 2000-2005, PostgreSQL Global Development Group
55 *
6- * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.150 2005/07/18 20:57:53 momjian Exp $
6+ * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.151 2005/07/25 17:17:41 momjian Exp $
77 */
88#include "postgres_fe.h"
99#include "command.h"
@@ -911,6 +911,7 @@ do_connect(const char *new_dbname, const char *new_user)
911911 const char * dbparam = NULL ;
912912 const char * userparam = NULL ;
913913 const char * pwparam = NULL ;
914+ char * password_prompt = NULL ;
914915 char * prompted_password = NULL ;
915916 bool need_pass ;
916917 bool success = false;
@@ -930,9 +931,18 @@ do_connect(const char *new_dbname, const char *new_user)
930931 else
931932 userparam = new_user ;
932933
934+ if (userparam == NULL )
935+ password_prompt = strdup ("Password: " );
936+ else
937+ {
938+ password_prompt = malloc (strlen ("Password for user %s: " ) - 2 +
939+ strlen (userparam ) + 1 );
940+ sprintf (password_prompt ,"Password for user %s: " , userparam );
941+ }
942+
933943 /* need to prompt for password? */
934944 if (pset .getPassword )
935- pwparam = prompted_password = simple_prompt ("Password: " , 100 , false);
945+ pwparam = prompted_password = simple_prompt (password_prompt , 100 , false);
936946
937947 /*
938948 * Use old password (if any) if no new one given and we are
@@ -956,11 +966,12 @@ do_connect(const char *new_dbname, const char *new_user)
956966 need_pass = true;
957967 free (prompted_password );
958968 prompted_password = NULL ;
959- pwparam = prompted_password = simple_prompt ("Password: " , 100 , false);
969+ pwparam = prompted_password = simple_prompt (password_prompt , 100 , false);
960970 }
961971 } while (need_pass );
962972
963973 free (prompted_password );
974+ free (password_prompt );
964975
965976 /*
966977 * If connection failed, try at least keep the old one. That's
0 commit comments