pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
[PATCH] psql : Improve code for help option
6+ messages / 3 participants
[nested] [flat]

Commits from this thread:
  2021-03-04 4a4241e15b  Remove redundant getenv() for PGUSER, in psql help.
* [PATCH] psql : Improve code for help option
@ 2021-03-02 02:57  miyake_kouta <miyake_kouta@oss.nttdata.com>
  0 siblings, 1 reply; 6+ messages in thread

From: miyake_kouta @ 2021-03-02 02:57 UTC (permalink / raw)
  To: pgsql-hackers

Hi.

I found some redundant code in psql/help.c, so I propose a patch to fix 
it.
In the current help.c, the variable "user" is set to the value of 
$PGUSER (or get_user_name).
However, $PGUSER is referenced again in the code that follows.
We can replace this part with "user", I think.

Regards.
--
Kota Miyake

Attachments:

psql_help.patch (text/x-diff, 698B) download diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c index e44120bf76..75a2217cac 100644 --- a/src/bin/psql/help.c +++ b/src/bin/psql/help.c @@ -134,9 +134,7 @@ usage(unsigned short int pager) fprintf(output, _(" -p, --port=PORT database server port (default: \"%s\")\n"), env ? env : DEF_PGPORT_STR); /* Display default user */ - env = getenv("PGUSER"); - if (!env) - env = user; + env = user; fprintf(output, _(" -U, --username=USERNAME database user name (default: \"%s\")\n"), env); fprintf(output, _(" -w, --no-password never prompt for password\n")); fprintf(output, _(" -W, --password force password prompt (should happen automatically)\n"));
^ permalink raw reply [nested|flat] 6+ messages in thread

* Re: [PATCH] psql : Improve code for help option
@ 2021-03-02 15:09  Fujii Masao <masao.fujii@oss.nttdata.com>
  parent: miyake_kouta <miyake_kouta@oss.nttdata.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Fujii Masao @ 2021-03-02 15:09 UTC (permalink / raw)
  To: miyake_kouta <miyake_kouta@oss.nttdata.com>; pgsql-hackers



On 2021/03/02 11:57, miyake_kouta wrote:
> Hi.
> 
> I found some redundant code in psql/help.c, so I propose a patch to fix it.
> In the current help.c, the variable "user" is set to the value of $PGUSER (or get_user_name).
> However, $PGUSER is referenced again in the code that follows.
> We can replace this part with "user", I think.

Good catch!

>  	fprintf(output, _("  -U, --username=USERNAME  database user name (default: \"%s\")\n"), env);

We can simplify the code more and remove "env = user"
by just using "user" instead of "env" in the above?

Regards,

-- 
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [PATCH] psql : Improve code for help option
@ 2021-03-03 03:27  miyake_kouta <miyake_kouta@oss.nttdata.com>
  parent: Fujii Masao <masao.fujii@oss.nttdata.com>
  0 siblings, 1 reply; 6+ messages in thread

From: miyake_kouta @ 2021-03-03 03:27 UTC (permalink / raw)
  To: Fujii Masao <masao.fujii@oss.nttdata.com>; +Cc: pgsql-hackers

2021-03-03 00:09, Fujii Masao wrote:
> We can simplify the code more and remove "env = user"
> by just using "user" instead of "env" in the above?

Thank you for your comment.
I updated my patch and replaced "env" with "user".
Please check.

Regards.
--
Kota Miyake

Attachments:

v02_psql_help.patch (text/x-diff, 810B) download diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c index e44120bf76..edb17ed5dc 100644 --- a/src/bin/psql/help.c +++ b/src/bin/psql/help.c @@ -133,11 +133,7 @@ usage(unsigned short int pager) env = getenv("PGPORT"); fprintf(output, _(" -p, --port=PORT database server port (default: \"%s\")\n"), env ? env : DEF_PGPORT_STR); - /* Display default user */ - env = getenv("PGUSER"); - if (!env) - env = user; - fprintf(output, _(" -U, --username=USERNAME database user name (default: \"%s\")\n"), env); + fprintf(output, _(" -U, --username=USERNAME database user name (default: \"%s\")\n"), user); fprintf(output, _(" -w, --no-password never prompt for password\n")); fprintf(output, _(" -W, --password force password prompt (should happen automatically)\n"));
^ permalink raw reply [nested|flat] 6+ messages in thread

