Commit 1161f1ae authored by Tom Lane's avatar Tom Lane

Remove the long-deprecated -u option from psql, since it does nothing very

useful and confuses people who think it is the same as -U.  (Eventually
we might want to re-introduce it as being an alias for -U, but that should
not happen until the switch has actually not been there for a few releases.)
Likewise in pg_dump and pg_restore.  Per gripe from Robert Treat and
subsequent discussion.
parent 3a7211aa
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.196 2007/10/29 17:29:59 momjian Exp $ $PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.197 2007/12/11 19:01:06 tgl Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -362,24 +362,6 @@ PostgreSQL documentation ...@@ -362,24 +362,6 @@ PostgreSQL documentation
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><option>-u</></term>
<listitem>
<para>
Forces <application>psql</application> to prompt for the user name and
password before connecting to the database.
</para>
<para>
This option is deprecated, as it is conceptually flawed.
(Prompting for a non-default user name and prompting for a
password because the server requires it are really two different
things.) You are encouraged to look at the <option>-U</option> and
<option>-W</option> options instead.
</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><option>-U <replaceable class="parameter">username</replaceable></></term> <term><option>-U <replaceable class="parameter">username</replaceable></></term>
<term><option>--username <replaceable class="parameter">username</replaceable></></term> <term><option>--username <replaceable class="parameter">username</replaceable></></term>
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* by PostgreSQL * by PostgreSQL
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.479 2007/11/19 23:48:33 momjian Exp $ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.480 2007/12/11 19:01:06 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -302,7 +302,7 @@ main(int argc, char **argv) ...@@ -302,7 +302,7 @@ main(int argc, char **argv)
} }
} }
while ((c = getopt_long(argc, argv, "abcCdDE:f:F:h:in:N:oOp:RsS:t:T:uU:vWxX:Z:", while ((c = getopt_long(argc, argv, "abcCdDE:f:F:h:in:N:oOp:RsS:t:T:U:vWxX:Z:",
long_options, &optindex)) != -1) long_options, &optindex)) != -1)
{ {
switch (c) switch (c)
...@@ -395,11 +395,6 @@ main(int argc, char **argv) ...@@ -395,11 +395,6 @@ main(int argc, char **argv)
simple_string_list_append(&table_exclude_patterns, optarg); simple_string_list_append(&table_exclude_patterns, optarg);
break; break;
case 'u':
force_password = true;
username = simple_prompt("User name: ", 100, true);
break;
case 'U': case 'U':
username = optarg; username = optarg;
break; break;
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_restore.c,v 1.84 2006/10/14 23:07:22 tgl Exp $ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_restore.c,v 1.85 2007/12/11 19:01:06 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -137,7 +137,7 @@ main(int argc, char **argv) ...@@ -137,7 +137,7 @@ main(int argc, char **argv)
} }
} }
while ((c = getopt_long(argc, argv, "acCd:ef:F:h:iI:lL:n:Op:P:RsS:t:T:uU:vWxX:1", while ((c = getopt_long(argc, argv, "acCd:ef:F:h:iI:lL:n:Op:P:RsS:t:T:U:vWxX:1",
cmdopts, NULL)) != -1) cmdopts, NULL)) != -1)
{ {
switch (c) switch (c)
...@@ -223,11 +223,6 @@ main(int argc, char **argv) ...@@ -223,11 +223,6 @@ main(int argc, char **argv)
opts->tableNames = strdup(optarg); opts->tableNames = strdup(optarg);
break; break;
case 'u':
opts->requirePassword = true;
opts->username = simple_prompt("User name: ", 100, true);
break;
case 'U': case 'U':
opts->username = optarg; opts->username = optarg;
break; break;
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright (c) 2000-2007, PostgreSQL Global Development Group * Copyright (c) 2000-2007, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.184 2007/12/09 19:01:40 tgl Exp $ * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.185 2007/12/11 19:01:06 tgl Exp $
*/ */
#include "postgres_fe.h" #include "postgres_fe.h"
#include "command.h" #include "command.h"
...@@ -1081,8 +1081,9 @@ prompt_for_password(const char *username) ...@@ -1081,8 +1081,9 @@ prompt_for_password(const char *username)
{ {
char *prompt_text; char *prompt_text;
prompt_text = malloc(strlen(username) + 32); prompt_text = malloc(strlen(username) + 100);
sprintf(prompt_text, "Password for user \"%s\": ", username); snprintf(prompt_text, strlen(username) + 100,
_("Password for user %s: "), username);
result = simple_prompt(prompt_text, 100, false); result = simple_prompt(prompt_text, 100, false);
free(prompt_text); free(prompt_text);
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright (c) 2000-2007, PostgreSQL Global Development Group * Copyright (c) 2000-2007, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.143 2007/12/09 19:04:47 tgl Exp $ * $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.144 2007/12/11 19:01:06 tgl Exp $
*/ */
#include "postgres_fe.h" #include "postgres_fe.h"
...@@ -104,8 +104,6 @@ main(int argc, char *argv[]) ...@@ -104,8 +104,6 @@ main(int argc, char *argv[])
{ {
struct adhoc_opts options; struct adhoc_opts options;
int successResult; int successResult;
char *username = NULL;
char *password = NULL; char *password = NULL;
char *password_prompt = NULL; char *password_prompt = NULL;
bool new_pass; bool new_pass;
...@@ -176,26 +174,14 @@ main(int argc, char *argv[]) ...@@ -176,26 +174,14 @@ main(int argc, char *argv[])
if (!pset.popt.topt.recordSep) if (!pset.popt.topt.recordSep)
pset.popt.topt.recordSep = pg_strdup(DEFAULT_RECORD_SEP); pset.popt.topt.recordSep = pg_strdup(DEFAULT_RECORD_SEP);
if (options.username)
{
/*
* The \001 is a hack to support the deprecated -u option which issues
* a username prompt. The recommended option is -U followed by the
* name on the command line.
*/
if (strcmp(options.username, "\001") == 0)
username = simple_prompt("User name: ", 100, true);
else
username = pg_strdup(options.username);
}
if (options.username == NULL) if (options.username == NULL)
password_prompt = pg_strdup(_("Password: ")); password_prompt = pg_strdup(_("Password: "));
else else
{ {
password_prompt = malloc(strlen(_("Password for user %s: ")) - 2 + password_prompt = malloc(strlen(_("Password for user %s: ")) - 2 +
strlen(username) + 1); strlen(options.username) + 1);
sprintf(password_prompt, _("Password for user %s: "), username); sprintf(password_prompt, _("Password for user %s: "),
options.username);
} }
if (pset.getPassword) if (pset.getPassword)
...@@ -208,7 +194,7 @@ main(int argc, char *argv[]) ...@@ -208,7 +194,7 @@ main(int argc, char *argv[])
pset.db = PQsetdbLogin(options.host, options.port, NULL, NULL, pset.db = PQsetdbLogin(options.host, options.port, NULL, NULL,
options.action == ACT_LIST_DB && options.dbname == NULL ? options.action == ACT_LIST_DB && options.dbname == NULL ?
"postgres" : options.dbname, "postgres" : options.dbname,
username, password); options.username, password);
if (PQstatus(pset.db) == CONNECTION_BAD && if (PQstatus(pset.db) == CONNECTION_BAD &&
PQconnectionNeedsPassword(pset.db) && PQconnectionNeedsPassword(pset.db) &&
...@@ -221,7 +207,6 @@ main(int argc, char *argv[]) ...@@ -221,7 +207,6 @@ main(int argc, char *argv[])
} }
} while (new_pass); } while (new_pass);
free(username);
free(password); free(password);
free(password_prompt); free(password_prompt);
...@@ -446,11 +431,10 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options) ...@@ -446,11 +431,10 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
extern char *optarg; extern char *optarg;
extern int optind; extern int optind;
int c; int c;
bool used_old_u_option = false;
memset(options, 0, sizeof *options); memset(options, 0, sizeof *options);
while ((c = getopt_long(argc, argv, "aAc:d:eEf:F:h:HlL:no:p:P:qR:sStT:uU:v:VWxX?1", while ((c = getopt_long(argc, argv, "aAc:d:eEf:F:h:HlL:no:p:P:qR:sStT:U:v:VWxX?1",
long_options, &optindex)) != -1) long_options, &optindex)) != -1)
{ {
switch (c) switch (c)
...@@ -551,13 +535,6 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options) ...@@ -551,13 +535,6 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
case 'T': case 'T':
pset.popt.topt.tableAttr = pg_strdup(optarg); pset.popt.topt.tableAttr = pg_strdup(optarg);
break; break;
case 'u':
pset.getPassword = true;
options->username = "\001"; /* hopefully nobody has that
* username */
/* this option is out */
used_old_u_option = true;
break;
case 'U': case 'U':
options->username = optarg; options->username = optarg;
break; break;
...@@ -644,10 +621,6 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options) ...@@ -644,10 +621,6 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
optind++; optind++;
} }
if (used_old_u_option && !pset.quiet)
fprintf(stderr, _("%s: Warning: The -u option is deprecated. Use -U.\n"), pset.progname);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment