Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1161f1a

Browse files
committed
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. (Eventuallywe might want to re-introduce it as being an alias for -U, but that shouldnot 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 andsubsequent discussion.
1 parent3a7211a commit1161f1a

File tree

5 files changed

+15
-69
lines changed

5 files changed

+15
-69
lines changed

‎doc/src/sgml/ref/psql-ref.sgml

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.196 2007/10/29 17:29:59 momjian Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.197 2007/12/11 19:01:06 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -362,24 +362,6 @@ PostgreSQL documentation
362362
</listitem>
363363
</varlistentry>
364364

365-
<varlistentry>
366-
<term><option>-u</></term>
367-
<listitem>
368-
<para>
369-
Forces <application>psql</application> to prompt for the user name and
370-
password before connecting to the database.
371-
</para>
372-
373-
<para>
374-
This option is deprecated, as it is conceptually flawed.
375-
(Prompting for a non-default user name and prompting for a
376-
password because the server requires it are really two different
377-
things.) You are encouraged to look at the <option>-U</option> and
378-
<option>-W</option> options instead.
379-
</para>
380-
</listitem>
381-
</varlistentry>
382-
383365
<varlistentry>
384366
<term><option>-U <replaceable class="parameter">username</replaceable></></term>
385367
<term><option>--username <replaceable class="parameter">username</replaceable></></term>

‎src/bin/pg_dump/pg_dump.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*by PostgreSQL
1313
*
1414
* IDENTIFICATION
15-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.479 2007/11/19 23:48:33 momjian Exp $
15+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.480 2007/12/11 19:01:06 tgl Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -302,7 +302,7 @@ main(int argc, char **argv)
302302
}
303303
}
304304