* Re: [PATCH] psql : Improve code for help option
@ 2021-03-03 07:39  Fujii Masao <masao.fujii@oss.nttdata.com>
  parent: miyake_kouta <miyake_kouta@oss.nttdata.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Fujii Masao @ 2021-03-03 07:39 UTC (permalink / raw)
  To: miyake_kouta <miyake_kouta@oss.nttdata.com>; +Cc: pgsql-hackers



On 2021/03/03 12:27, miyake_kouta wrote:
> 2021-03-03 00:09, Fujii Masao wrote:
>> We can simplify the code more and remove "env = user"
>> by just using "user" instead of "env" in the above?
> 
> Thank you for your comment.
> I updated my patch and replaced "env" with "user".
> Please check.

Thanks for updating the patch!
LGTM. Barrying any objection, I will commit this patch.

Regards,

-- 
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [PATCH] psql : Improve code for help option
@ 2021-03-03 08:05  Nitin Jadhav <nitinjadhavpostgres@gmail.com>
  parent: Fujii Masao <masao.fujii@oss.nttdata.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Nitin Jadhav @ 2021-03-03 08:05 UTC (permalink / raw)
  To: Fujii Masao <masao.fujii@oss.nttdata.com>; +Cc: miyake_kouta <miyake_kouta@oss.nttdata.com>; pgsql-hackers

Hi,

I have reviewed the patch and it looks good to me.

Thanks and Regards,
Nitin Jadhav

On Wed, Mar 3, 2021 at 1:09 PM Fujii Masao <masao.fujii@oss.nttdata.com>
wrote:

>
>
> On 2021/03/03 12:27, miyake_kouta wrote:
> > 2021-03-03 00:09, Fujii Masao wrote:
> >> We can simplify the code more and remove "env = user"
> >> by just using "user" instead of "env" in the above?
> >
> > Thank you for your comment.
> > I updated my patch and replaced "env" with "user".
> > Please check.
>
> Thanks for updating the patch!
> LGTM. Barrying any objection, I will commit this patch.
>
> Regards,
>
> --
> Fujii Masao
> Advanced Computing Technology Center
> Research and Development Headquarters
> NTT DATA CORPORATION
>
>
>

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [PATCH] psql : Improve code for help option
@ 2021-03-04 09:25  Fujii Masao <masao.fujii@oss.nttdata.com>
  parent: Nitin Jadhav <nitinjadhavpostgres@gmail.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Fujii Masao @ 2021-03-04 09:25 UTC (permalink / raw)
  To: Nitin Jadhav <nitinjadhavpostgres@gmail.com>; +Cc: miyake_kouta <miyake_kouta@oss.nttdata.com>; pgsql-hackers



On 2021/03/03 17:05, Nitin Jadhav wrote:
> Hi,
> 
> I have reviewed the patch and it looks good to me.

Thanks! Pushed.

Regards,

-- 
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION





^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2021-03-04 09:25 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-03-02 02:57 [PATCH] psql : Improve code for help option miyake_kouta <miyake_kouta@oss.nttdata.com>
2021-03-02 15:09 ` Fujii Masao <masao.fujii@oss.nttdata.com>
2021-03-03 03:27   ` miyake_kouta <miyake_kouta@oss.nttdata.com>
2021-03-03 07:39     ` Fujii Masao <masao.fujii@oss.nttdata.com>
2021-03-03 08:05       ` Nitin Jadhav <nitinjadhavpostgres@gmail.com>
2021-03-04 09:25         ` Fujii Masao <masao.fujii@oss.nttdata.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox