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 1jSykE-0005hU-ID for pgsql-general@arkaria.postgresql.org; Mon, 27 Apr 2020 08:04:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jSykD-00079W-3Z for pgsql-general@arkaria.postgresql.org; Mon, 27 Apr 2020 08:04:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jSykC-00079P-Pp for pgsql-general@lists.postgresql.org; Mon, 27 Apr 2020 08:04:00 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jSyk6-0003Dg-NM for pgsql-general@postgresql.org; Mon, 27 Apr 2020 08:04:00 +0000 Received: by mail-wm1-x342.google.com with SMTP id x25so18469374wmc.0 for ; Mon, 27 Apr 2020 01:03:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:content-transfer-encoding:mime-version:subject:message-id:date :to; bh=pt9HahfqTFEN3Yf/9XIJwPBeIutPvBqjL91i0GT98Zw=; b=Sf1H7dXe0ItJ27/UJBlNe+832pcXq+54vdox237DPZYELbZSh1zD5kM+dj0EW3pjX7 B98wLfl/aaFMLGXj4nG2/7qnlXdC4IPaYYfM32p6r/MhTHOQVGKLes+Y6YknL3YTOQGb ZQV6o4xnGjJXlzaBYRCppjCR5BcakahR7Q7BtBdudBAvPyc53gCGG/0N7dZ7iU7QyUTn v/C1S+2zArb8wP1WoZjJb0Y9RoTOGvMCAr1OL30XOYO+68W9Z7JiVVlHoLDLw1ECdZfo 3m/TS3Mitu8poL6Wg77F1Pw0bOt95dmnVt3wDQyzTzgCjh8E4wtLJek3MEgauYa54eEv wx5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:message-id:date:to; bh=pt9HahfqTFEN3Yf/9XIJwPBeIutPvBqjL91i0GT98Zw=; b=ihOL0Ab1bCgUcSt2kr4e2jp5WyY+DZW9w/LnsBupnjMUzNRYTluKbavIHwOgi3Y6Az DAfWa51LzeXfAFXXZRoSoJcc/zp9+SK0Cgaj/QGOtu6SymtkbWOJCqFZtfIQUbn3OG0U hYmzAWgvlfOBItUh8akkqbiEZGUuTYmhHFScyjPECQyOU3mZcyGO1pOTp6nC6xDJBHIW wwbzLJSwPblBPzctbxLurbmM5cKvSdLERNy0nEAE7/biqXzUNG3OgQ4HNxtUuZcRp4qE SwivpyXGctW1UraiJ3npLicVFfivUi07Hq82SDfuDax36JcTOiRK0prJR+5qvRbjJbS/ 12sw== X-Gm-Message-State: AGi0PuZuFkV/c8u1Dg76Gp2tRSHQMHsQ8aRpv9OCSnVloQOUO/a6cbdj DnbunfDWLUkmM/Jha5dny4fkgHdjyI0= X-Google-Smtp-Source: APiQypLibGjxNlow7Kda0OXYx+bRmadZM2wWxzzPMddYaj6UDG+bB2CCEB1te6Mt7OQ7oZHFk6Sp/w== X-Received: by 2002:a7b:c0c5:: with SMTP id s5mr24399364wmh.134.1587974633489; Mon, 27 Apr 2020 01:03:53 -0700 (PDT) Received: from [192.168.1.8] (241-57-239-77.dyn.cable.fcom.ch. [77.239.57.241]) by smtp.gmail.com with ESMTPSA id s12sm13854857wmc.7.2020.04.27.01.03.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Apr 2020 01:03:53 -0700 (PDT) From: =?utf-8?Q?Paul_F=C3=B6rster?= Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: HOST variable in psql Message-Id: <91ADA44B-9EFA-4784-A45F-8323B3F552B3@gmail.com> Date: Mon, 27 Apr 2020 10:03:52 +0200 To: pgsql-general X-Mailer: Apple Mail (2.3608.80.23.2.2) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, the use of :HOST in psql containing the socket directory for local = connections 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 = perform a \c to connect to a different database in the database cluster, = then :HOST 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: postgres=3D# \echo :HOST mypghost postgres=3D# create database test; CREATE DATABASE postgres=3D# \c test You are now connected to database "test" as user "postgres". test=3D# \echo :HOST /tmp The documentations (https://www.postgresql.org/docs/12/app-psql.html) = says: "HOST The database server host you are currently connected to. This is set = every time you connect to a database (including program start-up), but = can be changed or unset." "Files psqlrc and ~/.psqlrc Unless it is passed an -X option, psql attempts to read and execute = commands from the system-wide startup file (psqlrc) and then the user's = personal startup file (~/.psqlrc), after connecting to the database but = before accepting normal commands." Makes sense so far, except the last part "after connecting to the = database but before accepting normal commands." This applies only to the = first psql startup but not a subsequent \c. If I do a \c, then that is = connecting to a database and that means, the psqlrc *should* be executed = again, which it isn't. Bug or feature? If feature, is there any remedy to this behavior? Thanks in advance, Paul=