305-
while ((c=getopt_long(argc,argv,"abcCdDE:f:F:h:in:N:oOp:RsS:t:T:uU:vWxX:Z:",
305+
while ((c=getopt_long(argc,argv,"abcCdDE:f:F:h:in:N:oOp:RsS:t:T:U:vWxX:Z:",
306306
long_options,&optindex))!=-1)
307307
{
308308
switch (c)
@@ -395,11 +395,6 @@ main(int argc, char **argv)
395395
simple_string_list_append(&table_exclude_patterns,optarg);
396396
break;
397397

398-
case'u':
399-
force_password= true;
400-
username=simple_prompt("User name: ",100, true);
401-
break;
402-
403398
case'U':
404399
username=optarg;
405400
break;

‎src/bin/pg_dump/pg_restore.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
*
3535
*
3636
* IDENTIFICATION
37-
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_restore.c,v 1.84 2006/10/14 23:07:22 tgl Exp $
37+
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_restore.c,v 1.85 2007/12/11 19:01:06 tgl Exp $
3838
*
3939
*-------------------------------------------------------------------------
4040
*/
@@ -137,7 +137,7 @@ main(int argc, char **argv)
137137
}
138138
}
139139

140-
while ((c=getopt_long(argc,argv,"acCd:ef:F:h:iI:lL:n:Op:P:RsS:t:T:uU:vWxX:1",
140+
while ((c=getopt_long(argc,argv,"acCd:ef:F:h:iI:lL:n:Op:P:RsS:t:T:U:vWxX:1",
141141
cmdopts,NULL))!=-1)
142142
{
143143
switch (c)
@@ -223,11 +223,6 @@ main(int argc, char **argv)
223223
opts->tableNames=strdup(optarg);
224224
break;
225225

226-
case'u':
227-
opts->requirePassword= true;
228-
opts->username=simple_prompt("User name: ",100, true);
229-
break;
230-
231226
case'U':
232227
opts->username=optarg;
233228
break;

‎src/bin/psql/command.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2007, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.184 2007/12/09 19:01:40 tgl Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.185 2007/12/11 19:01:06 tgl Exp $
77
*/
88
#include"postgres_fe.h"
99
#include"command.h"
@@ -1081,8 +1081,9 @@ prompt_for_password(const char *username)
10811081
{
10821082
char*prompt_text;
10831083

1084-
prompt_text=malloc(strlen(username)+32);
1085-
sprintf(prompt_text,"Password for user \"%s\": ",username);
1084+
prompt_text=malloc(strlen(username)+100);
1085+
snprintf(prompt_text,strlen(username)+100,
1086+
_("Password for user %s: "),username);
10861087
result=simple_prompt(prompt_text,100, false);
10871088
free(prompt_text);
10881089
}

‎src/bin/psql/startup.c

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2007, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.143 2007/12/09 19:04:47 tgl Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.144 2007/12/11 19:01:06 tgl Exp $
77
*/
88
#include"postgres_fe.h"
99

@@ -104,8 +104,6 @@ main(int argc, char *argv[])
104104
{
105105
structadhoc_optsoptions;
106106
intsuccessResult;
107-
108-
char*username=NULL;
109107
char*password=NULL;
110108
char*password_prompt=NULL;
111109
boolnew_pass;
@@ -176,26 +174,14 @@ main(int argc, char *argv[])
176174
if (!pset.popt.topt.recordSep)
177175
pset.popt.topt.recordSep=pg_strdup(DEFAULT_RECORD_SEP);
178176

179-
if (options.username)
180-
{
181-
/*
182-
* The \001 is a hack to support the deprecated -u option which issues
183-
* a username prompt. The recommended option is -U followed by the
184-
* name on the command line.
185-
*/
186-
if (strcmp(options.username,"\001")==0)
187-
username=simple_prompt("User name: ",100, true);
188-
else
189-
username=pg_strdup(options.username);
190-
}
191-
192177
if (options.username==NULL)
193178
password_prompt=pg_strdup(_("Password: "));
194179
else
195180
{
196181
password_prompt=malloc(strlen(_("Password for user %s: "))-2+
197-
strlen(username)+1);
198-
sprintf(password_prompt,_("Password for user %s: "),username);
182+
strlen(options.username)+1);
183+
sprintf(password_prompt,_("Password for user %s: "),
184+
options.username);
199185
}
200186

201187
if (pset.getPassword)
@@ -208,7 +194,7 @@ main(int argc, char *argv[])
208194
pset.db=PQsetdbLogin(options.host,options.port,NULL,NULL,
209195
options.action==ACT_LIST_DB&&options.dbname==NULL ?
210196
"postgres" :options.dbname,
211-
username,password);
197+
options.username,password);
212198

213199
if (PQstatus(pset.db)==CONNECTION_BAD&&
214200
PQconnectionNeedsPassword(pset.db)&&
@@ -221,7 +207,6 @@ main(int argc, char *argv[])
221207
}
222208
}while (new_pass);
223209

224-
free(username);
225210
free(password);
226211
free(password_prompt);
227212

@@ -446,11 +431,10 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
446431
externchar*optarg;
447432
externintoptind;
448433
intc;
449-
boolused_old_u_option= false;
450434

451435
memset(options,0,sizeof*options);
452436

453-
while ((c=getopt_long(argc,argv,"aAc:d:eEf:F:h:HlL:no:p:P:qR:sStT:uU:v:VWxX?1",
437+
while ((c=getopt_long(argc,argv,"aAc:d:eEf:F:h:HlL:no:p:P:qR:sStT:U:v:VWxX?1",
454438
long_options,&optindex))!=-1)
455439
{
456440
switch (c)
@@ -551,13 +535,6 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
551535
case'T':
552536
pset.popt.topt.tableAttr=pg_strdup(optarg);
553537
break;
554-
case'u':
555-
pset.getPassword= true;
556-
options->username="\001";/* hopefully nobody has that
557-
* username */
558-
/* this option is out */
559-
used_old_u_option= true;
560-
break;
561538
case'U':
562539
options->username=optarg;
563540
break;
@@ -644,10 +621,6 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
644621

645622
optind++;
646623
}
647-
648-
if (used_old_u_option&& !pset.quiet)
649-
fprintf(stderr,_("%s: Warning: The -u option is deprecated. Use -U.\n"),pset.progname);
650-
651624
}
652625

653626

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp