BUG #3059: psql to 'postgres' shortcut

Started by Raymond Naseefabout 19 years ago8 messagesbugs
Jump to latest
#1Raymond Naseef
raymondnaseef@yahoo.com

The following bug has been logged online:

Bug reference: 3059
Logged by: Raymond Naseef
Email address: raymondnaseef@yahoo.com
PostgreSQL version: 8.2
Operating system: Windows XP
Description: psql to 'postgres' shortcut
Details:

The shortcut to run psql.exe added to the menus is a great think to do, but
when the program stops the window closes with no pause or time delay.

This is a serious issue if the login fails. Sometimes I forget to start the
server, but I do not know that because I cannot read text in ~0.02 seconds.

BTW, I bet some of your other .bat files have the same issue.

Please run it by doing 1 or other:
1. Putting a "pause" at the end of the batch file.
2. cmd.exe /K "<command line>"
(just note the "" for default user name will make this fail. Sorry I do
not know how to fix that unless username has no bad-for-cmd characters in
it, then quotes are not needed)

#2Bruce Momjian
bruce@momjian.us
In reply to: Raymond Naseef (#1)
Re: BUG #3059: psql to 'postgres' shortcut

Raymond Naseef wrote:

The following bug has been logged online:

Bug reference: 3059
Logged by: Raymond Naseef
Email address: raymondnaseef@yahoo.com
PostgreSQL version: 8.2
Operating system: Windows XP
Description: psql to 'postgres' shortcut
Details:

The shortcut to run psql.exe added to the menus is a great think to do, but
when the program stops the window closes with no pause or time delay.

This is a serious issue if the login fails. Sometimes I forget to start the
server, but I do not know that because I cannot read text in ~0.02 seconds.

BTW, I bet some of your other .bat files have the same issue.

Please run it by doing 1 or other:
1. Putting a "pause" at the end of the batch file.
2. cmd.exe /K "<command line>"
(just note the "" for default user name will make this fail. Sorry I do
not know how to fix that unless username has no bad-for-cmd characters in
it, then quotes are not needed)

These solutions are going to make psql very annoying when it does work
properly.

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#3Magnus Hagander
magnus@hagander.net
In reply to: Bruce Momjian (#2)
Re: BUG #3059: psql to 'postgres' shortcut

On Mon, Feb 26, 2007 at 09:46:24AM -0500, Bruce Momjian wrote:

Raymond Naseef wrote:

The following bug has been logged online:

Bug reference: 3059
Logged by: Raymond Naseef
Email address: raymondnaseef@yahoo.com
PostgreSQL version: 8.2
Operating system: Windows XP
Description: psql to 'postgres' shortcut
Details:

The shortcut to run psql.exe added to the menus is a great think to do, but
when the program stops the window closes with no pause or time delay.

This is a serious issue if the login fails. Sometimes I forget to start the
server, but I do not know that because I cannot read text in ~0.02 seconds.

BTW, I bet some of your other .bat files have the same issue.

Please run it by doing 1 or other:
1. Putting a "pause" at the end of the batch file.
2. cmd.exe /K "<command line>"
(just note the "" for default user name will make this fail. Sorry I do
not know how to fix that unless username has no bad-for-cmd characters in
it, then quotes are not needed)

These solutions are going to make psql very annoying when it does work
properly.

Indeed. But it *is* also a problem the way it is now (I've noticed
myself a couple of times, but never had the time to fix it)

Perhaps a reasonable thing to do would be to have the shortcut point to
a .BAT file that does a "pause" only if psql exits with a non-zero
exitcode.

Is this reasonable? Will psql always exit with non-zero when something
like this happen and also importantly, willi t always exit with a zero
exitcode if there is no problem?

//Magnus

#4Phil Frost
phil@macprofessionals.com
In reply to: Magnus Hagander (#3)
Re: BUG #3059: psql to 'postgres' shortcut

Hrm...I haven't used windows for a while now, but isn't there an
option on all shortcuts to command-line programs to make the shell
pause on exit? It is something like, right click on shortcut, select
'properties', uncheck 'close shell on exit'. It would seem this would
solve the problem of not being able to see errors, while also not
adding a pause for programs which execute psql.bat directly.

On Feb 27, 2007, at 8:28 AM, Magnus Hagander wrote:

Show quoted text

On Mon, Feb 26, 2007 at 09:46:24AM -0500, Bruce Momjian wrote:

Raymond Naseef wrote:

The following bug has been logged online:

Bug reference: 3059
Logged by: Raymond Naseef
Email address: raymondnaseef@yahoo.com
PostgreSQL version: 8.2
Operating system: Windows XP
Description: psql to 'postgres' shortcut
Details:

The shortcut to run psql.exe added to the menus is a great think
to do, but
when the program stops the window closes with no pause or time
delay.

This is a serious issue if the login fails. Sometimes I forget
to start the
server, but I do not know that because I cannot read text in
~0.02 seconds.

BTW, I bet some of your other .bat files have the same issue.

Please run it by doing 1 or other:
1. Putting a "pause" at the end of the batch file.
2. cmd.exe /K "<command line>"
(just note the "" for default user name will make this fail.
Sorry I do
not know how to fix that unless username has no bad-for-cmd
characters in
it, then quotes are not needed)

These solutions are going to make psql very annoying when it does
work
properly.

Indeed. But it *is* also a problem the way it is now (I've noticed
myself a couple of times, but never had the time to fix it)

Perhaps a reasonable thing to do would be to have the shortcut
point to
a .BAT file that does a "pause" only if psql exits with a non-zero
exitcode.

Is this reasonable? Will psql always exit with non-zero when something
like this happen and also importantly, willi t always exit with a zero
exitcode if there is no problem?

#5Magnus Hagander
magnus@hagander.net
In reply to: Phil Frost (#4)
Re: BUG #3059: psql to 'postgres' shortcut

On Tue, Feb 27, 2007 at 09:06:17AM -0500, Phil Frost wrote:

Hrm...I haven't used windows for a while now, but isn't there an
option on all shortcuts to command-line programs to make the shell
pause on exit? It is something like, right click on shortcut, select
'properties', uncheck 'close shell on exit'. It would seem this would
solve the problem of not being able to see errors, while also not
adding a pause for programs which execute psql.bat directly.

Yes, that is exactly the point -it would be very annoying in all other
cases, as Bruce pointed out.

I guess another option would be to add a commandline option to psql to
pause on error, but I don't think that's going to fly ;-)

//Magnus

#6Bruce Momjian
bruce@momjian.us
In reply to: Magnus Hagander (#5)
Re: BUG #3059: psql to 'postgres' shortcut

Magnus Hagander wrote:

On Tue, Feb 27, 2007 at 09:06:17AM -0500, Phil Frost wrote:

Hrm...I haven't used windows for a while now, but isn't there an
option on all shortcuts to command-line programs to make the shell
pause on exit? It is something like, right click on shortcut, select
'properties', uncheck 'close shell on exit'. It would seem this would
solve the problem of not being able to see errors, while also not
adding a pause for programs which execute psql.bat directly.

Yes, that is exactly the point -it would be very annoying in all other
cases, as Bruce pointed out.

I guess another option would be to add a commandline option to psql to
pause on error, but I don't think that's going to fly ;-)

I just ran a test on Unix and found psql exits with '2' if the password
fails. In fact, looking at the psql sources I see:

#ifndef EXIT_SUCCESS
#define EXIT_SUCCESS 0
#endif

#ifndef EXIT_FAILURE
#define EXIT_FAILURE 1
#endif

#define EXIT_BADCONN 2

#define EXIT_USER 3

Notice EXIT_BADCONN. So, what if we call psql from a batch file, and
check for a '2' exit status, and then issue a pause for only that case?

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#7Raymond Naseef
raymondnaseef@yahoo.com
In reply to: Bruce Momjian (#6)
Re: BUG #3059: psql to 'postgres' shortcut

Dear Team,

I checked the shortcut and was unable to find any note about "close on exit" or anything like that. The .bat method sounds wonderful, and I would appreciate such a change to make the product a little more responsive.

Thank you for your consideration and time,

Raymond Naseef

P.S. I apologize if my email were not being sent properly. I will pay close attention to this going forward.

----- Original Message ----
From: Bruce Momjian <bruce@momjian.us>
To: Magnus Hagander <magnus@hagander.net>
Cc: Phil Frost <phil@macprofessionals.com>; Raymond Naseef <raymondnaseef@yahoo.com>; pgsql-bugs@postgresql.org
Sent: Tuesday, February 27, 2007 2:08:38 PM
Subject: Re: [BUGS] BUG #3059: psql to 'postgres' shortcut

Magnus Hagander wrote:

On Tue, Feb 27, 2007 at 09:06:17AM -0500, Phil Frost wrote:

Hrm...I haven't used windows for a while now, but isn't there an
option on all shortcuts to command-line programs to make the shell
pause on exit? It is something like, right click on shortcut, select
'properties', uncheck 'close shell on exit'. It would seem this would
solve the problem of not being able to see errors, while also not
adding a pause for programs which execute psql.bat directly.

Yes, that is exactly the point -it would be very annoying in all other
cases, as Bruce pointed out.

I guess another option would be to add a commandline option to psql to
pause on error, but I don't think that's going to fly ;-)

I just ran a test on Unix and found psql exits with '2' if the password
fails. In fact, looking at the psql sources I see:

#ifndef EXIT_SUCCESS
#define EXIT_SUCCESS 0
#endif

#ifndef EXIT_FAILURE
#define EXIT_FAILURE 1
#endif

#define EXIT_BADCONN 2

#define EXIT_USER 3

Notice EXIT_BADCONN. So, what if we call psql from a batch file, and
check for a '2' exit status, and then issue a pause for only that case?

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

____________________________________________________________________________________
It's here! Your new message!
Get new email alerts with the free Yahoo! Toolbar.
http://tools.search.yahoo.com/toolbar/features/mail/

#8Magnus Hagander
magnus@hagander.net
In reply to: Bruce Momjian (#6)
Re: BUG #3059: psql to 'postgres' shortcut

On Tue, Feb 27, 2007 at 02:08:38PM -0500, Bruce Momjian wrote:

Magnus Hagander wrote:

On Tue, Feb 27, 2007 at 09:06:17AM -0500, Phil Frost wrote:

Hrm...I haven't used windows for a while now, but isn't there an
option on all shortcuts to command-line programs to make the shell
pause on exit? It is something like, right click on shortcut, select
'properties', uncheck 'close shell on exit'. It would seem this would
solve the problem of not being able to see errors, while also not
adding a pause for programs which execute psql.bat directly.

Yes, that is exactly the point -it would be very annoying in all other
cases, as Bruce pointed out.

I guess another option would be to add a commandline option to psql to
pause on error, but I don't think that's going to fly ;-)

Notice EXIT_BADCONN. So, what if we call psql from a batch file, and
check for a '2' exit status, and then issue a pause for only that case?

I have applied a fix for the 8.3 pginstaller that does just this. Will be
in the next snapshot/release.

//Magnus