3
3
*
4
4
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
5
5
*
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 $
7
7
*/
8
8
#include "postgres_fe.h"
9
9
#include "command.h"
@@ -911,6 +911,7 @@ do_connect(const char *new_dbname, const char *new_user)
911
911
const char * dbparam = NULL ;
912
912
const char * userparam = NULL ;
913
913
const char * pwparam = NULL ;
914
+ char * password_prompt = NULL ;
914
915
char * prompted_password = NULL ;
915
916
bool need_pass ;
916
917
bool success = false;
@@ -930,9 +931,18 @@ do_connect(const char *new_dbname, const char *new_user)
930
931
else
931
932
userparam = new_user ;
932
933
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
+
933
943
/* need to prompt for password? */
934
944
if (pset .getPassword )
935
- pwparam = prompted_password = simple_prompt ("Password: " , 100 , false);
945
+ pwparam = prompted_password = simple_prompt (password_prompt , 100 , false);
936
946
937
947
/*
938
948
* 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)
956
966
need_pass = true;
957
967
free (prompted_password );
958
968
prompted_password = NULL ;
959
- pwparam = prompted_password = simple_prompt ("Password: " , 100 , false);
969
+ pwparam = prompted_password = simple_prompt (password_prompt , 100 , false);
960
970
}
961
971
} while (need_pass );
962
972
963
973
free (prompted_password );
974
+ free (password_prompt );
964
975
965
976
/*
966
977
* If connection failed, try at least keep the old one. That's
0 commit comments