Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jT2k9-0006Fu-5w for pgsql-general@arkaria.postgresql.org; Mon, 27 Apr 2020 12:20:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jT2k7-00083Z-MJ for pgsql-general@arkaria.postgresql.org; Mon, 27 Apr 2020 12:20:11 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jT2k7-00080t-EE for pgsql-general@lists.postgresql.org; Mon, 27 Apr 2020 12:20:11 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jT2k5-0000XZ-7y for pgsql-general@postgresql.org; Mon, 27 Apr 2020 12:20:10 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id 03RCK636003326; Mon, 27 Apr 2020 08:20:06 -0400 From: Tom Lane To: =?utf-8?Q?Paul_F=C3=B6rster?= cc: pgsql-general Subject: Re: HOST variable in psql In-reply-to: <91ADA44B-9EFA-4784-A45F-8323B3F552B3@gmail.com> References: <91ADA44B-9EFA-4784-A45F-8323B3F552B3@gmail.com> Comments: In-reply-to =?utf-8?Q?Paul_F=C3=B6rster?= message dated "Mon, 27 Apr 2020 10:03:52 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3324.1587990006.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 27 Apr 2020 08:20:06 -0400 Message-ID: <3325.1587990006@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk =3D?utf-8?Q?Paul_F=3DC3=3DB6rster?=3D writes: > the use of :HOST in psql containing the socket directory for local conne= ctions is pretty useless for us, so we set it to the hostname in a global = psqlrc file: > \set HOST `hostname -s` > This works great when invoking psql on the command line. But if I perfor= m a \c to connect to a different database in the database cluster, then :H= OST gets reset to the socket directory. On the one hand, this makes sense,= on the other, the global psqlrc file does not seem to be executed again, = thus leaving :HOST in an unuable state for us: AFAICS, psql is behaving as documented. Why are you trying to override HOST like that, instead of just using some other variable? regards, tom lane