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 1uYc5c-008V77-DW for pgsql-hackers@arkaria.postgresql.org; Mon, 07 Jul 2025 03:00:20 +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 1uYc5a-00GU7F-3x for pgsql-hackers@arkaria.postgresql.org; Mon, 07 Jul 2025 03:00:18 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uYc5Z-00GU77-IK for pgsql-hackers@lists.postgresql.org; Mon, 07 Jul 2025 03:00:18 +0000 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uYc5X-0069np-1c for pgsql-hackers@lists.postgresql.org; Mon, 07 Jul 2025 03:00:17 +0000 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-74b54cead6cso1576998b3a.1 for ; Sun, 06 Jul 2025 20:00:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1751857212; x=1752462012; darn=lists.postgresql.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=LTriTAAUFqCcmPv8KI8k/oUOl71tdw8c0rc+p5gBAhs=; b=QSC3TQm9goFywVebZ/fFY3V5LNQX3up45o0atYbB1tIDXiLNmWppprhczr3yt88jnT Hxs1BhpV/U5hlBYRQ4JBxfW/gwydiyfHPjFlZn8jqvBQnIMBtAvMJnc+8+lXPwJPlHzQ qPlngG+qvpBC38skruWRKJhyltRw9dkEFIq3Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751857212; x=1752462012; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LTriTAAUFqCcmPv8KI8k/oUOl71tdw8c0rc+p5gBAhs=; b=uNhsRDU7Sn4+lGcQSGbxEYar3D3lVrYD1G5jYS8kjlJCzMsPgYrxMcWe9ZwYxU7R2z nabzwO8J0HJeSDJhGdsIRLdjGsxY1GNkyN/ugGQze7j1EgCtI6rmEIPtC6JRJ+Mdy6Nt ivoUeMNKLl91FdK/Y4S7ovBrHxQuQpm+YVccBOKuzpNzBXED1nX1tvRN0fcyMyhUbVxQ qpbxKC7oInTX8mXpX0wdgrikIIIGZS7T53jHtitHH1ZGvScCJ8Ffrrs8gsSGWiVYA5EG uePL2NPwp/VIiga6Fcrb6ieh3F9P7oupUm//ds69bFov9qb1zzOnNKb+Hn9Av6DWVVgD GDJg== X-Forwarded-Encrypted: i=1; AJvYcCXyBtiwPbBtRfoyB9UFMRe26yfVXAKDeZeB96xe0qS3/CwiaIOrgGA/7ThbRKQm5hxfO92loSbFnUWnGe9E@lists.postgresql.org X-Gm-Message-State: AOJu0Yx4chIPyqY7lluOlQ1VlgUjqsv1LCViXhsC3enLfUkDZM4vwvZE 0hoOB7iBreMr0QEWAqhW5vqIutqEZeINzCb/pd6PNWvLpH+s0TU04/qW0nkcGEy7+99U5N5LGxP P+84= X-Gm-Gg: ASbGnculIBzcst7jppmeQnUOKS0Dwopj/LzZog5DKx+2WlkP8b8d77YV/tj7xreucol TWWDHf2ThdrWdIUK+nBlQEo5b89hKx5YzC7qJhUSztdWMrdpdSwgxWK/vdztPnYT+aSp191xMfC GkYzu9GxvECqc/v/Ia9qhmQjus0kjOaokE0Ea8kXH4+lfg+gcCdUZUYRGtAj2pbEm1UoVn+FFLt zdSsNA/1SfUZbmniZyCOTCNsfBUSPbUa7NYYK65b6igv52Riv1DFCIGBtJRQamPDrH/CufNJcif rmLgoZl41MNw0PTz32epoG9oodKh0mPSyvcx0pzuqZK41CKx8+AUkSoEmxpyQnxB7zWb0GIezsL q0qfKssZHpD3wCLM= X-Google-Smtp-Source: AGHT+IE0bCYxYKtZXSP9skuKdIJCTjX/mlhZfitmN+qlYZl4TO4dBqYoRjGc+ntLjie+RlUvTWT4gw== X-Received: by 2002:a05:6a00:3985:b0:736:54c9:df2c with SMTP id d2e1a72fcca58-74ce65a90e7mr15825768b3a.15.1751857212214; Sun, 06 Jul 2025 20:00:12 -0700 (PDT) Received: from google.com (c-76-132-193-99.hsd1.ca.comcast.net. [76.132.193.99]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-74ce417f7a2sm8188896b3a.96.2025.07.06.20.00.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 06 Jul 2025 20:00:11 -0700 (PDT) Date: Sun, 6 Jul 2025 20:00:09 -0700 From: Noah Misch To: Michael Paquier Cc: Michael Banck , Greg Sabino Mullane , PostgreSQL Hackers Subject: Re: [PATCH] Add support for displaying database service in psql prompt Message-ID: <20250707030009.b8.nmisch@google.com> References: <6723c612.050a0220.1567f4.b94a@mx.google.com> <6748cfd4.050a0220.1537dc.43bb@mx.google.com> <6760a25e.a70a0220.2e9d8f.d542@mx.google.com> <6761397c.df0a0220.68885.210d@mx.google.com> <20250706161319.c1.nmisch@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/2.2.12 (2023-09-09) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Jul 07, 2025 at 11:06:06AM +0900, Michael Paquier wrote: > On Sun, Jul 06, 2025 at 09:13:19AM -0700, Noah Misch wrote: > > This new PQservice() function from commit 4b99fed75 came up in the annual > > exports.txt diff. The standard in libpq has been to not clutter the API with > > new functions that simply retrieve one PQconninfoOption value. PQconninfo() > > provides access to all those values in a generic way. What do you think of > > making psql use PQconninfo() for this, then removing PQservice()? The rest of > > the commit (adding the struct field, necessary for PQconninfo() to include the > > value) looks good. > > Sure, I was not aware of such a policy. Relying on PQconninfoOption > is less efficient because we would need to look through the whole set > of options when looking for the service name, and this needs one extra > allocation as PQconninfoFree() frees the values allocated. With two > callers perhaps this inefficiency is OK to live with anyway. I think the choice to make there is whether to call PQconninfo() once per prompt emission or to cache the value, invalidating that cache e.g. once per SyncVariables(). My first thought was to cache, but the decision is not too important. A PQconninfo() call is likely negligible relative to all that happens between prompts. Even if not negligible, the overhead of not caching will affect only prompts using the new escape sequence.