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 1tMusT-007L5O-Tr for pgsql-general@arkaria.postgresql.org; Sun, 15 Dec 2024 20:06:10 +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 1tMusQ-00GlzQ-3Z for pgsql-general@arkaria.postgresql.org; Sun, 15 Dec 2024 20:06:07 +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 1tMusP-00GlvI-Kd for pgsql-general@lists.postgresql.org; Sun, 15 Dec 2024 20:06:06 +0000 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tMusL-0031W2-Om for pgsql-general@postgresql.org; Sun, 15 Dec 2024 20:06:06 +0000 Received: by mail-pj1-x1029.google.com with SMTP id 98e67ed59e1d1-2ee9a780de4so2190474a91.3 for ; Sun, 15 Dec 2024 12:06:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734293159; x=1734897959; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=ib1UF1F9rJEMC3f9hcP7k3f3e9XD61WoQi2izCYf+94=; b=cZe3AIo17f4uM3nbidlCfiHD/LULsLg1SwVUXaK3+IBW817NpBje/XubE7xWmEjcMf ZSUHs7y1mjHQjnwUFZWQaIItGkL1Cw7pilh4hw1KFiJJQiUM96t5kIY/0Iak3m4uwShu ujYyG/Ek8FDhoWvjjNNI2o5BtiLYq/cWiQ7FsdokCeniXS46kPxLon1tcD17pANR8CKJ ZFzbRxxtXe8yEbOas0NfSWGrYxoZNZ90jGxYVyGtkFzw4giIuagxsJ1dyWEnYKDdqKZJ 4EsR3+oyTiegrAiQBgK5Z3rScQtNnF8pkOFmjeAqag60Y0Tv51Z/QqxmTk7Wes2yAWK5 lY6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734293159; x=1734897959; h=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=ib1UF1F9rJEMC3f9hcP7k3f3e9XD61WoQi2izCYf+94=; b=KvkpQMpkb+z0I7810VdhgbxwJ2jcLSkpBv5bZj7xtBKvW+tQi3IyHW07LGP44hF8d6 WfVO6Xs/HDkLwjPDyafQwZCouvhjaQkdMkT7uIjiNcrSbQMMhdgQtyz3jK51nk+HZZdx XmXHoA+tOS2w2x63G+6vgQwHNrJWld6c+HYzwew6vwJpkhhYdFqa5ZoSp0qh0tX6t76O txWyj0I9kl57Gciybg4dPypPLwVeDTgev+PWD5vFp1asTaVheL4LLOEh7bYmgJeTpnsD b/W4DPtRFuhmtyz6By+545qcOKhKESX+rhHBEXQ+kuMh1a4jm3Sz372vEk5NK69xOZtY Yc4Q== X-Forwarded-Encrypted: i=1; AJvYcCXatALFvXtdXYNtWFoSa1r09H3RaQIwBMam/uavjFOgY3qyuw7GPYBvVxcwWnUpITud42vRN7oy5M0CvxU1@postgresql.org X-Gm-Message-State: AOJu0Yw4eTdMUiAwerxeatgkgTbWKUbfWgWFQV+7aYC+6NvPveRg733m DWNT28yndHefvJ15/Dnv261d980TuxNdRSij+7GS9rG+2T9dkEkcLbJKvT9EUWYRzv3A85HpVcK YN96aC6dqra5iApu9mGB9Ju1SH88= X-Gm-Gg: ASbGncskIyGiBuHR6RnfdAw5Sy2pPCDOnYhTeEfiY75ECvhZj6wbABaVMKkDT2KB82c 94YoeKvrY+yvjTpASLrNowhCDSjsarp3suChAkg== X-Google-Smtp-Source: AGHT+IFupTr6Hhm0Ay0fGXbXThFxFXm+/e1TO+hviHZzw0ZTL0deyo8miV6fLuI7klvTI40dSvYJYOpdwsoi9L5JbDk= X-Received: by 2002:a17:90b:3b85:b0:2ee:bbe0:98c6 with SMTP id 98e67ed59e1d1-2f28fa5107cmr15355102a91.8.1734293159330; Sun, 15 Dec 2024 12:05:59 -0800 (PST) MIME-Version: 1.0 References: <1627466.1734283766@sss.pgh.pa.us> <1753818.1734290423@sss.pgh.pa.us> In-Reply-To: <1753818.1734290423@sss.pgh.pa.us> From: Isaac Morland Date: Sun, 15 Dec 2024 15:05:46 -0500 Message-ID: Subject: Re: Request for new column in pg_namespace To: Tom Lane Cc: Pavel Stehule , Ron Johnson , pgsql-general Content-Type: multipart/alternative; boundary="000000000000b2cc560629549748" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000b2cc560629549748 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, 15 Dec 2024 at 14:20, Tom Lane wrote: > Isaac Morland writes: > > On Sun, 15 Dec 2024 at 12:29, Tom Lane wrote: > >> What I'd suggest as an improvement that could be implemented > >> immediately is to wrap the checks in a user-defined function > >> like "is_system_schema(nspname name)". > > > Would it make sense to make the parameter be of type regnamespace? > > Meh ... you could, but what the function really needs is the name. > Getting from regnamespace (which is an OID) to the name would incur > an extra syscache lookup. Admittedly, if it removes the need for > the calling query to join to pg_namespace at all, you'd probably > come out about even --- the net effect would be about like a > hashjoin to pg_namespace, I think, since the syscache would act > like the inner hashtable of a hashjoin. Thanks for the critique. It occurs to me that this function is perhaps just as much about =E2=80=9Cis this name a system-reserved name?=E2=80=9D as =E2= =80=9Cis this schema a system schema?=E2=80=9D. So putting in a name that doesn=E2=80=99t actually= exist in the database should be perfectly valid, which of course only works if it takes a string. Generally speaking I am a big fan of the reg* data types but in this specific case I think it=E2=80=99s not a clear win. I might still sugg= est providing both versions using function overloading. --000000000000b2cc560629549748 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Sun, 15 Dec 2024 at 14:20, Tom Lane &l= t;tgl@sss.pgh.pa.us> wrote:
=
Isa= ac Morland <isaac.morland@gmail.com> writes:
> On Sun, 15 Dec 2024 at 12:29, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> What I'd suggest as an improvement that could be implemented >> immediately is to wrap the checks in a user-defined function
>> like "is_system_schema(nspname name)".

> Would it make sense to make the parameter be of type regnamespace?

Meh ... you could, but what the function really needs is the name.
Getting from regnamespace (which is an OID) to the name would incur
an extra syscache lookup.=C2=A0 Admittedly, if it removes the need for
the calling query to join to pg_namespace at all, you'd probably
come out about even --- the net effect would be about like a
hashjoin to pg_namespace, I think, since the syscache would act
like the inner hashtable of a hashjoin.

Tha= nks for the critique. It occurs to me that this function is perhaps just as= much about =E2=80=9Cis this name a system-reserved name?=E2=80=9D as =E2= =80=9Cis this schema a system schema?=E2=80=9D. So putting in a name that d= oesn=E2=80=99t actually exist in the database should be perfectly valid, wh= ich of course only works if it takes a string. Generally speaking I am a bi= g fan of the reg* data types but in this specific case I think it=E2=80=99s= not a clear win. I might still suggest providing both versions using funct= ion overloading.
--000000000000b2cc560629549748--