Thread: BUG #3059: psql to 'postgres' shortcut

BUG #3059: psql to 'postgres' shortcut

From
"Raymond Naseef"
Date:
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)

Re: BUG #3059: psql to 'postgres' shortcut

From
Bruce Momjian
Date:
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. +

Re: BUG #3059: psql to 'postgres' shortcut

From
Magnus Hagander
Date:
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

Re: BUG #3059: psql to 'postgres' shortcut

From
Phil Frost
Date:
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:

> 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?

Re: BUG #3059: psql to 'postgres' shortcut

From
Magnus Hagander
Date:
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

Re: BUG #3059: psql to 'postgres' shortcut

From
Bruce Momjian
Date:
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. +

Re: BUG #3059: psql to 'postgres' shortcut

From
Raymond Naseef
Date:
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 app=
reciate 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 clos=
e 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@y=
ahoo.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=20=20
> > option on all shortcuts to command-line programs to make the shell=20=
=20
> > pause on exit? It is something like, right click on shortcut, select=20=
=20
> > 'properties', uncheck 'close shell on exit'. It would seem this would=
=20=20
> > solve the problem of not being able to see errors, while also not=20=20
> > adding a pause for programs which execute psql.bat directly.
>=20
> Yes, that is exactly the point -it would be very annoying in all other
> cases, as Bruce pointed out.
>=20
> 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:
=20=20=20=20
    #ifndef EXIT_SUCCESS
    #define EXIT_SUCCESS 0
    #endif
=20=20=20=20
    #ifndef EXIT_FAILURE
    #define EXIT_FAILURE 1
    #endif
=20=20=20=20
    #define EXIT_BADCONN 2
=20=20=20=20
    #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?

--=20
  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. +


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

Re: BUG #3059: psql to 'postgres' shortcut

From
Magnus Hagander
Date:
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