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.96) (envelope-from ) id 1wfONW-005QWm-0G for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Jul 2026 20:51:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wfONT-0036nN-16 for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Jul 2026 20:51:19 +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.96) (envelope-from ) id 1wfONT-0036nE-04 for pgsql-hackers@lists.postgresql.org; Thu, 02 Jul 2026 20:51:19 +0000 Received: from mail-yx1-xb129.google.com ([2607:f8b0:4864:20::b129]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wfONQ-00000001OuH-2PRn for pgsql-hackers@postgresql.org; Thu, 02 Jul 2026 20:51:18 +0000 Received: by mail-yx1-xb129.google.com with SMTP id 956f58d0204a3-664dd23829eso2225267d50.3 for ; Thu, 02 Jul 2026 13:51:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1783025475; cv=none; d=google.com; s=arc-20260327; b=ZZVKtrUSdsOR9BHW5+GnJJcjT1OJRKBbkfRPM2fYyMs5DXWtCA6P10PvgP8HpzMqs+ pLwUPFlsnfvxIF1uniICWHopHHTfneM1VlQDk1CzDzhZTZPUzv/79uKrUTC7QNtyOYBZ O56G9RJ0OmiMKWjAlEEGZQLkBi5FZDnsJqEPSmIvlbYPB4/Jth9oquR6mrtEPjQ9Iace 5z6Tj2cFc7xMGLVqxEtvi+BBI7wm1G3RGDmc2QgQD7XtNjYzoODLe/ABwHM7+KndsE2l wew2/G8+jeM0THvuDdSdQY4QjYf+o4NEaS7vQRW8CvpwXC0f1/FHeM62sY3jTOi5CM/b j6/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:dkim-signature; bh=oxn/Sddrc4iXJFHd44MmeEU6UwPA7Qi4PCPiYUnFYEo=; fh=HUpu4GD7Glo61GJxkcSFvfRzyAFCnTlHM6gktGNXIIY=; b=Uyct0IyzvTOQWxtOG+HmY0EHO+1kZPUfJvsUe9ZvS2FoKkG5c27J+/lpbyBFvkD9Wq lTvoPHeCMb9oNOIq2Cco6Ko2buaLm6QNCOHtAICs9IkauiPMNA8hDFDF42wLlzrFIB39 6XTyeGsWq+WbpoVFkqcKN1MRF9dfFe41OIMOWFtUjwp6uqunPLhY+W1huL7ZBo2SSPJ5 lHGmSLS1c2i27Fv76swRAPu8xFpWAPCYS9oNl7xKamb7cie0YZRaM8Pr3oygyx8hxhai y7HJMS3rboqYkBB9mOY6azFYDgLowBiIfU0pqN7L7IhqjG8MZ8IezDsxtbsdQ6sFrrU1 uiCw==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783025474; x=1783630274; darn=postgresql.org; h=content-type:cc:to:subject:message-id:date:from:references :in-reply-to:mime-version:from:to:cc:subject:date:message-id :reply-to:content-type; bh=oxn/Sddrc4iXJFHd44MmeEU6UwPA7Qi4PCPiYUnFYEo=; b=kc8j1WO/45OIsjYrVIJkvYf01+URV8fvb71JpENEHvhXeo7s5Y0jiDv+PwIrGUZp2w nNtWDJ6OJIImOiwUPebswaOh6xU0FnFrDiQijIYsDwx/7s/hftqoeh+gcwZY5JJD7KQu yLuleynj0QooK1rYsl1x2sFDuFkoupgsvr1NTfcFvNPnxZm9G8MgsmdF7yP15llVDV+0 RgIPLabmO5Q4t6e8FrjwXgkRFnZ5W9QSPBbaiMPMV2fKzFTkMzj3n4emfHUuSge9Z6cG +AKdRcjgaum7bGzzO3UkmeyyTwQrtJI41hj2hpkz11NCoekoRTJpWElBkXexZ814lCu8 E2Jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783025475; x=1783630275; h=content-type:cc:to:subject:message-id:date:from:references :in-reply-to:mime-version:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=oxn/Sddrc4iXJFHd44MmeEU6UwPA7Qi4PCPiYUnFYEo=; b=BS8xSaH6Z+Mt9rlEvYS/y/TdyT41CvmcwTBllDkQCiYQfaqUGlshAGGp0KFJ9w8C3I MyPrt+6qGb3v2yhbbunTlHtTmRLYZtameLbl3IRFF3G4obD4O37JvAtA1BFMYYn/w08c r3erbh7berZiCjdNN4S6A7zdy8rt6rw5esYEPDFV3MB/aGCHuukW2Awu2ChMgXuVrQmV ZeFHal4JAvVdifJ6BTphAuXqUFUm7YfCaqaUAfJ8Jsk4byoioB3XT68Sc9f+M3/HPoGF kAqvTW0sCENZ8dftU/dOFcmLL++gA0QgcQ/aNjV8cjRJx2D8c7hhAldzSpJqAoOd8GD2 xLMA== X-Forwarded-Encrypted: i=1; AHgh+RqV65qpXaYXOda4DHeoddFGwTHWbBxY+R00fxguLVQFllPQIzzMRTcEcrI+p9aNp8MOCD4RYnG2mXE4TkKO@postgresql.org X-Gm-Message-State: AOJu0YyNUggsXaYMQDskfzyIwNLoezJGiVeXs4vlUk/4PPAbi10Ka/tv VBjHGMHY3kXa24iKcv7JCZ7lrPLfi/9qWr0NMmJVXkGl7fremlhtvvHWVTNi03s5ehH8RNJqOKB nGEK4RwWsq1JMd39XHafMp8aRMXcgM1Q= X-Gm-Gg: AfdE7cmnXV6XwStAhLFMKnFgdcJGceQkwxeuonCFx2e2LaOt/rNWo2GlQGSoiEMWyAo IlQ1OXoSQW4/LZf/5w+i0ThpifiNIGJtvYUHktmhaivh33612G1pKs6JAUiipGKbgYxsw6PC9py SoGqEHNDFAZL1zHORRyI9P12gI15AjmdMP7pVBlZxVeJ+pyYqwFULNmkGhY1rV7rS7X+nHFUU5+ XeRTdV/yHTDJnpXFp7VLEJF1bsSzZykL/5ucjLPuRMsHu6iTf/TY5RhfxcYIAOvi8/FrogZKPur bGfZZUHoUOstNoU6lRnXMo157rPZ X-Received: by 2002:a05:690e:140b:b0:664:ae69:230a with SMTP id 956f58d0204a3-6659672606amr6584132d50.71.1783025474648; Thu, 02 Jul 2026 13:51:14 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a05:7010:9c93:b0:516:db2d:12e6 with HTTP; Thu, 2 Jul 2026 13:51:13 -0700 (PDT) In-Reply-To: References: <4c358bf8-87e8-4760-83d5-a6f9fcd88907@postgresfriends.org> <1b702de4-86b0-4144-a2d0-38266296894f@postgresfriends.org> <82b4223e-84d4-432d-8167-dd698ce489f5@postgresfriends.org> From: "David G. Johnston" Date: Thu, 2 Jul 2026 13:51:13 -0700 X-Gm-Features: AVVi8Cf-ebUjSO57rRGtoXmgOrT6PBpJqHphlCLZ1JJJT30YY7RwpuuflUIrVSw Message-ID: Subject: Re: implement CAST(expr AS type FORMAT 'template') To: Robert Haas Cc: Haibo Yan , jian he , Corey Huinker , Zsolt Parragi , Vik Fearing , PostgreSQL-development Content-Type: multipart/alternative; boundary="0000000000000abdc30655a6f805" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000000abdc30655a6f805 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thursday, July 2, 2026, Robert Haas wrote: > On Wed, Jul 1, 2026 at 4:59=E2=80=AFPM David G. Johnston > wrote: > > I think the fact the standard put this inside the 'cast(...)' means it'= s > quite reasonable to consider the aspect part of a cast definition as > opposed to something wholly different. > > > > When we issue "create table" both pg_class and pg_attribute are > modified. It seems quite reasonable that executing "create cast" causes > both pg_cast and pg_cast_format to be populated. > > I don't see how this would work. The existence of a regular cast > doesn't mean there has to be a format cast, Agree > > and the existence of a > format cast doesn't mean there has to be a regular cast. Disagree > But then we'd still have to have ALTER > CAST commands that modify the format-cast part of the object and the > non-format cast part of the object separately. That seems extremely > unpleasant to sort out, especially since right now a cast can't be > modified after it's created, and changing that might have security > implications. Then we don;t need the alter to be able to modify the non-format portion of the cast. I do imagine that the formatter is an optional component of a cast. So =E2=80=9Calter cast =E2=80=A6 {attach|detach} formatter =E2=80=A6= =E2=80=9D. We don=E2=80=99t even need a create command component though seems nice to keep it for convenience. I don=E2=80=99t have any qualms adding this so as long as fits into the exi= sting system cleanly. The array example does actually provide new ease-of-use for an admittedly possibly rare use case. David J. --0000000000000abdc30655a6f805 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thursday, July 2, 2026, Robert Haas <robertmhaas@gmail.com> wrote:
On Wed, Jul 1, 2026 at 4:59=E2=80=AFPM David G. Johnston
<david.g.johnston@gmail.co= m> wrote:
> I think the fact the standard put this inside the 'cast(...)' = means it's quite reasonable to consider the aspect part of a cast defin= ition as opposed to something wholly different.
>
> When we issue "create table" both pg_class and pg_attribute = are modified.=C2=A0 It seems quite reasonable that executing "create c= ast" causes both pg_cast and pg_cast_format to be populated.

I don't see how this would work. The existence of a regular cast
doesn't mean there has to be a format cast,

=
Agree
=C2=A0

and the existence of a
format cast doesn't mean there has to be a regular cast.

Disagree
=C2=A0
But then we'd still have to have ALTER
CAST commands that modify the format-cast part of the object and the
non-format cast part of the object separately. That seems extremely
unpleasant to sort out, especially since right now a cast can't be
modified after it's created, and changing that might have security
implications.

Then we don;t need the alter = to be able to modify the non-format portion of the cast.=C2=A0 I do imagine= that the formatter is an optional component of a cast.=C2=A0 So =E2=80=9Ca= lter cast =E2=80=A6 {attach|detach} formatter =E2=80=A6=E2=80=9D.=C2=A0 We = don=E2=80=99t even need a create command component though seems nice to kee= p it for convenience.

I don=E2=80=99t have any qua= lms adding this so as long as fits into the existing system cleanly.=C2=A0 = The array example does actually provide new ease-of-use for an admittedly p= ossibly rare use case.

David J.

--0000000000000abdc30655a6f805--