Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ssl8i-00Agsm-3D for pgsql-general@arkaria.postgresql.org; Mon, 23 Sep 2024 15:38:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1ssl8g-00BHkD-Qk for pgsql-general@arkaria.postgresql.org; Mon, 23 Sep 2024 15:38:14 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ssl8g-00BHjC-G4 for pgsql-general@lists.postgresql.org; Mon, 23 Sep 2024 15:38:14 +0000 Received: from mail-oo1-xc29.google.com ([2607:f8b0:4864:20::c29]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1ssl8e-000fTd-1V for pgsql-general@postgresql.org; Mon, 23 Sep 2024 15:38:13 +0000 Received: by mail-oo1-xc29.google.com with SMTP id 006d021491bc7-5e1b55346c0so1720941eaf.3 for ; Mon, 23 Sep 2024 08:38:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727105891; x=1727710691; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=QBEWxD/6BSjajn0actnCasDttNFBy6D3DjwdA49loCk=; b=IGqPI9MkQRx1HDW91K8lggy9qsH+cqY7gYJIn58pSV1iHnh8x/hwBoPwLk8M//etHJ pexkdl5C/8sI+ueWEalN8TOsn7WM3cDE5mvY4KCqwhS6BC+lun2n+TQbD406VtI3aw+s JQ5fmCqTMVv9cUgpyz089zG/UUaf2yBHaFN3qAckx97tXMsrz2pE+bY+Au5aIgTcc5dI vptiQcVyaB400Pczf2jsW6iLQpp6NubFw/3k3rF54pec/amJAIQlnVT2FCyeMfi40Vpc D8wrQZgq4MDm1+4DaeXOKPk/6ex1XwDJDtiQ7dHmVT6XowCoarNUTJNC7KvKqFamRxn9 0Tdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727105891; x=1727710691; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QBEWxD/6BSjajn0actnCasDttNFBy6D3DjwdA49loCk=; b=lsAjSKp0rqbZ1HGb5nJu87kzcfXuiQGM/1x0r7XyhP/LewDxa9HG8JhjB3bFgkMloD 9WaN0dNQRmOc02RV6WEBfF1l4cLadkeeJ8bPVc67h850U+uZYzmteTPYnwPuaj91wW4X X7wR9gmC4S3bidOX1EGK81WrXu087mSRMcJBY2NesDUnqKYd4LjRyxuzMXaczF3+MZoB ScYpxWaQbNWaKvLTxT8RSGKnvEqUuIKeCRB+rPYoWRnj5DonJhPOWKrwZ9MVDomKmbWS tLhkviALv2lhCqRz7m2gH3MXFtISEnFW6CjMK264UX3GzG39XPZzlTkbEPwoQooBDKZy xtmA== X-Forwarded-Encrypted: i=1; AJvYcCWv/sFh6HundrZwL9NCD1m0aK2I9Y2k7dqOIikTgixLEFBMJrqjby3iPa+2EY9U18UTaBVdunuf+EKERvOH@postgresql.org X-Gm-Message-State: AOJu0YzPy2frN5f/Spz2NNIeflfMVJllbky8MJrUUuquHxarjiRvV2MQ Hz28m8I+591FIMbmhBXc/nBzNdSn41QrGEQhsnK7XSsNBIaHC0zmeE0CP3LyiV4CL8OrDL58MbB dE5kZBYreEbCt88fcHDBE5/AzzJg= X-Google-Smtp-Source: AGHT+IHCdSA9IuHqKl2njUATGriScDkjwld0tbJAQGvrpO8EzKvwb5gB5gFbLuUIv02EDn3MGup+e87A2jnaPz1NmSk= X-Received: by 2002:a05:6820:614:b0:5e1:ea03:928f with SMTP id 006d021491bc7-5e58ba6ad96mr6434252eaf.7.1727105890478; Mon, 23 Sep 2024 08:38:10 -0700 (PDT) MIME-Version: 1.0 References: <3079980.1727103295@sss.pgh.pa.us> In-Reply-To: From: Dominique Devienne Date: Mon, 23 Sep 2024 17:37:58 +0200 Message-ID: Subject: Re: Customize psql prompt to show current_role To: Adrian Klaver Cc: Tom Lane , Laurenz Albe , Erik Wienhold , Asad Ali , pgsql-general@postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Sep 23, 2024 at 5:16=E2=80=AFPM Adrian Klaver wrote: > On 9/23/24 08:07, Dominique Devienne wrote: > > I often resort to \conninfo, but it's less automatic and > > harder to visually parse (IMHO) compared to a custom ad-hoc prompt. > For me that shows the user that connected(session_user) not the current_u= ser. yeah, sure, I realized that just after sending my last post... I resort to using both \conninfo *and* `select current_role`. I used \conninfo to tell me which server I'm on (since not on the default prompt, before I played with it today), which session_user I'm connected with (ddevienne or dd_login in my recent example), and finally `select current_role` which matters in my use-cases (session_user or dd_admin or dd_user). I'd like not to have to type those commands/queries all the time, and have them in the prompt at all time. I get that it's not for everyone, nor even necessary all the time, but I sincerely think it is definitely use= ful. I'd be glad to use Pavel's proposed %N. --DD