Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id E825EB5DC58 for ; Mon, 5 Sep 2011 15:44:59 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 62101-03-6 for ; Mon, 5 Sep 2011 18:44:53 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from cronos.madness.at (madness.at [217.196.146.217]) by mail.postgresql.org (Postfix) with ESMTP id 176C3B5DC72 for ; Mon, 5 Sep 2011 15:44:48 -0300 (ADT) Received: from gatekeeper.kaltenbrunner.cc ([83.215.243.9] helo=[192.168.8.22]) by cronos.madness.at with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.72) (envelope-from ) id 1R0e9w-0004J7-I2; Mon, 05 Sep 2011 20:44:42 +0200 Message-ID: <4E651898.5030502@kaltenbrunner.cc> Date: Mon, 05 Sep 2011 20:44:40 +0200 From: Stefan Kaltenbrunner User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.16) Gecko/20110702 Iceowl/1.0b1 Icedove/3.0.11 MIME-Version: 1.0 To: Tom Lane CC: depesz@depesz.com, pgsql-bugs@postgresql.org Subject: Re: psql doesn't reuse -p after backend fail References: <20110905174633.GA7752@depesz.com> <11444.1315247243@sss.pgh.pa.us> In-Reply-To: <11444.1315247243@sss.pgh.pa.us> X-Enigmail-Version: 1.0.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201109/34 X-Sequence-Number: 31051 On 09/05/2011 08:27 PM, Tom Lane wrote: > hubert depesz lubaczewski writes: >> ran psql with specyfying port: >> psql -p 4329 -U postgres -d some_database > >> then I run query which breaks backend: > >> =# select * from categories limit 1; >> The connection to the server was lost. Attempting reset: Failed. >> !> > >> When I'll try to re-issue \c some_database now, I got: > >> !> \c some_database >> could not connect to server: No such file or directory >> Is the server running locally and accepting >> connections on Unix domain socket "/tmp/.s.PGSQL.5432"? >> !> > > 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. hmm I can see this as potentially very dangerous, just picture what might happen if you actually get a connection because there is another instance actually running on the default port (say 5432 is production and 4329 is development) and you end up issuing the wrong commands. If we provide "automatic reconnect" we should rather do that correctly or not at all... Stefan