Unix Technical Forum

BUG #3059: psql to 'postgres' shortcut

This is a discussion on BUG #3059: psql to 'postgres' shortcut within the pgsql Bugs forums, part of the PostgreSQL category; --> The following bug has been logged online: Bug reference: 3059 Logged by: Raymond Naseef Email address: raymondnaseef@yahoo.com PostgreSQL version: ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Bugs

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-10-2008, 10:38 AM
Raymond Naseef
 
Posts: n/a
Default BUG #3059: psql to 'postgres' shortcut


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)

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-10-2008, 10:38 AM
Bruce Momjian
 
Posts: n/a
Default 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. +

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-10-2008, 10:38 AM
Magnus Hagander
 
Posts: n/a
Default 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

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-10-2008, 10:38 AM
Phil Frost
 
Posts: n/a
Default 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:

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


---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-10-2008, 10:38 AM
Magnus Hagander
 
Posts: n/a
Default 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

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-10-2008, 10:38 AM
Bruce Momjian
 
Posts: n/a
Default 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. +

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 04-10-2008, 10:46 AM
Magnus Hagander
 
Posts: n/a
Default 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


---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 01:01 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com