Re: psql doesn't reuse -p after backend fail

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, depesz(at)depesz(dot)com, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: psql doesn't reuse -p after backend fail
Date: 2012-08-15 23:06:12
Message-ID: 20120815230612.GT25473@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, Sep 14, 2011 at 10:52:50PM -0500, Robert Haas wrote:
> On Thu, Sep 8, 2011 at 5:09 AM, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:
> > On tis, 2011-09-06 at 17:12 +0200, hubert depesz lubaczewski wrote:
> >> On Mon, Sep 05, 2011 at 02:27:23PM -0400, Tom Lane wrote:
> >> > It's not just the port, it's all the connection parameters ---
> >> > do_connect relies on the PGconn object to remember those, and in this
> >> > case there no longer is a PGconn object.
> >> >
> >> > We could have psql keep that information separately, but I'm not sure
> >> > it's really worth the trouble.
> >>
> >> well, I think it's definitely worth the trouble. If I had datbaase
> >> standing at 5432, it would connect to it, and then I could mistakenly
> >> ran commands to wrong database.
> >> this is clearly not a good thing.
> >
> > Perhaps just prevent \connect without argument if the information is no
> > longer available.
>
> I think it'd be worth actually having psql maintain the information
> separately from the PGconn... but if nobody feels motivated to go do
> that, doing at least this much would remove the foot-gun. So +1 for
> that.

OK, I have applied the attached, applied patch to do as you suggest.

Here are examples:

!> SELECT * FROM mytable WHERE to_ascii(convert_to(mytext, 'latin1'), 'latin1')
-> = to_ascii(convert_to('nicetry', 'latin1'), 'latin1');
You are currently not connected to a database.
!> \c
All connection parameters must be supplied because no database connection exists
!> \q
$ psql -p 5433 test
psql (9.3devel)
Type "help" for help.

test=> \c
You are now connected to database "test" as user "postgres".
test=> \q

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +

Attachment Content-Type Size
psql.diff text/x-diff 559 bytes

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message daniel 2012-08-15 23:06:41 BUG #7498: Questionable interval parsing when in the form 'n m days'
Previous Message Tom Lane 2012-08-15 22:42:51 Re: [BUGS] BUG #6184: Inconsistencies in log messages